Created
June 15, 2011 08:06
-
-
Save apoStyLEE/1026671 to your computer and use it in GitHub Desktop.
Araçlar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetIpAdress() | |
| { | |
| if (string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"])) | |
| { | |
| return "127.0.0.1"; | |
| } | |
| else | |
| { | |
| return System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"].ToString(); | |
| } | |
| } | |
| public static bool isNumeric(string value) | |
| { | |
| int result; | |
| return int.TryParse(value, out result); | |
| } | |
| public static bool IsTcNo(string tcKimlikNo) | |
| { | |
| bool returnvalue = false; | |
| if (tcKimlikNo.Length == 11) | |
| { | |
| char[] charlar = tcKimlikNo.ToCharArray(0, 10); | |
| int sayi = 0; | |
| foreach (char item in charlar) | |
| { | |
| sayi += int.Parse(item.ToString()); | |
| } | |
| string sayistr = sayi.ToString(); | |
| if (sayistr.Substring(sayistr.Length - 1) == tcKimlikNo.Substring(10)) | |
| { | |
| returnvalue = true; | |
| } | |
| } | |
| return returnvalue; | |
| } | |
| public static string RandomNumber() | |
| { | |
| Random r = new Random(); | |
| string strRsayi = r.Next(1, 10000000).ToString() + String.Format("{0:T}", DateTime.Now).Replace(":", string.Empty); | |
| return strRsayi; | |
| } | |
| public static string TextCrop(string gelen,int uzunluk) | |
| { | |
| string desen = @"<script\s[^>]*>.*?</script>|<\s*(?!/?(?:br?|i|p|u)\b[^>]*>)[^>]*>"; | |
| gelen = Regex.Replace(gelen, desen, string.Empty); | |
| if (gelen.Length >= uzunluk) | |
| { | |
| gelen = gelen.Substring(0, uzunluk)+".."; | |
| } | |
| return gelen; | |
| } | |
| public static string sqlEnjeksiyon(string strGelen) { | |
| string[] strYasaklilar ={"'","--",";--",";","/*","*/","@@", | |
| "char","nchar","varchar","nvarchar", | |
| "alter","begin","cast","create","cursor","declare","delete","drop","end","exec","execute", | |
| "fetch","insert","kill","open", | |
| "select", "sys","sysobjects","syscolumns", | |
| "table","update"}; | |
| for (int i = 0; i < strYasaklilar.Length; i++) | |
| { | |
| strGelen = strGelen.Replace(strYasaklilar[i],string.Empty); | |
| } | |
| return strGelen; | |
| } | |
| public static string sefLink(String adres,string tur,string id, string uzanti) | |
| { | |
| string[] pattern = new string[] { "[^a-zA-Z0-9-]", "-+" }; | |
| string[] replacements = new string[] { "-", "-" }; | |
| adres = adres.Trim(); | |
| adres = adres.Replace("Ç", "C"); | |
| adres = adres.Replace("ç", "c"); | |
| adres = adres.Replace("Ğ", "G"); | |
| adres = adres.Replace("ğ", "g"); | |
| adres = adres.Replace("Ü", "U"); | |
| adres = adres.Replace("ü", "u"); | |
| adres = adres.Replace("Ş", "S"); | |
| adres = adres.Replace("ş", "s"); | |
| adres = adres.Replace("İ", "I"); | |
| adres = adres.Replace("ı", "i"); | |
| adres = adres.Replace("Ö", "O"); | |
| adres = adres.Replace("ö", "o"); | |
| for (int i = 0; i < pattern.Length; i++) | |
| { | |
| adres = Regex.Replace(adres, pattern[i], replacements[i]); | |
| } | |
| return tur + "/" + id + "/" + adres + uzanti; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment