<?php

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` <=> '" . mysql_real_escape_string($search_text) . "' OR `nick` like '%" . mysql_real_escape_string($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 . "'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = mysql_query("SELECT * FROM `user` WHERE `id` <=> '" . mysql_real_escape_string($search_text) . "' OR `nick` like '%" . mysql_real_escape_string($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 = mysql_fetch_assoc($q)) {
    echo "<table class='list-group-item-null'><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>";
    echo "<div class='hr'></div>";
}

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