proxy скрипт

dashe

Registered
Не ми трябва скритп.. :)
За прокси по заглавието.. :)
А ми трябва скрипт които забранява ползването на прокси в сайта.. :)
 
Няма такова нещо. Проксито, влиза в другите компютри и от там влиза в интернета!
Поздрави!
 
luudman каза:
Няма такова нещо. Проксито, влиза в другите компютри и от там влиза в интернета!
Поздрави!
Кофти.. :(
Все пак благодаря.. :?
 
<?php

## CONFIG ##

# Default to simple mode when the page is loaded. [false]
define('DEFAULT_SIMPLE',false);
# Force the page to always be in simple mode (no advanced mode option). [false]
define('FORCE_SIMPLE',false);
# Width for the URL box when in simple mode (CSS "width" attribute). [300px]
define('SIMPLE_MODE_URLWIDTH','300px');

# Default value for tunnel server. []
define('DEFAULT_TUNNEL_PIP','');
# Default value for tunnel port. []
define('DEFAULT_TUNNEL_PPORT','');
# Should the tunnel fields be displayed? "false" value here will force the defaults above [true]
define('FORCE_DEFAULT_TUNNEL',true);

# Default value for "Persistent URL" checkbox [true]
define('DEFAULT_URL_FORM',true);
# Default value for "Remove Cookies" checkbox [false]
define('DEFAULT_REMOVE_COOKIES',false);
# Default value for "Remove Referer Field" checkbox [false]
define('DEFAULT_REMOVE_REFERER',false);
# Default value for "Remove Scripts" checkbox [false]
define('DEFAULT_REMOVE_SCRIPTS',false);
# Default value for "Remove Objects" checkbox [false]
define('DEFAULT_REMOVE_OBJECTS',false);
# Default value for "Encrypt URLs" checkbox [false]
define('DEFAULT_ENCRYPT_URLS',false);
# Default value for "Encrypt Cookies" checkbox [false]
define('DEFAULT_ENCRYPT_COOKS',false);

# Time limit in seconds for a single request and parse. [30]
define('TIME_LIMIT',30);
# Time limit in minutes for a DNS entry to be kept in the cache. [10]
define('DNS_CACHE_EXPIRE',10);

# Protocol that proxy is running on. Uncomment this line to define it manually.
# If you leave this line commented, the code detects if you are running on an
# HTTPS connection. If you are, then 'https' is used as the PROTO value,
# otherwise 'http' is used. If you need a different value here, then define it.
#define('PROTO','http');

/*/ Address Blocking Notes \*\

Formats for address blocking are as follows:

1.2.3.4 - plain IP address
1.2.3.4/24 - subnet blocking
php.net - domain blocking

Default Value: '10.0.0.0/24','172.0.0.0/24','192.168.0.0/16','127.0.0.0/24'

\*\ End Address Blocking Notes /*/

$blocked_addresses=array('10.0.0.0/24','172.0.0.0/24','192.168.0.0/16','127.0.0.0/24');
#$blocked_addresses=array(); # DEBUG

## END CONFIG ##



// DON'T EDIT ANYTHING AFTER THIS POINT \\


#
# (unless you absolutely know what you are doing...)
#


# set error level to not display notices
error_reporting(E_ALL^E_NOTICE);

# set time limit to the defined time limit, if not in safe mode
if(!ini_get('safe_mode')) set_time_limit(TIME_LIMIT);

# use gzip compression if available
if(extension_loaded('zlib') && !ini_get('zlib.output_compression')) ob_start('ob_gzhandler'); # use gzip encoding to compress all data, if possible

# reverse magic quotes if enabled
if(get_magic_quotes_gpc()){
function stripslashes_recurse($var){
if(is_array($var)) $var=array_map('stripslashes_recurse',$var);
else $var=stripslashes($var);
return $var;
}
$_GET=stripslashes_recurse($_GET);
$_POST=stripslashes_recurse($_POST);
$_COOKIE=stripslashes_recurse($_COOKIE);
}

# script environment constants
if(!defined('PROTO')) define('PROTO',($_SERVER['HTTPS']=='on'?'https':'http'));
define('VERSION','1.0-rc1');
define('THIS_SCRIPT',PROTO."://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}");
define('SIMPLE_MODE',DEFAULT_SIMPLE || FORCE_SIMPLE);

# Randomized cookie prefixes #
function gen_randstr($len){
$chars=null;
for($i=0;$i<$len;$i++){
$char=rand(0,25);
$char=chr($char+97);
$chars.=$char;
}
return $chars;
}

function dosetcookie($cookname,$cookval,$expire=null){
$_COOKIE[$cookname]=$cookval;
if($expire===null) setcookie($cookname,$cookval);
else setcookie($cookname,$cookval,$expire);
}

define('FIRST_LOAD',empty($_COOKIE['PHPSESSID']));
session_start();
if(empty($_SESSION['sesspref'])){
$sesspref=gen_randstr(30);
$_SESSION['sesspref']=$sesspref;
}
else $sesspref=$_SESSION['sesspref'];

if(empty($_COOKIE['user'])){
$cookpref=gen_randstr(12);
dosetcookie('user',$cookpref);
}
else $cookpref=$_COOKIE['user'];

define('SESS_PREF',$sesspref);
define('COOK_PREF',$cookpref);
define('COOKIE_SEPARATOR','__'.COOK_PREF.'__');
unset($sesspref,$cookpref);

if(FIRST_LOAD){
if(DEFAULT_URL_FORM) dosetcookie(COOK_PREF.'_url_form',true);
if(DEFAULT_REMOVE_COOKIES) dosetcookie(COOK_PREF.'_remove_cookies',true);
if(DEFAULT_REMOVE_REFERER) dosetcookie(COOK_PREF.'_remove_referer',true);
if(DEFAULT_REMOVE_SCRIPTS) dosetcookie(COOK_PREF.'_remove_scripts',true);
if(DEFAULT_REMOVE_OBJECTS) dosetcookie(COOK_PREF.'_remove_objects',true);
if(DEFAULT_ENCRYPT_URLS) dosetcookie(COOK_PREF.'_encrypt_urls',true);
if(DEFAULT_ENCRYPT_COOKS) dosetcookie(COOK_PREF.'_encrypt_cooks',true);
}

# end #

# SETUP #
global $postandget,$blocked_addresses,$dns_cache_array;
$postandget=array_merge($_GET,$_POST);

define('PAGETYPE_MINIREGEXP','(=[_\.\-]?\&=|=)?');
define('PAGETYPE_REGEXP','/^'.PAGETYPE_MINIREGEXP.'(.*)$/');
if(!empty($postandget[COOK_PREF])) $oenc_url=$postandget[COOK_PREF];
else{
$pagetype_str=preg_replace(PAGETYPE_REGEXP,'\1',$_SERVER['QUERY_STRING']);
define('QUERY_STRING',substr($_SERVER['QUERY_STRING'],strlen($pagetype_str),strlen($_SERVER['QUERY_STRING'])-strlen($pagetype_str)));
define('PAGETYPE_NULL',0);
define('PAGETYPE_FORCE_MAIN',1);
define('PAGETYPE_FRAME_TOP',2);
define('PAGETYPE_FRAMED_PAGE',3);
define('PAGETYPE_FRAMED_CHILD',4); // framing children for crimes isn't very nice, but the script does it anyway
switch($pagetype_str){
case '=&=': define('PAGETYPE_ID',PAGETYPE_FRAME_TOP); break;
case '=_&=': define('PAGETYPE_ID',PAGETYPE_FRAMED_PAGE); break;
case '=-&=': define('PAGETYPE_ID',PAGETYPE_FORCE_MAIN); break;
case '=.&=': define('PAGETYPE_ID',PAGETYPE_FRAMED_CHILD); break;
# this is one more unencoded string for future features
# case '=*&=': define('PAGETYPE_ID',); break;
default: define('PAGETYPE_ID',PAGETYPE_NULL); break;
}
unset($pagetype_str);

define('NEW_PAGETYPE_FRAME_TOP',(PAGETYPE_ID===PAGETYPE_FRAMED_CHILD?PAGETYPE_FRAMED_CHILD:PAGETYPE_FRAME_TOP));
define('NEW_PAGETYPE_FRAMED_PAGE',(PAGETYPE_ID===PAGETYPE_FRAMED_CHILD?PAGETYPE_FRAMED_CHILD:PAGETYPE_FRAMED_PAGE));

$oenc_url=QUERY_STRING;
//define('OENC_URL',urldecode(preg_replace('/^([^&]*).*?$/i','\1',QUERY_STRING)));
}
if(strpos(substr($oenc_url,0,6),'%')!==false || strpos($oenc_url,'%')<strpos($oenc_url,'/') || strpos($oenc_url,'%')<strpos($oenc_url,':')) $oenc_url=urldecode($oenc_url);
define('OENC_URL',preg_replace('/^([^\?\&]+)\&/i','\1?',$oenc_url));
unset($oenc_url);
define('ORIG_URL',proxdec(OENC_URL));
global $curr_url;
$curr_url=ORIG_URL;

function gethardattr($attr){ return (empty($postandget[COOK_PREF.'_set_values'])?!empty($_COOKIE[COOK_PREF."_{$attr}"]):!empty($postandget[COOK_PREF."_{$attr}"])); }
define('ENCRYPT_URLS',gethardattr('encrypt_urls'));
define('URL_FORM',gethardattr('url_form'));
define('PAGE_FRAMED',(PAGETYPE_ID===PAGETYPE_FRAMED_PAGE || PAGETYPE_ID===PAGETYPE_FRAMED_CHILD || QUERY_STRING=='js_regexps_framed' || QUERY_STRING=='js_funcs_framed'));
#define('URLVAR',(ENCRYPT_URLS?'e':null).'url');
# END SETUP #

function my_base64_decode($string){ return base64_decode(str_replace(' ','+',urldecode($string))); }

function proxdec($url){
if(substr($url,0,1)!='~' && strtolower(substr($url,0,3))!='%7e') return $url;
#while(strpos($url,'%')!==false) $url=urldecode($url);
#$url=urldecode($url);
while(substr($url,0,1)=='~' || strtolower(substr($url,0,3))=='%7e'){
$url=substr($url,1,strlen($url)-1);
$url=my_base64_decode($url);
$new_url=null;
for($i=0;$i<strlen($url);$i++){
$char=ord(substr($url,$i,1));
$char-=ord(substr(SESS_PREF,$i%strlen(SESS_PREF),1));
while($char<32) $char+=94;
$new_url.=chr($char);
}
$url=$new_url;
}
return urldecode($url);
}

// JS_PE OBJECT \\
// JS_PROXENC \\
function js_proxenc(){ ?>
//<script>
<?php echo(COOK_PREF); ?>_pe={
expon:function(a,b){
var num;
if(b==0) return 1;
num=a; b--;
while(b>0){ num*=a; b--; }
return num;
},

dectobin:function(){
var dec=arguments[0],chars=arguments[1]||8,binrep="";
for(j=chars-1;j>=0;j--){
if(dec>=this.expon(2,j)){
binrep+="1"; dec-=this.expon(2,j);
}
else binrep+="0";
}
return binrep;
},

bintodec:function(){
var bin=arguments[0],chars=arguments[1]||8,dec=0;
for(var j=0;j<chars;j++) if(bin.substring(j,j+1)=="1") dec+=this.expon(2,chars-1-j);
return dec;
},

b64e:function(string){
var encstr="",binrep="";
var charbin,charnum;
for(var i=0;i<string.length;i++){
charnum=string.charCodeAt(i);
binrep+=this.dectobin(charnum);
}
while(binrep.length%6) binrep+="00";
for(var i=1;i*6<=binrep.length;i++){
charbin=binrep.substring((i-1)*6,i*6);
charnum=this.bintodec(charbin,6);
if(charnum<=25) charnum+=65;
else if(charnum<=51) charnum+=71;
else if(charnum<=61) charnum-=4;
else if(charnum==62) charnum=43;
else if(charnum==63) charnum=47;
encstr+=String.fromCharCode(charnum);
}
while(encstr.length%8) encstr+="=";
return encstr;
},

proxenc:function(url){
var new_url="";
var charnum;
if(url.substring(0,1)=="~" || url.substring(0,3).toLowerCase()=="%7e") return url;
url=encodeURIComponent(url);
var sess_pref="<?php echo(SESS_PREF); ?>";
for(i=0;i<url.length;i++){
charnum=url.charCodeAt(i);
charnum+=sess_pref.charCodeAt(i%sess_pref.length);
while(charnum>126) charnum-=94;
new_url+=String.fromCharCode(charnum);
}
return "~"+encodeURIComponent(this.b64e(new_url));
}
}
<? }

if(PAGETYPE_ID===PAGETYPE_FORCE_MAIN || (substr(QUERY_STRING,0,3)!='js_' && ORIG_URL==null)){

## First Page Displayed When Accessing the Proxy ##

$useragentinfo=null;
if(preg_match('/linux/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Linux';
elseif(preg_match('/win(?:dows|32)/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Windows';
elseif(preg_match('/mac(?:intosh|_powerpc)/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Macintosh';
elseif(preg_match('/bsd/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='BSD';
else $useragentinfo.='Unknown';

$useragentinfo.=' / ';

if(preg_match('/msie/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Internet Explorer';
elseif(preg_match('/firefox/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Firefox';
elseif(preg_match('/netscape/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Netscape';
elseif(preg_match('/konqueror/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Konqueror';
elseif(preg_match('/seamonkey/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='SeaMonkey';
elseif(preg_match('/opera/i',$_SERVER['HTTP_USER_AGENT'])) $useragentinfo.='Opera';
else $useragentinfo.='Unknown';

$useragent_array=array(
array(null,"Actual ({$useragentinfo})"),
array('-1',' [ Don\'t Send ] '),
array('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061024 Firefox/2.0','Windows XP / Firefox 2.0'),
array('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1)','Windows XP / Internet Explorer 7'),
array('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)','Windows XP / Internet Explorer 6'),
array('Opera/9.02 (Windows NT 5.1; U; en)','Windows XP / Opera 9.02'),
array('Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.8.1) Gecko/20061024 Firefox/2.0','Mac OS X / Firefox 2.0'),
array('Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/521.25 (KHTML, like Gecko) Safari/521.24','Mac OS X / Safari 3.0'),
array('Opera/9.02 (Macintosh; PPC Mac OS X; U; en)','Mac OS X / Opera 9.02'),
array('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061024 Firefox/2.0','Linux / Firefox 2.0'),
array('Opera/9.02 (X11; Linux i686; U; en)','Linux / Opera 9.02'),
array('Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko)','Linux / Konqueror 3.5.5'),
array('Links (2.1pre19; Linux 2.6 i686; x)','Linux / Links (2.1pre19)'),
array('Lynx/2.8.5rel.1','Any / Lynx 2.8.5rel.1'),
array('Dillo/0.8.6','Any / Dillo 0.8.6'),
array('Wget/1.10.2','Any / Wget 1.10.2'),
array('1',' [ Custom ] <noscript><b>**</b></noscript>')
);

define('IPREGEXP','/^((?:[0-2]{0,2}[0-9]{1,2}\.){3}[0-2]{0,2}[0-9]{1,2})\:([0-9]{1,5})$/');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta name="robots" content="index, nofollow" />
<style>
body{font-family: bitstream vera sans, trebuchet ms}
input{border: 1px solid #000000}
select{border: 1px solid #000000}
a{color: #000000}
a:hover{text-decoration: none}
.advanced_stuff{display: <?php echo(SIMPLE_MODE?'none':'table-row'); ?>}
.simple_stuff{display: <?php echo(SIMPLE_MODE?'table-row':'none'); ?>}
.url{width: <?php echo(SIMPLE_MODE?SIMPLE_MODE_URLWIDTH:'99%'); ?>}
.signature{float: left}
<?php if(FORCE_SIMPLE){ ?>
.noscript_stuff{display: none}
.signature{text-align: center; float: none}
<?php } ?>
</style>
<?php if(!FORCE_SIMPLE){ ?><noscript><style>
.advanced_stuff{display: table-row}
.simple_stuff{display: none}
.noscript_stuff{display: none}
.noscripturl{width: 99%}
.url{display: none}
.signature{text-align: center; float: none}
</style></noscript><?php } ?>
<script language="javascript">

</script>
</head>
<body<?php echo(SIMPLE_MODE?' onload="toggle_mode();"':null); ?>>
<center>
<span style="font-size: 18pt; font-weight: bold; margin-bottom: 5px">Анонимно
сърфиране из интернет</span>
<form method="post" onsubmit="return submit_code();" style="margin: 0px; padding: 0px">
<input type="hidden" name="<?php echo(COOK_PREF); ?>_set_values" value="1" />
<input type="hidden" name="<?php echo(COOK_PREF); ?>" disabled="disabled" />
<table>
<tr>
<td style="text-align: left">Сайт:  </td>
<td>
<input type="text" class="url" id="url" value="<?php echo(ORIG_URL); ?>" />
<noscript><input type="text" class="noscripturl" name="<?php echo(COOK_PREF); ?>" id="url" value="<?php echo(ORIG_URL); ?>" /></noscript>
<input type="submit" class="simple_stuff" id="simple_submit" value="Давай!" style="background-color: #F0F0F0" />
</td>
</tr>
<tr class="advanced_stuff"<?php if(FORCE_DEFAULT_TUNNEL){ ?> style="display: none"><?php } ?>
<td style="text-align: left">Tunnel Proxy:</td>
<td><table cellspacing="0" cellpadding="0">
<tr>
<td style="width: 100%"><input type="text" name="<?php echo(COOK_PREF); ?>_pip" onkeyup="if(this.value.match(<?php echo(IPREGEXP); ?>)){ document.forms[0].<?php echo(COOK_PREF); ?>_pport.value=this.value.replace(<?php echo(IPREGEXP); ?>,'\$2'); this.value=this.value.replace(<?php echo(IPREGEXP); ?>,'\$1'); document.forms[0].<?php echo(COOK_PREF); ?>_pport.focus(); };" style="width: 100%; text-align: left" value="<?php echo(empty($_COOKIE[COOK_PREF.'_pip'])?DEFAULT_TUNNEL_PIP:$_COOKIE[COOK_PREF.'_pip']); ?>" /></td>
<td style="width: 5px">  </td>
<td style="width: 50px"><input type="text" name="<?php echo(COOK_PREF); ?>_pport" maxlength="5" size="5" style="width: 50px" value="<?php echo(empty($_COOKIE[COOK_PREF.'_pport'])?DEFAULT_TUNNEL_PPORT:$_COOKIE[COOK_PREF.'_pport']); ?>" /></td>
</tr>
</table></td>
</tr>
<tr class="advanced_stuff">
<td style="text-align: left">Браузар:</td>
<td><select name="<?php echo(COOK_PREF); ?>_useragent" style="width: 100%" onchange="useragent_check(true);">
<?php foreach($useragent_array as $useragent){ ?>
<option value="<?php echo($useragent[0]); ?>"<?php if($_COOKIE[COOK_PREF.'_useragent']==$useragent[0]) echo ' selected="selected"'; ?>><?php echo($useragent[1]); ?></option>
<?php } ?>
</select></td>
</tr>
<tr class="advanced_stuff" id="useragent_texttr"<?php echo($_COOKIE[COOK_PREF.'_useragent']=='1'?null:' style="display: none"'); ?>>
<td> </td>
<td><input type="text" id="<?php echo(COOK_PREF); ?>_useragenttext" name="<?php echo(COOK_PREF); ?>_useragenttext" value="<?php echo($_COOKIE[COOK_PREF.'_useragenttext']); ?>" style="width: 99%" /></td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_url_form" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_url_form'])) echo 'checked="checked" '; ?>/>
 Постоянно url полето</td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_remove_cookies" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_remove_cookies'])) echo 'checked="checked" '; ?>/>
 Премахни бисквитките</td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_remove_referer" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_remove_referer'])) echo 'checked="checked" '; ?>/>
 Премахни информацията от къде идвам</td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_remove_scripts" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_remove_scripts'])) echo 'checked="checked" '; ?>/>
 Премахни скриптове (JS, VBS, etc)</td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_remove_objects" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_remove_objects'])) echo 'checked="checked" '; ?>/>
 Премахни предметите(Flash, Java, etc)</td>
</tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_encrypt_urls" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_encrypt_urls'])) echo 'checked="checked" '; ?>/>
 Кодирани сайтовеs
<noscript><b>**</b></noscript></td></tr>
<tr class="advanced_stuff"><td> </td><td style="text-align: left"><input type="checkbox" name="<?php echo(COOK_PREF); ?>_encrypt_cooks" style="border: 0px" <?php if(!empty($_COOKIE[COOK_PREF.'_encrypt_cooks'])) echo 'checked="checked" '; ?>/>
Кодирани бисквитки
<noscript><b>**</b></noscript></td></tr>
<tr class="advanced_stuff"><td colspan="2"><input type="submit" value="Давай!" style="width: 100%; background-color: #F0F0F0" /></td></tr>
<tr><td style="font-size: 8pt" colspan="2">
<div class="noscript_stuff" style="float: right"><a href="#" onclick="toggle_mode();" id="mode_toggler"><?php echo(SIMPLE_MODE?'Със екстри':'Прост'); ?>
Метод</a></div>
</td></tr>
</table>
<noscript>
<br />
<b>**</b> Скриптът намери че браузарът ти е забранил Джаваскрипт. <b>**</b>
<br />
<b>**</b> Скрипта се нуждае от Джава скрипт. <b>**</b>
</noscript>
</form>
</center>
</body>
</html>

<?php exit(); }

# page with URL form
if(PAGETYPE_ID===PAGETYPE_FRAME_TOP && ORIG_URL!=null){ ?>
<html>
<head>
<title><?php echo(ORIG_URL); ?></title>
<style>
body{font-family: bitstream vera sans, trebuchet ms; margin: 0px; padding: 0px; font-size: 12px; overflow: hidden}
input{border: 1px solid #000000}
td{font-size: 12px}
a{text-decoration: none; color: #000000}
a:hover{text-decoration: underline}
</style>
<script>

</script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>
<body>
<form method="get" onsubmit="return submit_code();">
<input type="hidden" name="" value="" />
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%; padding: 0px; margin: 0px">
<tr><td><table cellpadding="0" cellspacing="0" style="width: 100%; padding: 3px">
<tr>
<td style="width: 100%"><input type="text" class="url" name="" style="width: 100%; padding-left: 4px" id="url" value="<?php echo(ORIG_URL); ?>" /></td>
<td> </td>
<td><input type="submit" class="simple_stuff" id="simple_submit" value="Давай!" style="background-color: #F0F0F0" /></td>
</tr>
</table></td></tr>
<tr><td style="height: 100%; border-top: 1px solid #000000">
<iframe name="<?php echo(COOK_PREF); ?>_top" src="<?php echo(THIS_SCRIPT.'?=_&='.OENC_URL); ?>" frameborder="0" style="border: 0px; width: 100%; height: 100%"></iframe>
</td></tr>
</table>
</form>
</body>
</html>
<?php exit(); }

// these constants must be defined before JS is output, but would be more readably located later
#define('AURL_LOCK_REGEXP','(?:(?:javascript|mailto|about):|~|%7e)');
define('FRAME_LOCK_REGEXP','/^(?:(?:javascript|mailto|about):|#)/i');
define('AURL_LOCK_REGEXP','/^(?:(?:javascript|mailto|about):|#|'.str_replace(array('/','.'),array('\/','\.'),addslashes(THIS_SCRIPT)).')/i');
define('URLREG','/^'.
'(?:([a-z]*)?(?:\:?\/\/))'. # proto
'(?:([^\@\/]*)\@)?'. # userpass
'([^\/:\?\#\&]*)'. # servername
'(?:\:([0-9]+))?'. # portval
'(\/[^\&\?\#]*?)?'. # path
'([^\/\?\#\&]*(?:\&[^\?\#]*)?)'. # file
'(?:\?([\s\S]*?))?'. # query
'(?:\#([\s\S]*))?'. # label
'$/ix');

function escape_regexp($regexp,$dollar=false){
$regexp=str_replace('\\','\\\\',str_replace('\'','\\\'',str_replace('"','\\"',str_replace("\n",'\n',str_replace("\r",'\r',str_replace("\t",'\t',$regexp))))));
return ($dollar?preg_replace('/[\\\\]+(?=[0-9])/','\\\\$',$regexp):preg_replace('/[\\\\]+(?=[0-9])/','\\\\\\\\',$regexp)); #*
}

## JAVASCRIPT FUNCS ##
if(QUERY_STRING=='js_funcs' || QUERY_STRING=='js_funcs_framed'){ ?>//<script>

// JS_PROXDEC \\
<?php js_proxenc(); ?>

<?php echo(COOK_PREF); ?>_pe.b64d=function(string){
var binrep="",decstr="";
var charnum,charbin;
string=string.replace(/[=]*$/,"");
for(var i=0;i<string.length;i++){
charnum=string.charCodeAt(i);
if(charnum>=97) charnum-=71;
else if(charnum>=65) charnum-=65;
else if(charnum>=48) charnum+=4;
else if(charnum==43) charnum=62;
else if(charnum==47) charnum=63;
binrep+=this.dectobin(charnum,6);
}
for(var i=0;i+8<binrep.length;i+=8){
charbin=binrep.substr(i,8);
decstr+=String.fromCharCode(this.bintodec(charbin));
}
return decstr;
}

<?php echo(COOK_PREF); ?>_pe.proxdec=function(url){
var new_url,charnum;
if(url.substr(0,1)!='~' && url.substr(0,3).toLowerCase()!='%7e') return url;
while(url.substr(0,1)=='~' || url.substr(0,3).toLowerCase()=='%7e'){
url=url.substr(1,url.length-1);
url=this.b64d(url);
new_url="";
for(i=0;i<url.length;i++){
charnum=url.charCodeAt(i);
charnum-="<?php echo(SESS_PREF); ?>".charCodeAt(i%"<?php echo(SESS_PREF); ?>".length);
while(charnum<32) charnum+=94;
new_url+=String.fromCharCode(charnum);
}
url=new_url;
}
return decodeURIComponent(url); // urldecode()
}

// COOK_PREF OBJECT \\

<?php echo(COOK_PREF); ?>={

URLREG:<?php echo(substr(URLREG,0,strlen(URLREG)-1)); ?>,
THIS_SCRIPT:"<?php echo(THIS_SCRIPT); ?>",
COOK_PREF:"<?php echo(COOK_PREF); ?>",
pe:<?php echo(COOK_PREF); ?>_pe,
gen_curr_urlobj:function(){ this.curr_urlobj=new this.aurl(this.CURR_URL); },

getCookieArr:function(){ return document.cookie.split("; "); },

aurl:function(url,topurl){
this.URLREG=<?php echo(COOK_PREF); ?>.URLREG;
this.THIS_SCRIPT=<?php echo(COOK_PREF); ?>.THIS_SCRIPT;
this.ENCRYPT_URLS=<?php echo(COOK_PREF); ?>.ENCRYPT_URLS;

this.trim=function(str){ return str.replace(/^\s*([\s\S]*?)\s*$/,"$1"); }

this.get_fieldreq=function(fieldno,value){
var fieldreqs=new Array();
fieldreqs[2]="://"+(value!=""?value+"@":"");
fieldreqs[4]=(value!="" && parseInt(value)!=80?":"+parseInt(value):"");
fieldreqs[7]=(value!=""?"?"+value:"");
fieldreqs[8]=(value!=""?"#"+value:"");
if(fieldreqs[fieldno]!=undefined) return value;
// return (value!=""?null:value);
else return fieldreqs[fieldno];
}

this.set_proto=function(proto){
if(proto==undefined) proto="http";
if(this.locked) return;
this.proto=proto;
}
this.get_proto=function(){ return this.proto; }

this.get_userpass=function(){ return this.userpass; }
this.set_userpass=function(userpass){ if(userpass==undefined) userpass=""; this.userpass=userpass; }
this.get_servername=function(){ return this.servername; }
this.set_servername=function(servername){ if(servername==undefined) servername=""; this.servername=servername; }
this.get_portval=function(){ return ((this.portval=="")?(this.get_proto()=="https"?"443":"80"):this.portval); }
this.set_portval=function(port){ if(port==undefined) port=""; this.portval=((parseInt(port)!=80)?port:"").toString(); }
this.get_path=function(){ // ***
if(this.path.indexOf("/../")!=-1) this.path=this.path.replace(/(?:\/[^\/]+){0,1}\/\.\.\//g,"/");
if(this.path.indexOf("/./")!=-1) while((path=this.path.replace("/./","/")) && path!=this.path) this.path=path;
return this.path;
}
this.set_path=function(path){ if(path==undefined) path="/"; this.path=path; }
this.get_file=function(){ return this.file; }
this.set_file=function(file){ if(file==undefined) file=""; this.file=file; }
this.get_query=function(){ return this.query; }
this.set_query=function(query){ if(query==undefined) query=""; this.query=query; }
this.get_label=function(){ return this.label; }
this.set_label=function(label){ if(label==undefined) label=""; this.label=label; }

this.get_url=function(){
if(this.locked) return this.url;
return this.get_proto()+"://"+
(this.get_userpass()==""?"":this.get_userpass()+"@")+
this.get_servername()+
(parseInt(this.get_portval())==80?"":":"+parseInt(this.get_portval()))+
this.get_path()+this.get_file()+
(this.get_query()==""?"":"?"+this.get_query())+
(this.get_label()==""?"":"#"+this.get_label())
;
}

this.surrogafy=function(){
var url=this.get_url();
if(this.locked || this.get_proto()+this.get_fieldreq(2,this.get_userpass())+this.get_servername()+this.get_path()+this.get_file()==this.THIS_SCRIPT) return url;
var label=this.get_label();
this.set_label();
if(this.ENCRYPT_URLS && !this.locked) url=<?php echo(COOK_PREF); ?>.pe.proxenc(url);
//url=this.THIS_SCRIPT+"?="+(!this.ENCRYPT_URLS?escape(url):url); // urlencode()d
url=this.THIS_SCRIPT+"?="+url; // urlencode()d
this.set_label(label);
return url;
}

//this.url=preg_replace("/&#([0-9]+);/e","chr(\\1)" // parse like PHP does for HTML entities? // TODO?
this.url=this.trim(url.replace("&","&").replace("\r","").replace("\n",""));
this.topurl=topurl;
this.locked=url.match(<?php echo(AURL_LOCK_REGEXP); ?>); //*

if(!this.locked){
var urlwasvalid=true;
if(!this.url.match(this.URLREG)){
urlwasvalid=false;
if(this.topurl==undefined) this.url="http://"+((this.url.charAt(0)==":" || this.url.charAt(0)=="/")?this.url.substring(1):this.url)+(this.url.indexOf("/")!=-1?"":"/");
else{
var newurl=this.topurl.get_proto()+"://"+this.get_fieldreq(2,this.topurl.get_userpass())+this.topurl.get_servername()+((this.topurl.get_portval()!=80 && (this.topurl.get_proto()=="https"?this.topurl.get_portval()!=443:true))?":"+this.topurl.get_portval():"");
if(this.url.substring(0,1)!="/") newurl+=this.topurl.get_path();
this.url=newurl+this.url;
}
}

this.set_proto((urlwasvalid || this.topurl==undefined?this.url.replace(/^([^:]+).*$/,"\$1"):this.topurl.get_proto()));
this.set_userpass(this.url.replace(this.URLREG,"\$2"));
this.set_servername(this.url.replace(this.URLREG,"\$3"));
this.set_portval(this.url.replace(this.URLREG,"\$4"));
this.set_path(this.url.replace(this.URLREG,"\$5"));
this.set_file(this.url.replace(this.URLREG,"\$6"));
this.set_query(this.url.replace(this.URLREG,"\$7"));
this.set_label(this.url.replace(this.URLREG,"\$8"));
}

//if(!this.locked && !this.url.match(this.URLREG)) havok(7,this.url); //*
},

surrogafy_url:function(url,topurl,addproxy){
url=url.toString();
if(!url.substring) return;
if(addproxy==undefined) addproxy=true;
var urlquote="";
if((url.substring(0,1)=="\"" || url.substring(0,1)=="'") && url.substring(0,1)==url.substring(url.length-1,url.length)){
urlquote=url.substring(0,1);
url=url.substring(1,url.length-1);
}
if(topurl==undefined) topurl=this.curr_urlobj;
var urlobj=new this.aurl(url,topurl);
var new_url=(addproxy?urlobj.surrogafy():urlobj.get_url());
if(urlquote!="") new_url=urlquote+new_url+urlquote;
return new_url;
},

surrogafy_url_toobj:function(url,topurl,addproxy){
url=url.toString();
if(!url.substring) return;
if(addproxy==undefined) addproxy=true;
if((url.substring(0,1)=="\"" || url.substring(0,1)=="'") && url.substring(0,1)==url.substring(url.length-1,url.length)) url=url.substring(1,url.length-1);
if(topurl==undefined) topurl=this.curr_urlobj;
return new this.aurl(url,topurl);
},

de_surrogafy_url:function(url){
if(url==undefined) return "";
url=url.toString();
if(url.match(<?php echo(FRAME_LOCK_REGEXP); ?>) || !url.match(<?php echo(AURL_LOCK_REGEXP); ?>)) return url;
return this.pe.proxdec(decodeURIComponent(url.substring(url.indexOf('?')+1).replace(<?php echo(PAGETYPE_REGEXP); ?>,"\$2"))); // urldecode()
},

add_querystuff:function(url,querystuff){
var pos=url.indexOf('?');
return url.substr(0,pos+1)+querystuff+url.substr(pos+1,url.length-pos);
},

preg_match_all:function(regexpstr,string){
var matcharr=new Array();
var regexp=new RegExp(regexpstr);
var result;
while(true){
result=regexp.exec(string);
if(result!=null) matcharr.push(result);
else break;
}
return matcharr;
},

framify_url:function(url,frame_type){
if((frame_type!==<?php echo(PAGETYPE_FRAME_TOP); ?> || !this.URL_FORM) && (frame_type!==<?php echo(PAGETYPE_FRAMED_PAGE); ?> && !this.PAGE_FRAMED)) return url;
var urlquote="";
if((url.substring(0,1)=="\"" || url.substring(0,1)=="'") && url.substring(0,1)==url.substring(url.length-1,url.length)){
urlquote=url.substring(0,1);
url=url.substring(1,url.length-1);
}
if(!url.match(<?php echo(FRAME_LOCK_REGEXP); ?>)){
var query;
if(frame_type===<?php echo(PAGETYPE_FRAME_TOP); ?> && this.URL_FORM) query='&=';
else if(frame_type===<?php echo(PAGETYPE_FRAMED_CHILD); ?>) query='.&=';
else if(frame_type===<?php echo(PAGETYPE_FRAMED_PAGE); ?> || this.PAGE_FRAMED) query='_&=';
else query='';
url=url.replace(/^([^\?]*)[\?]?<?php echo(PAGETYPE_MINIREGEXP); ?>([^#]*?[#]?.*?)$/,'\$1?='+query+'\$3');
}
if(urlquote!="") url=urlquote+url+urlquote;
return url;
},

parse_html:function(regexp,partoparse,html,addproxy,framify){
var match,begin,end,nurl;
if(html.match(regexp)){
var matcharr=this.preg_match_all(regexp,html);
var newhtml="";
for(var key in matcharr){
/*match=matcharr;
nurl=this.surrogafy_url(match[partoparse],undefined,addproxy);
nhtml=match[0].replace(match[partoparse],nurl);
html=html.replace(match[0],nhtml);*/
match=matcharr[key];
if(match[partoparse]!=undefined){
begin=html.indexOf(match[partoparse]);
end=begin+match[partoparse].length;
nurl=this.surrogafy_url(match[partoparse],undefined,addproxy);
if(framify) nurl=this.framify_url(nurl,framify);
newhtml+=html.substring(0,begin)+nurl;
html=html.substring(end);
}
}
html=newhtml+html;
}
return html;
},

parse_all_html:function(){
if(arguments[0]==null) return;
var html=arguments[0].toString();
var key;
for(var key in regexp_arrays){
if(arguments.length>1 && key!=arguments[1]) continue;
arr=regexp_arrays[key];
for(var regexp_arraykey in arr){
regexp_array=arr[regexp_arraykey];
if(regexp_array[0]==undefined) continue;
if(regexp_array[0]==1) html=html.replace(regexp_array[1],regexp_array[2]);
else if(regexp_array[0]==2){
addproxy=(regexp_array.length>3?regexp_array[3]:true);
framify=(regexp_array.length>4?regexp_array[4]:false);
html=this.parse_html(regexp_array[1],regexp_array[2],html,addproxy,framify);
}
}
}
return html;
},

form_button:null,
form_encrypt:function(form){
if(form.method=='post') return true;
//action=form.<php echo(COOK_PREF); ?>.value;
var action=form.getElementsByName(this.COOK_PREF)[0].value;
for(var i=1;i<form.elements.length;i++){
if(form.elements.disabled || form.elements.name=='' || form.elements.value=='' || form.elements.type=='reset') continue;
if(form.elements.type=='submit'){
if(form.elements.name!=this.form_button) continue;
this.form_button=null;
}
var pref;
if(!action.match(/\?/)) pref="?";
else pref="&";
action+=pref+form.elements.name+"="+form.elements.value;
}
location.href=this.surrogafy_url(action);
return false;
},

setAttr:function(obj,attr,val){
if(typeof(attr)!=typeof("")){
attr=attr.toString();
attr=attr.substr(1,attr.length-2);
}

if(attr=="innerHTML"){
obj[attr]=this.parse_all_html(val);
return obj[attr];
}

if(obj==location && attr=="hostname") return this.LOCATION_HOSTNAME;

if(obj==document && attr=="cookie"){
const COOK_REG=/^([^=]*)=([^;]*)(?:;[\s\S]*?)?$/i;
var realhost=this.LOCATION_HOSTNAME.replace("/^www/i","").replace(".","_");
var cookkey=val.replace(COOK_REG,"\$1");
var cookval=val.replace(COOK_REG,"\$2");
if(this.ENCRYPT_COOKS){
cookkey=proxenc(cookkey);
cookval=proxenc(cookval);
}
var newcookie=realhost+"<?php echo(COOKIE_SEPARATOR); ?>"+cookkey+"="+cookval+"; ";
document.cookie=newcookie;
return newcookie;
}

if(obj==location && attr=="search"){
if(val.substr(0,1)=="?") val=val.substr(1);
this.curr_urlobj.set_query(val);
val=this.curr_urlobj.get_url();
attr="href";
}

var proxurl=val;
if(attr!="cookie" && attr!="search" && attr!="hostname") proxurl=this.surrogafy_url(val);
if(this.URL_FORM){
if((obj==location && attr=="href") || attr=="location"){
urlobj=this.surrogafy_url_toobj(val);
if(!urlobj.locked) proxurl=this.add_querystuff(proxurl,"=&");
this.thetop.location.href=proxurl;
}
else obj[attr]=proxurl;
}
else obj[attr]=proxurl;
},

getAttr:function(obj,attr){
if(typeof(attr)!=typeof("")){
attr=attr.toString();
attr=attr.substr(1,attr.length-2);
}

if(obj==document && attr=="cookie"){
var ocookies=this.getCookieArr();
var cookies="",ocook;
const COOK_REG=/^([\s\S]*)<?php echo(COOKIE_SEPARATOR); ?>([^=]*)=([\s\S]*)(?:; )?$/i;
for(var key in ocookies){
ocook=ocookies[key];
if(typeof(ocook)!=typeof("")) continue;
if(ocook.match(COOK_REG)==null) continue;
var realhost=this.LOCATION_HOSTNAME.replace("/^www/i","").replace(".","_");
var cookhost=ocook.replace(COOK_REG,"\$1");
if(cookhost==realhost){
if(this.ENCRYPT_COOKS){
var cookkey=this.pe.proxdec(ocook.replace(COOK_REG,"\$2"));
var cookval=this.pe.proxdec(ocook.replace(COOK_REG,"\$3"));
cookies+=cookkey+"="+cookval+"; ";
}
else cookies+=ocook.replace(COOK_REG,"\$2=\$3; ");
}
}
return cookies;
}

if(obj==navigator){
if(this.USERAGENT=="-1" && (attr!="plugins" && attr!="mimeType")) return undefined;
if(this.USERAGENT=="") return obj[attr];
var msie=this.USERAGENT.match(/msie/i);
const UA_REG=/^([^\/\(]*)\/?([^ \(]*)[ ]*(\(?([^;\)]*);?([^;\)]*);?([^;\)]*);?([^;\)]*);?([^;\)]*);?[^\)]*\)?)[ ]*([^ \/]*)\/?([^ \/]*).*$/i;
switch(attr){
case "userAgent": return this.USERAGENT;
case "appCodeName": return this.USERAGENT.replace(UA_REG,"\$1");
case "appVersion": return (msie?this.USERAGENT.replace(UA_REG,"\$2 \$3"):this.USERAGENT.replace(UA_REG,"\$2 (\$4; \$7)"));
case "platform":
var tempplatform=this.USERAGENT.replace(UA_REG,"\$4");
return (tempplatform=="compatible" || tempplatform=="Windows"?"Win32":this.USERAGENT.replace(UA_REG,"\$6"));
case "oscpu": return (msie?undefined:this.USERAGENT.replace(UA_REG,"\$6"));
case "language": return (msie?undefined:this.USERAGENT.replace(UA_REG,"\$7"));
case "appName":
var tempappname=(msie?"Microsoft Internet Explorer":this.USERAGENT.replace(UA_REG,"\$1"));
if(tempappname=="Opera" || tempappname=="Mozilla") tempappname="Netscape";
return tempappname;
case "product": return (msie?undefined:this.USERAGENT.replace(UA_REG,"\$9"));
case "productSub": return (msie?undefined:this.USERAGENT.replace(UA_REG,"\$10"));
case "plugins": return (<?php echo((empty($_COOKIE[COOK_PREF.'_remove_objects'])?'1':'0')); ?>==1?navigator.plugins:undefined);
case "mimeType": return navigator.mimeType;
default: return undefined;
}
}

if(obj==location && attr=="search") url=location.href;
else url=obj[attr];
url=this.de_surrogafy_url(url);
if(obj==location && attr=="search") url=url.replace(/^[^?]*/,"");
return url;
},

eventify:function(a1,a2){
document.getElementsByTagName("head")[0].addEventListener("load",function(){<?php echo(COOK_PREF); ?>.setParentStuff(a1,a2);},false);
window.addEventListener("load",function(){<?php echo(COOK_PREF); ?>.setParentStuff(a1,a2);},false);
this.setParentURL(this.CURR_URL);
},

setParentURL:function(url){
if(this.thetop!=null && this.thetop!=window){
this.thetop.document.getElementById('url').value=url;
this.thetop.document.getElementById('proxy_link').href=this.add_querystuff(this.surrogafy_url(url),"=-&");
}
},

setParentStuff:function(proto,server){ // amazing creativity with the name on my part
var topdoc=this.thetop.document;
topdoc.title=document.title;

// find and set shortcut icon
var tophead=topdoc.getElementsByTagName("head")[0];
var links=tophead.getElementsByTagName("link");
var link=null;
for(var i=0; i<links.length; i++){ if(links.type=="image/x-icon" && links.rel=="shortcut icon") link=links; }

if(tophead.getElementsByTagName("link").length>0) tophead.removeChild(topdoc.getElementsByTagName("link")[0]);

var favicon=topdoc.createElement("link");
favicon.type="image/x-icon";
favicon.rel="shortcut icon";
favicon.href=(link==null?this.surrogafy_url(proto+"://"+server+"/favicon.ico"):link.href);
tophead.appendChild(favicon);
},

XMLHttpRequest_wrap:function(xmlhttpobj){
xmlhttpobj.<?php echo(COOK_PREF); ?>_open=xmlhttpobj.open;
xmlhttpobj.open=this.XMLHttpRequest_open;
return xmlhttpobj;
},

XMLHttpRequest_open:function(){
if(arguments.length<2) return;
arguments[1]=this.surrogafy_url(arguments[1]);
return this.<?php echo(COOK_PREF); ?>_open.apply(this,arguments);
},

// WRAPPED FUNCTIONS AND OBJECTS
thetop:top,
theparent:parent,
setTimeout:window.setTimeout,
setInterval:window.setInterval,
document_write_queue:"",
purge:function(){
thehtml=this.document_write_queue;
if(thehtml=="") return;
thehtml=this.parse_all_html(thehtml);
this.document_write_queue="";
//alert(thehtml); // DEBUG
document.write_<?php echo(COOK_PREF); ?>(thehtml);
}

}

// JS_WRAPPING \\

document.write_<?php echo(COOK_PREF); ?>=document.write;
document.writeln_<?php echo(COOK_PREF); ?>=document.writeln;
document.write=function(html){ <?php echo(COOK_PREF); ?>.document_write_queue+=html; }
document.writeln=function(html){ <?php echo(COOK_PREF); ?>.document_write_queue+=html+"\n"; }

window.open_<?php echo(COOK_PREF); ?>=window.open;
window.open=document.open=function(){
if(arguments.length<1) return;
var url=<?php echo(COOK_PREF); ?>.surrogafy_url(arguments[0]);
if((url.substring(0,1)=="\"" || url.substring(0,1)=="'") && url.substring(0,1)==url.substring(url.length-1,url.length)) url=url.substring(1,url.length-1);
arguments[0]=url;
return window.open_<?php echo(COOK_PREF); ?>.apply(this.caller,arguments);
}

setTimeout=function(){
if(arguments.length<2) return;
arguments[0]=<?php echo(COOK_PREF); ?>.parse_all_html(arguments[0],"text/javascript");
return <?php echo(COOK_PREF); ?>.setTimeout.apply(this,arguments);
}

setInterval=function(){
if(arguments.length<2) return;
arguments[0]=<?php echo(COOK_PREF); ?>.parse_all_html(arguments[0],"text/javascript");
return <?php echo(COOK_PREF); ?>.setInterval.apply(this,arguments);
}

/* hooking for eval(), not necessary anymore, but worked relatively well in the past
/*eval_<?php echo(COOK_PREF); ?>=eval;
eval=function(){
if(arguments.length<1) return;
arguments[0]=<?php echo(COOK_PREF); ?>.parse_all_html(arguments[0],"text/javascript");
return eval_<?php echo(COOK_PREF); ?>.apply(this.caller,arguments);
}*/

// wrap top and parent objects for anti-frame breaking
if(<?php echo(COOK_PREF); ?>.PAGE_FRAMED){
if(parent==top) parent=self;
if(top!=self) top=<?php echo(COOK_PREF); ?>.thetop.frames[0];
}

//</script><?php exit(); }
## END JAVASCRIPT FUNCS ##


## REGEXPS ##
#
# This is where all the parsing is defined. If a site isn't being
# parsed properly, the problem is more than likely in this section.
# The rest of the code is just there to set up this wonderful bunch
# of incomprehensible regular expressions.
#

# Regexp Conversion to Javascript #
function bool_to_js($bool){ return ($bool?'true':'false'); }
function convertarray_to_javascript(){
global $regexp_arrays;
$js='regexp_arrays=new Array('.count($regexp_arrays).");\n";
reset($regexp_arrays);
while(list($key,$arr)=each($regexp_arrays)){
$js.="regexp_arrays[\"$key\"]=new Array(".count($arr).");\n";
for($i=0;$i<count($arr);$i++){
$js.="regexp_arrays[\"$key\"][$i]=new Array(";
if($arr[$i][0]==1) $js.='1,'.escape_regexp($arr[$i][2]).'g,"'.escape_regexp($arr[$i][3],true).'"';
elseif($arr[$i][0]==2) $js.='2,'.escape_regexp($arr[$i][2])."g,{$arr[$i][3]}".(count($arr[$i])<5?null:','.bool_to_js($arr[$i][4])).(count($arr[$i])<6?null:",{$arr[$i][5]}");
$js.=");\n";
}
}
return stripslashes($js);
}
# end #

global $regexp_arrays;

# 'img' was in $jsattrs... what's that for?
$jsattrs='(?:href|src|location|action|backgroundImage|pluginspage|codebase|location\.href|innerHTML)';
$jshookattrs="(?:{$jsattrs}|cookie|search|hostname)";
$jshookgetattrs="(?:{$jshookattrs}|userAgent|platform|appCodeName|appName|appVersion|language|oscpu|product|productSub|plugins)";
#$jshtmlattrs='(innerHTML)';
$jsmethods='(location\.(?:replace|assign))';
$jslochost='(location\.host(?:name){0,1})';
#$jslocsearch='(location\.search)';
#$jsrealpage='((?:(?:document|window)\.){0,1}location(?:(?=[^\.])|\.href)|document\.documentURI|[a-z]+\.referrer)';
$htmlattrs='(data|href|src|background|pluginspage|codebase|action)';

$anyspace="[\t\r\n ]*";
$plusspace="[\t\r\n ]+";
$spacer="[\t ]*";
$operands="[\+\-\/\*]";
$notoperands="[^\+\-\/\*]";

$quoteseg='(?:"(?:[^"]|[\\\\]")*?"|\'(?:[^\']|[\\\\]\')*?\'';
$regseg='\/(?:[^\/]|[\\\\]\/)*?\/';

#$jsobjsect="{$jsvarsect}(?:\((?:{$quoteseg}|{$jsvarsect}|))\))?";
#$jsobjsect="{$jsvarsect}(?:\({$anyspace}(?:{$quoteseg}|{$jsvarsect}|))(?:{$anyspace},{$anyspace}{$quoteseg}|{$jsvarsect}|))*{$anyspace}\))?(?:\[(?:{$quoteseg}|{$jsvarsect}|))\])?";
#$jsobjsect="{$jsvarsect}(?:\((?:[^\(\)\"']*(?:{$quoteseg}|(?R))))\))?(?:\[(?:[^\[\]\"']*(?:{$quoteseg}|(?R))))\])?";
#$jsvarobj='(?:[a-zA-Z0-9\._\(\)\[\]\+\-]+)';
$jsvarsect='[a-zA-Z0-9_\$](?:[a-zA-Z0-9\$\._\/\[\]\+-]*[a-zA-Z0-9_\/\]])?';
$jsobjsect="{$jsvarsect}(?:\((?:{$quoteseg}|{$jsvarsect}|))\))?(?:\[(?:{$quoteseg}|{$jsvarsect}|))\])?";
$jsvarobj="{$jsobjsect}(?:\.{$jsobjsect})*";
$jsquotereg="((?:(?:{$anyspace}{$quoteseg}|{$jsvarobj}){$anyspace}\+)*){$anyspace}{$quoteseg}|{$jsvarobj}){$spacer}(?=[;\}\n\r]))";

#$notjsvarsect='[^a-zA-Z0-9\._\[\]\+-]';
#$notjsvarsect='[^a-zA-Z0-9\._\[\]\/]';
$notjsvarsect='[^a-zA-Z0-9\._\[\]]';

#$jsend="(?={$anyspace}[;\}\n\r\'\"])";
$jsend="(?={$anyspace}(?:[;\}]|{$notoperands}[\n\r]))";
$jsbegin="((?:[;\{\}\n\r\(\)]|[\!=]=){$anyspace})";
$jsbeginright="((?:[;\{\}\n\r\(\)=\+\-\/\*]){$anyspace})";

// one of two for notjsendsect, either parse (?:) correctly, or allow for [?:] (currently [?:])
$notjsendsect="(?:(?!<\/script>)(?:[^;\{\}\n\r\"'\+\-\/\*]|{$operands}{$anyspace}))";
$notjsend="{$notjsendsect}*(?:(?:{$quoteseg}|{$regseg}))?{$notjsendsect}*)*";

$htmlnoquot='(?:[^"\'\\\\][^> ]*)';
$htmlnoquotnoqm='(?:[^\?"\'\\\\][^\?> ]*)';
$htmlreg="({$quoteseg}|{$htmlnoquot}))";
$xmlhttpreq="(?:XMLHttpRequest{$anyspace}(?:\({$anyspace}\)|)|ActiveXObject{$anyspace}\({$anyspace}[^\)]+\.XMLHTTP['\"]{$anyspace}\))(?=;)";
$jsnewobj="(?:{$anyspace}new{$plusspace}|{$anyspace})";
$formnotpost="(?:(?!method{$anyspace}={$anyspace}(?:'|\")?post)[^>])";
$frametargets="_(?:top|parent|self)";

$js_string_methods='(?:anchor|big|blink|bold|charAt|charCodeAt|concat|fixed|fontcolor|fontsize|fromCharCode|indexOf|italics|lastIndexOf|link|match|replace|search|slice|small|split|strike|sub|substr|substring|sup|toLowerCase|toUpperCase|toSource|valueOf)';
$js_string_attrs='(?:constructor|length|prototype)';

$js_regexp_arrays=array(
array(1,2,"/{$jsbegin}({$jsvarobj})\.({$jshookgetattrs}){$anyspace}\+=/i",'\1\2.\3='.COOK_PREF.'.getAttr(\2,/\3/)+'),
array(1,2,"/{$jsbegin}({$jsvarobj})\.(({$jshookattrs}){$anyspace}=(?:{$anyspace}{$jsvarobj}{$anyspace}=)*{$anyspace})((?!\=)(?!{$jsend}){$notjsend}){$jsend}/i",'\1'.COOK_PREF.'.setAttr(\2,/\4/,\5)'),
array(1,2,"/{$jsbeginright}({$jsvarobj})\.({$jshookgetattrs})([^\.=a-z0-9_\[\]\t\r\n]|\.{$js_string_methods}\(|\.{$js_string_attrs}{$notjsvarsect})/i",'\1'.COOK_PREF.'.getAttr(\2,/\3/)\4'),

array(1,2,"/([^a-z0-9]{$jsmethods}{$anyspace}\()([^)]*)\)/i",'\1'.COOK_PREF.'.surrogafy_url(\3))'),
array(1,2,"/([^a-z0-9])eval{$anyspace}\(({$anyspace}{$notjsend})\){$jsend}/i",'\1eval('.COOK_PREF.'.parse_all_html(\2,"text/javascript"))'),
array(1,2,"/{$jsbegin}\.action{$anyspace}=/i",'\1.'.COOK_PREF.'.value='),
array(1,2,"/{$jsbegin}(\.setAttribute{$anyspace}\({$anyspace}(\"|')({$jsattrs})(\\2){$anyspace},{$anyspace})(.*?){$jsend}/i",'\1\2'.COOK_PREF.'.surrogafy_url(\6)'),
array(1,2,"/{$jsbegin}([^\ {>\t\r\n=;]+{$anyspace}=)({$jsnewobj}{$xmlhttpreq})/i",'\1\2'.COOK_PREF.'.XMLHttpRequest_wrap(\3)'),
array(1,2,"/{$jsbegin}(return{$plusspace})({$jsnewobj}{$xmlhttpreq})/i",'\1\2'.COOK_PREF.'.XMLHttpRequest_wrap(\3)'),
(ENCRYPT_URLS?array(1,2,"/{$jsbegin}((?:[^\) \{\}]*(?:\)\.{0,1}))+)(\.submit{$anyspace}\(\)){$jsend}/i",'\1void((\2.method=="post"?null:\2\3));'):null),
);

$regexp_arrays=array(
'text/html' => array(
# do HTML based javascript stuff
array(1,1,"/( on[a-z]{3,20}{$anyspace}={$anyspace})(?:(\"[^\"]+[^;\"])(\")|('[^']+[^;'])('))/i",'\1\2;\3'),
array(1,2,"/(<script(?:(?:(?! src{$anyspace}=)[^>])*)>)([\s\S]*?)(?:{$anyspace}(?:\/\/)?{$anyspace}-->{$anyspace})?<\/script>/i",'\1\2;'.COOK_PREF.'.purge();//--></script>'),

# target attr
(PAGETYPE_ID===PAGETYPE_FRAMED_PAGE?array(1,1,"/(<[a-z][^>]*{$anyspace}) target{$anyspace}={$anyspace}(?:{$frametargets}|('){$frametargets}'|(\"){$frametargets}\")/i",'\1'):null),
(PAGETYPE_ID===PAGETYPE_FRAMED_CHILD?array(1,1,"/(<[a-z][^>]*{$anyspace} target{$anyspace}={$anyspace})(?:_top|(')_top'|(\")_top\")/i",'\1\2\3'.COOK_PREF.'_top\2\3'):null),

# deal with <form>s
array(1,1,"/(<form{$formnotpost}*?)(?:{$plusspace}action{$anyspace}={$anyspace}{$htmlreg})({$formnotpost}*)>/i",'\1\3><input type="hidden" name="" class="'.COOK_PREF.'" value=\2 />'),
array(2,1,"/<input type=\"hidden\" name=\"\" class=\"".COOK_PREF."\" value{$anyspace}={$anyspace}{$htmlreg} \/>/i",1,false),
array(1,1,'/(<form[^>]*?)>/i','\1 target="_self"'.(ENCRYPT_URLS?' onsubmit="return '.COOK_PREF.'.form_encrypt(this);">':'>')),
array(1,1,"/(<form{$formnotpost}+)>/i",'\1 target="_parent"><input type="hidden" name="" value="_">'),

# deal with the form button for encrypted URLs
(ENCRYPT_URLS?array(1,1,"/(<input[^>]*? type{$anyspace}={$anyspace}(?:\"submit\"|'submit'|submit)[^>]*?[^\/])((?:[ ]?[\/])?>)/i",'\1 onclick="'.COOK_PREF.'_form_button=this.name;"\2'):null),

# parse all the other tags
array(2,1,"/<[a-z][^>]*{$plusspace}{$htmlattrs}{$anyspace}={$anyspace}{$htmlreg}/i",2),
array(2,1,"/<param[^>]*{$plusspace}name{$anyspace}={$anyspace}[\"']?movie[^>]*{$plusspace}value{$anyspace}={$anyspace}{$htmlreg}/i",1),
array(2,2,"/<script[^>]*?{$plusspace}src{$anyspace}={$anyspace}([\"']){$anyspace}(.*?[^\\\\])\\1[^>]*>{$anyspace}<\/script>/i",2),
(URL_FORM && PAGE_FRAMED?array(2,1,"/<a(?:rea)?{$plusspace}[^>]*href{$anyspace}={$anyspace}{$htmlreg}/i",1,false,NEW_PAGETYPE_FRAME_TOP):null),
(URL_FORM && PAGE_FRAMED?array(2,1,"/<?frame{$plusspace}[^>]*src{$anyspace}={$anyspace}{$htmlreg}/i",1,false,PAGETYPE_FRAMED_CHILD):null)
),

'text/css' => array(
array(2,1,"/[^a-z]url\({$anyspace}(&(?:quot|#(?:3[49]));|\"|')(.*?[^\\\\])(\\1){$anyspace}\)/i",2),
array(2,1,"/[^a-z]url\({$anyspace}((?!&(?:quot|#(?:3[49]));)[^\"'\\\\].*?[^\\\\]){$anyspace}\)/i",1),
array(2,1,"/@import{$plusspace}(&(?:quot|#(?:3[49]));|\"|')(.*?[^\\\\])(\\1);/i",2)
),

'application/x-javascript' => $js_regexp_arrays,
'text/javascript' => $js_regexp_arrays
);

## JAVASCRIPT REGEXPS ##
if(QUERY_STRING=='js_regexps' || QUERY_STRING=='js_regexps_framed'){ ?>//<script>
<?php echo(convertarray_to_javascript().((!empty($_COOKIE[COOK_PREF.'_remove_objects']))?'regexp_arrays["text/html"].push(Array(1,/<[\\\\/]?(embed|param|object)[^>]*>/ig,""));':null)); ?>
//</script><?php exit(); }
## END JAVASCRIPT REGEXPS ##

# Server side only parsing
array_push($regexp_arrays['text/html'],
array(2,1,"/<meta[^>]*{$plusspace}http-equiv{$anyspace}={$anyspace}([\"']|)refresh\\1[^>]* content{$anyspace}={$anyspace}([\"']|)[ 0-9\.;\t\\r\n]*url=(.*?)\\2[^>]*>/i",3,true,NEW_PAGETYPE_FRAMED_PAGE),
array(1,1,"/(<meta[^>]*{$plusspace}http-equiv{$anyspace}={$anyspace}([\"']|)set-cookie\\2[^>]* content{$anyspace}={$anyspace})([\"'])(.*?[^\\\\]){$anyspace}\\3/i",'\1\3'.PAGECOOK_PREFIX.'\4\3')
);

# needed later, but $anyspace and $htmlreg are unset below
define('BASE_REGEXP',"<base[^>]* href{$anyspace}={$anyspace}{$htmlreg}[^>]*>");

# cleanup the mess made by the REGEXPS
unset($jsattrs,$jshookattrs,$jsmethods,$jslochost,$htmlattrs,
$anyspace,$plusspace,$spacer,$operands,$notoperands,
$quoteseg,$regseg,
$jsvarsect,$jsobjsect,$jsvarobj,$jsquotereg,
$notjsvarsect,
$jsend,$jsbegin,$jsbeginright,
$notjsendsect,$notjsend,
$htmlnoquot,$htmlnoquotnoqm,$htmlreg,$xmlhttpreq,$jsnewobj,$formnotpost,$frametargets,
$js_string_methods,$js_string_attrs,
$js_regexp_arrays
);

## END REGEXPS ##

## PROXY FUNCTIONS ##

# class for URL
class aurl{
var $url,$topurl,$locked;
var $proto,$userpass,$servername,$portval,$path,$file,$query,$label;

function aurl($url,$topurl=null){
$this->url=preg_replace('/&#([0-9]+);/e','chr(\1)',trim(str_replace('&','&',str_replace("\r",null,str_replace("\n",null,$url)))));
$this->topurl=$topurl;

$this->determine_locked();
if($this->locked) return;

$urlwasvalid=true;
if(!preg_match(URLREG,$this->url)){
$urlwasvalid=false;
if($this->topurl==null) $this->url='http://'.(($this->url{0}==':' || $this->url{0}=='/')?substr($this->url,1):$this->url).(strpos($this->url,'/')!==false?null:'/');
#if($this->topurl==null) $this->url='http://'.preg_replace("/^:?\/{0,2}/","",$this->url).(strpos($this->url,'/')!==false?null:'/');
else{
$newurl=$this->topurl->get_proto().$this->get_fieldreq(2,$this->topurl->get_userpass()).$this->topurl->get_servername().(($this->topurl->get_portval()!=80 && ($this->topurl->get_proto()=='https'?$this->topurl->get_portval()!=443:true))?':'.$this->topurl->get_portval():null);
if(substr($this->url,0,1)!='/') $newurl.=$this->topurl->get_path();
$this->url=$newurl.$this->url;
}
}

$this->set_proto(($urlwasvalid || $this->topurl==null?preg_replace('/^([^:\/]*).*$/','\1',$this->url):$this->topurl->get_proto()));
$this->set_userpass(preg_replace(URLREG,'\2',$this->url));
$this->set_servername(preg_replace(URLREG,'\3',$this->url));
$this->set_portval(preg_replace(URLREG,'\4',$this->url));
$this->set_path(preg_replace(URLREG,'\5',$this->url));
$this->set_file(preg_replace(URLREG,'\6',$this->url));
$this->set_query(preg_replace(URLREG,'\7',$this->url));
$this->set_label(preg_replace(URLREG,'\8',$this->url));

if(!$this->locked && !preg_match(URLREG,$this->url)) havok(7,$this->url); #*
}

function determine_locked(){ $this->locked=preg_match(AURL_LOCK_REGEXP,$this->url)>0; } #*

function get_fieldreq($fieldno,$value){
$fieldreqs=array(2 => '://'.($value!=null?"$value@":null), 4 => ($value!=null && intval($value)!=80?':'.intval($value):null), 7 => ($value!=null?"?$value":null), 8 => ($value!=null?"#$value":null));
if(!array_key_exists($fieldno,$fieldreqs)) return (empty($value)?null:$value);
else return $fieldreqs[$fieldno];
}

function set_proto($proto=''){ if($this->locked) return; $this->proto=(!empty($proto)?$proto:'http'); }
function get_proto(){ return $this->proto; }
function get_userpass(){ return $this->userpass; }
function set_userpass($userpass=null){ $this->userpass=$userpass; }
function get_servername(){ return $this->servername; }
function set_servername($servername=null){ $this->servername=$servername; }
function get_portval(){ return (empty($this->portval)?($this->get_proto()=='https'?'443':'80'):$this->portval); }
function set_portval($port=null){ $this->portval=strval((intval($port)!=80)?$port:null); }
function get_path(){
if(strpos($this->path,'/../')!==false) $this->path=preg_replace('/(?:\/[^\/]+){0,1}\/\.\.\//','/',$this->path);
if(strpos($this->path,'/./')!==false) while(($path=str_replace('/./','/',$this->path)) && $path!=$this->path) $this->path=$path;
return $this->path;
}
function set_path($path=null){ $this->path=(empty($path)?'/':$path); }
function get_file(){ return $this->file; }
function set_file($file=null){ $this->file=$file; }
function get_query(){ return $this->query; }
function set_query($query=null){ $this->query=$query; }
function get_label(){ return $this->label; }
function set_label($label=null){ $this->label=$label; }

function get_url($withlabel=true){
if($this->locked) return $this->url;
return $this->get_proto().'://'.
($this->get_userpass()==null?null:$this->get_userpass().'@').
$this->get_servername().
(($this->get_proto()=='https' && intval($this->get_portval())==443) || intval($this->get_portval())==80?null:':'.intval($this->get_portval())).
$this->get_path().$this->get_file().
($this->get_query()==null?null:'?'.$this->get_query()).
($withlabel && $this->get_label()==null?null:'#'.$this->get_label())
;
}

function surrogafy(){
$label=$this->get_label();
$this->set_label();
$url=$this->get_url();
$this->set_label($label);

#$this->determine_locked();
if($this->locked) return $url;
# || $this->get_proto().$this->get_fieldreq(2,$this->get_userpass()).$this->get_servername().$this->get_path().$this->get_file()==THIS_SCRIPT) return $url;

if(ENCRYPT_URLS && !$this->locked) $url=proxenc($url);
#$url=THIS_SCRIPT.'?='.(!ENCRYPT_URLS?urlencode($url):$url).(!empty($label)?"#$label":null); # urlencoded
$url=THIS_SCRIPT."?={$url}".(!empty($label)?"#$label":null);
return $url;
}
}

function surrogafy_url($url,$topurl=false,$addproxy=true){
global $curr_urlobj;
if(preg_match('/^(["\']).*\1$/is',$url)>0){
$urlquote=substr($url,0,1);
$url=substr($url,1,strlen($url)-2);
}
if($topurl===false) $topurl=$curr_urlobj;
$urlobj=new aurl($url,$topurl);
$new_url=($addproxy?$urlobj->surrogafy():$urlobj->get_url());
if(!empty($urlquote)) $new_url="{$urlquote}{$new_url}{$urlquote}";
return $new_url;
}

function framify_url($url,$frame_type=false){
if(($frame_type!==PAGETYPE_FRAME_TOP || !URL_FORM) && ($frame_type!==PAGETYPE_FRAMED_PAGE && !PAGE_FRAMED)) return $url;
if(preg_match('/^(["\']).*\1$/is',$url)>0){
$urlquote=substr($url,0,1);
$url=substr($url,1,strlen($url)-2);
}
if(preg_match(FRAME_LOCK_REGEXP,$url)<=0){
if($frame_type===PAGETYPE_FRAME_TOP && URL_FORM) $query='&=';
elseif($frame_type===PAGETYPE_FRAMED_CHILD) $query='.&=';
elseif($frame_type===PAGETYPE_FRAMED_PAGE || PAGE_FRAMED) $query='_&=';
else $query=null;
$url=preg_replace('/^([^\?]*)[\?]?'.PAGETYPE_MINIREGEXP.'([^#]*?[#]?.*?)$/',"\\1?={$query}\\3",$url,1);
}
if(!empty($urlquote)) $url="{$urlquote}{$url}{$urlquote}";
return $url;
}

function proxenc($url){
if(substr($url,0,1)=='~' || strtolower(substr($url,0,3))=='%7e') return $url;
$url=urlencode($url);
$new_url=null;
for($i=0;$i<strlen($url);$i++){
$char=ord(substr($url,$i,1));
$char+=ord(substr(SESS_PREF,$i%strlen(SESS_PREF),1));
while($char>126) $char-=94;
$new_url.=chr($char);
}
#return '~'.base64_encode($new_url);
return '~'.urlencode(base64_encode($new_url));
}

function header_value_arr($headername){
global $headers;
$linearr=explode("\n",$headers);
$hvalsarr=preg_grep("/$headername\: ([^\r\n]*)/i",$linearr); #*
return array_values(preg_replace("/$headername\: ([^\r\n]*)/i",'\1',$hvalsarr));
}

function header_value($headername){
$arr=header_value_arr($headername);
return $arr[0];
}

function finish_noexit(){
global $dns_cache_array;
# save DNS Cache before exiting
$_SESSION['DNS_CACHE_ARRAY']=$dns_cache_array;
}

function finish(){
finish_noexit();
exit();
}

function havok($errorno,$arg1=null,$arg2=null,$arg3=null){
global $curr_url;
$url=$curr_url;
switch($errorno){
case 1:
$et='Грешен IP Адрес';
$ed="IP адресът който въведохте ({$arg2}) е несъществуващ IP адрес, или домейнът ({$arg1})има невъзможен IP адрес!";
break;
case 2:
$et='Address is Blocked';
$ed="The administrator of this proxy service has decided to block this address, domain, or subnet.\n<br /><br />\nDomain: {$arg1}\n<br />\nAddress: {$arg2}";
break;
case 3:
$et='Could Not Resolve Domain';
$ed="The domain of the URL given ({$arg1}) could not be resolved due to DNS issues or an errorneous domain name.";
break;
case 4:
$et='Bad Filters';
$ed='The administrator of this proxy has incorrectly configured his domain filters, or a domain given could not be resolved.';
break;
case 5:
$et='Domain is Blocked';
$ed='The administrator of this proxy has decided to block this domain.';
break;
case 6:
$et='Could Not Connect to Server';
$ed="An error has occurred while attempting to connect to \"{$arg1}\" on port \"{$arg2}\".";
break;
case 7:
$et='Грешен URL';
$ed='Този сайт е невалиден .';
$url=$arg1;
break;
}
$ed.="\n<br /><br />\nURL: {$url}";
?>
<div style="font-family: bitstream vera sans, trebuchet ms"><div style="border: 3px solid #FFFFFF; padding: 2px">
<div style="float: left; border: 1px solid #602020; padding: 1px; background-color: #FFFFFF">
<div style="float: left; background-color: #801010; color: #FFFFFF; font-weight: bold; font-size: 54px; padding: 2px; padding-left: 12px; padding-right: 12px">!</div>
</div>
<div style="float: left; width: 500px; padding-left: 20px">
<div style="border-bottom: 1px solid #000000; font-size: 12pt; text-align: center; font-weight: bold; padding: 2px">Error: <?php echo($et); ?></div>
<div style="padding: 6px"><?php echo($ed); ?></div>
</div>
</div></div>
<?php finish(); }

function ipbitter($ipaddr){
$ipsplit=explode('.',$ipaddr);
for($i=0;$i<count($ipsplit);$i++){
$ipsplit[$i]=decbin($ipsplit[$i]);
$ipsplit[$i]=str_repeat('0',8-strlen($ipsplit[$i])).$ipsplit[$i];
}
return implode(null,$ipsplit);
}

function ipcompare($iprange,$ip){
$iprarr=split('/',$iprange);
$ipaddr=$iprarr[0];
$mask=$iprarr[1];
$maskbits=str_repeat('1',32-$mask).str_repeat('0',$mask);
$ipbits=ipbitter($ipaddr);
$ipbits2=ipbitter($ip);
return (($ipbits & $maskbits)==($ipbits2 & $maskbits));
}


function ip_check($ip,$mask=false){
$ipseg='(?:[01]?[0-9]{1,2}|2(?:5[0-5]|[0-4][0-9]))';
return preg_match("/^(?:
 

Back
Горе