Search Box to Block IP Address

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
omar.php
Forum Newbie
Posts: 3
Joined: Wed Jun 10, 2009 4:38 pm

Search Box to Block IP Address

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Search Box to Block IP Address

Post by requinix »

Okay. Go right ahead.




Maybe you have a question to ask?
omar.php
Forum Newbie
Posts: 3
Joined: Wed Jun 10, 2009 4:38 pm

Re: Search Box to Block IP Address

Post by omar.php »

Yes my question is how to write it ...any help please? or a hint
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Search Box to Block IP Address

Post 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.
Post Reply