<?


function aut()
{
global $set;





if ($set['web']==false)
{
echo "<div class='aut'>";
global $user;
if (isset($user))
{
echo "<a href='/info.php'>Моя страничка</a>  \n";
echo "| <a href='/umenu.php'>меню</a> \n";
echo "| <a href='/exit1.php'>выход</a><br />\n";
$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 "<img src='/style/icons/mess0.png' alt='$k_new' /> <a href='/new_mess.php'><u>+ $k_new</u></a> \n";

if ($k_new_fav!=0)
echo "<a href='/new_mess.php'><img src='/style/icons/mail.gif' alt='$k_new_fav' /></a> \n";


$knj=mysql_result(mysql_query("SELECT COUNT(*) FROM `present_jurnal` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0);
if ($knj>0)
echo "<img src='/style/icons/pod16.gif' alt='' class='icon'/> <a href=\"/present/jurnal.php\" title=\"Gifts\"><u>+ $knj</u></a> \n";

$nj=mysql_result(mysql_query("SELECT COUNT(*) FROM `jurnal` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($nj>0)echo "<img src='/style/icons/uv.png' alt='' /> <a href=\"/jurnal.php\" title=\"Jurnal\"><u>+ $nj</u></a> \n";

$q=mysql_query("SELECT * FROM `lot_list` WHERE `die` = '0' AND `time_add` > 'time()+600'");
while($post=mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]'"));
if($post['prize']=='money')
{
mysql_query("UPDATE `user` SET `balls` = '$ank[balls]'+'$post[sum]' WHERE `id` = '$ank[id]' LIMIT 1");
$text="".vremja($post['time'])." Вы покупали лотерейный билет.Ваш выигрыш составил $post[sum] бал. Удачи вам!";
}
elseif($post['prize']=='rating')
{
mysql_query("UPDATE `user` SET `rating` = '$ank[rating]'+'$post[sum]' WHERE `id` = '$ank[id]' LIMIT 1");
mysql_query("INSERT INTO `user_voice2` (`rating`, `id_user`, `id_kont`) VALUES ('$post[sum]','0','$ank[id]')");
$text="".vremja($post['time'])." Вы покупали лотерейный билет.Ваш выигрыш составил $post[sum] рейтинга. Удачи вам!";
}
else $text="".vremja($post['time'])." Вы покупали лотерейный билет.К сожелению Вы ничего не выиграли. Удачи вам!";
mysql_query("INSERT INTO `mail` SET `id_user` = '0', `id_kont` = '$ank[id]', `time` = '$time', `msg` = '$text'");
mysql_query("UPDATE `lot_list` SET `die` = '1' WHERE `id` = '$post[id]'");
}

if($user['group_access']==3 || $user['group_access']==7 || $user['group_access']==8 || $user['group_access']==9 || $user['group_access']==15)

{
$forumm_k=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_komm_cmpl` WHERE `ok` = '0'"),0);
$forumm_t=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_them_cmpl` WHERE `ok` = '0'"),0);
if($forumm_k>0 || $forumm_t>0)echo"<a href='/forumm/?cmpl'>Жалобы(форумм) [$forumm_k/$forumm_t]</a><br/>\n";
}


$nj=mysql_result(mysql_query("SELECT COUNT(*) FROM `ocenka` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($nj>0)echo "<img src='/style/icons/5.png' alt='' /> <a href=\"/ocenka.php\" title=\"Jurnal\"><u>+ $nj</u></a> \n";

$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
if($lenta>0) echo "<img src='/style/icons/lenta.gif' alt='' class='icon'/> <a href='/lenta.php'><u>+ $lenta</u></a> ";

$obsuzh = mysql_result(mysql_query("SELECT COUNT(*) FROM `obsuzh` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
if($obsuzh>0) echo "<img src='/style/icons/irc14.png' alt='' class='icon'/> <a href='/obsuzh.php'><u>+ $obsuzh</u></a> ";

$new_g=mysql_result(mysql_query("SELECT COUNT(*) FROM `myguests` WHERE `id_ank` = '$user[id]' AND `read`='1'"),0);
if($new_g!=0)echo "<img src='/style/icons/eye.png' alt='' /> <a href='/myguests.php'><u>+ $new_g</u></a> \n";

$zoz = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0) > 0)
{
echo "<img src='/style/icons/user_add.png' alt='' /> <a href='/frend_new.php'><u>+ $zoz</u></a> ";
}

$zoz = mysql_result(mysql_query("SELECT COUNT(*) FROM `fanat_obm` WHERE `to` = '$user[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `fanat_obm` WHERE `to` = '$user[id]' LIMIT 1"), 0) > 0)
{
echo "<img src='/style/icons/readers.gif' alt='' /> <a href='/fanat_obm.php'><u>+ $zoz</u></a> ";
}



}
else
{

echo "<img src='/img/enter.gif' alt=''/> <a href='/aut.php'>Вход</a> | <a href='/reg.php'><font color='red'>Регистрация</font></a>\n";

}
echo "</div>\n";
}
}



?>