Page 1 of 1

How to limit php 1 load per hour?

Posted: Sun Jun 08, 2008 11:05 am
by baoky
How to limit php 1 load per hour?

I want to make e.g my download.php can be only call once by a single ip once per hour.

if user call over 1 time within the hour , they will be Echo Error message that they only can call once with time left to the next call . is it possible?

can anyone provide me the code . thanks !

Re: How to limit php 1 load per hour?

Posted: Sun Jun 08, 2008 11:32 am
by onion2k
baoky wrote:How to limit php 1 load per hour?

I want to make e.g my download.php can be only call once by a single ip once per hour.

if user call over 1 time within the hour , they will be Echo Error message that they only can call once with time left to the next call . is it possible?
Sure it's possible. Store a list of the IP addresses that have accessed the script in a database table with a timestamp. Whenever someone tries to download the file check the list ... if the IP isn't there then the user is allowed to download the file, which you send to them, and at the same time add their IP to the table with the current time. If the user's IP is already in the table then don't send them the file. Whenever anyone accesses the script delete any timestamps that are more than an hour old before checking if the current user is allowed though, otherwise if noone has accessed the download since that user tried then they would be blocked.

Eg

User loads the script
Delete all the IP addresses more than 1 hour old
Check for the user's IP
If it's not there send the file to the user
If it is there send the error message to the user
Add the user's IP to the database table
baoky wrote:can anyone provide me the code . thanks !
No. Noone here is running a free code writing service for you. If you want to pay someone then post in the Job Hunt folder.