__Red_EyEs__ Admin
Number of posts : 306 Age : 39 Registration date : 2007-07-10
| Subject: Basic IP Ban script Wed Jul 11, 2007 4:08 am | |
| Okay, heres something quick. All it really does is grab the user's IP and then check it against a list of banned users. If the IP matches a banned one, then it stops them from viewing the site and gives them a message. The code is quite basic, but I'll explain some anyway.
PHP Code:
<php> Pretty simple stuff, but it does the job. Let's explain it a little.
- $ip = getenv('REMOTE_ADDR'); - I'm assigning the person's IP to the variable $ip. $ip is used when checking the IP against the banned list. - $email = "your@mail.com" - Change [email] your@mail.com[/email] to your e-mail. This gives people a chance to contact you in case of a mistake. - $banzored1 = "000.000.000" - Change the 0's to the person's IP you wish to ban. That assigns the banned person's IP to the variable. It is the same with banzored1 to 3. - if($ip == $banzored1 || $ip == $banzored2 || $ip == $banzored3) - Here we're checking the $ip variable (where we stored the persons IP) against a list of banned IPs. If it matches, it echos and will not let them view the site. If it does not match, the user will be allowed to view the site normally.
----
Simple but it works. You can have as many IP's in the $banzored lists as you want. Just remember to assign to the variable and check it in our if statement.
Maybe some more stuff from me coming soon. Will see how popular this is !! See ya | |
|