Exemplo n.º 1
0
    echo $host;
    ?>
</td>
</tr>
<?php 
}
// if ($countrows > $perpage)
// echo $pagertop;
//begin_table();
print "<tr>\n\r\n<br><br><td class=colhead><a class=colhead href=\"" . $_SERVER['PHP_SELF'] . "?id={$userid}&order=access\">Last access</a></td>\n\r\n<td class=colhead><a class=colhead href=\"" . $_SERVER['PHP_SELF'] . "?id={$userid}&order=ip\">IP</a></td>\n\r\n<td class=colhead>Hostname</td>\n\r\n</tr>\n";
while ($arr = mysql_fetch_array($res)) {
    $addr = "";
    $ipshow = "";
    if ($arr["ip"]) {
        $ip = $arr["ip"];
        $dom = @gethostbyaddr_timeout($arr["ip"]);
        if ($dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"]) {
            $addr = "";
        } else {
            $addr = $dom;
        }
        $queryc = "SELECT COUNT(*) FROM\r\n(\r\nSELECT u.id FROM users AS u WHERE u.ip = " . sqlesc($ip) . "\r\nUNION SELECT u.id FROM users AS u RIGHT JOIN iplog ON u.id = iplog.userid WHERE iplog.ip = " . sqlesc($ip) . "\r\nGROUP BY u.id\r\n) AS ipsearch";
        $resip = mysql_query($queryc) or sqlerr(__FILE__, __LINE__);
        $arrip = mysql_fetch_row($resip);
        $ipcount = $arrip[0];
        $nip = ip2long($ip);
        $banres = mysql_query("SELECT COUNT(*) FROM bans WHERE {$nip} >= first AND {$nip} <= last") or sqlerr(__FILE__, __LINE__);
        $banarr = mysql_fetch_row($banres);
        if ($banarr[0] == 0) {
            if ($ipcount > 1) {
                $ipshow = "<b><a href=ipsearch.php?ip=" . $arr['ip'] . ">" . $arr['ip'] . "</a></b>";
Exemplo n.º 2
0
    // find the response type
    $type = @unpack("s", substr($response, $requestsize + 2));
    if ($type[1] == 0xc00) {
        // set up our variables
        $host = "";
        $len = 0;
        // set our pointer at the beginning of the hostname
        // uses the request size from earlier rather than work it out
        $position = $requestsize + 12;
        // reconstruct hostname
        do {
            // get segment size
            $len = unpack("c", substr($response, $position));
            // null terminated string, so length 0 = finished
            if ($len[1] == 0) {
                // return the hostname, without the trailing .
                return substr($host, 0, strlen($host) - 1);
            }
            // add segment to our host
            $host .= substr($response, $position + 1, $len[1]) . ".";
            // move pointer on to the next segment
            $position += $len[1] + 1;
        } while ($len != 0);
        // error - return the hostname we constructed (without the . on the end)
        return $ip;
    }
    return $ip;
}
echo gethostbyaddr_timeout($ip = '202.96.128.68', '8.8.8.8', $timeout = 1000);
echo gethostbyaddr_timeout($ip = 'www.xiu.com', '8.8.8.8', $timeout = 1000);
Exemplo n.º 3
0
// ////////////////////
function gethostbyaddr_timeout($ip, $timeout = 2)
{
    $host = `host -W {$timeout} {$ip}`;
    if (preg_match('`in-addr.arpa domain name pointer (.*)\\.\\n$`i', $host, $matches)) {
        $host = $matches[1];
    } else {
        $host = $ip;
    }
    return $host;
}
// //////////////
// ///////////////
if ($user['ip'] && (get_user_class() >= UC_MODERATOR || $user['id'] == $CURUSER['id'])) {
    $ip = $user['ip'];
    $dom = gethostbyaddr_timeout($ip);
    if ($dom == $ip) {
        $addr = '<a href="whois.php?query=' . $ip . '">' . $ip . '</a>';
    } else {
        $dom = htmlentities($dom, ENT_QUOTES);
        $addr = '<a href="whois.php?query=' . $ip . '">' . $ip . '</a> (' . $dom . ')';
    }
}
// /////////////////////////////
$joindate = $user['added'] == '0000-00-00 00:00:00' ? 'N/A' : $user['added'] . ' (' . get_elapsed_time(sql_timestamp_to_unix_timestamp($user['added'])) . ' ago)';
$lastseen = $user['last_access'] == '0000-00-00 00:00:00' ? 'Never' : $user['last_access'] . ' (' . get_elapsed_time(sql_timestamp_to_unix_timestamp($user['last_access'])) . ' ago)';
$lapsetime = ($lapsetime = time() - sql_timestamp_to_unix_timestamp($user["last_login"])) / 3600 % 24 . ' Hours ' . $lapsetime / 60 % 60 . ' minutes ' . $lapsetime % 60 . ' seconds ';
$onlinetime = "{$user['last_login']} (" . get_date_time(sql_timestamp_to_unix_timestamp($user["last_access"])) . ")";
$res = sql_query("SELECT COUNT(*) FROM comments WHERE user="******"id"])) or sqlerr();
$arr3 = mysql_fetch_row($res);
$torrentcomments = $arr3[0];
Exemplo n.º 4
0
        $position = $requestsize + 12;
        // reconstruct hostname
        do {
            // get segment size
            $len = unpack("c", substr($response, $position));
            // null terminated string, so length 0 = finished
            if ($len[1] == 0) {
                // return the hostname, without the trailing .
                return substr($host, 0, strlen($host) - 1);
            }
            // add segment to our host
            $host .= substr($response, $position + 1, $len[1]) . ".";
            // move pointer on to the next segment
            $position += $len[1] + 1;
        } while ($len != 0);
        // error - return the hostname we constructed (without the . on the end)
        return $ip;
    }
    return $ip;
}
if (filter_var($query, FILTER_VALIDATE_IP)) {
    $output['IP'] = $query;
    $output['Host'] = gethostbyaddr_timeout($query, '208.67.222.222', 1000);
    // $output['Host']=gethostbyaddr($query);
} else {
    if (gethostbyname($query) != $query) {
        $output['Host'] = $query;
        $output['IP'] = gethostbyname($query);
    }
}
echo json_encode($output);