<?php

$k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `id` <=> '" . $db->safesql($search_text) . "' OR `nick` like '%" . $db->safesql($search_text) . "%' OR (`ank_icq` <=> '" . $search_text . "' AND `ank_icq` != '0') OR (`ank_city` = '" . $search_text . "') OR (`ip` <=> '" . ip2long($search_text) . "' AND `ip` != NULL) OR `ank_mail` <=> '" . $search_text . "'");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = $db->query("SELECT * FROM `user` WHERE `id` <=> '" . $db->safesql($search_text) . "' OR `nick` like '%" . $db->safesql($search_text) . "%' OR (`ank_icq` <=> '" . $search_text . "' AND `ank_icq` != '0') OR (`ank_city` = '" . $search_text . "') OR (`ip` <=> '" . ip2long($search_text) . "' AND `ip` != NULL) OR `ank_mail` <=> '" . $search_text . "' ORDER BY `date_last` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
    $doc->NoResult();
}

while ($ank = $db->get_row($q)) {
    echo "<table class='list-group-item-null list-group-item-grey dop'><tr><td class='icon14'>";
    avatar($ank['id'], '48', 'border-radius: 2px;');
    echo "</td><td class='null'>";
    echo user($ank['id']) . " ";

    echo "<br />\n";
    if (long2ip($ank['ip']) == $search_text) {
        echo 'Найден по IP: <font color="' . $color . '">' . long2ip($ank['ip']) . '</font><br />';
    }

    if ($ank['id'] == $search_text) {
        echo 'Найден по ID: <font color="' . $color . '">' . intval($ank['id']) . '</font><br />';
    }

    if ($ank['nick'] == $search_text) {
        echo 'Найден по логину: <font color="' . $color . '">' . stripcslashes(htmlspecialchars($ank['nick'])) . '</font><br />';
    }

    if ($ank['ank_city'] == $search_text) {
        echo 'Найден по городу: <font color="' . $color . '">' . stripcslashes(htmlspecialchars($ank['ank_city'])) . '</font><br />';
    }

    if ($ank['ank_mail'] == $search_text) {
        echo 'Найден по E-Mail: <font color="' . $color . '">' . stripcslashes(htmlspecialchars($ank['ank_mail'])) . '</font><br />';
    }

    echo "</td></tr></table>";
}

if ($k_page > 1) {
    str("?search=people&amp;", $k_page, $page);
}
