Código
<?php /* Listado con las IPs */ /* Listado con el rango de IP. Use the '*' as the range selector */ /* Ip Visitante */ $user_ip = $_SERVER['REMOTE_ADDR']; /* Mensaje que verá si está baneado */ $msg = 'You do not have permission to access this page.'; /* Message to output if the IP is in the ban list */ { } /* Check if the Visitor's IP is in our range's list */ { foreach($ban_ip_range as $range) { { } } } ?>
Explicación de cómo banear correctamente un rango:
Ayuda:Cómo bloquear un rango
http://es.wikipedia.org/wiki/Ayuda:C%C3%B3mo_bloquear_un_rango
Usando mejor siempre el sufijo /24 para bloquear 256 ip's
Código
<? $banned[0]="x.x.x.x"; { exit; } ?>
Código
<?php foreach ($ipArray as $ipTest) { } } ?>
Código
<? $targetAddr = "123.123..*..*"; //yes is two dots //this code will match any class of 123.123.x.x, //you can also do "123.123.123..*" to do anything that is 123.123.123.x //remote address match, do something or don't do anything } else { //do whatever you want to address that doesn't match } ?>
Código
<?php $ip = $_SERVER['REMOTE_ADDR']; for ($i=0; $i<$contador; $i++) { ?>
Mirando un listado de ip's un fichero txt
Código
<?php $count_blocks = 0; foreach($ip_lines as $single_line){ if($ip[1] == $_SERVER['REMOTE_ADDR']){ } } ?>
Código
<?php $banned_ip[] = '111.111.111.111'; $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 "You have been banned!"; } } // rest of PHP Script here! ?>
Código
<?php { if($ip == FALSE) { return FALSE; } { return FALSE; } foreach($range AS $key => $val) { { return FALSE; } else { if($start_ip == FALSE) { return FALSE; } } { if($ip == $start_ip) { return TRUE; } } else { if($stop_ip == FALSE) { return FALSE; } } if($start_ip <= $ip && $ip <= $stop_ip) { return TRUE; } } return FALSE; } function longip($ip) { { return FALSE; } { return FALSE; } $i = 3; $block_ip = 0; foreach($block as $k => $v) { if($v < 0) { $v = 0; } if($v > 255) { $v = 255; } $i--; } return $block_ip; } //usage '192.168.4.0 - 192.168.4.255', '192.168.6.1' ); $ip = '192.168.3.255'; if(ban($block_range, '192.168.6.1')) { echo "BAN\n"; } else { echo "UNBAN\n"; } ?>