using System; using System.Text; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Text.RegularExpressions; namespace basic { /// /// QZRequest 的摘要说明 /// public class QZRequest { /// /// 获得指定Url参数的值 /// /// Url参数 /// Url参数的值 public static string GetQueryString(string strName) { return GetString(strName); } /// /// 获得指定Url参数的值 转换为int /// /// 参数 /// 默认值 public static int GetQueryInt(string strName, int intDefault) { int Int = intDefault; if (HttpContext.Current.Request.QueryString[strName] == null) { Int = intDefault; } else { try { Int = Int32.Parse(HttpContext.Current.Request.QueryString[strName]); } catch { Int = intDefault; } } return Int; } /// /// 获得指定Url参数的值 /// /// Url参数 /// 是否进行SQL安全检查 /// Url参数的值 private static string GetString(string strName) { if (HttpContext.Current.Request.QueryString[strName] == null) { return ""; } bool bol = true; bol = IsSafeString(HttpContext.Current.Request.QueryString[strName]); if (!bol) { return ""; } return HttpContext.Current.Request.QueryString[strName]; } // 检查危险字符 private static bool IsSafeString(string Str) { string SqlStr = "'|and|exec|insert|select|delete|update|count|*|chr|mid|master|truncate|char|declare"; bool ReturnValue = true; try { if (Str != "") { string[] anySqlStr = SqlStr.Split('|'); foreach (string ss in anySqlStr) { if (Str.IndexOf(ss) >= 0) { ReturnValue = false; break; } } } } catch { ReturnValue = false; } return ReturnValue; } } }