<?php

defined('_CONSTANT_') or die('Error. You don`t have permision to access.');

global $user, $Count, $Filter, $User;

if (!empty($user) && $user['design'] == 'touch-blue') 
{
    ?> 
    <div class="line-footer"></div>
    <?php
}
# Party;
if ($_SERVER['SCRIPT_NAME'] != '/modules/dungeons/party.php') 
{
    $User->partyLink(); 
}

# Task; 
if (!empty($user['task_id'])) 
{
    ?> 
    <a href="<?=HOME?>/modules/task/<?=$user['task_id']?>/index.php" class="link-touch">Перейти к заданию</a>
    <?php
}
?>
<hr><div class="line"></div>
<?php

# Index link;
if ($_SERVER['PHP_SELF'] != '/index.php' && $_SERVER['PHP_SELF'] != '/game/index.php' && $_SERVER['PHP_SELF'] != '/game/') 
{
    if (empty($user) || !empty($user) && $user['design'] != 'touch-blue') 
    {
        ?>
        <a href="<?=HOME?>/" class="link-touch"><?=ico('home.png')?> На главную</a>
        <?php
    }
}

# Only for user;
if ($user) 
{ 
    if ($user['access'] == 2) 
    {
        ?> 
        <a href="<?=HOME?>/modules/administrative/" class="link-touch"><?=ico('panel.png')?> Панель Управления</a> 
        <?php
    }

    # Journal
    $journalCount = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM " . JOURNAL . " WHERE `user_id` = ?", [$user['id']]);
    $journalNewCount = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM " . JOURNAL . " WHERE `user_id` = ? AND `status` = ? ", [$user['id'], 1]); 
    
    if ($user['design'] == 'touch-blue') 
    {
        ?> 
        <table style="width: 100%;text-align: center;" cellspacing="0" cellpadding="0">
            <tr>
                <td style="vertical-align:top;width:30%;white-space: nowrap;">
                    <a href="<?=HOME?>/game/index.php"><img class="foot-image" src="<?=HOME?>/img/home-foot.png" width="50px"></a>
                </td>
                <td style="vertical-align:top;width:30%;white-space: nowrap;">
                    <a href="<?=HOME?>/modules/user/index.php?userId=<?=$user['id']?>"><img class="foot-image" src="<?=HOME?>/img/user-foot.png" width="50px"></a>
                </td>
                <td style="vertical-align:top;width:30%;white-space: nowrap;">
                    <a href="<?=HOME?>/modules/clan/<?=(!empty($user['clan_id']) ? 'index.php' : 'clans.php')?>"><img class="foot-image" src="<?=HOME?>/img/clan-foot.png" width="50px"></a>
                </td>
            </tr>
        </table>
        <a href="<?=HOME?>/modules/user/journal/index.php" class="link-touch"><?=ico('journal.png')?> Журнал (<?=$journalCount?>) <?=($journalNewCount > 0 ? '<span class="count">+ ' . $journalNewCount . '</span>' : NULL)?></a>
    <a href="<?=HOME?>/modules/user/items/index.php?do=rack" class="link-touch"><?=ico('rack.png')?> Рюкзак <span class="count"><?=$Filter->clearInt($user['inv'])?>/<?=$Filter->clearInt($user['max_inv'])?></span></a>
        <?php
    } 
    else 
    {
        ?> 
        <a href="<?=HOME?>/modules/user/index.php?userId=<?=$user['id']?>" class="link-touch"><?=ico('user.png')?> Мой профиль <span class="count"><?=$Filter->clearInt($user['lvl'])?> ур.</span></a>
        <a href="<?=HOME?>/modules/user/journal/index.php" class="link-touch"><?=ico('journal.png')?> Журнал (<?=$journalCount?>) <?=($journalNewCount > 0 ? '<span class="count">+ ' . $journalNewCount . '</span>' : NULL)?></a>
        <a href="<?=HOME?>/modules/user/items/index.php?do=rack" class="link-touch"><?=ico('rack.png')?> Рюкзак <span class="count"><?=$Filter->clearInt($user['inv'])?>/<?=$Filter->clearInt($user['max_inv'])?></span></a>
        <?php 
        if ($user['clan_id'] != 0) 
        {
            ?> 
            <a href="<?=HOME?>/modules/clan/index.php" class="link-touch"><?=ico('user.png')?> Мой клан</a>
            <?php
        } 
    }
    ?>
    <hr><div class="line"></div>
    <table style="width:100%" cellspacing="0" cellpadding="0">
        <tr>
            <td style="vertical-align:top;width:50%;white-space: nowrap;">
                <a href="<?=HOME?>/modules/user/settings/index.php?do=setDesign" class="link-touch">Сменить дизайн</a>
            </td>
            <td style="vertical-align:top;width:50%;white-space: nowrap;"> 
                <a href="<?=HOME?>/modules/login/exit.php" class="link-touch">Выход</a>
            </td>
        </tr>
    </table>
<?php
}
?>
<hr><div class="line"></div>
<a href="<?=(empty($user) ? '#' : ''.HOME.'/modules/rating/index.php?do=usersOnline')?>" class="link-touch"><?=ico('users.png')?> В игре <span class="count"><?=$Count->userCountOnline()?></span></a>
<?php
if (!empty($user) && $user['access'] == 2) 
{
    ?> 
    <a href="#" class="link-touch">Pgen <span class="count"><?=genTimerStop()?></span></a>
    <?php
} 
?>
<a href="#" class="link-touch">На сервере <span class="count"><?=dataTime()?></span></a>
<a href="https://vk.com/wapgame_inc" target="_blank" class="link-touch">Мы вконтакте</a>
<br/><hr>
<div class="content">
    <div class="link-touch">
        &COPY; amfetaminf<br/> 
    </div>
    <a href="<?=HOME?>/modules/agreement/index.php" class="link-touch">Правила</a>
</div>
<?=CLOSE_DIV.CLOSE_DIV?>
<div class="wrap" style="opacity: 0.1;">
    <?=($_SERVER['PHP_SELF'] == '/index.php' || $_SERVER['PHP_SELF'] == '/game/index.php' ? '<a href="http://statok.net/go/16106"><img src="http://statok.net/image/16106" alt="Statok.net" /></a>' : '<a href="http://statok.net/go/16106"><img src="http://statok.net/imageOther/16106" alt="Statok.net" /></a>')?>
    <!--LiveInternet counter-->
    <script type="text/javascript">
        document.write("<a href='//www.liveinternet.ru/click' "+
        "target=_blank><img src='//counter.yadro.ru/hit?t24.6;r"+
        escape(document.referrer)+((typeof(screen)=="undefined")?"":
        ";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
        screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
        ";"+Math.random()+
        "' alt='' title='LiveInternet: number of visitors for today is"+
        " shown' "+
        "border='0' width='88' height='15'><\/a>")
    </script>
    <!--/LiveInternet-->
</div>
</body></html>