#region 禁止代理服务器的cc攻击 if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)//使用代理服务器,则禁止 { string path2 = Server.MapPath("/cc/"); if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } string filename1 = path2 + "//" + DateTime.Now.ToShortDateString() + "_代理服务器.txt"; string content1 = "代理服务器IP:" + Request.ServerVariables["HTTP_X_FORWARDED_FOR"] + "/t真实IP:" + Request.ServerVariables["REMOTE_ADDR"] + "/t" + DateTime.Now.ToString() + "/r/n"; FileObj.FileAdd(filename1, content1); Response.Redirect("/cc.shtml"); Response.End(); } #endregion #region 刷新频繁的防CC攻击 if (Session["refresh"] == null || Session["refresh"]=="") { Session["refresh"] = 1; Session["tid"] = tid; Session["proid"] = proid; Session["page"] = _page; } else { if (Session["page"].ToString() == _page.ToString() && Session["proid"].ToString() == proid.ToString() && Session["tid"].ToString() == tid.ToString()) { Session["refresh"] = Convert.ToInt32(Session["refresh"]) + 1; if (Convert.ToInt32(Session["refresh"]) > 5) { string path1 = Server.MapPath("/cc/"); if (!Directory.Exists(path1)) { Directory.CreateDirectory(path1); } string filename = path1 + "//" + DateTime.Now.ToShortDateString() + "_刷新频繁.txt"; string content = Fun.GetIp() + "/t" + DateTime.Now.ToString() + "/r/n"; FileObj.FileAdd(filename, content); Session["refresh"] = ""; Session["tid"] = ""; Session["proid"] = ""; Session["page"] = ""; Response.Redirect("/cc.shtml"); Response.End(); } } } #endregion