Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

97 строки
3.0 KiB

  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Text.RegularExpressions;
  9. namespace basic
  10. {
  11. /// <summary>
  12. /// QZRequest 的摘要说明
  13. /// </summary>
  14. public class QZRequest
  15. {
  16. /// <summary>
  17. /// 获得指定Url参数的值
  18. /// </summary>
  19. /// <param name="strName">Url参数</param>
  20. /// <returns>Url参数的值</returns>
  21. public static string GetQueryString(string strName)
  22. {
  23. return GetString(strName);
  24. }
  25. /// <summary>
  26. /// 获得指定Url参数的值 转换为int
  27. /// </summary>
  28. /// <param name="strName">参数</param>
  29. /// <param name="intDefault">默认值</param>
  30. public static int GetQueryInt(string strName, int intDefault)
  31. {
  32. int Int = intDefault;
  33. if (HttpContext.Current.Request.QueryString[strName] == null)
  34. {
  35. Int = intDefault;
  36. }
  37. else
  38. {
  39. try
  40. {
  41. Int = Int32.Parse(HttpContext.Current.Request.QueryString[strName]);
  42. }
  43. catch
  44. {
  45. Int = intDefault;
  46. }
  47. }
  48. return Int;
  49. }
  50. /// <summary>
  51. /// 获得指定Url参数的值
  52. /// </summary>
  53. /// <param name="strName">Url参数</param>
  54. /// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
  55. /// <returns>Url参数的值</returns>
  56. private static string GetString(string strName)
  57. {
  58. if (HttpContext.Current.Request.QueryString[strName] == null)
  59. {
  60. return "";
  61. }
  62. bool bol = true;
  63. bol = IsSafeString(HttpContext.Current.Request.QueryString[strName]);
  64. if (!bol)
  65. {
  66. return "";
  67. }
  68. return HttpContext.Current.Request.QueryString[strName];
  69. }
  70. // 检查危险字符
  71. private static bool IsSafeString(string Str)
  72. {
  73. string SqlStr = "'|and|exec|insert|select|delete|update|count|*|chr|mid|master|truncate|char|declare";
  74. bool ReturnValue = true;
  75. try
  76. {
  77. if (Str != "")
  78. {
  79. string[] anySqlStr = SqlStr.Split('|');
  80. foreach (string ss in anySqlStr)
  81. {
  82. if (Str.IndexOf(ss) >= 0)
  83. {
  84. ReturnValue = false;
  85. break;
  86. }
  87. }
  88. }
  89. }
  90. catch
  91. {
  92. ReturnValue = false;
  93. }
  94. return ReturnValue;
  95. }
  96. }
  97. }