Gazelle/classes/proxies.class.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
//Useful: http://www.robtex.com/cnet/
$AllowedProxies = array(
//Opera Turbo (may include opera owned IPs that aren't used for Turbo, but shouldn't run much risk of exploitation)
'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;
for ($i=0,$il=count($AllowedProxies);$i<$il;++$i) {
//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
for ($j=0,$jl=strlen($IP);$j<$jl;++$j) {
//completed iteration and no inequality
if ($j == $jl-1 && $IP[$j] === $AllowedProxies[$i][$j]) {
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;
}