Page 1 of 1

Search Box to Block IP Address

Posted: Wed Jun 10, 2009 4:52 pm
by omar.php
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

Re: Search Box to Block IP Address

Posted: Wed Jun 10, 2009 6:03 pm
by requinix
Okay. Go right ahead.




Maybe you have a question to ask?

Re: Search Box to Block IP Address

Posted: Wed Jun 10, 2009 6:57 pm
by omar.php
Yes my question is how to write it ...any help please? or a hint

Re: Search Box to Block IP Address

Posted: Wed Jun 10, 2009 7:06 pm
by requinix
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.