Jump to content

Recommended Posts

After a couple days of search google and looking through the plethora of books here on the shelf, I have come to the conclusion that what I am looking for I simply don't have the right terminology for it as the results I am getting are clearly not what I am looking for.  Therefore I post in hope that someone here could shine a light onto where I am going wrong.

 

The Brief:

 

I have an IP address lookup script that can use GET or POST to produce the GEO Location of an IP address, fairly simply stuff.  However the system is getting abused which is not fair on our other visitors looking to find out those nasties.

 

I would like to LIMIT the amount of lookups, say 10 in any one hour.  This is where I hit the proverbial wall, as I am unsure as to how one could achieve this, nor do I have an understanding on what this would be called as my assumed "Limit Form Submits" does not bear fruit.

 

Any help, guidance of RTFMs appreciated.

One way to do it is to have a database table with 2 columns: an ID column and a timestamp column.  Each time the form is submitted, insert a row into the table with the current timestamp and ID of the user.  If you require the user to be logged in, you can use their ID associated with their login that you should already have. Also, requiring login will make it easier to enforce your limit.  If you do not require login, you can use their IP address instead.  This can easily be spoofed (e.g. user goes through a proxy service) but there's no much you can do about that, except to make them login.

 

Then you will have logic that selects by the ID for the last hour and if there's more than 10 entries, give an appropriate message instead of performing the lookup.

 

Should prolly make an additional script to purge old data and put that on a cron job, unless you want to keep records for something else (e.g. showing user a history of use, etc.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.