2006-11
26

Dottext0.96的版本是没有垃圾控制的,导致Spam无数,又不想去改以前的程序,只好打补丁了。

protected void Application_BeginRequest(Object sender, EventArgs e) {

HttpApplication application = (HttpApplication)sender;

HttpContext context = application.Context;

System.Web.Caching.Cache cache = context.Cache;

string block_ips = String.Empty;

if (cache["block_ips"] == null) {

using (System.IO.FileStream fs = System.IO.File.Open(context.Server.MapPath(“/ip.txt”), System.IO.FileMode.Open)) {

System.IO.StreamReader sr = new System.IO.StreamReader(fs);

block_ips = sr.ReadToEnd();

cache.Insert(“block_ips”, block_ips, new CacheDependency(context.Server.MapPath(“/ip.txt”)));

sr.Close();

}

}

string ip = context.Request.UserHostAddress;

if (cache["block_ips"].ToString().IndexOf(ip) > 0) {

Response.Redirect(“http://www.google.com”);

}

}

: http://blog.dayuer.com/archives/2006/11/26/175.html

I want to say something ...

Login , Register