<?php

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

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

only_reg();
$set['title'] = lang('Настройка верхней панели');
include_once H . 'sys/inc/thead.php';

err();
aut();

switch ((isset($_GET['m'])) ? htmlspecialchars($_GET['m']) : null) {
    default:
        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Верхняя панель');
        echo "</small></div><br />";

        echo "<a href='?m=settings' class='list-group-item-null list-group-item-grey'><i class='fa fa-cog fa-fw'></i> " . lang('Настройки панели') . "</a>";
        echo "<a href='?m=style_verh' class='list-group-item-null list-group-item-grey'><font color='#$user[colorfp]'><i class='fa fa-circle fa-fw'></i></font> " . lang('Цвет вверхний градиент') . "</a>";
        echo "<a href='?m=style_niz' class='list-group-item-null list-group-item-grey'><font color='#$user[colorbs]'><i class='fa fa-circle fa-fw'></i></font> " . lang('Цвет нижний градиент') . "</a>";
        echo "<a href='?m=icon_color' class='list-group-item-null list-group-item-grey'><font color='#$user[colorlp]'><i class='fa fa-circle fa-fw'></i></font> " . lang('Цвет иконок') . "</a>";
        echo "<a href='?m=link_color' class='list-group-item-null list-group-item-grey'><font color='#$user[colorbp]'><i class='fa fa-circle fa-fw'></i></font> " . lang('Цвет текста заголовка') . "</a>";

        break;

    case 'settings':

        if (isset($_POST['check'])) {

            if (isset($_POST['set_icon_panel']) && ($_POST['set_icon_panel'] == 1 || $_POST['set_icon_panel'] == 0)) {
                $user['set_icon_panel'] = intval($_POST['set_icon_panel']);
                $db->query("UPDATE `user` SET `set_icon_panel` = '$user[set_icon_panel]' WHERE `id` = '$user[id]' LIMIT 1");
            } else {
                $err[] = lang('Ошибка выбора иконки');
            }

            $user['set_search'] = (isset($_POST['set_search']) && $_POST['set_search']) ? '1' : '0';
            $db->query("UPDATE `user` SET `set_search` = '" . $user['set_search'] . "' WHERE `id` = '" . $user['id'] . "' LIMIT 1");


            $icon_left = stripcslashes(htmlspecialchars($_POST['icon_panel_left']));
            $icon_right = stripcslashes(htmlspecialchars($_POST['icon_panel_right']));

            $db->query("UPDATE `user` SET `icon_panel_left` = '$icon_left', `icon_panel_right` = '$icon_right' WHERE `id` = '$user[id]' LIMIT 1");

            $_SESSION['message'] = lang("Изменения сохранены");
            header("Location: panels.php?m=settings" . SID);
            exit;
        }

        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/panels.php'>" . lang('Верхняя панель') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Настройки панели');
        echo "</small></div><br />";

        echo "<form method='post' class='list-group-item-null' action='?m=settings&amp;$passgen'>";

        echo "<b>" . lang('Левая кнопка') . "</b><br />";

        $doc->Radio('set_icon_panel', 'Аватар', '1', "" . ($user['set_icon_panel'] == '1' ? " checked='checked'" : null) . "", 'image');
        $doc->Radio('set_icon_panel', 'Иконка', '0', "" . ($user['set_icon_panel'] == '0' ? " checked='checked'" : null) . "", 'user');

        echo "<br /><b>" . lang('Левая иконка') . "</b><br />";
        echo "<div class='input-group'><input value='$user[icon_panel_left]' type='text' name='icon_panel_left' class='form-control'>";
        echo "<span class='input-group-addon'><i class='fa fa-$user[icon_panel_left] fa-fw'></i></span>";
        echo "</div>";
        echo "<br /><b>" . lang('Правая иконка') . "</b><br />";
        echo "<div class='input-group'><input value='$user[icon_panel_right]' type='text' name='icon_panel_right' class='form-control'>";
        echo "<span class='input-group-addon'><i class='fa fa-$user[icon_panel_right] fa-fw'></i></span>";
        echo "</div>";
        echo "<br /><a href='http://fontawesome.io/icons/'><i class='fa fa-fa fa-fw'></i> <b>" . lang('Список иконок') . "</b></a><br /><br />";

        $doc->Checkbox('set_search', 'Показывать поиск', 1, "" . ($user['set_search'] ? " checked='checked'" : null) . "", 'search');

        echo "<br />";
        $doc->Button('btn btn-success btn-sm', 'check', 'save', 'Сохранить');
        echo "</form>";

        break;

    case 'style_verh':
        $style = array(
            'ffebee', 'ffcdd2', 'ef9a9a', 'e57373', 'ef5350', 'f44336',
            'fce4ec', 'f8bbd0', 'f48fb1', 'f06292', 'ec407a', 'e91e63',
            'f3e5f5', 'e1bee7', 'ce93d8', 'ba68c8', 'ab47bc', '9c27b0',
            'ede7f6', 'd1c4e9', 'b39ddb', '9575cd', '7e57c2', '673ab7',
            'e8eaf6', 'c5cae9', '9fa8da', '7986cb', '5c6bc0', '3f51b5',
            'e3f2fd', 'bbdefb', '90caf9', '64b5f6', '42a5f5', '2196f3',
            'e1f5fe', 'b3e5fc', '81d4fa', '4fc3f7', '29b6f6', '03a9f4',
            'e0f7fa', 'b2ebf2', '80deea', '4dd0e1', '26c6da', '00bcd4',
            'e0f2f1', 'b2dfdb', '80cbc4', '4db6ac', '26a69a', '009688',
            'e8f5e9', 'c8e6c9', 'a5d6a7', '81c784', '66bb6a', '4caf50',
            'f1f8e9', 'dcedc8', 'c5e1a5', 'aed581', '9ccc65', '8bc34a',
            'f9fbe7', 'f0f4c3', 'e6ee9c', 'dce775', 'd4e157', 'cddc39',
            'fffde7', 'fff9c4', 'fff59d', 'fff176', 'ffee58', 'ffeb3b',
            'fff8e1', 'ffecb3', 'ffe082', 'ffd54f', 'ffca28', 'ffc107',
            'fff3e0', 'ffe0b2', 'ffcc80', 'ffb74d', 'ffa726', 'ff9800',
            'fbe9e7', 'ffccbc', 'ffab91', 'ff8a65', 'ff7043', 'ff5722',
            'efebe9', 'd7ccc8', 'bcaaa4', 'a1887f', '8d6e63', '795548',
            'fafafa', 'f5f5f5', 'eeeeee', 'e0e0e0', 'bdbdbd', '9e9e9e'
        );
        if (isset($_GET['ok']) && isset($_GET['color']) && $_GET['color'] < 108) {
            $st = intval($_GET['color']);
            $user['colorfp'] = $style[$st];
            $db->query("UPDATE `user` SET `colorfp` = '" . $user['colorfp'] . "', `panel` = '" . $st . "' WHERE `id` = '$user[id]' LIMIT 1");
            header('Location: ?m=style_verh');
            $_SESSION['message'] = lang('Изменения сохранены');
            exit();
        }

        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/panels.php'>" . lang('Верхняя панель') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Выберите цвет');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>" . lang('Выберите цвет вверней части') . "</div>";
        echo "<div class='list-group-item-null'>";

        for ($i = 0; $i <= 107; $i++) {
            echo "<div style='background-color: #$style[$i];'>";
            echo "<a href='panels.php?m=style_verh&amp;color=$i&amp;ok' style='display:block; text-decoration:none; padding:5px;'>";
            echo "<div style='height:19px; " . ($user['colorfp'] == $style[$i] ? 'background: url(/style/icons/img_p.png) center no-repeat;' : null) . "'></div>";
            echo "</a>";
            echo "</div>";
        }

        echo "</div>";

        break;
    case 'style_niz':
        $style = array(
            'ffebee', 'ffcdd2', 'ef9a9a', 'e57373', 'ef5350', 'f44336',
            'fce4ec', 'f8bbd0', 'f48fb1', 'f06292', 'ec407a', 'e91e63',
            'f3e5f5', 'e1bee7', 'ce93d8', 'ba68c8', 'ab47bc', '9c27b0',
            'ede7f6', 'd1c4e9', 'b39ddb', '9575cd', '7e57c2', '673ab7',
            'e8eaf6', 'c5cae9', '9fa8da', '7986cb', '5c6bc0', '3f51b5',
            'e3f2fd', 'bbdefb', '90caf9', '64b5f6', '42a5f5', '2196f3',
            'e1f5fe', 'b3e5fc', '81d4fa', '4fc3f7', '29b6f6', '03a9f4',
            'e0f7fa', 'b2ebf2', '80deea', '4dd0e1', '26c6da', '00bcd4',
            'e0f2f1', 'b2dfdb', '80cbc4', '4db6ac', '26a69a', '009688',
            'e8f5e9', 'c8e6c9', 'a5d6a7', '81c784', '66bb6a', '4caf50',
            'f1f8e9', 'dcedc8', 'c5e1a5', 'aed581', '9ccc65', '8bc34a',
            'f9fbe7', 'f0f4c3', 'e6ee9c', 'dce775', 'd4e157', 'cddc39',
            'fffde7', 'fff9c4', 'fff59d', 'fff176', 'ffee58', 'ffeb3b',
            'fff8e1', 'ffecb3', 'ffe082', 'ffd54f', 'ffca28', 'ffc107',
            'fff3e0', 'ffe0b2', 'ffcc80', 'ffb74d', 'ffa726', 'ff9800',
            'fbe9e7', 'ffccbc', 'ffab91', 'ff8a65', 'ff7043', 'ff5722',
            'efebe9', 'd7ccc8', 'bcaaa4', 'a1887f', '8d6e63', '795548',
            'fafafa', 'f5f5f5', 'eeeeee', 'e0e0e0', 'bdbdbd', '9e9e9e'
        );
        if (isset($_GET['ok']) && isset($_GET['color']) && $_GET['color'] < 108) {
            $st = intval($_GET['color']);
            $user['colorbs'] = $style[$st];
            $db->query("UPDATE `user` SET `colorbs` = '" . $user['colorbs'] . "', `panel` = '" . $st . "' WHERE `id` = '$user[id]' LIMIT 1");
            header('Location: ?m=style_niz');
            $_SESSION['message'] = lang('Изменения сохранены');
            exit();
        }

        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/panels.php'>" . lang('Верхняя панель') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Выберите цвет');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>" . lang('Выберите цвет нижней части') . "</div>";
        echo "<div class='list-group-item-null'>";

        for ($i = 0; $i <= 107; $i++) {
            echo "<div style='background-color: #$style[$i];'>";
            echo "<a href='panels.php?m=style_niz&amp;color=$i&amp;ok' style='display:block; text-decoration:none; padding:5px;'>";
            echo "<div style='height:19px; " . ($user['colorbs'] == $style[$i] ? 'background: url(/style/icons/img_p.png) center no-repeat;' : null) . "'></div>";
            echo "</a>";
            echo "</div>";
        }

        echo "</div>";

        break;
    case 'icon_color':
        $style = array(
            'ffebee', 'ffcdd2', 'ef9a9a', 'e57373', 'ef5350', 'f44336',
            'fce4ec', 'f8bbd0', 'f48fb1', 'f06292', 'ec407a', 'e91e63',
            'f3e5f5', 'e1bee7', 'ce93d8', 'ba68c8', 'ab47bc', '9c27b0',
            'ede7f6', 'd1c4e9', 'b39ddb', '9575cd', '7e57c2', '673ab7',
            'e8eaf6', 'c5cae9', '9fa8da', '7986cb', '5c6bc0', '3f51b5',
            'e3f2fd', 'bbdefb', '90caf9', '64b5f6', '42a5f5', '2196f3',
            'e1f5fe', 'b3e5fc', '81d4fa', '4fc3f7', '29b6f6', '03a9f4',
            'e0f7fa', 'b2ebf2', '80deea', '4dd0e1', '26c6da', '00bcd4',
            'e0f2f1', 'b2dfdb', '80cbc4', '4db6ac', '26a69a', '009688',
            'e8f5e9', 'c8e6c9', 'a5d6a7', '81c784', '66bb6a', '4caf50',
            'f1f8e9', 'dcedc8', 'c5e1a5', 'aed581', '9ccc65', '8bc34a',
            'f9fbe7', 'f0f4c3', 'e6ee9c', 'dce775', 'd4e157', 'cddc39',
            'fffde7', 'fff9c4', 'fff59d', 'fff176', 'ffee58', 'ffeb3b',
            'fff8e1', 'ffecb3', 'ffe082', 'ffd54f', 'ffca28', 'ffc107',
            'fff3e0', 'ffe0b2', 'ffcc80', 'ffb74d', 'ffa726', 'ff9800',
            'fbe9e7', 'ffccbc', 'ffab91', 'ff8a65', 'ff7043', 'ff5722',
            'efebe9', 'd7ccc8', 'bcaaa4', 'a1887f', '8d6e63', '795548',
            'fafafa', 'f5f5f5', 'eeeeee', 'e0e0e0', 'bdbdbd', '9e9e9e'
        );
        if (isset($_GET['ok']) && isset($_GET['color']) && $_GET['color'] < 108) {
            $st = intval($_GET['color']);
            $user['colorlp'] = $style[$st];
            $db->query("UPDATE `user` SET `colorlp` = '" . $user['colorlp'] . "', `panel` = '" . $st . "' WHERE `id` = '$user[id]' LIMIT 1");
            header('Location: ?m=icon_color');
            $_SESSION['message'] = lang('Изменения сохранены');
            exit();
        }

        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/panels.php'>" . lang('Верхняя панель') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Выберите цвет');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>" . lang('Выберите цвет иконок') . "</div>";
        echo "<div class='list-group-item-null'>";

        for ($i = 0; $i <= 107; $i++) {
            echo "<div style='background-color: #$style[$i];'>";
            echo "<a href='panels.php?m=icon_color&amp;color=$i&amp;ok' style='display:block; text-decoration:none; padding:5px;'>";
            echo "<div style='height:19px; " . ($user['colorlp'] == $style[$i] ? 'background: url(/style/icons/img_p.png) center no-repeat;' : null) . "'></div>";
            echo "</a>";
            echo "</div>";
        }

        echo "</div>";

        break;
    case 'link_color':
        $style = array(
            'ffebee', 'ffcdd2', 'ef9a9a', 'e57373', 'ef5350', 'f44336',
            'fce4ec', 'f8bbd0', 'f48fb1', 'f06292', 'ec407a', 'e91e63',
            'f3e5f5', 'e1bee7', 'ce93d8', 'ba68c8', 'ab47bc', '9c27b0',
            'ede7f6', 'd1c4e9', 'b39ddb', '9575cd', '7e57c2', '673ab7',
            'e8eaf6', 'c5cae9', '9fa8da', '7986cb', '5c6bc0', '3f51b5',
            'e3f2fd', 'bbdefb', '90caf9', '64b5f6', '42a5f5', '2196f3',
            'e1f5fe', 'b3e5fc', '81d4fa', '4fc3f7', '29b6f6', '03a9f4',
            'e0f7fa', 'b2ebf2', '80deea', '4dd0e1', '26c6da', '00bcd4',
            'e0f2f1', 'b2dfdb', '80cbc4', '4db6ac', '26a69a', '009688',
            'e8f5e9', 'c8e6c9', 'a5d6a7', '81c784', '66bb6a', '4caf50',
            'f1f8e9', 'dcedc8', 'c5e1a5', 'aed581', '9ccc65', '8bc34a',
            'f9fbe7', 'f0f4c3', 'e6ee9c', 'dce775', 'd4e157', 'cddc39',
            'fffde7', 'fff9c4', 'fff59d', 'fff176', 'ffee58', 'ffeb3b',
            'fff8e1', 'ffecb3', 'ffe082', 'ffd54f', 'ffca28', 'ffc107',
            'fff3e0', 'ffe0b2', 'ffcc80', 'ffb74d', 'ffa726', 'ff9800',
            'fbe9e7', 'ffccbc', 'ffab91', 'ff8a65', 'ff7043', 'ff5722',
            'efebe9', 'd7ccc8', 'bcaaa4', 'a1887f', '8d6e63', '795548',
            'fafafa', 'f5f5f5', 'eeeeee', 'e0e0e0', 'bdbdbd', '9e9e9e'
        );
        if (isset($_GET['ok']) && isset($_GET['color']) && $_GET['color'] < 108) {
            $st = intval($_GET['color']);
            $user['colorbp'] = $style[$st];
            $db->query("UPDATE `user` SET `colorbp` = '" . $user['colorbp'] . "', `panel` = '" . $st . "' WHERE `id` = '$user[id]' LIMIT 1");
            header('Location: ?m=link_color');
            $_SESSION['message'] = lang('Изменения сохранены');
            exit();
        }

        #Навигация
        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 "<a href='/?umenu'>" . lang('Кабинет') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/'>" . lang('Настройки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/user/settings/panels.php'>" . lang('Верхняя панель') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Выберите цвет');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>" . lang('Выберите цвет текста заголовка') . "</div>";
        echo "<div class='list-group-item-null'>";

        for ($i = 0; $i <= 107; $i++) {
            echo "<div style='background-color: #$style[$i];'>";
            echo "<a href='panels.php?m=link_color&amp;color=$i&amp;ok' style='display:block; text-decoration:none; padding:5px;'>";
            echo "<div style='height:19px; " . ($user['colorbp'] == $style[$i] ? 'background: url(/style/icons/img_p.png) center no-repeat;' : null) . "'></div>";
            echo "</a>";
            echo "</div>";
        }

        echo "</div>";

        break;
}

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