2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
//Useful: http://www.robtex.com/cnet/
|
|
|
|
$AllowedProxies = array(
|
2013-06-18 08:00:48 +00:00
|
|
|
//Opera Turbo (may include Opera-owned IP addresses that aren't used for Turbo, but shouldn't run much risk of exploitation)
|
2011-03-28 14:21:28 +00:00
|
|
|
'64.255.180.*', //Norway
|
|
|
|
'64.255.164.*', //Norway
|
|
|
|
'80.239.242.*', //Poland
|
|
|
|
'80.239.243.*', //Poland
|
|
|
|
'91.203.96.*', //Norway
|
|
|
|
'94.246.126.*', //Norway
|
|
|
|
'94.246.127.*', //Norway
|
|
|
|
'195.189.142.*', //Norway
|
|
|
|
'195.189.143.*', //Norway
|
|
|
|
);
|
|
|
|
|
|
|
|
function proxyCheck($IP) {
|
|
|
|
global $AllowedProxies;
|
2013-06-18 08:00:48 +00:00
|
|
|
for ($i = 0, $il = count($AllowedProxies); $i < $il; ++$i) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//based on the wildcard principle it should never be shorter
|
|
|
|
if (strlen($IP) < strlen($AllowedProxies[$i])) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//since we're matching bit for bit iterating from the start
|
2013-06-18 08:00:48 +00:00
|
|
|
for ($j = 0, $jl = strlen($IP); $j < $jl; ++$j) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//completed iteration and no inequality
|
2013-06-18 08:00:48 +00:00
|
|
|
if ($j == $jl - 1 && $IP[$j] === $AllowedProxies[$i][$j]) {
|
2011-03-28 14:21:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//wildcard
|
|
|
|
if ($AllowedProxies[$i][$j] === '*') {
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//inequality found
|
|
|
|
if ($IP[$j] !== $AllowedProxies[$i][$j]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|