<?php

/* DCMS Special)
 * Дата последнего редактирования 10.10.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 = $db->query("SELECT * FROM `adm_menu` ORDER BY `pos` ASC");

    while ($post_menu = $db->get_row($adm_menu)) {

        echo "<a class='list-group-item-null list-group-item-grey dop' 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="tag tag-info right">';
            @include H . $post_menu['counter'];
            echo '</span>';
        }

        echo "</a>";
    }


    if (access('adm_menu')) {
        echo "<div class='list-group-item-null'>";
        $doc->Link('btn btn-secondary btn-sm', 'adm_menu.php?add', 'plus', 'Добавить пункт');
        echo "</div>";
    }
} 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';
