![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() |
IP Blocking method (finished, source included)
block.php :
<?php
$list = array(
"123.*.*.*",
"124.51.12.*"
);
function checkBlockList() {
global $list;
foreach($list as $ip) {
$ip = split($ip, ".");
$rmip = split($_SERVER['REMOTE_ADDR'], ".");
$count = 0;
if(count($ip) != 4)
die("Invald IP in \$list array. Check \"{$_SERVER['PHP_SELF']}\" file.");
if(count($rmip) != 4)
die("Invalid remote IP address??!?!");
for($i=0;$i<4;$i++)
if(trim($ip[$i]) != "*" && trim($ip[$i]) != trim($rmip[$i]))
break;
if($i == 4)
die("Your IP is invalid. You're blocked, must suck.");
}
}
?>index.php (implementation example) : <?php
include("block.php");
checkBlockList();
echo "You aren't on the block list, welcome!";
?>
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|