<?
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

$set['title']='Обитатели Xhata.Su'; // заголовок страницы
include_once 'sys/inc/thead.php';
title();
//aut();
$sort='id';

$por='DESC';

if (isset($_GET['ASC']))$por='ASC'; // прямой порядок
if (isset($_GET['DESC']))$por='DESC'; // обратный порядок


switch (@$_GET['sort']) {
	case 'balls':$sql_sort='`user`.`balls`';$sort='balls'; // баллы
 	break;
	case 'level':$sql_sort='`user_group`.`level`';$sort='level'; // уровень
 	break;
	case 'pr':$sql_sort='`user`.`pr`';$sort='pr'; // уровень
 	break;
	case 'rating':$sql_sort='`user`.`rating`';$sort='rating'; // рейтинг
 	break;
	case 'pol':$sql_sort='`user`.`pol`';$sort='pol'; // пол
 	break;
 	default:$sql_sort='`user`.`id`';$sort='id'; // ID
 	break;
}








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='textmes'>";
echo "<img src='/style/icons/search.gif' alt='' class='icon'/>\n";
echo "Введите НИК или часть его\n";

echo "<form method=\"post\" action=\"/users.php?go&amp;sort=$sort&amp;$por\">";
echo "<input type=\"text\" name=\"usearch\" maxlength=\"16\" value=\"$usearch\" />\n";
echo "<input type=\"submit\" value=\"Поиск\" />";
echo "</form>\n";
echo "</div>\n";
}


echo "Сорт:\n";
echo "<a href='?sort=pr&amp;DESC&amp;page=$page'>привлек</a> |\n";
echo "<a href='?sort=balls&amp;DESC&amp;page=$page'>LM</a> |\n";
echo "<a href='?sort=rating&amp;DESC&amp;page=$page'>рейтинг</a> |\n";
echo "<a href='?sort=id&amp;ASC&amp;page=$page'>id</a> |\n";
echo "<a href='?sort=id&amp;DESC&amp;page=$page'>новые</a> \n";

echo "</div>\n";

echo "<table class='post'>\n";
if ($k_post==0)
{


}
$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_array($q))
{
$ank=get_user($ank['id']);


echo '<tr><td class="icon16">';
echo " <a href='/foto/$ank[id]/'>\n";
avatar4($ank['id']);
echo "</a>\n";
echo '<td class="sponline">';
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
echo "<font color='red'>[BAN]</font>\n";
echo "".online($ank['id'])." <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a> \n";

if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
if ($ank['stran']==0)echo "\n";
if ($ank['stran']==1)echo " <img src='/style/strana/ru.png'>\n";
if ($ank['stran']==2)echo " <img src='/style/strana/ua.png'>\n";
if ($ank['stran']==3)echo " <img src='/style/strana/by.png'>\n";
if ($ank['stran']==4)echo " <img src='/style/strana/az.png'>\n";
if ($ank['stran']==5)echo " <img src='/style/strana/kz.png'>\n";
if ($ank['stran']==6)echo " <img src='/style/strana/uz.png'>\n";
if ($ank['stran']==7)echo " <img src='/style/strana/england.png'>\n";
if ($ank['stran']==8)echo " <img src='/style/strana/de.png'>\n";
echo "<br />\n";
////////////////////////////////////////////////////////////////////////////////////////////////
if($ank['rating']>=0 && $ank['rating']<=25)echo "<img src='/style/stat.png'> <font color='red'>Новичок </font>$ank[rating] %</img><br />";
if($ank['rating']>=26 && $ank['rating']<=50)echo "<img src='/style/stat.png'> <font color='red'>Продвинутый </font>$ank[rating] %</img><br />";
if($ank['rating']>=51 && $ank['rating']<=75)echo "<img src='/style/stat.png'> <font color='red'>Бывалый </font>$ank[rating] %</img><br />";
if($ank['rating']>=76 && $ank['rating']<=110)echo "<img src='/style/stat.png'> <font color='red'>МегаОбитатель </font>$ank[rating] %</img><br />";
if($ank['rating']>=111 && $ank['rating']<=149)echo "<img src='/style/stat.png'> <font color='red'>Ветеран </font>$ank[rating] %</img><br />";
if($ank['rating']>=150 && $ank['rating']<=199)echo "<img src='/style/stat.png'> <font color='red'>Почетный Юзер </font>$ank[rating] %</img><br />";
if ($ank['srating']!=NULL)
echo "<img src='/style/stat.png'><span style=\"color:$ank[mcolor]\"> $ank[srating]</span> $ank[rating] %<br/>\n";
else
if($ank['rating']>=200 && $ank['rating']<=1120)echo "<img src='/style/stat.png'> <font color='red'>Лидер </font>$ank[rating] %</img><br />";

if ($ank['pol']==1)
echo "(Муж),";
else
echo "(Жен),";
if ($ank['ank_city']!=NULL)echo "<span class=\"ank_n\"></span> <span class=\"ank_d\">$ank[ank_city]</span><br />\n";
else
echo "<span class=\"ank_n\"></span> <span class=\"ank_no\">Город не определен</span><br />\n";

if ($sort=='rating')
echo "<span class=\"ank_n\">Рейтинг:</span> <span class=\"ank_d\">$ank[rating]</span><br />\n";
if ($sort=='pr')
echo "<img src='/style/icons/love.png'> Привлекательность:</span> <span class=\"ank_d\">$ank[pr] %<br />\n";
if ($sort=='balls')
echo "<span class=\"ank_n\">LM:</span> <span class=\"ank_d\">$ank[balls]</span><br />\n";

if ($sort=='pol')
echo "<span class=\"ank_n\">Пол:</span> <span class=\"ank_d\">".(($ank['pol']==1)?'Мужской':'Женский')."</span><br />\n";

if ($sort=='id')


if (user_access('user_prof_edit') && $user['level']>$ank['level'])
{
echo "<a href='/adm_panel/user.php?id=$ank[id]'>Редактировать профиль</a><br />\n";
}


echo "  </td>\n";
echo "   </tr>\n";

}
echo "</table>\n";
if ($k_page>1)str("users.php?sort=$sort&amp;$por&amp;",$k_page,$page); // Вывод страниц




$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;
$usearch=ereg_replace("( ){1,}","",$usearch);


if (isset($_GET['go']) && $usearch!=NULL)
{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` like '%".mysql_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='post'>\n";

if ($k_post==0)
{

echo "Нет результатов<br/>\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href='users.php'>назад</a>\n";

}
$q=mysql_query("SELECT `id` FROM `user` WHERE `nick` like '%".mysql_escape_string($usearch)."%' OR `id` = '".intval($usearch)."' ORDER BY `$sort` $por LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_array($q))
{
$ank=get_user($ank['id']);
echo '<tr><td class="icon16">';
echo " <a href='/foto/$ank[id]/'>\n";
avatar4($ank['id']);
echo "</a>\n";
echo '<td class="sponline">';
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
echo "<font color='red'>[BAN]</font>\n";
echo "".online($ank['id'])." <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a>\n";
if ($ank['obit']==0)
{
if ($ank['group_access']>1)echo "<img src='/style/adm.png'>\n";
}
if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
if ($ank['stran']==0)echo "\n";
if ($ank['stran']==1)echo " <img src='/style/strana/ru.png'>\n";
if ($ank['stran']==2)echo " <img src='/style/strana/ua.png'>\n";
if ($ank['stran']==3)echo " <img src='/style/strana/by.png'>\n";
if ($ank['stran']==4)echo " <img src='/style/strana/az.png'>\n";
if ($ank['stran']==5)echo " <img src='/style/strana/kz.png'>\n";
if ($ank['stran']==6)echo " <img src='/style/strana/uz.png'>\n";
if ($ank['stran']==7)echo " <img src='/style/strana/england.png'>\n";
if ($ank['stran']==8)echo " <img src='/style/strana/de.png'>\n";
echo "<br />\n";
////////////////////////////////////////////////////////////////////////////////////////////////
if($ank['rating']>=0 && $ank['rating']<=25)echo "<img src='/style/stat.png'> <font color='red'>Новичок </font>$ank[rating] %</img><br />";
if($ank['rating']>=26 && $ank['rating']<=50)echo "<img src='/style/stat.png'> <font color='red'>Продвинутый </font>$ank[rating] %</img><br />";
if($ank['rating']>=51 && $ank['rating']<=75)echo "<img src='/style/stat.png'> <font color='red'>Бывалый </font>$ank[rating] %</img><br />";
if($ank['rating']>=76 && $ank['rating']<=110)echo "<img src='/style/stat.png'> <font color='red'>МегаОбитатель </font>$ank[rating] %</img><br />";
if($ank['rating']>=111 && $ank['rating']<=149)echo "<img src='/style/stat.png'> <font color='red'>Ветеран </font>$ank[rating] %</img><br />";
if($ank['rating']>=150 && $ank['rating']<=199)echo "<img src='/style/stat.png'> <font color='red'>Почетный Юзер </font>$ank[rating] %</img><br />";
if ($ank['srating']!=NULL)
echo "<img src='/style/stat.png'><span style=\"color:$ank[mcolor]\"> $ank[srating]</span> $ank[rating] %<br/>\n";
else
if($ank['rating']>=200 && $ank['rating']<=1120)echo "<img src='/style/stat.png'> <font color='red'>Лидер </font>$ank[rating] %</img><br />";

if ($ank['pol']==1)
echo "(Муж),";
else
echo "(Жен),";

if ($ank['ank_city']!=NULL)echo "<span class=\"ank_n\"></span> <span class=\"ank_d\">$ank[ank_city]</span><br />\n";
else
echo "<span class=\"ank_n\"></span> <span class=\"ank_no\">Город не определен</span><br />\n";


if ($sort=='rating')
echo "<span class=\"ank_n\">Рейтинг:</span> <span class=\"ank_d\">$ank[rating]</span><br />\n";
if ($sort=='balls')
echo "<span class=\"ank_n\">LM:</span> <span class=\"ank_d\">$ank[balls]</span><br />\n";

if ($sort=='pol')
echo "<span class=\"ank_n\">Пол:</span> <span class=\"ank_d\">".(($ank['pol']==1)?'Мужской':'Женский')."</span><br />\n";

if ($sort=='id')

if (user_access('user_prof_edit') && $user['level']>$ank['level'])
{
echo "<a href='/adm_panel/user.php?id=$ank[id]'>Редактировать профиль</a><br />\n";
}

echo "  </td>\n";
echo "   </tr>\n";

}
echo "</table>\n";
if ($k_page>1)str("users.php?go&amp;sort=$sort&amp;$por&amp;",$k_page,$page); // Вывод страниц
}




include_once 'sys/inc/tfoot.php';
?>