IP Banner

Dismounted

59.***.***.***
1,440 days ago

IP Banner

IP Banner This will ban certain IP's from accessing your site. Make a new file called "ipban.php" and insert this code:

PHP code:

<?php function ip_check() { // IP's to Block if ( in_array($_SERVER['REMOTE_ADDR'], $block_ip) ) { return false; } else { return true; } } ?>

To add a new IP, just type under "// IP's to Block":

PHP code:

$block_ip[] = 'ip.address.to.block';

Replace "ip.address.to.block" with the IP. You can do this as many times as you want. To make it work, add this to the top of pages you want to activate bans.

PHP code:

<?php include 'ipban.php'; if ( !ip_check() ) { die ('Your IP is been banned.'); } ?>

That should be it! :)

phool4fool

203.***.***.***
1,417 days ago

Ban range of IPs rather than just one

With this simple script you can ban a range of ips instead of just 1 or two at a time. Simply edit the array range.
php:

PHP code:

0<?php
1 // Addresses to block.
2 $range = array('0'=>'127.0.0',
3 '1'=>'198.168'
4 );
5
6 // Check current IP.
7 foreach($range as $list){
8 if(strstr($_SERVER['REMOTE_ADDR'], $list)){
9 echo 'BANNED!';
10 exit();
11 }
12 }
13?>


Usage Example:
php:

PHP code:

0<?php
1 // Addresses to block.
2 $range = array('0'=>'127.0.0',
3 '1'=>'198.168'
4 );
5
6 // Check current IP.
7 foreach($range as $list){
8 if(strstr($_SERVER['REMOTE_ADDR'], $list)){
9 echo 'BANNED!';
10 exit();
11 }
12 }
13?>