PDA

View Full Version : How to BAN IP ? Please help!


kaisellgren
06-25-2006, 02:45 PM
Hi,

I have made a wonderful IP listing script, buttt...

How do I make a script that checks wheather a $ip value is listed in a ban.txt called file. The ips are listed one per one line.

Help?

lavinpj1
06-25-2006, 03:00 PM
Something like...


<?php
$filename = "ban.txt";
$handle = fopen($filename, "r");
$string = fread($handle, filesize($filename));
fclose($handle);

$sArr = explode("\n",$string);

if (in_array($_SERVER['REMOTE_ADDR'], $sArr)) {
die("YOU BE BANNED!!");
}
?>


~Phil~