<?
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'] = 'Знакомства'; // заголовок страницы
include_once '../../sys/inc/thead.php';
title();
aut();

if (isset($_GET['orders']) && $_GET['orders'] == 'man')
{
	$_SESSION['orders'] = " AND `pol` = '1'";
	$_SESSION['nav1'] = 'activ';
	$_SESSION['nav2'] = NULL;
	$_SESSION['nav3'] = NULL;
}
elseif (isset($_GET['orders']) && $_GET['orders']=='woman')
{
	$_SESSION['orders'] = " AND `pol` = '0'";
	$_SESSION['nav1'] = NULL;
	$_SESSION['nav2'] = 'activ';
	$_SESSION['nav3'] = NULL;
}
elseif (isset($_GET['orders']) && $_GET['orders']=='all')
{
	$_SESSION['orders'] = NULL;
	$_SESSION['nav1'] = NULL;
	$_SESSION['nav2'] = NULL;
	$_SESSION['nav3'] = 'activ';
}
elseif (!isset($_SESSION['orders']))
{
	$_SESSION['orders'] = NULL;
	$_SESSION['nav1'] = NULL;
	$_SESSION['nav2'] = NULL;
	$_SESSION['nav3'] = 'activ';
}

	$cel = "(
	`ank_lov_1` = '1' OR 
	`ank_lov_2` = '1' OR 
	`ank_lov_3` = '1' OR 
	`ank_lov_4` = '1' OR 
	`ank_lov_5` = '1' OR 
	`ank_lov_6` = '1' OR 
	`ank_lov_7` = '1' OR 
	`ank_lov_8` = '1' OR 
	`ank_lov_9` = '1' OR 
	`ank_lov_10` = '1' OR 
	`ank_lov_11` = '1' OR 
	`ank_lov_12` = '1' OR 
	`ank_lov_13` = '1' OR 
	`ank_lov_14` = '1'
	)";
	$orien = "(
	`ank_orien` = '1' OR 
	`ank_orien` = '2' OR 
	`ank_orien` = '3'
	)";
	$opar = "(
	`ank_o_par` IS NOT NULL 
	)";
	$osebe = "(
	`ank_o_sebe` IS NOT NULL 
	)";

	echo "<div id='comments' class='menus'>";
	echo "<div class='webmenu'>";
	echo "<a href='?orders=all' class='$_SESSION[nav3]'>Все</a>";
	echo "</div>"; 
	echo "<div class='webmenu last'>";
	echo "<a href='?orders=woman' class='$_SESSION[nav2]'>Девушки</a>";
	echo "</div>"; 
	echo "<div class='webmenu last'>";
	echo "<a href='?orders=man' class='$_SESSION[nav1]'>Парни</a>";
	echo "</div>"; 
	echo "</div>";

$avt = mysql_fetch_assoc(mysql_query("SELECT id, avtoritet, avtoritet_count, ank_city
                                      FROM `user` 
                                      WHERE `avtoritet_count` > '0' " . (isset($user) ? "AND `ank_city` = '$user[ank_city]'" : null). " AND ank_city is not NULL AND ank_city != ''
                                      ORDER BY `avtoritet_count` DESC LIMIT 1"));
                                      
?>
<div class="mess">
<?
if (isset($avt['id'])) 
{
  ?>
  <b>Авторитет города</b> <span class="on"><?= text($avt['ank_city'])?></span><br />
  <?= user::avatar($avt['id'], 1) . user::nick($avt['id'], 1, 1, 1)?><br />
  <div style="color: #4e4e4e"><img src="/style/avtoritet/a8.png" alt="*" />Авторитет за неделю [<?= $avt['avtoritet_count']?> очков]</div>

  <? if ($avt['avtoritet'] >= 5) { ?>
    <div><?= star($avt['avtoritet'])?></div>
  <? } ?>
  
  <?
} else {
  if (isset($user) && !$user['ank_city']) {
    ?><span class="off">У вас не указан Город! Участие в топе невозможно!</span><br /><?
  }
  ?>Из вашего города еще нет авторитетов! Хочешь сюда?<br /><?
}
?>
<a href="/user/avtoritet.city.php?city=<?= urlencode($avt['ank_city'])?>"><img src="/style/avtoritet/icon_13.png" /> Стать авторитетом</a><br />
</div>
<?
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE $cel AND $orien AND $opar AND $osebe $_SESSION[orders] AND `date_last` > '".(time()-259200)."'"), 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 ank_o_sebe,nick,id FROM `user` WHERE $cel AND $orien AND $opar AND $osebe $_SESSION[orders] AND `date_last` > '".(time()-259200)."' order BY `date_last` DESC LIMIT $start, $set[p_str]");

echo '<table class="post">';
if ($k_post == 0)
{
	echo '<div class="mess">';
	echo 'Список анкет пуст';
	echo '</div>';
}

while ($ank = mysql_fetch_assoc($q))
{
$ank=get_user($ank['id']);

/*-----------зебра-----------*/ 
if ($num==0){
	echo '<div class="nav1">';
	$num=1;
}
elseif ($num==1){
	echo '<div class="nav2">';
	$num=0;
}
/*---------------------------*/

echo status($ank['id']);

echo group($ank['id']) . ' <a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a> ';

echo medal($ank['id']) . online($ank['id']) . '<br />';

echo output_text($ank['ank_o_sebe']);

echo '</div>';
}

echo '</table>';if ($k_page>1)str("?",$k_page,$page); // Вывод страниц

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