示例#1
0
        //防止恶意请求
        public static bool IsRedis(HttpContext context, string key)
        {
            if (context.Request.Browser.Crawler)
            {
                return(false);
            }
            if (RedisCacheTools.Exists(key))
            {
                string keycount = "keycount:" + key;
                bool   check    = RedisCacheTools.Exists(keycount);
                if (check)
                {
                    RedisCacheTools.Incr(keycount);
                    int hit = RedisCacheTools.Get <int>(keycount);
                    if (hit > 700000)
                    {
                        return(false);
                    }
                }
                else
                {
                    DateTime dt = DateTime.Now.Date.AddDays(1);
                    RedisCacheTools.Incr(keycount);

                    RedisCacheTools.Expire(keycount, dt);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        private string gotoRedirectUrl = "/404.html";//最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string jump    = QueryString("key"); //参数1:用户传当前推广的网址
            string getJump = jump;               //参数1:授权key

            string getUrl = QueryString("url");  //参数1:用户传当前推广的网址,url需要编码

            if (string.IsNullOrEmpty(getJump) || string.IsNullOrEmpty(getUrl))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                getJump = getJump + "!" + getUrl;
                string domainLeft = "https://";

                string domainCenter = GetRandHostUrl();
                gotoRedirectUrl = domainLeft + domainCenter + "/HomeHost.ashx";
                // string xxx =PostHtml(gotoRedirectUrl, getJump);

                string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                html = html.Replace("$newsView", gotoRedirectUrl).Replace("$newsValue", getJump);

                bool check = RedisCacheTools.Exists(jump + "IsTitle");
                if (check)
                {
                    html = html.Replace("太阳湾软件", "");
                }
                //  LogTools.WriteLine(getJump);

                context.Response.Write(html);
            }
            context.Response.End();
        }
示例#3
0
        private string gotoRedirectUrl = "/404.html";                                                 //最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string jump    = QueryString("jump"); //参数1:用户传当前推广的网址
            string getJump = jump;                //参数1:用户传当前推广的网址

            if (string.IsNullOrEmpty(getJump))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                Random ran     = new Random();
                int    RandKey = ran.Next(00, 99);
                getJump = getJump + "!" + RandKey;

                string   hosturl    = ConfigTool.ReadVerifyConfig("ActionName", "WeChatAnti"); //这些域名都需要指向用户最终要访问的站点
                string[] sArray     = hosturl.Split(',');
                int      RandKey1   = ran.Next(0, sArray.Length);                              //随机选中action
                string   actionName = sArray[RandKey1];
                string   domainLeft = "http://";

                string isHttps = ConfigTool.ReadVerifyConfig("IsSSL", "WeChatAnti");//这些域名都需要指向用户最终要访问的站点

                if (isHttps.ToLower() == "true")
                {
                    string agent = context.Request.UserAgent;
                    if (!agent.Contains("Macintosh") && !agent.Contains("iPhone") && !agent.Contains("iPod") && !agent.Contains("iPad") && !agent.Contains("Windows Phone") && !agent.Contains("Windows NT"))
                    {
                        domainLeft = "https://";
                    }
                }

                string domainCenter = GetRandHostUrl();
                if (string.IsNullOrEmpty(domainCenter))
                {
                    context.Response.Redirect(gotoRedirectUrl);
                }
                else
                {
                    gotoRedirectUrl = domainLeft + domainCenter + "/" + actionName;
                    // string xxx =PostHtml(gotoRedirectUrl, getJump);

                    string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                    html = html.Replace("$newsView", gotoRedirectUrl).Replace("$newsValue", getJump);

                    bool check = RedisCacheTools.Exists(jump + "IsTitle");
                    if (check)
                    {
                        html = html.Replace("太阳湾软件", "");
                    }


                    context.Response.Write(html);
                }
            }
            context.Response.End();
        }
示例#4
0
        //防止恶意请求
        public static bool IsRedis(HttpContext context)
        {
            if (context.Request.Browser.Crawler)
            {
                return(false);
            }
            string key   = userIP;
            bool   check = RedisCacheTools.Exists(key);

            if (check)
            {
                RedisCacheTools.Incr(key);
                int hit = RedisCacheTools.Get <int>(key);
                if (hit > 16)
                {
                    return(false);
                }

                /*
                 *  $redis->incr($key);
                 *  $count = $redis->get($key);
                 *  if($count > 5){
                 *      exit('请求太频繁,请稍后再试!');
                 *  }
                 */
            }
            else
            {
                DateTime dt = DateTime.Now.AddDays(1);
                RedisCacheTools.Incr(key);

                /*
                 *  $redis->incr($key);
                 *      //限制时间为60秒
                 *      $redis->expire($key,60)
                 */
                RedisCacheTools.Expire(key, dt);
            }

            return(true);
        }
示例#5
0
        private string gotoRedirectUrl = "/404.html";//最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string jump    = QueryString("jump"); //参数1:用户传当前推广的网址
            string getJump = jump;                //参数1:用户传当前推广的网址

            if (string.IsNullOrEmpty(getJump))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                Random ran     = new Random();
                int    RandKey = ran.Next(00, 99);
                getJump = getJump + "!" + RandKey;

                string domainLeft = "https://";
                string isHttps    = ConfigTool.ReadVerifyConfig("IsSSL", "WapToWeiXin");
                if (isHttps.ToLower() == "false")
                {
                    domainLeft = "http://";
                }

                string domainCenter = GetRandHostUrl();
                gotoRedirectUrl = domainLeft + domainCenter + "/HomeWX.aspx";


                string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                html = html.Replace("$newsView", gotoRedirectUrl).Replace("$newsValue", getJump);

                bool check = RedisCacheTools.Exists(jump + "IsTitle");
                if (check)
                {
                    html = html.Replace("太阳湾软件", "");
                }

                context.Response.Write(html);
            }
            context.Response.End();
        }