I need to write a script which disables an IP address if that IP do more than 5 queries in less than 3 minutes.
Thank you
Search Box to Block IP Address
Moderator: General Moderators
Re: Search Box to Block IP Address
Okay. Go right ahead.
Maybe you have a question to ask?
Maybe you have a question to ask?
Re: Search Box to Block IP Address
Yes my question is how to write it ...any help please? or a hint
Re: Search Box to Block IP Address
Configuring your web server would be the best way. But if you want to do it in PHP...
Make every PHP page start with a specific file - auto_prepend_file can be useful for that. Have it look somewhere for a list of IP address/access time pairs. If it finds more than 5 requests within 180 seconds then it stops execution (or whatever you want).
Otherwise it logs the IP (look in $_SERVER) and the time and lets the rest of the code continue.
Make every PHP page start with a specific file - auto_prepend_file can be useful for that. Have it look somewhere for a list of IP address/access time pairs. If it finds more than 5 requests within 180 seconds then it stops execution (or whatever you want).
Otherwise it logs the IP (look in $_SERVER) and the time and lets the rest of the code continue.