Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Prevent multiple postings
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Prevent multiple postings

 Post Reply Post Reply
Author
Eagle View Drop Down
Newbie
Newbie


Joined: 09 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eagle Quote  Post ReplyReply Direct Link To This Post Topic: Prevent multiple postings
    Posted: 28 November 2003 at 4:44pm

I’m new with all this and I’m trying to prevent the users of my ASP forms to do multiple postings in a few seconds. I’ve found an ASP code that would work but the problem is that it uses a database and I’ve never done that. I don’t even know how to create it or to make the table that it requires. Could someone help me with this stuff, please? Here is the code:

 

<%
      ' This assumes the following:
      ' The database ~abuseConnection~ contains a table called 'abuse'
      ' and this table has two columns, 'ip' and 'ok.' IP contains the
      ' IP address of the poster, 'ok' is when the user may post again.
      
      ' Save the IP address in a variable.
      abuseIP = request.servervariables("REMOTE_HOST")
      ' Enter your database connection string
      abuseConnection = ""
      ' You can add this code as a type of 'last seen function' too,
      ' add a 'doing' table and call this sub with checkAbuse("Posting a message")
      ' or something. For now, just IP and OK will work. Make sure to
      ' include the final WHERE statement.
      abuseSQL = "SELECT ip, ok from abuse where ip = '" & abuseIP & "'"
      ' How many seconds between actions? I use 30 seconds on my site, but its up to you.
      abuseWait = 30
      ' Where do we direct the user if they fail the check?
      abuseDirect = "toofast.asp"
      
      ' Connect to the databse.
      Set abuseConnection = Server.CreateObject("ADODB.Connection")
      abuseConnection.Open abueConnection
      Set abuseRecordset = Server.CreateObject("ADODB.Recordset")
      abuseRecordset.open abuseSQL, abuseConnection, 3, 3
      
      ' If no records exist at all then the user is OK.
      ' All we have to do is add a record and set it for abuseWait seconds from now.
      if abuseRecordset.recordCount = 0 then
       abuseRecordset.addnew
        abuseRecordset("ip") = abuseIP
        abuseRecordset("ok") = dateadd("s", abuseWait, now)
       abuseRecordset.update
       returnValue = True
      else
      ' If a record exists, make sure that the "OK Time" is NOT greater than the
      ' current time. If it is, kick the user to another page, if not, reset the value.
      ' updte the time to 30s and return true.
       if abuseRecordset("ok") > now or isNull(abuseRecordset("ok")) then
        returnValue = False
       else
        abuseRecordset.update "ok", dateadd("s", abuseWait, now)
        returnValue = True
       end if
      end if
      
      abuseRecordset.close
      set abuseRecordset = Nothing
      abuseConnection.close
      set abuseConnection = Nothing
      
      If Not returnValue Then Response.Redirect(abuseDirect)
      ' You may want to turn this to a function for more versatility in your code.
      ' Just change the 'Sub's to 'Function's and add checkAbuse = returnValue.
      ' NOTE: This is really basic. You can add a counter, for example x posts in x seconds,
      ' as well as code to clean older entries. Maybe I'll do it if you REALLY like it :)
     End Sub
    %>

Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 29 November 2003 at 1:21am

Humm, aren't you using wwforums? They already have that feature, go into the admin console and choose the Anti-Spam Configuration option.

If you are not using wwf, it can be done like this: When a post is created, it should write the poster ID and the time it was posted to the DB, when updating the DB, aslo write to the user cookie a new key (ie. antispam) and set the time, then, when the user trys to post again, check against the time he last posted and decide whether to allow or not.

There are other ways, like checking against the DB for the time he last posted.

It would help if you tell us what DB and forums you are using, maybe one of us can mod it for you.

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 29 November 2003 at 10:38am

hey you scientist..

Originally posted by theSCIENTIST theSCIENTIST wrote:

maybe one of us can mod it for you.

Dont say that.. if you say that some of us can mod it for him, ppl think that its just to command us to do it.. thats not the way its gonna be.. they should try themselves first, then ask for help..

but of course, if you want to code for ppl you dont know, thats up to you..

Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 30 November 2003 at 5:30am

Hi AnthraX,

You are right, I shouldn't said WE, and sometimes when I'm free not involved in any project I do provide simple solution for people, let's see what DB he is using, one should assume that since he's posting in this forums that he's using WWF and that feature is already present.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.