incipience Posted August 18, 2013 Share Posted August 18, 2013 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. Quote Link to comment Share on other sites More sharing options...
.josh Posted August 18, 2013 Share Posted August 18, 2013 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.) Quote Link to comment Share on other sites More sharing options...
incipience Posted August 19, 2013 Author Share Posted August 19, 2013 Thanks, this gives me a good place to start. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.