<a href="/" class="logo"></a>
<?php
if (isset($user)) {
    #Путь к своей странице
    echo "<a href='/info.php' class='list-group-item-null'>";
    echo avatar($user['id'], 40, 40);
    echo "<span class='nick'><b> " . gradient("$user[nick]", "$user[ncolor]", "$user[ncolor2]") . "</b></span>";
    echo "<div class='clear'></div>";
    echo "</a>";

    #Здесь начало вывода др у друзей
    $cD = date("d", time());
    $cM = date("m", time());

    function s_t($int, $expressions) {
        if (count($expressions) < 3) {
            $expressions[2] = $expressions[1];
        }
        $count = $int % 100;
        if ($count >= 5 && $count <= 20) {
            $result = 2;
        } else {
            $count = $count % 10;
        }
        if ($count == 1) {
            $result = 0;
        } elseif ($count >= 2 && $count <= 4) {
            $result = 1;
        } else {
            $result = 2;
        }
        return $int . ' ' . $expressions[$result];
    }

    $count_dr = 0;
    $friends_dr = $db->query("select `friends` from `friends` WHERE `user` = '" . $user['id'] . "' AND `i` = '1'");
    while ($c_d = $db->get_row($friends_dr)) {
        $q = $db->super_query("SELECT COUNT(*) as count FROM user WHERE id > '$c_d[friends]' AND ank_d_r = '$cD' AND ank_m_r = '$cM'");
        if ($q['count'] != 0) {
            $count_dr++;
        }
        unset($q);
    }

    if ($count_dr != 0) {
        echo "<a href='/?users&act=dr' class='list-group-item-null list-group-item-grey'><i class='fa fa-birthday-cake fa-fw'></i> " . lang('ДР у') . " " . s_t($count_dr, array('друга', 'друзей', 'друзей')) . " <i class='fa fa-calendar-check-o' style='float: right;'></i></a>";
    }
    unset($count_dr);
    ##конец др
    #
    #уведомления о сообщениях
    $q = $db->super_query("SELECT COUNT(*) as count FROM mail WHERE id_kont = '$user[id]' AND `read` = '0' AND `deleted` != '$user[id]' AND `deleted` != '-1' AND `flaggedTo` = 'inbox'");
    $mail = $q['count'];
    $q = $db->super_query("SELECT COUNT(*) as count FROM notification WHERE id_kont = '$user[id]' AND `read` = '0'");
    $jn = $q['count'];
    $q = $db->super_query("SELECT COUNT(*) as count FROM events WHERE id_kont = '$user[id]' AND `read` = '0'");
    $jne = $q['count'];
    $q = $db->super_query("SELECT COUNT(*) as count FROM f_journal WHERE id_user = '$user[id]' AND `read` = '0'");
    $jnf = $q['count'];
    $q = $db->super_query("SELECT COUNT(*) as count FROM myguests WHERE id_ank = '$user[id]' AND `read` = '1'");
    $guest = $q['count'];

    $not = $jn + $jne + $jnf;
    $q = $db->super_query("SELECT COUNT(*) as count FROM friends_new WHERE `to` = '$user[id]'");

    $friends = $q['count'];

    echo "<a href='/user/anketa/?name=$user[nick]' class='list-group-item-null list-group-item-grey'><i class='fa fa-user fa-fw'></i> " . lang('Моя анкета') . "</a>";
    echo "<a href='/user/bookmark/?id=$user[id]' class='list-group-item-null list-group-item-grey'><i class='fa fa-bookmark fa-fw'></i> " . lang('Мои закладки') . "</a>";
    echo "<a href='/modules/foto/$user[id]/' class='list-group-item-null list-group-item-grey'><i class='fa fa-photo fa-fw'></i> " . lang('Мои фотографии') . "</a>";
    echo "<a href='/modules/gifts/index.php?id=$user[id]' class='list-group-item-null list-group-item-grey'><i class='fa fa-gift fa-fw'></i> " . lang('Мои подарки') . "</a>";
    echo "<a href='/modules/diary/user.php?id=$user[id]' class='list-group-item-null list-group-item-grey'><i class='fa fa-book fa-fw'></i> " . lang('Мои блоги') . "</a>";
    echo "<a href='/user/friends/?id=$user[id]' class='list-group-item-null list-group-item-grey'><i class='fa fa-users fa-fw'></i> " . lang('Мои друзья') . " " . (($friends > 0) ? "<span class='tag tag-info right'><b>+$friends</b></span>" : "") . "</a>";
    echo "<a href='/user/guests.php' class='list-group-item-null list-group-item-grey'><i class='fa fa-eye fa-fw'></i> " . lang('Мои гости') . " " . (($guest > 0) ? "<span class='tag tag-info right'><b>+$guest</b></span>" : "") . "</a>";
    echo "<a href='/user/mail/' class='list-group-item-null list-group-item-grey'><i class='fa fa-envelope fa-fw'></i> " . lang('Мои сообщения') . " " . (($mail > 0) ? "<span class='tag tag-info right'><b>+$mail</b></span>" : "") . "</a>";
    echo "<a href='/user/notification/' class='list-group-item-null list-group-item-grey'><i class='fa fa-bell fa-fw'></i> " . lang('Мои уведомления') . " " . (($not > 0) ? "<span class='tag tag-info right'><b>+$not</b></span>" : "") . "</a>";

    if (access('adm_panel_show')) {
        $q1 = $db->super_query("SELECT COUNT(*) as count FROM support");
        $k_p = $q1['count'];
        $q2 = $db->super_query("SELECT COUNT(*) as count FROM support WHERE time > '" . (time() - 86400) . "'");
        $k_n = $q2['count'];
        if ($k_n == 0) {
            $k_n = NULL;
        } else {
            $k_n = " +$k_n";
        }

        echo "<div class='hr'></div>";
        echo "<a href='/panel/help.php' class='list-group-item-null list-group-item-grey'><i class='fa fa-support fa-fw'></i> " . lang('Тикеты') . " <span class='tag tag-info right'><b>$k_p$k_n</b></span></a>";
        echo "<a href='/panel/' class='list-group-item-null list-group-item-grey'><i class='fa fa-cogs fa-fw'></i> " . lang('Панель управления') . "</a>";

        unset($q);
        unset($q1);
        unset($q2);
    }
    ?>


    <div class="hr"></div>

    <a href="/exit.php" class="list-group-item-null list-group-item-grey"><i class="fa fa-sign-out fa-fw"></i> Выход</a>

    <?php
} else {
    ?>
    <a href="/aut.php" class="list-group-item-null list-group-item-grey"><i class="fa fa-sign-in fa-fw"></i> Вход</a> 
    <a href="/reg.php" class="list-group-item-null list-group-item-grey"><i class="fa fa-key fa-fw"></i> Регистрация</a>
    <?php
}