Exemplo n.º 1
0
 public function Display(Console $con, $resIps, $errorsOnly)
 {
     foreach ($this->GetChangedLines() as $line) {
         if ($errorsOnly && $line->code < 400) {
             continue;
             // not an error entry, go to next one
         }
         $con->WritePart('[' . $con->Colorize('ACCESS', Console::C_CYAN) . '] ');
         $con->WritePart($con->Colorize($resIps ? substr(str_pad(resolve_ip($line->ip), 48), 0, 48) : str_pad($line->ip, 16), Console::C_YELLOW) . ' ');
         $con->WritePart($con->Colorize(str_pad($line->domain, 32), Console::C_BROWN) . ' ');
         $con->WritePart($con->Colorize(str_pad($line->method, 8), Console::C_LIGHT_PURPLE));
         $long_mesg = '' . $con->Colorize(str_replace('&', $con->Colorize('&', Console::C_DARK_GRAY), $line->url), Console::C_WHITE) . $con->Colorize(' > ', Console::C_DARK_GRAY) . $con->Colorize($line->code, $line->code < 400 ? Console::C_GREEN : Console::C_RED) . $con->Colorize(' (', Console::C_DARK_GRAY) . $con->Colorize($line->size, Console::C_WHITE) . $con->Colorize(' bytes)', Console::C_DARK_GRAY);
         //write_line(implode(str_pad(PHP_EOL, count_parts()), str_split($long_mesg, cli_width() - count_parts())));
         $con->WriteLine($long_mesg);
     }
 }
Exemplo n.º 2
0
        /* If IP Address not detected properly */
        $ip = ip2long(gethostbyname($host));
        if ($ip === false || $ip == -1) {
            return false;
        }
    }
    return $ip;
}
/* Content Header Type */
header('Content-Type: text/plain');
/* Validate Request */
if (empty($_GET['info_hash']) || empty($_GET['port']) || !is_numeric($_GET['port'])) {
    exit("Invalid Request");
}
/* Resolve IP */
$ip = resolve_ip(empty($_GET['ip']) ? $_SERVER['REMOTE_ADDR'] : $_GET['ip']);
if ($ip === false) {
    exit("unable to resolve host name");
    /* Exit in case HostName is not resolved properly */
}
/* Connect to Database */
@mysql_pconnect($db_ip, $db_user, $db_pass) or exit("database unavailable");
@mysql_select_db($db_database) or exit("database unavailable");
$announce_interval = 60;
/* Announce interval */
/* Update Database */
$columns = '`info_hash`, `ip`, `port`';
$values = '\'' . mysql_real_escape_string($_GET['info_hash']) . '\', ' . $ip . ', ' . $_GET['port'];
@mysql_query("INSERT IGNORE INTO `{$db_table}` ({$columns}) VALUES ({$values});") or exit("Database update error");
/* Retrieve Peers from Database */
$peers = array();