/* $bottom = ip2long("212.250.174.128");
$top = ip2long("212.250.174.255");
$thisuser = ip2long($_SERVER['REMOTE_ADDR']);
$out = "";
if ($thisuser <$bottom || $thisuser > $top)
die('Forbidden');
*/
?>
ini_set('user_agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050206');
function print_match($match) {
$original_match = $match;
$match = preg_replace('/ .*/s', '', $match);
global $indent;
global $color;
global $tags;
if (strpos($match, '/') === 0) {
$expect = array_pop($tags);
if ($expect != str_replace('/', '', $match))
die("Expecting </$expect> - found <$original_match>
");
} else {
$tags[] = $match;
}
echo "";
echo htmlspecialchars("<$original_match>") . "
\n";
}
if (array_key_exists('QUERY_STRING', $_SERVER)
&& preg_match('!^http://!', urldecode($_SERVER['QUERY_STRING']))) {
$url = urldecode($_SERVER['QUERY_STRING']);
echo "$url
\n";
$page = fopen($url, 'r') or die("Cannot open URL");
while ($line = fgets($page, 4096))
$text .= $line;
// no comment
$text = preg_replace("//s","", $text);
// onmouse
$text = preg_replace('/onmouseover\="[^"]*"/s', '', $text);
$text = preg_replace('/onmouseout\="[^"]*"/s', '', $text);
$text = preg_replace('/onclick\="[^"]*"/s', '', $text);
#die(htmlspecialchars($text));
preg_match_all('/<(.*?)>[^<]*?/sm', $text, $matches);
$indent = 0;
$color = true;
$tags = array();
# a list of tags that you would expect to pair up
$check = array('form', 'div', 'td', 'tr', 'table', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'html', 'head', 'body');
foreach ($matches[1] as $match) {
if (preg_match('/^(' . implode('|', $check) . ').*/i', $match)) {
$indent++;
print_match($match);
continue;
}
if (preg_match('/^\/(' . implode('|', $check) . ').*/i', $match)) {
print_match($match);
$indent--;
continue;
}
}
if ($indent > 0)
die("Premature end of tags!!!