Solved

Controlling number of user searches

Posted on 2008-06-26
5
173 Views
Last Modified: 2013-12-12
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
Comment
Question by:jrmajor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:JurgenvH
ID: 21878677
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
 

Author Comment

by:jrmajor
ID: 21878703
my apologies for not adding this information!

no the feature will be available to all users i.e. there are no registered users.
0
 
LVL 2

Expert Comment

by:JurgenvH
ID: 21878771
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
 

Author Comment

by:jrmajor
ID: 21878820
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
 
LVL 2

Accepted Solution

by:
JurgenvH earned 250 total points
ID: 21878975
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question