<?

if (isset($user)){

/*

=================================

Страничка

=================================

*/

echo '<a href="/info.php?"><span class="link_title">Моя стр</span></a>';

/*

=================================

Почта

=================================

*/

$k_new=mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail`

 LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]'

 WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"),0);

$k_new_fav=mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail`

 LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]'

 WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"),0);



 if ($k_new!=0 && $k_new_fav==0){

 

echo "<a href='/new_mess.php'><span class='link_title'><img src='/style/icons/new_mess.gif' alt='S'/> Почта (<font color=\"#ff0000\">+$k_new</font>)</span></a>";

}else{

echo "<a href='/konts.php'><span class='link_title'>Почта</span></a>";

}

/*

=================================

Лента

=================================

*/

$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "),0);

echo "<a href='/user/tape/index.php'><span class='link_title'>Лента";

$k_l = $lenta;

if($k_l>0)echo " <font color=\"#ff0000\">(+$k_l)</font>";

echo "</span></a>";



/*

=================================

Обсуждения

=================================

*/

$discuss = mysql_result(mysql_query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "),0); // Обсуждения

$k_l = $discuss;

echo "<a href='/user/discussions/index.php'><span class='link_title'>Обсуждения";

if($k_l>0)echo " <font color=\"#ff0000\">(+$k_l)</font>";

echo "</span></a>";

/*

=================================

Уведомления

=================================

*/

$k_notif = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); // Уведомления

$k_l = $k_notif;

if($k_l>0){

	echo "<a href='/user/notification/index.php'><span class='link_title'>Уведомления";

	echo " <font color=\"#ff0000\">(+$k_l)</font>";

	echo "</span></a>";

}



/*

=================================

Друзья

=================================

*/

$k_f = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0);

if ($k_f>0)

echo "<a href='/user/frends/new.php'><span class='link_title'>Друзья (<font color='red'>+$k_f</font>)</span></a>";

else 

echo '<a href="/user/frends/?id='.$user['id'].'"><span class="link_title">Друзья</span></a>';

/*

=================================

Обновить

=================================

*/

echo '<a href="'.htmlspecialchars($_SERVER['REQUEST_URI']).'"><span class="link_title">Обновить</span></a>';

}elseif ($_SERVER['PHP_SELF'] != '/aut.php' && $_SERVER['PHP_SELF'] != '/reg.php'){









echo '<script src="//ulogin.ru/js/ulogin.js"></script>';

$tUlogin = '<div id="uLogin" data-ulogin="display=panel;fields=first_name,last_name,city,sex,photo,photo_big;providers=vkontakte,odnoklassniki,mailru,facebook,yandex;hidden;redirect_uri=http%3A%2F%2F'.$_SERVER['HTTP_HOST'].'/user/connect/loginAPI.php"></div>';



echo '<a href="#user" rel="facebox"><span class="link_title">Авторизация/Регистрация</span></a>';

echo '<div id="user" style="display:none;">';

echo '<div class="mess">

Войти через:<br />' . $tUlogin;

echo '</div>';

echo "<div class = 'foot'>Авторизация</div>";

	echo "<form class='mess' method='post' action='/login.php'>

		Логин:<br /><input type='text' name='nick' maxlength='32' /><br />

		Пароль:<br /><input type='password' name='pass' maxlength='32' /><br />

		<label><input type='checkbox' name='aut_save' value='1' /> Запомнить меня</label><br />

		<input type='submit' value='Войти' /> <a href='/pass.php'>Забыли пароль?</a> <br />

		</form><br />";

echo "<div class = 'foot'>Регистрация</div>";

echo "<form class='mess' method='post' action='/reg.php?$passgen'>\n";

echo "Выберите ник [A-zА-я0-9 -_]:<br /><input type='text' name='nick' maxlength='32' /><br />\n";

echo "Регистрируясь, Вы автоматически соглашаетесь с <a href='/rules.php'>правилами</a> сайта<br />\n";

echo "<input type='submit' value='Продолжить' />\n";

echo "</form><br />\n";

			

echo'</div>';







}