|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP脚本是采用明文(plain text)方式来编写的。法式|反复|反复提交 此为CGI子法式的一个Asp改编版本,个中利用FileSystemObject对象中的TextStream对象的ReadAll办法。因而,需求按期清算纪录文件floodcheck.ini。以避免影响速度。该处置办法的一个优点是留有Post者的ip地址纪录而且能使用于分歧类型的体系。(只需在您的处置代码处用Response.Redirect "你的处置Post Asp页")就能够了。
我改编的Asp代码
<%
'避免反复提交的asp代码
'floodcheck.ini文件格局
'最初宣布工夫|IP地址
'变量声明
'两个Post距离工夫,以分为单元
Dim Wait_between_Post
'发贴者IP地址
dim IPNumber
'本次Post工夫
Dim This_Post_Time
'前次Post工夫
Dim Last_Post_Time
Wait_between_Post=0.1
This_Post_time=Now
IPNumber=Request.ServerVariables("REMOTE_ADDR")
dim fso
Set fso=CreateObject("Scripting.FileSystemObject")
'1 forReading
Set f=fso.OpenTextFile("floodcheck.ini",1,true)
if f.atEndOfStream then
f.close
'2 forWritting
Set f=fso.OpenTextFile("floodcheck.ini",2,true)
f.WriteLine(this_Post_Time & "|" & IPNumber)
f.close
Set fso=Nothing
'交换成您的处置代码
response.write "转到到Post处置页或处置代码"
response.end
'交换成您的处置代码
else
dim PostRec
dim varTemp
PostRec=f.ReadAll
f.close
dim objRegExp
Set objRegExp=new RegExp
objRegExp.Pattern=".+|" & IPNumber & ""
objRegExp.Global = True
Set objMatches = objRegexp.Execute(PostRec)
for each objMatch in objMatches
varTemp=split(objMatch.Value,"|")
last_post_time=cdate(varTemp(0))
if dateadd("s",wait_between_post*60,last_post_time)>this_post_time then '转化为秒
set fso=nothing
'交换成您的处置代码
response.write "抱愧,您方才宣布过一篇文章,为了不反复宣布,请稍候前往" & wait_between_post & "分钟再宣布您的文章."
response.end
'交换成您的处置代码
end if
next
'8 forAppending
Set f=fso.OpenTextFile("floodcheck.ini",8,true)
f.WriteLine(this_Post_Time & "|" & IPNumber)
f.close
set fso=nothing
'交换成您的处置代码
response.write "转到到Post处置页或处置代码"
response.end
'交换成您的处置代码
end if
%>
CGI原代码 摘自经典服装论坛http://202.106.124.52/zmy/ubb/Ultimate.cgi?action=intro
sub floodcheck
{ # blocks multiple posting in a short period
$wait_between_posts = "0.2"; # edit in the default number of minutes to wait
$lastpost_list_length = 15; # edit in the number of records to keep
my $IPNumber = $ENV{'REMOTE_ADDR'}; # the IP address
my $this_post_time = time(); # secs since 1970
open(LASTPOST, "$NonCGIPath/BanLists/Floodcheck.cgi"); # don't bother with error code if it doesn't exist
@last_post_list = <LASTPOST>;
close(LASTPOST);
foreach (@last_post_list)
{ # check if this user has posted already
if (/^$IPNumber/){
($junk,$last_post_time) = split(/\|!!\|/,$_);  </p> asp可以使用微软的activeX 使得网页功能无比强大,不过安全性也较差,而且是基于的windows服务器,所以性能稳定性也一般 |
|