Файл: pages/search/index.php
Строк: 148
<?php
require_once '../../sys/inc/start.php';
require_once '../../sys/inc/compress.php';
require_once '../../sys/inc/sess.php';
require_once '../../sys/inc/settings.php';
require_once '../../sys/inc/db_connect.php';
require_once '../../sys/inc/ipua.php';
require_once '../../sys/inc/fnc.php';
require_once '../../sys/inc/user.php';
$set['title'] = 'Пользователи';
require_once '../../sys/inc/thead.php';
aut();
$sort = 'id';
$por = 'DESC';
if (isset($_GET['ASC'])) {
$por = 'ASC';
} #прямой порядок
if (isset($_GET['DESC'])) {
$por = 'DESC';
} #обратный порядок
switch (@$_GET['sort']) {
case 'money':
$sql_sort = '`user`.`money`';
$sort = 'money'; #монеты
break;
case 'activity':
$sql_sort = '`user`.`activity`';
$sort = 'activity'; #активность
break;
case 'level':
$sql_sort = '`user_group`.`level`';
$sort = 'level'; #уровень
break;
case 'rating':
$sql_sort = '`user`.`rating`';
$sort = 'rating'; #рейтинг
break;
case 'sex':
$sql_sort = '`user`.`sex`';
$sort = 'sex'; #пол
break;
default:
$sql_sort = '`user`.`id`';
$sort = 'id'; #ID
break;
}
$usearch = NULL;
if (isset($_SESSION['usearch'])) {
$usearch = $_SESSION['usearch'];
}
if (isset($_POST['usearch'])) {
$usearch = $_POST['usearch'];
}
if ($usearch == NULL) {
unset($_SESSION['usearch']);
} else {
$_SESSION['usearch'] = $usearch;
}
echo "<div class = 'tabs'>";
echo "<a href = '/pages/search/' class = 'active'>Люди</a>";
echo "<a href = '/diary/'>Дневники</a>";
echo "</div><div class = 'tabcontent'>";
if (isset($_GET['go']) && $usearch != NULL) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` like '%" . mysql_real_escape_string($usearch) . "%' OR `id` = '" . intval($usearch) . "'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "Сортировать по: <br /><form>";
echo "<select name = 'menu' onchange = 'top.location.href = this.options[this.selectedIndex].value;'>";
echo "<option value = '0'>Выбрать сортировку</option>
<option value = '?go&sort=money&DESC&page=$page'>Монеты</option>
<option value = '?go&sort=level&DESC&page=$page'>Должность</option>
<option value = '?go&sort=activity&DESC&page=$page'>Активность</option>
<option value = '?go&sort=rating&DESC&page=$page'>Рейтинг</option>
<option value = '?go&sort=id&ASC&page=$page'>ID</option>
<option value = '?go&sort=sex&ASC&page=$page'>Пол</option>
<option value = '?go&sort=id&DESC&page=$page'>Новые</option>";
echo "</select></form></td></tr></table>";
if ($k_post == 0) {
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
$q = mysql_query("SELECT `id` FROM `user` WHERE `nick` like '%" . mysql_real_escape_string($usearch) . "%' OR `id` = '" . intval($usearch) . "' ORDER BY `$sort` $por LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_assoc($q)) {
$ank = get_user($ank['id']);
echo "<table class = 'foot'><tr><td class = 'icon48'>";
avatar($ank['id'], '30');
echo "</td><td class = 'null'>";
user($ank['id']);
echo "<br />";
if ($sort == 'rating') {
echo "Рейтинг: $ank[rating]<br />";
}
if ($sort == 'money') {
echo "Монеты: $ank[money]<br />";
}
if ($sort == 'activity') {
echo "Активность: $ank[activity]<br />";
}
if ($sort == 'level') {
if ($ank['group_access'] > 1) {
echo "$ank[group_name]<br />";
} else {
echo "Пользователь<br />";
}
}
if ($sort == 'sex') {
echo "Пол: " . (($ank['sex'] == 1) ? 'Мужской' : 'Женский') . "<br />";
}
if ($sort == 'id') {
echo "ID: $ank[id]<br />";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("index.php?go&sort=$sort&$por&", $k_page, $page);
}
} else {
echo "<form class = 'blok' name = 'search' method = 'POST' action = 'index.php?go&sort=$sort&$por'>";
$usearch = stripcslashes(htmlspecialchars($usearch));
echo "<input type = 'search' name = 'usearch' maxlength = '16' title = 'Введите ID или НИК пользователя' value = '$usearch' />";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/thumb_top.png' />";
echo "</button></form>";
}
if (!isset($_GET['go'])) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
echo "<div class = 'blok'>";
echo "Сортировать по: <br /><form>";
echo "<select name = 'menu' onchange = 'top.location.href = this.options[this.selectedIndex].value;'>";
echo "<option value = '0'>Выбрать сортировку</option>
<option value = '?sort=money&DESC&page=$page'>Монеты</option>
<option value = '?sort=level&DESC&page=$page'>Должность</option>
<option value = '?sort=activity&DESC&page=$page'>Активность</option>
<option value = '?sort=rating&DESC&page=$page'>Репутация</option>
<option value = '?sort=id&ASC&page=$page'>ID</option>
<option value = '?sort=sex&ASC&page=$page'>Пол</option>
<option value = '?sort=id&DESC&page=$page'>Новые</option>";
echo "</select></form></div>";
if ($k_post == 0) {
echo "<table class = 'blok'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
$q = mysql_query("SELECT `user`.`id` FROM `user` LEFT JOIN `user_group` ON `user`.`group_access` = `user_group`.`id` ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_assoc($q)) {
$ank = get_user($ank['id']);
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '30');
echo "</td><td class = 'null'>";
user($ank['id']);
echo "<br />";
if ($sort == 'rating') {
echo "Рейтинг: $ank[rating]<br />";
}
if ($sort == 'level') {
if ($ank['group_access'] > 1) {
echo "$ank[group_name]<br />";
}
} else {
}
if ($sort == 'money') {
echo "Монеты: $ank[money]<br />";
}
if ($sort == 'activity') {
echo "Активность: $ank[activity]<br />";
}
if ($sort == 'sex') {
echo "Пол: " . (($ank['sex'] == 1) ? 'Мужской' : 'Женский') . "<br />";
}
if ($sort == 'id') {
echo "ID: $ank[id]<br />";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("index.php?sort=$sort&$por&", $k_page, $page);
}
}
echo "</div>";
require_once '../../sys/inc/tfoot.php';