} $vbulletin->GPC['username'] = vB_String::unHtmlSpecialChars($userinfo['username']); } else { $userid = 0; } } if ($vbulletin->GPC['ipaddress'] or $userid) { if ($vbulletin->GPC['ipaddress']) { print_form_header('', ''); print_table_header(construct_phrase($vbphrase['ip_address_search_for_ip_address_x'], $vbulletin->GPC['ipaddress'])); $hostname = @gethostbyaddr($vbulletin->GPC['ipaddress']); if (!$hostname or $hostname == $vbulletin->GPC['ipaddress']) { $hostname = $vbphrase['could_not_resolve_hostname']; } print_description_row("<div style=\"margin-" . vB_Template_Runtime::fetchStyleVar('left') . ":20px\"><a href=\"usertools.php?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip=" . $vbulletin->GPC['ipaddress'] . "\">" . $vbulletin->GPC['ipaddress'] . "</a> : <b>{$hostname}</b></div>"); $results = construct_ip_usage_table($vbulletin->GPC['ipaddress'], 0, $vbulletin->GPC['depth']); print_description_row($vbphrase['post_ip_addresses'], false, 2, 'thead'); print_description_row($results ? $results : $vbphrase['no_matches_found_gerror']); $results = construct_ip_register_table($vbulletin->GPC['ipaddress'], 0, $vbulletin->GPC['depth']); print_description_row($vbphrase['registration_ip_addresses'], false, 2, 'thead'); print_description_row($results ? $results : $vbphrase['no_matches_found_gerror']); print_table_footer(); } if ($userid) { print_form_header('', ''); print_table_header(construct_phrase($vbphrase['ip_address_search_for_user_x'], htmlspecialchars_uni($vbulletin->GPC['username']))); print_label_row($vbphrase['registration_ip_address'], $userinfo['ipaddress'] ? $userinfo['ipaddress'] : $vbphrase['n_a']); $results = construct_user_ip_table($userid, 0, $vbulletin->GPC['depth']); print_description_row($vbphrase['post_ip_addresses'], false, 2, 'thead'); print_description_row($results ? $results : $vbphrase['no_matches_found_gerror']); if ($userinfo['ipaddress']) {
function construct_user_ip_table($userid, $previpaddress, $depth = 2) { global $vbulletin, $vbphrase; if (VB_AREA == 'AdminCP') { $userscript = 'usertools.php'; } else { $userscript = 'user.php'; } $depth--; $ips = $vbulletin->db->query_read_slave("\n\t\tSELECT DISTINCT ipaddress\n\t\tFROM " . TABLE_PREFIX . "post\n\t\tWHERE userid = {$userid} AND\n\t\tipaddress <> '" . $vbulletin->db->escape_string($previpaddress) . "' AND\n\t\tipaddress <> ''\n\t\tORDER BY ipaddress\n\t"); $retdata = ''; while ($ip = $vbulletin->db->fetch_array($ips)) { $retdata .= '<li>' . "<a href=\"{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=gethost&ip={$ip['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$ip['ipaddress']}</a> " . construct_link_code($vbphrase['find_more_users_with_this_ip_address'], "{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=doips&ipaddress={$ip['ipaddress']}&hash=" . CP_SESSIONHASH) . "</li>\n"; if ($depth > 0) { $retdata .= construct_ip_usage_table($ip['ipaddress'], $userid, $depth); } } if (empty($retdata)) { return ''; } else { return '<ul>' . $retdata . '</ul>'; } }
function construct_user_ip_table($userid, $previpaddress, $depth = 2) { global $vbulletin, $vbphrase; if (VB_AREA == 'AdminCP') { $userscript = 'usertools.php'; } else { $userscript = 'user.php'; } $depth--; $ips = vB_Api::instanceInternal('user')->searchIP($userid, $depth); $retdata = ''; // @TODO user api currently returns only 1 IP per user. $result = array('ipaddress' => $ips['regip']); foreach ($result as $ip) { $retdata .= '<li>' . "<a href=\"{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip={$ip['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$ip['ipaddress']}</a> " . construct_link_code($vbphrase['find_more_users_with_this_ip_address'], "{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=doips&ipaddress={$ip['ipaddress']}&hash=" . CP_SESSIONHASH) . "</li>\n"; if ($depth > 0) { $retdata .= construct_ip_usage_table($ip['ipaddress'], $userid, $depth); } } if (empty($retdata)) { return ''; } else { return '<ul>' . $retdata . '</ul>'; } }