ragazzi ho questo codice:
Codice PHP:
<?php
function ip2double($ip) {
return (double)(sprintf("%u", ip2long($ip)));
}
function in_network($ip, $netip = '192.168.0.0', $netmask = '255.255.255.0') {
$network = long2ip(ip2long($netip) & ip2long($netmask));
$broadcast = long2ip(ip2long($netip) | (ip2long($netmask) ^ ip2long("255.255.255.255")));
$net = ip2double($network);
$bcast = ip2double($broadcast);
$ip = ip2double($ip);
if ($ip >= $net && $ip <= $bcast) {
return true;
}
return false;
}
$ranges = array();
$ranges[] = array('ip' => '10.0.0.0', 'netmask' => '255.0.0.0');
$ranges[] = array('ip' => '151.0.0.0', 'netmask' => '255.0.0.0');
$blocked = false;
foreach ($ranges as $range) {
$blocked = $blocked || in_network($_SERVER['REMOTE_ADDR'], $netip = '192.168.0.0', $netmask = '255.255.255.0');
}
if ($blocked) {
die('NON TI è PERMESSO ACCEDERE!');
}
echo('Accesso consentito');
?>
vorrei che invece del messaggio non ti è permesso accedere ti indirizzasse in una pagina noaccess.php
e se fosse accesso consentito al normale index.php
potete aiutarmi'???
grazie