<?php

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

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'adm_check', 'user') as $inc) {
    require_once "../sys/inc/$inc.php";
}

access('adm_panel_show', null, '/index.php?' . SID);

$_SESSION['adm_auth'] = $time + 600;

if (isset($_SESSION['adm_auth']) && $_SESSION['adm_auth'] > $time || isset($_SESSION['captcha']) && isset($_POST['chislo']) && $_SESSION['captcha'] == $_POST['chislo']) {
    $_SESSION['adm_auth'] = $time + 600;

    if (isset($_GET['go']) && $_GET['go'] != null) {
        header('Location: ' . base64_decode($_GET['go']));
        exit;
    }


    $set['title'] = lang('Панель управления');
    require_once H . 'sys/inc/thead.php';

    aut();
    err();

    #Навигация
    echo "<div class='list-group-item-null list-group-item-grey'><small>";
    echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Панель управления');
    echo "</small></div><br />";

    $adm_menu = mysql_query("SELECT * FROM `adm_menu` ORDER BY `pos` ASC");

    while ($post_menu = mysql_fetch_assoc($adm_menu)) {
        if (!isset($post_menu['icon'])) {
            mysql_query('ALTER TABLE `adm_menu` ADD `icon` VARCHAR( 32 ) NULL DEFAULT NULL');
        }


        echo "<a class='list-group-item-null' href = '$post_menu[url]'>";
        echo icons($post_menu['icon']) . " $post_menu[name]";

        if ($post_menu['counter'] != NULL && is_file(H . $post_menu['counter'])) {
            echo '<span class="count">';
            @include H . $post_menu['counter'];
            echo '</span>';
        }

        echo "</a>";
    }


    if (access('adm_menu')) {
        echo "<a href='adm_menu.php' class='list-group-item-null list-group-item-info'><i class='fa fa-plus fa-fw'></i> Добавить меню</a>";
    }
} else {

    $set['title'] = lang('Защита от автоматических изменений');
    require_once H . 'sys/inc/thead.php';

    aut();
    err();

    echo "<div class='list-group-item-null'><center><b>Защита от автоматических изменений</b></center></div>";

    echo "<form method='post' class='list-group-item-null' action='?gen=$passgen&amp;" . (isset($_GET['go']) ? "go=$_GET[go]" : null) . "'>\n";
    echo "<img src='/captcha.php?$passgen&amp;SESS=$sess' width = '100' height = '30' alt = 'Проверочное число' /><br />";
    echo "Введите число с картинки:<br />";

    echo "<input class='form-control' style='width: 30%;' name='chislo' maxlength='5' value='' type='text' />";

    echo "<hr>";

    echo "<button class='btn btn-success'><span class='fa fa-sign-in fa-fw'></span> Войти</button>";
    echo "</form>";
}

require_once H . 'sys/inc/tfoot.php';
