public Image GetUploadImage(HttpPostedFile file, Page page) { if (!Licencing.validate()) { return(null); } if (file != null & savePath != string.Empty) { string FileName = file.FileName; string saveFile = savePath + FileName; if (checkFileToUpload(file)) { file.SaveAs(saveFile); System.Drawing.Image IMG = System.Drawing.Image.FromFile(saveFile); //IMG = AddWaterMark(IMG, System.Drawing.Image.FromFile(saveFile)); //390;195 //IMG.Save(pge.Server.MapPath("~/Styling/Uploads/2" + FileName)); try { File.Delete(saveFile); } catch { } return(IMG); } } return(null); }
public static System.Drawing.Image PerformASPImageUpload(HttpPostedFile file, HttpServerUtility server, string folder) { if (!Licencing.validate()) { return(null); } string FileName = file.FileName; string saveFile = server.MapPath(folder + ((folder.Replace("/", "\\").EndsWith("\\")) ? "" : "\\") + Useful_Classes.StringManipulation.GenerateRandomString(25) + "." + FileName.Split('.')[FileName.Split('.').Length - 1]); if (validateFolderExistance(saveFile)) { file.SaveAs(saveFile); System.Drawing.Image IMG = System.Drawing.Image.FromFile(saveFile); try { File.Delete(saveFile); } catch { } return(IMG); } return(null); }
///<summary> ///Do DeSQL Injection on string ///</summary> ///<param name="unSqldString">String to DeSql</param> ///<returns>DeSql String</returns> / <returns>LOL if limit is reached</returns> public static string deSQL(string unSqldString) { if (!Licencing.validate()) { return(null); } try { bool found = true; int count = -1; while (found) { count++; unSqldString = doREP(unSqldString); if (unSqldString.Equals(doREP(unSqldString))) { found = false; } if (count > injectLimit) { throw new Exception("LIMIT REACHED"); } } return(unSqldString); } catch { return("LOL"); } }
public static byte[][] GetUploadedImagesBytes(string[] files, string saveFilePath, HttpRequestBase request) { List <byte[]> images = new List <byte[]>(); if (!Licencing.validate()) { return(null); } if (validateFileIsUploadable(files)) { for (int i = 0; i < files.Length; i++) { string filename = files[i]; validateFolderExistance(filename); string savePath = Environment.CurrentDirectory + "\\" + ((saveFilePath.Length > 0) ? saveFilePath + ((saveFilePath.Replace("/", "\\").EndsWith("\\")) ? "" : "\\") : "") + Useful_Classes.StringManipulation.GenerateRandomString(27) + "." + filename.Split('.')[filename.Split('.').Length - 1]; HttpPostedFileBase file = request.Files[i]; if (file.ContentLength > 0) { file.SaveAs(savePath); byte[] bytes = null; FileStream fs = null; try { fs = File.OpenRead(savePath); bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); } finally { try { if (fs != null) { fs.Close(); fs.Dispose(); } } catch { } } images.Add(bytes); try { File.Delete(savePath); } catch { } } } } return(images.ToArray()); }
public static string Decrypt(string StringToDecrypt, string Salt) { if (!Licencing.validate()) { return(null); } String salt = encryptStr(StringToDecrypt, Salt, true); return(decryptStr(StringToDecrypt, Salt, true)); }
public static System.Drawing.Image GetImageFromByteArray(byte[] image) { if (!Licencing.validate()) { return(null); } MemoryStream ms = new MemoryStream(image); Image returnImage = Bitmap.FromStream(ms); return(returnImage); }
public static byte[] GetByteArrayFromImage(System.Drawing.Image image) { if (!Licencing.validate()) { return(null); } MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); return(ms.ToArray()); }
public void UploadFile(HttpPostedFile file, Page page) { if (!Licencing.validate()) { return; } if (file != null & savePath != string.Empty) { string FileName = file.FileName; string saveFile = savePath + FileName; if (checkFileToUpload(file)) { file.SaveAs(saveFile); } } }
public static string GenerateRandomString() { if (!Licencing.validate()) { return(null); } StringBuilder builder = new StringBuilder(); char ch; for (int i = 0; i < 125; i++) { ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))); builder.Append(ch); } return(builder.ToString()); }
public static byte[] ResizeMyImage(byte[] image, Size newSize) { if (!Licencing.validate()) { return(null); } Bitmap newImage = new Bitmap(newSize.Width, newSize.Height); using (Graphics gr = Graphics.FromImage(newImage)) { gr.SmoothingMode = SmoothingMode.HighQuality; gr.InterpolationMode = InterpolationMode.HighQualityBicubic; gr.PixelOffsetMode = PixelOffsetMode.HighQuality; gr.DrawImage(GetImageFromByteArray(image), new Rectangle(0, 0, newSize.Width, newSize.Height)); } return(GetByteArrayFromImage(newImage)); }
public bool checkFileToUpload(HttpPostedFile file) { if (!Licencing.validate()) { return(false); } if (file != null & savePath != string.Empty) { string FileName = file.FileName; if (allowedExtensions.Contains(FileName.Split('.')[FileName.Split('.').Length - 1])) { if (file.ContentLength < maxFileSize) { return(true); } } } return(false); }
public static string PerformASPFileUpload(HttpPostedFile file, HttpServerUtility server, string folder) { if (!Licencing.validate()) { return(string.Empty); } string FileName = file.FileName; string newFIleName = Useful_Classes.StringManipulation.GenerateRandomString(25) + "." + FileName.Split('.')[FileName.Split('.').Length - 1]; string saveFile = server.MapPath(folder + ((folder.Replace("/", "\\").EndsWith("\\")) ? "" : "\\") + newFIleName); if (validateFolderExistance(saveFile)) { file.SaveAs(saveFile); return(newFIleName); } return(string.Empty); }
public byte[] GetUploadFileIgnoreLimits(HttpPostedFile file, Page page) { if (!Licencing.validate()) { return(null); } if (file != null & savePath != string.Empty) { string FileName = file.FileName; string saveFile = savePath + FileName; //if (checkFileToUpload(file)) { file.SaveAs(saveFile); byte[] bytes = null; FileStream fs = null; try { fs = File.OpenRead(saveFile); bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); } finally { try { if (fs != null) { fs.Close(); fs.Dispose(); } File.Delete(saveFile); } catch { } } return(bytes); } } return(null); }
public static bool validateFileIsUploadable(string[] files) { if (!Licencing.validate()) { return(false); } if (files.Length > 0) { foreach (string file in files) { if (file.Length < 5) { return(false); } } return(true); } return(false); }
public static Image[] GetUploadedImages(string[] files, string saveFilePath, HttpRequestBase request) { List <Image> images = new List <Image>(); if (!Licencing.validate()) { return(null); } if (validateFileIsUploadable(files)) { for (int i = 0; i < files.Length; i++) { string filename = files[i]; validateFolderExistance(filename); string savePath = Environment.CurrentDirectory + "\\" + ((saveFilePath.Length > 0) ? saveFilePath + ((saveFilePath.Replace("/", "\\").EndsWith("\\")) ? "" : "\\") : "") + Useful_Classes.StringManipulation.GenerateRandomString(27) + "." + filename.Split('.')[filename.Split('.').Length - 1]; HttpPostedFileBase file = request.Files[i]; if (file.ContentLength > 0) { file.SaveAs(savePath); System.Drawing.Image IMG = System.Drawing.Image.FromFile(savePath); images.Add(IMG); try { File.Delete(savePath); } catch { } } } } return(images.ToArray()); }