<?php
header("Content-type: text/html");

// tell php to automatically flush after every output
// including lines of output produced by shell commands
disable_ob();

$remoteip = getenv('REMOTE_ADDR');
$remoteport = getenv('REMOTE_PORT');

$reverseip = '/usr/bin/dig +short -x ' . $remoteip;
$whois = '/usr/bin/whois ' . $remoteip;
$date = exec('/bin/date');


echo "<html><head><title>for everyone</title></head>\n<body><p align=center>Your IP address seems to be: <b>" . $remoteip . " [Port " . $remoteport . "]</b><br>\n";
echo "curent date & time: <b>" . $date . "</b></p>\n";

echo "<hr>\n";
echo "-> reverse IP lookup: " . $remoteip . "<br>\n<pre>";
system($reverseip);
echo "</pre>";

echo "<hr>\n";
echo "-> whois lookup: <br>\n<pre>";
system($whois);
echo "</pre>";

echo "</body></html>\n";


function disable_ob() {
    // Turn off output buffering
    ini_set('output_buffering', 'off');
    // Turn off PHP output compression
    ini_set('zlib.output_compression', false);
    // Implicitly flush the buffer(s)
    ini_set('implicit_flush', true);
    ob_implicit_flush(true);
    // Clear, and turn off output buffering
    while (ob_get_level() > 0) {
        // Get the curent level
        $level = ob_get_level();
        // End the buffering
        ob_end_clean();
        // If the current level has not changed, abort
        if (ob_get_level() == $level) break;
    }
    // Disable apache output buffering/compression
    if (function_exists('apache_setenv')) {
        apache_setenv('no-gzip', '1');
        apache_setenv('dont-vary', '1');
    }
}
?>
