<?php
// not for sale. free content. by [email protected]
@setcookie("lastaddress",$_GET['addr'],time()+691200);
require'requiref/htmlhead.rqf';
if($_GET['mode']){
$url = htmlspecialchars(trim($_GET['addr']));
if(!preg_match("#^https?://#iU",$url)) $url= "http://".$url;
$purl = @parse_url($url);
//get extens. file
$ext = strtolower(strrchr($url,'.'));
if($ext=='.jpg' or $ext=='.gif' or $ext=='.bmp' or $ext=='.ico' or $ext=='.png'){
echo "
<div id='jpeg' align='center'>
<img src='".$url."' alt=''/>
</div> ";
require'requiref/htmlbotttom.rqf';
exit;
}
$cnt = @file_get_contents($url);
//charset processing
preg_match("#encoding ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$ch);
if(empty($ch[2])){
preg_match("#charset ?= ?([^'\"]+)('|\")#i",$cnt,$ch);
$ch[2] = $ch[1];
}
if($ch[2]!=='utf-8')
$cnt = iconv($ch[2],"utf-8//IGNORE",$cnt);
if(!$cnt){ echo"<div id='error'> Невозможно обратится к адресу (".$url.")<br />
Проверьте правильность введенного вами адреса и проверьте, доступен ли он с обычного браузера</div>";
require'requiref/htmlbotttom.rqf';
exit;
}
if($_GET['mode']!='printscan')
echo"<div style='background: #5fa8dd; color: white; margin: 4px; padding: 4px;'>
<a href='index.php?mode=printscan&addr={$url}' title='Для печати'>
<img src='78poo.png' alt=''/></a>
<a href='".$_SERVER['REQUEST_URI']."' title='Обновить'><img src='78gkok.png' alt=''/></a>
<a href='#' title='Help (none)'><img src='coquette_part_5_preview.png' alt=''/></a>
</div>";
//icon processing
preg_match("#<link ?rel ?= ?('|\") ?shortcut icon('|\") +href ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$out);
if(empty($out[4])) $out[4] = '/favicon.ico';
//title processing
preg_match("#< ?title ?>(.+)< ?/ ?title ?>#i",$cnt,$title);
if(empty($title[1])){
preg_match("# ?title ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$title);
$title[1] = $title[2];
}
//stat info
echo"
<div style='background: #5fa8dd; color: white; margin: 4px; padding: 4px;'>
<img src='http://".$purl['host'].htmlspecialchars($out[4])."' alt='Praktolog.Inc' width='15' height='15' style='vertical-align: middle'/>
<b>Адрес:</b> ".strtolower($url)."<br />
<b style='font-size: small'><".htmlspecialchars($title[1])."></b>
</div>";
if($_GET['mode']=='scan'){
//replaces
$cnt = preg_replace("#@import ?('|\")/?([^;'\"]+)#is","<a href='index.php?addr=http://".$purl['host']."/".$purl['path']."&mode=scan'>\\2</a>",$cnt);
//x-ray
$cnt = htmlspecialchars($cnt);
//absolute site
$cnt = preg_replace("#<link ?rel ?= ?('|") ?stylesheet('|") +href ?= ?('|")/([a-z/\.\?\#0-9-_\+\(\)]+)('|")(.+)( ?/ ?>)+#i","<a href='index.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#((<img ?src ?= ?)('|"))/([a-z/\.\?\#0-9]+)(('|")(.+)/ ?>)#i","\\1<a href='index.php?addr=http://".trim($purl['host'],'/')."/\\4&mode=scan'>\\4</a>\\5",$cnt);
$cnt = preg_replace("#<script(.*) +(src|href) ?= ?('|")/([a-z/\.\?\#0-9-_\+\(\)]+)('|")(.+)( ?>)+#i","<a href='index.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#(<a(.*) +href ?= ?('|"))/([a-z/\.\?\#0-9-_\+\(\)]+)(('|")(.+)( ?>)+)#i","\\1<a href='index.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\4</a>\\5",$cnt);
//localy
$cnt = preg_replace("#<link ?rel ?= ?('|") ?stylesheet('|") +href ?= ?('|")([^/][a-z/\.\?\#0-9-_\+\(\)]+)('|")(.+)( ?/ ?>)+#is","<a href='index.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#((<img ?src ?= ?)('|"))([^/][a-z/\.\?\#0-9]+)(('|")(.+)/ ?>)#is","\\1<a href='index.php?addr=http://".trim($purl['host'],'/')."/".$purl['path']."\\4&mode=scan'>\\4</a>\\5",$cnt);
$cnt = preg_replace("#<script([^;]) +(src|href) ?= ?('|")([^/][a-z/\.\?\#0-9\-_\+\(\)]+)('|")(.+)( ?>)+#is","<a href='index.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#(<a(.*) +href ?= ?('|"))([^/][a-z/\.\?\#0-9\-_\+\(\),]+)(('|")(.+)( ?>)+)#is","\\1<a href='index.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\4</a>\\5",$cnt);
//url
$cnt = preg_replace("#<link ?rel ?= ?('|") ?stylesheet('|") +href ?= ?('|")(http?://[a-z/\.\?\#0-9-_\+\(\)]+)('|")(.+)( ?/ ?>)+#i","<a href='index.php?addr=\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#((<img ?src ?= ?)('|"))(http://[a-z/\.\?\#0-9]+)(('|")(.+)/ ?>)#i","\\1<a href='index.php?addr=\\4&mode=scan'>\\4</a>\\5",$cnt);
$cnt = preg_replace("#<script(.*) +(src|href) ?= ?('|")(http://[a-z/\.\?\#0-9\-_\+\(\)]+)('|")(.+)( ?>)+#i","<a href='index.php?addr=\\4&mode=scan'>\\0</a>",$cnt);
$cnt = preg_replace("#(<a(.*) +href ?= ?('|"))(http://[a-z/\.\?\#0-9\-_\+\(\),]+)(('|")(.+)( ?>)+)#i","\\1<a href='index.php?addr=\\4&mode=scan'>\\4</a>\\5",$cnt);
}
switch($_GET['mode']){
case'scan':
echo"<div style='padding: 5px; background:#cdcdcd; border: 1px dashed yellow; padding-left: 1.1em'>";
echo"<div style='opacity:1; color: green; font-weight: normal; font-family: \"Courier new\"'>";
echo nl2br($cnt);
echo"</div>";
echo"</div>";
//scan
break;
case 'copyscan':
echo"<textarea cols='20' rows='16'>".nl2br($cnt)."</textarea>";
break;
case'printscan':
$cnt = preg_replace("#<style[^<]+</ ?style>#i","",$cnt);
$cnt = preg_replace("#<script[^<]+</ ?script>#i","",$cnt);
$cnt = preg_replace("#<object[^<]+</ ?object>#i","",$cnt);
$cnt = preg_replace("#&[0-9a-z]+;#i","",$cnt);
echo"<div style='padding: 5px; background:#cdcdcd; opacity:0.5;'>";
echo"<div style='opacity:1; color: green; font-weight: bold'>";
echo nl2br(strip_tags($cnt));
echo"</div>";
echo"</div>";
break;
default:
require'requiref/htmlbotttom.rqf';
exit;
}
}else{
//radioactivity - ray
$_COOKIE['lastaddress'] = htmlspecialchars($_COOKIE['lastaddress']);
echo"
<div id='formstart' style='border-top: 3px dashed #cdcdcd; padding-left: 6px; background-image: url(luna_blue_preview.png); background-repeat: no-repeat;'>
<form method='get' action='index.php'>
<b style='color: #9fcaff; font-size: 20px; font-family: \"Courier new\"'> ADDRESS:</b><br />
<input type='text' name='addr' id='addr' value='{$_COOKIE['lastaddress']}' style='background:url(tile_sub.gif); border:0;'/>
<input type='submit' id='button' value=' ' style='background:url(okbt.png); background-repeat: no-repeat;
width: 32px; height: 32px; border:0;'/>
<div class='GBG'><input type='radio' id='copyradio' class='formradio' name='mode' value='scan' checked> <u style='color:white'>Обычный</u> </div>
<div class='GBG'><input type='radio' id='copyradio' class='formradio' name='mode' value='copyscan'> <u style='color:white'>Копировать</u></div>
<div class='GBG'><input type='radio' id='copyradio' class='formradio' name='mode' value='printscan'> <u style='color:white'>\"Для печати\"</u></div>
</div>
</form>
";
}
require'requiref/htmlbotttom.rqf';
?>