IPB
Your FREE membership includes:
  • A friendly community where you can come to chat
  • Receive completely FREE quality web hosting!
  • Get reviews and suggestions for your websites!
  • Take part in competitions where you can win prizes from cash, vouchers, or win special unadvertised hosting

Welcome Guest ( Log In | Register )


Shortcut links:
Like this topic? Digg it... Digg this topic · Save to del.icio.us · Slashdot It · Post to Technorati · Post to Furl · Submit to Reddit · Share on Facebook · Fark It · Googlize This Post · Add to ma.gnolia · Tag to Wink · Add to MyWeb · Add to Netscape
 
Reply to this topicStart new topic
> Banning a user's IP, There is a spammer at your site? Learn how to ban him!
escsy
post Dec 2 2007, 09:36 AM
Post #1


Starter Member
Group Icon

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!
Go to the top of the page
 
+Quote Post
Corey
post Dec 5 2007, 12:37 AM
Post #2


Professional
Group Icon

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.


--------------------
Need a PHP script, or help with programming? Visit ScriptScribes.com!

ScriptScribes.com!


-Corey
Go to the top of the page
 
+Quote Post
testtorrent
post Dec 8 2007, 09:00 AM
Post #3


Newbie


Group: Members
Posts: 10
Joined: 8-December 07
Member No.: 1294



QUOTE(escsy @ Dec 2 2007, 09:36 AM) *
<?
$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!



this is easy
Go to the top of the page
 
+Quote Post
javayahtzee
post Jan 8 2008, 08:18 PM
Post #4


Professional
Group Icon

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.


--------------------
Go to the top of the page
 
+Quote Post
schumacher
post Jan 10 2008, 12:00 AM
Post #5


Starter Member
Group Icon

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.
Go to the top of the page
 
+Quote Post
javayahtzee
post Jan 10 2008, 02:13 PM
Post #6


Professional
Group Icon

Group: Members
Posts: 539
Joined: 20-October 07
Member No.: 1199



Good point, but how else can you block a spammer?


--------------------
Go to the top of the page
 
+Quote Post
aungcho
post Aug 5 2008, 10:52 PM
Post #7


Advanced Member
Group Icon

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?


--------------------
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are browsing this forum (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts  
13 Mario 578 20th May 2007 - 08:29 PM
Last post by: Mario
No New Posts  
7 Knox 321 15th February 2008 - 01:16 PM
Last post by: mrdj204
No New Posts  
4 Corey 195 25th January 2007 - 11:16 AM
Last post by: Blazer
No New Posts  
1 Corey 152 19th March 2007 - 12:27 AM
Last post by: Hood15
No New Posts  
2 Corey 167 5th December 2007 - 12:33 AM
Last post by: Corey



© GrandForums.com