Page 1 of 1

Log and blocking visitors to your site

Posted: Wed Dec 28, 2011 6:13 am
by polarbear1981
// I have write some code but I want to improve this code so maby somebody have some suggestions to improve this code

Code: Select all

<?
$banned[0]="82.100.220.59"; 
$banned[1]="119.27.62.254";
if (in_array($_SERVER['REMOTE_ADDR'],$banned)) 
{ 
echo "<b>You have no permission to visit this site.</b>"; 

exit;
}
?>

<html>
<h1>voorbeeld.com </h1>
<br>

This site is under construction <br>
Regards moderator. <br><br>

<A HREF="http://www.voorbeeld.com/contact.php">Contact</A> <br><br>
</html>

<?
 
$ip= $_SERVER['REMOTE_ADDR'] . "   -  index.php - " ;
$date= date('D M j G:i:s T Y') . " -";
$data= $date . " ". $ip;


$logfile = '/home/polarbear/domains/voorbeeld.com/public_html/log.php'; 

if (!$handle = fopen($logfile, 'a+')) { 
   die("Failed to open log file"); 
} 

if (fwrite($handle, $data ) === FALSE) { 
    die("Failed to write to log file"); 
} 
   
fclose($handle); 
?>

Re: Log and blocking visitors to your site

Posted: Wed Dec 28, 2011 7:42 pm
by Christopher
Looks fine. What part do you want to improve -- the blocking or logging?