Exemplo n.º 1
0
        /// <summary>
        /// 获取页面地址的参数值并检查安全性,相当于 Request.QueryString
        /// chkType 有 CheckGetEnum.Int, CheckGetEnum.Safety两种类型,
        /// CheckGetEnum.Int 保证参数是数字型
        /// CheckGetEnum.Safety 保证提交的参数值没有操作数据库的语句
        /// </summary>
        public static string Get(string name, CheckGetEnum chkType)
        {
            #region 获取页面地址的参数值并检查安全性,相当于 Request.QueryString public static string Get(string name, CheckGetEnum chkType)
            string value  = Get(name);
            bool   isPass = false;
            switch (chkType)
            {
            default:
                isPass = true;
                break;

            case CheckGetEnum.Int:
            {
                try
                {
                    int.Parse(value);
                    isPass = IsNumeric(value);
                }
                catch
                {
                    isPass = false;
                }
                break;
            }

            case CheckGetEnum.Safety:
                isPass = IsSafety(value);
                break;
            }
            if (!isPass)
            {
                //"地址栏中参数“" + name + "”的值不符合要求或具有潜在威胁,请不要手动修改URL。");
                return(string.Empty);
            }
            return(value);

            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取页面地址的参数值并检查安全性,相当于 Request.QueryString
        /// chkType 有 CheckGetEnum.Int, CheckGetEnum.Safety两种类型,
        /// CheckGetEnum.Int 保证参数是数字型
        /// CheckGetEnum.Safety 保证提交的参数值没有操作数据库的语句
        /// </summary>
        public static string Get(string name, CheckGetEnum chkType)
        {
            string value  = Get(name);
            bool   isPass = false;

            switch (chkType)
            {
            default:
                isPass = true;
                break;

            case CheckGetEnum.Int:
            {
                try
                {
                    int.Parse(value);
                    isPass = RegExp.IsNumeric(value);
                }
                catch
                {
                    isPass = false;
                }
                break;
            }

            case CheckGetEnum.Safety:
                isPass = RegExp.IsSafety(value);
                break;
            }
            if (!isPass)
            {
                new Terminator().Throw("地址栏中参数“" + name + "”的值不符合要求或具有潜在威胁,请不要手动修改URL。");
                return(string.Empty);
            }
            return(value);
        }
Exemplo n.º 3
0
 /// <summary>
 /// ��ȡҳ���ַ�IJ���ֵ����鰲ȫ�ԣ��൱�� Request.QueryString
 /// chkType �� CheckGetEnum.Int�� CheckGetEnum.Safety�������ͣ�
 /// CheckGetEnum.Int ��֤������������
 /// CheckGetEnum.Safety ��֤�ύ�IJ���ֵû�в������ݿ�����
 /// </summary>
 public static string Get(string name, CheckGetEnum chkType)
 {
     #region ��ȡҳ���ַ�IJ���ֵ����鰲ȫ�ԣ��൱�� Request.QueryString public static string Get(string name, CheckGetEnum chkType)
     string value = Get(name);
     bool isPass = false;
     switch (chkType)
     {
         default:
             isPass = true;
             break;
         case CheckGetEnum.Int:
             {
                 try
                 {
                     int.Parse(value);
                     isPass = IsNumeric(value);
                 }
                 catch
                 {
                     isPass = false;
                 }
                 break;
             }
         case CheckGetEnum.Safety:
             isPass = IsSafety(value);
             break;
     }
     if (!isPass)
     {
         //"��ַ���в�����" + name + "����ֵ������Ҫ������DZ����в���벻Ҫ�ֶ��޸�URL��");
         return string.Empty;
     }
     return value;
     #endregion
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取参数值 QueryString
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        public static string Get(string name, CheckGetEnum chkType)
        {
            string text1 = Get(name);
            bool flag1 = false;
            switch (chkType)
            {
                case CheckGetEnum.Int:
                    flag1 = IsNumeric(text1);
                    break;

                case CheckGetEnum.Safety:
                    flag1 = IsSafety(text1);
                    break;

                default:
                    flag1 = true;
                    break;
            }
            if (!flag1)
            {
                return string.Empty;
            }
            return text1;
        }