<?php

/* DCMS Special
 * Дата последнего редактирования 18.01.2016
 * Модифицировал densnet
 */

$i = 0;
$q = $db->super_query("SELECT COUNT(*) as count FROM `gallery_foto` WHERE `id_user` = '$ank[id]' ORDER BY `id` DESC");
$inc_foto = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `gallery` WHERE `id_user` = '$ank[id]'");
$foto_count = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `gallery` WHERE `id_user` = '$ank[id]' AND `time` > '" . (time() - 86400) . "'");
$foto_count_new = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `gallery_foto` WHERE `id_user` = '$ank[id]'");
$foto_photo = $q['count'];
$q = $db->super_query("SELECT COUNT(id_user) as count FROM `bookmark_user` WHERE `id_user` = '$ank[id]'");
$users = $q['count'];
$q = $db->super_query("SELECT COUNT(id_user) as count FROM `gifts` WHERE `id_user` = '$ank[id]'");
$gifts = $q['count'];
$q = $db->super_query("SELECT COUNT(id_user) as count FROM `diary` WHERE `id_user` = '$ank[id]'");
$blog = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `loads_list` WHERE `id_user` = '$ank[id]'");
$files = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `gallery_rating` WHERE `avtor` = '$ank[id]'");
$ocenky = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `history_nick` WHERE `user_id` = '$ank[id]'");
$log = $q['count'];

$refs = $db->num_rows($db->query("select * from `user_referals` WHERE `id_ref` = '" . $ank['id'] . "'"));
$q = $db->super_query("SELECT COUNT(id_user) as count FROM `bookmark_foto` WHERE `id_user` = '$ank[id]'");
$fotos = $q['count'];
$bookmark_count = $users + $fotos;
$q = $db->super_query("SELECT COUNT(*) as count FROM `user_blacklist` WHERE `id_user` = '$ank[id]'");
$black_count = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `myguests` WHERE `id_ank` = '$ank[id]'");
$guests = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `myguests` WHERE `id_ank` = '$ank[id]' AND `time` > '" . (time() - 86400) . "'");
$guests_new = $q['count'];

if ($guests_new == 0) {
    $guests_new = NULL;
} else {
    $guests_new = " +$guests_new";
}

$q = $db->super_query("SELECT COUNT(*) as count FROM `friends` WHERE `user` = '$ank[id]' AND `i` = '1'");
$k_fr = $q['count'];

$q = $db->super_query("SELECT COUNT(`read`) as count FROM `notification` WHERE `id_kont` = '$user[id]'");
$not = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `notification` WHERE `id_kont` = '$user[id]' AND `time` > '" . (time() - 86400) . "'");
$not_new = $q['count'];
$q = $db->super_query("SELECT COUNT(`read`) as count FROM `notifications` WHERE `id_kont` = '$user[id]'");
$nots = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `notifications` WHERE `id_kont` = '$user[id]' AND `time` > '" . (time() - 86400) . "'");
$nots_new = $q['count'];
$q = $db->super_query("SELECT COUNT(`read`) as count FROM `events` WHERE `id_kont` = '$user[id]'");
$event = $q['count'];
$q = $db->super_query("SELECT COUNT(*) as count FROM `events` WHERE `id_kont` = '$user[id]' AND `time` > '" . (time() - 86400) . "'");
$event_new = $q['count'];

$not = $not + $nots + $event;
$not_new = $event_new + $not_new + $nots_new;

if ($not_new > 0) {
    $not = "$not +$not_new";
} else {
    $not = $not;
}


$count_gifts = $db->num_rows($db->query("SELECT * FROM `gifts` WHERE `id_user` = '$ank[id]'"));

if ($count_gifts > 0) {
    echo "<div class='list-group-item-null'>";
}

$query = $db->query("SELECT * FROM `gifts` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT 6");

while ($post = $db->get_array($query)) {
    $gift = $db->get_array($db->query("SELECT * FROM `gift` WHERE `id` = '$post[id_gift]'"));
    echo "<a href = '/modules/gifts/?id=$ank[id]&amp;gift=$post[id]' style = 'margin-right:4px;'><img src = '/modules/gifts/images/$gift[image]' width = '40' height = '40' /></a>\n";
}
if ($count_gifts > 6) {
    echo " <a href = '/modules/gifts/?id=$ank[id]' style = 'margin-left: 4px;text-decoration: none;'><span style = 'font-size: large;text-decoration: none;vertical-align: bottom;'>&raquo;</span></a>";
}
if ($count_gifts > 0) {
    echo "</div>";
}

##############################################################Обновлено с 7.2.1
if ($user['set_profile'] == 1) {
    echo "<div class='list-group-item-null'>";
    if (IS_WEB) {
        echo "<div class='tile-menu'>";
        if (isset($user)) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/anketa/?name=$ank[nick]'><div class='menu_picat'><i class='fa fa-user fa-3x'></i></div> <div class='menu_title_s'>" . lang('Анкета') . "</div></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/bookmark/?id=$ank[id]'><span class='hint--bottom' data-hint='$bookmark_count'><div class='menu_picat'><i class='fa fa-bookmark fa-3x'></i></div> <div class='menu_title_s'> " . lang('Закладки') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/foto/$ank[id]/'><span class='hint--bottom' data-hint='$foto_photo'><div class='menu_picat'><i class='fa fa-photo fa-3x'></i></div> <div class='menu_title_s'> " . lang('Фотографии') . " </div></span></a></div>";
        if (isset($user) && $user['id'] == $ank['id']) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/foto/ocenky.php?id=$ank[id]'><span class='hint--bottom' data-hint='$ocenky'><div class='menu_picat'><i class='fa fa-html5 fa-3x'></i></div> <div class='menu_title_s'> " . lang('Оценки к фото') . " </div></span></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/gifts/index.php?id=$ank[id]'><span class='hint--bottom' data-hint='$gifts'><div class='menu_picat'><i class='fa fa-gift fa-3x'></i></div> <div class='menu_title_s'> " . lang('Подарки') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/diary/user.php?id=$ank[id]'><span class='hint--bottom' data-hint='$blog'><div class='menu_picat'><i class='fa fa-book fa-3x'></i></div> <div class='menu_title_s'> " . lang('Блоги') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/files.php?id=$ank[id]'><span class='hint--bottom' data-hint='$files'><div class='menu_picat'><i class='fa fa-file fa-3x'></i></div> <div class='menu_title_s'> " . lang('Файлы') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/friends/?id=$ank[id]'><span class='hint--bottom' data-hint='$k_fr'><div class='menu_picat'><i class='fa fa-users fa-3x'></i></div> <div class='menu_title_s'> " . lang('Друзья') . " </div></span></a></div>";

        if (isset($user) && $user['id'] == $ank['id']) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/guests.php'><span class='hint--bottom' data-hint='$guests$guests_new'><div class='menu_picat'><i class='fa fa-eye fa-3x'></i></div> <div class='menu_title_s'> " . lang('Гости') . "</div></span></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/mail/'><div class='menu_picat'><i class='fa fa-envelope fa-3x'></i></div> <div class='menu_title_s'> " . lang('Сообщения') . "</div></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/blacklist/'><span class='hint--bottom' data-hint='$black_count'><div class='menu_picat'><i class='fa fa-ban fa-3x'></i></div> <div class='menu_title_s'> " . lang('Черный список') . "</div></span></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/notification/'><span class='hint--bottom' data-hint='$not'><div class='menu_picat'><i class='fa fa-bell fa-3x'></i></div> <div class='menu_title_s'> " . lang('Уведомления') . "</div></span></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/referals/?id=$ank[id]'><span class='hint--bottom' data-hint='$refs'><div class='menu_picat'><i class='fa fa-map-marker fa-3x'></i></div> <div class='menu_title_s'> " . lang('Рефералы') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/history_login.php?id=$ank[id]'><span class='hint--bottom' data-hint='$log'><div class='menu_picat'><i class='fa fa-i-cursor fa-3x'></i></div> <div class='menu_title_s'> " . lang('История логинов') . " </div></span></a></div>";

        echo "<div class='clear'></div>";
        echo "</div>";
    } else {
        #То как видят с телефона
        echo "<div class='tile-menu'>";
        if (isset($user)) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/anketa/?name=$ank[nick]'><div class='menu_picat'><i class='fa fa-user fa-2x'></i></div> <div class='menu_title_s'>" . lang('Анкета') . "</div></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/bookmark/?id=$ank[id]'><span class='hint--bottom' data-hint='$bookmark_count'><div class='menu_picat'><i class='fa fa-bookmark fa-2x'></i></div> <div class='menu_title_s'> " . lang('Закладки') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/foto/$ank[id]/'><span class='hint--bottom' data-hint='$foto_photo'><div class='menu_picat'><i class='fa fa-photo fa-2x'></i></div> <div class='menu_title_s'> " . lang('Фотографии') . " </div></span></a></div>";
        if (isset($user) && $user['id'] == $ank['id']) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/foto/ocenky.php?id=$ank[id]'><span class='hint--bottom' data-hint='$ocenky'><div class='menu_picat'><i class='fa fa-html5 fa-2x'></i></div> <div class='menu_title_s'> " . lang('Оценки') . " </div></span></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/gifts/index.php?id=$ank[id]'><span class='hint--bottom' data-hint='$gifts'><div class='menu_picat'><i class='fa fa-gift fa-2x'></i></div> <div class='menu_title_s'> " . lang('Подарки') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/modules/diary/user.php?id=$ank[id]'><span class='hint--bottom' data-hint='$blog'><div class='menu_picat'><i class='fa fa-book fa-2x'></i></div> <div class='menu_title_s'> " . lang('Блоги') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/files.php?id=$ank[id]'><span class='hint--bottom' data-hint='$files'><div class='menu_picat'><i class='fa fa-file fa-2x'></i></div> <div class='menu_title_s'> " . lang('Файлы') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/friends/?id=$ank[id]'><span class='hint--bottom' data-hint='$k_fr'><div class='menu_picat'><i class='fa fa-users fa-2x'></i></div> <div class='menu_title_s'> " . lang('Друзья') . " </div></span></a></div>";

        if (isset($user) && $user['id'] == $ank['id']) {
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/guests.php'><span class='hint--bottom' data-hint='$guests$guests_new'><div class='menu_picat'><i class='fa fa-eye fa-2x'></i></div> <div class='menu_title_s'> " . lang('Гости') . "</div></span></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/mail/'><div class='menu_picat'><i class='fa fa-envelope fa-2x'></i></div> <div class='menu_title_s'> " . lang('Сообщения') . "</div></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/blacklist/'><span class='hint--bottom' data-hint='$black_count'><div class='menu_picat'><i class='fa fa-ban fa-2x'></i></div> <div class='menu_title_s'> " . lang('Черн. список') . "</div></span></a></div>";
            echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/notification/'><span class='hint--bottom' data-hint='$not'><div class='menu_picat'><i class='fa fa-bell fa-2x'></i></div> <div class='menu_title_s'> " . lang('Уведомления') . "</div></span></a></div>";
        }
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/referals/?id=$ank[id]'><span class='hint--bottom' data-hint='$refs'><div class='menu_picat'><i class='fa fa-map-marker fa-2x'></i></div> <div class='menu_title_s'> " . lang('Рефералы') . "</div></span></a></div>";
        echo "<div class='menu_wrapeer'><a class='menu_link_s' href='/user/history_login.php?id=$ank[id]'><span class='hint--bottom' data-hint='$log'><div class='menu_picat'><i class='fa fa-i-cursor fa-2x'></i></div> <div class='menu_title_s'> " . lang('Ист. логинов') . " </div></span></a></div>";

        echo "<div class='clear'></div>";
        echo "</div>";
    }
    echo "</div>";
} else {
    if (isset($user)) {
        echo "<a href='/user/anketa/?name=$ank[nick]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-user fa-fw'></i> " . lang('Анкета') . "</a>";
    }
    echo "<a href='/user/bookmark/?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-bookmark fa-fw'></i> " . lang('Закладки') . " <span class='tag tag-info right'>$bookmark_count</span></a>";
    echo "<a href='/modules/foto/$ank[id]/' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-photo fa-fw'></i> " . lang('Фотографии') . " <span class='tag tag-info right'>$foto_photo</span></a>";
    if (isset($user) && $user['id'] == $ank['id']) {
        echo "<a href='/modules/foto/ocenky.php?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-html5 fa-fw'></i> " . lang('Оценки к фото') . " <span class='tag tag-info right'>$ocenky</span></a>\n";
    }
    echo "<a href='/modules/gifts/index.php?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-gift fa-fw'></i> " . lang('Подарки') . " <span class='tag tag-info right'>$gifts</span></a>";
    echo "<a href='/modules/diary/user.php?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-book fa-fw'></i> " . lang('Блоги') . " <span class='tag tag-info right'>$blog</span></a>";
    echo "<a href='/user/files.php?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-file fa-fw'></i> " . lang('Файлы') . " <span class='tag tag-info right'>$files</span></a>";
    echo "<a href='/user/friends/?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-users fa-fw'></i> " . lang('Друзья') . " <span class='tag tag-info right'>$k_fr</span></a>";

    if (isset($user) && $user['id'] == $ank['id']) {
        echo "<a href='/user/guests.php' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-eye fa-fw'></i> " . lang('Гости') . " <span class='tag tag-info right'>$guests$guests_new</span></a>";
        echo "<a href='/user/mail/' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-envelope fa-fw'></i> " . lang('Сообщения') . "</a>";
        echo "<a href='/user/blacklist/' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-ban fa-fw'></i> " . lang('Черный список') . " <span class='tag tag-info right'>$black_count</span></a>";
        echo "<a href='/user/notification/' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-bell fa-fw'></i> " . lang('Уведомления') . " <span class='tag tag-info right'>$not</span></a>";
    }
    echo "<a href='/user/referals/?id=$ank[id]' class='list-group-item-null list-group-item-grey dop'><i class='fa fa-map-marker fa-fw'></i> " . lang('Рефералы') . " <span class='tag tag-info right'>$refs</span></a>";
    echo "<a class='list-group-item-null list-group-item-grey dop' href='/user/history_login.php?id=$ank[id]'><i class='fa fa-i-cursor fa-fw'></i> " . lang('История логинов') . " <span class='tag tag-info right'>$log</span></a>";
}

include H . 'user/friends/include.php';
#################################################################Конец обновления
#
#Видно другому пользователю, вам не видно
if (isset($user) && $user['id'] != $ank['id']) {
    if (isset($user) && $user['level'] > $ank['level'] && $user['id'] != $ank['id']) {

        if (access('user_prof_edit')) {
            $doc->Link('list-group-item-null list-group-item-info', "/panel/user.php?id=$ank[id]", 'edit', 'Редактировать профиль');
        }
        if (access('user_ban_set') || access('user_ban_set_h') || access('user_ban_unset')) {
            $doc->Link('list-group-item-null list-group-item-info', "/panel/ban.php?id=$ank[id]", 'gavel', 'Дать бан');
        }
        if (access('user_delete')) {
            $doc->Link('list-group-item-null list-group-item-info', "/panel/delete_user.php?id=$ank[id]", 'user-times', 'Удалить');
            $mass[0] = $ank['id'];
            if (access('collisions') && count(collision($mass, 1)) > 1) {
                $doc->Link('list-group-item-null list-group-item-info', "/panel/delete_user.php?id=$ank[id]&amp;all", 'user-times', 'Удалить все уч. записи');
            }
        }
        if (access('adm_log_read') && $ank['level'] && ($ank['id'] == $user['id'] || $ank['level'] < $user['level'])) {
            $doc->Link('list-group-item-null list-group-item-info', "/panel/adm_log.php?id=$ank[id]", 'list-alt', 'Отчет действий');
        }
    }
}
    