Program | repeat | This is an ASP adapted version of the CGI subroutine that uses the ReadAll method of the TextStream object in the FileSystemObject object. Therefore, you need to periodically clean up the record file Floodcheck.ini. Lest affect the speed. One advantage of this approach is that it leaves the Post's IP address record and can be applied to different types of systems. (Just use Response.Redirect "Your processing post ASP page" in your processing code).
I adapted the ASP code
<%
' Prevent duplicate submission of ASP code
' Floodcheck.ini file format
' Last Published time | IP Address
' Variable declaration
' Two post intervals to be divided into units
Dim Wait_between_post
' IP address of the person who posts
Dim ipnumber
' This post time
Dim This_post_time
' Last Post time
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
' Replace with your processing code
Response.Write "Go to post Process page or process code"
Response.End
' Replace with your processing code
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 ' converts to seconds
Set fso=nothing
' Replace with your processing code
Response.Write "Sorry, you have just published an article, in order to avoid repeated publication, please return" & Wait_between_post & minutes later to publish your article. "
Response.End
' Replace with your processing code
End If
Next
' 8 ForAppending
Set F=fso. OpenTextFile ("Floodcheck.ini", 8,true)
F.writeline (This_post_time & "|" & Ipnumber)
F.close
Set fso=nothing
' Replace with your processing code
Response.Write "Go to post Process page or process code"
Response.End
' Replace with your processing code
End If
%>
CGI Original CodeExcerpt from the classic forum 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 ' 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 (/\|!! \|/,$_);