<?

//-------- Счетчики --------

//Почта
$count_mail = 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);
//Почта
$count_new_mail = 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);
//Лента
$count_lenta = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "),0);
//Обсуждения
$count_discuss = mysql_result(mysql_query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "),0);
//Друзья
$count_friend = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$user[id]'"), 0);
//Уведомления
$count_notif = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0);		

//-------- Счетчики end --------

# Нижняя панель пользователя
if (isset($user)){
echo '<table class="foot" cellspacing="0" cellpadding="0">';
if ($_SERVER['PHP_SELF'] == '/user/feed/index.php'){
echo '<td><a class="foot_panel" href="/"><img src="/img/panel/home_ok.png"></a></td>';
}else{
echo '<td><a class="foot_panel" href="/"><img src="/img/panel/home.png"></a></td>';
}
if ($_SERVER['PHP_SELF'] == '/user/people.php'){
echo '<td><a class="foot_panel" href="/user/people.php"><img src="/img/panel/search_ok.png"></a></td>';
}else{
echo '<td><a class="foot_panel" href="/user/people.php"><img src="/img/panel/search.png"></a></td>';
}
echo '<td><a class="foot_panel" href="/modules/photo/'.$user[id].'/'.$user[id].'/?act=upload"><img src="/img/panel/plus.png"></a></td>';
# Действия
if ($count_notif > 0){
$j2 = 'notify';
}else{
$j2 = 'notify';
}
$k_l = $count_notif;
if($k_l > 0){
echo '<td><a class="foot_panel" href="/user/'.$j2.'/"><span class="count_notify">'.$k_l.'</span><img src="/img/panel/like.png"></br><span style="position: absolute; color: #f7465a; font-size: 10px; margin: -2px;">●</span> </a></td>';
}else{
if ($_SERVER['PHP_SELF'] == '/user/notify/index.php'){
echo '<td><a class="foot_panel" href="/user/notify/"><img src="/img/panel/like_ok.png"></a></td>';
}else{
echo '<td><a class="foot_panel" href="/user/notify/"><img src="/img/panel/like.png"></a></td>';
}
}
if ($_SERVER['PHP_SELF'] == '/user/profil.php'){
echo '<td><a class="foot_panel" href="/id'.$user[id].'"><img src="/img/panel/user_ok.png"></a></td>';
}else{
echo '<td><a class="foot_panel" href="/id'.$user[id].'"><img src="/img/panel/user.png"></a></td>';
}
echo '</table>';
}

echo '</div>';

echo '</body></html>';

exit;

?>