• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

Controlling number of user searches

hi,

we are adding a php lookup/search feature on our website (lamp).  This feature searches against a single table in a mysql database.

What methods can I use to limit the number of searches performed by users over a period of time e.g. 10mins?  

thanks!
0
jrmajor
Asked:
jrmajor
  • 3
  • 2
1 Solution
 
JurgenvHCommented:
Do you have registered users who can search or can everybody search who visits the website?
In the last case you'd best track the seaches bij IP-address. Register the searches in a database.
0
 
jrmajorAuthor Commented:
my apologies for not adding this information!

no the feature will be available to all users i.e. there are no registered users.
0
 
JurgenvHCommented:
Then probably the check on IP-address will be sufficient. It probably doesn't matter how many people download from the same computer, they can't work on it at the same time.
$_SERVER['REMOTE_ADDR'] gives you the IP-address, save this in the database with a download counter
0
 
jrmajorAuthor Commented:
ok so I would write the ip address to a table and have an autoincrement field to keep track of the number of searches.

what do you think would be best approach for checking the number of searches over a fixed period of time?
0
 
JurgenvHCommented:
Say you wish max of 5 downloads in 10 minutes.
Every time a download starts you check if the ip is already present in the table. If not:
- write the ipaddress to a table with 1 as no. of downloads and a timestamp.

If the ip address is found, check timestamp to current time. If the difference is less than 10 minutes:
- increment no. of downloads (no change of timestamp)

If the difference is greater than 10 minutes:
- update no. of downloads to 1 and timestamp to current time
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now