Your FREE membership includes:
|
| Shortcut links: |
|
|
Like this topic? Digg it...
|
![]() ![]() |
Dec 2 2007, 09:36 AM
Post
#1
|
|
|
Starter Member Group: Members Posts: 30 Joined: 2-December 07 Member No.: 1282 |
<?
$IP=$_SERVER['REMOTE_ADDR']; $banned=array('255.255.255.1', '60.190.240.76', '85.140.220.7', '62.205.212.194'); if(in_array($IP, $banned)){ die("YOU ARE BANNED!"); } ?> If u want 2 put more ip adreses yust add , 'ip' at the end of array tag! |
|
|
|
Dec 5 2007, 12:37 AM
Post
#2
|
|
|
Professional ![]() Group: Moderators Posts: 1169 Joined: 13-January 07 From: St.Louis Member No.: 496 |
You could also just edit your .htaccess file...
CODE <Limit GET POST> order allow,deny deny from XX.XX.X.XX deny from XXX.XXX.XXX.XXX allow from all </Limit> Or use this more advanced script; CODE <html> <head> <title>:: IP Banner by Bri ::</title> </head> <body> <!--Start of Banned IP Addresses & Security Log Script --> <?php // Allows you to ban people from viewing your website. $getip = $_SERVER["REMOTE_ADDR"]; $getdate = date( "l dS of F Y" ); $gettime = date( "h:i:sa (@B" ); $banned_ip = array(); $banned_ip[] = '111.111.111.110'; $banned_ip[] = '111.111.111.111'; $banned_ip[] = '111.111.111.112'; $banned_ip[] = '111.111.111.113'; $banned_ip[] = '111.111.111.114'; foreach($banned_ip as $banned) { $ip = $_SERVER['REMOTE_ADDR']; if($ip == $banned){ echo "It seems you have been banned from viewing this website."; echo "<br />"; echo "If you think you have been banned in error please contact me."; $fp = fopen("bans.txt", "a"); fputs($fp, "**BANNED** Visit logged on $getdate at $gettime internet time) for IP: $getip "); fputs($fp, ""); fclose($fp); exit(); } } echo "<b><font size=3 color=#000000>Update in progress.</font></b>"; echo "<br />"; echo "'<b><font color=#007700>Authorized Visit</font></b>' detected and logged on $getdate at $gettime internet time) for IP: $getip"; $fp = fopen("bans.txt", "a"); fputs($fp, "Authorized Visit logged on $getdate at $gettime internet time) for IP: $getip "); fputs($fp, ""); fclose($fp); ?> <!--End of Banned IP Addresses & Security Log Script --> </body> </html> Make a bans.txt text file and CHMOD it to 777. -------------------- |
|
|
|
Dec 8 2007, 09:00 AM
Post
#3
|
|
|
Newbie Group: Members Posts: 10 Joined: 8-December 07 Member No.: 1294 |
|
|
|
|
Jan 8 2008, 08:18 PM
Post
#4
|
|
![]() Professional Group: Members Posts: 539 Joined: 20-October 07 Member No.: 1199 |
Cool! these are neat. I haven't had problems with spammers before but this can be used for other things such as checking that one computer only makes one account etc.
A very helpful tutorial. -------------------- |
|
|
|
Jan 10 2008, 12:00 AM
Post
#5
|
|
|
Starter Member Group: Members Posts: 86 Joined: 12-January 07 Member No.: 491 |
Banning IPs generally isn't that effectives simply because most accounts with ISP's use dynamic IP which means they change rapidly. This means after a month the spammers IP will most likely be different and as such you will be banning/blocking an innocent user.
|
|
|
|
Jan 10 2008, 02:13 PM
Post
#6
|
|
![]() Professional Group: Members Posts: 539 Joined: 20-October 07 Member No.: 1199 |
Good point, but how else can you block a spammer?
-------------------- |
|
|
|
Aug 5 2008, 10:52 PM
Post
#7
|
|
|
Advanced Member Group: Members Posts: 233 Joined: 17-October 06 From: Myanmar Member No.: 69 |
QUOTE Banning IPs generally isn't that effectives simply because most accounts with ISP's use dynamic IP which means they change rapidly. This means after a month the spammers IP will most likely be different and as such you will be banning/blocking an innocent user. Right, How could we solve this problem? How can we check spammer's IP and someone who come through proxy server? -------------------- |
|
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
13 | Mario | 578 | 20th May 2007 - 08:29 PM Last post by: Mario |
|||
![]() |
7 | Knox | 321 | 15th February 2008 - 01:16 PM Last post by: mrdj204 |
|||
![]() |
4 | Corey | 195 | 25th January 2007 - 11:16 AM Last post by: Blazer |
|||
![]() |
1 | Corey | 152 | 19th March 2007 - 12:27 AM Last post by: Hood15 |
|||
![]() |
2 | Corey | 167 | 5th December 2007 - 12:33 AM Last post by: Corey |
|||
| Lo-Fi Version | Time is now: 7th January 2009 - 08:36 PM |