Ranger135xp
2006-12-20 21:02:49
this will ban a person's Ip address from your site. now u can ban that pesky person who mis-uses ur forms or forums.
this goes in after the <BODY> tag on the pages u want to be protected and blocked from this person or people:
[PHP]<?php $message; require('/banned.php'); echo "$message";?>[/PHP]
this goes in the file u should name "banned.php", put it in the site's root folder or rename the above script according to it's path or name.
this belongs in that "banned.php" file:
[PHP]<?php // Allows you to ban people from viewing your website.
$getip = $_SERVER["REMOTE_ADDR"];
$getdate = date( "l dS of F Y" );
$timezone=-4;//YOu will probably pull this value from the database. I used -6 because I live in Iowa ;)
$time=time();//It is a timestamp of the event. You will also pull this from the DB
$gmttime= gmdate("M d Y H:i:s", $time);
$convertedtime=date("l - F j, Y - g:i:s A",strtotime("$timezone hours",strtotime($gmttime)));
$gettime = $convertedtime;
$banned_ip = array();
$banned_ip[] = '111.111.111.116';
$banned_ip[] = '111.111.111.111';
$banned_ip[] = '111.111.111.115';
$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 "<center><font size=4 color=#ffffff>It seems you have been banned from viewing this website.";
echo "<br><br>";
//if($wait) echo "<center><font size=4 color=#ffffff>You are banned for $wtime more $days.";
//echo "<br><br>";
echo "Have a Nice Day.</font></center>";
$fp = fopen("/ip_data.txt", "a");
fputs($fp, "**BANNED** Visit logged on $gettime for IP: $getip
");
fputs($fp, "");
fclose($fp);
exit();
}
}
/*$message= "<b><font size=3 color=#000000>Update in progress.</font></b>";
$message.= "<br />";
$message.= "'<b><font color=#007700>Authorized Visit</font></b>' detected and logged on $gettime for IP: $getip";
//$fp = fopen("/ip_data.txt", "a");
//fputs($fp, "Authorized Visit logged on $gettime for IP: $getip");
//fputs($fp, "");
//fclose($fp);*/
return $message;
?>[/PHP]
happy PHP scripting!
this goes in after the <BODY> tag on the pages u want to be protected and blocked from this person or people:
[PHP]<?php $message; require('/banned.php'); echo "$message";?>[/PHP]
this goes in the file u should name "banned.php", put it in the site's root folder or rename the above script according to it's path or name.
this belongs in that "banned.php" file:
[PHP]<?php // Allows you to ban people from viewing your website.
$getip = $_SERVER["REMOTE_ADDR"];
$getdate = date( "l dS of F Y" );
$timezone=-4;//YOu will probably pull this value from the database. I used -6 because I live in Iowa ;)
$time=time();//It is a timestamp of the event. You will also pull this from the DB
$gmttime= gmdate("M d Y H:i:s", $time);
$convertedtime=date("l - F j, Y - g:i:s A",strtotime("$timezone hours",strtotime($gmttime)));
$gettime = $convertedtime;
$banned_ip = array();
$banned_ip[] = '111.111.111.116';
$banned_ip[] = '111.111.111.111';
$banned_ip[] = '111.111.111.115';
$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 "<center><font size=4 color=#ffffff>It seems you have been banned from viewing this website.";
echo "<br><br>";
//if($wait) echo "<center><font size=4 color=#ffffff>You are banned for $wtime more $days.";
//echo "<br><br>";
echo "Have a Nice Day.</font></center>";
$fp = fopen("/ip_data.txt", "a");
fputs($fp, "**BANNED** Visit logged on $gettime for IP: $getip
");
fputs($fp, "");
fclose($fp);
exit();
}
}
/*$message= "<b><font size=3 color=#000000>Update in progress.</font></b>";
$message.= "<br />";
$message.= "'<b><font color=#007700>Authorized Visit</font></b>' detected and logged on $gettime for IP: $getip";
//$fp = fopen("/ip_data.txt", "a");
//fputs($fp, "Authorized Visit logged on $gettime for IP: $getip");
//fputs($fp, "");
//fclose($fp);*/
return $message;
?>[/PHP]
happy PHP scripting!