<?php

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

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

access('adm_panel_show', null, '/index.php?' . SID);
only_reg();
$set['title'] = lang('Тикеты');

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

aut();

if (isset($_GET['help'])) {
    $support = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `id` = '" . intval($_GET['help']) . "'");
    if ($support['count']) {
        $help = $db->get_row($db->query("SELECT * FROM `support` WHERE `id` = '" . intval($_GET['help']) . "' LIMIT 1"));
    }
    if (isset($_GET['close']) && $help['read'] != 2) {
        $db->query("UPDATE `support` SET `read` = '2' WHERE `id` = '$help[id]';");
        header("Location: ?help=$help[id]" . SID);
    } elseif (isset($_GET['open']) && $help['read'] == 2) {
        $db->query("UPDATE `support` SET `read` = '1' WHERE `id` = '$help[id]';");
        header("Location: ?help=$help[id]" . SID);
    }

    if (isset($_POST['msg'])) {
        $msg = $_POST['msg'];
        $mat = antimat($msg);
        if ($mat) {
            $err[] = lang("В тексте сообщения обнаружен мат") . ": $mat";
        }
        if (utf8_strlen($msg) > 1024) {
            $err[] = lang('Сообщение слишком длинное');
        } elseif (utf8_strlen($msg) < 2) {
            $err[] = lang('Короткое сообщение');
        }
        $k = $db->super_query("SELECT COUNT(*) as count FROM `support_msg` WHERE `id_t` = '" . intval($_GET['help']) . "' AND `id_user` = '$user[id]' AND `msg` = '" . $db->safesql($msg) . "' LIMIT 1");
        if ($k['count'] != 0) {
            $err = lang('Ваше сообщение повторяет предыдущее');
        }
        if (!isset($err)) {
            $db->query("INSERT INTO `support_msg` (`id_user`, `time`, `msg`, `id_t`) values('$user[id]', '$time', '" . $db->safesql($msg) . "', '" . intval($_GET['help']) . "')");

            $msgp = "Вам ответили в тикете: [url=/user/help.php?help=$help[id]]$help[name][/url]";
            if ($help['id_user'] != $user['id']) {
                $db->query("INSERT INTO `notification` (`id_user`, `id_kont`, `id_img`, `msg`, `time`) values('0', '" . $help['id_user'] . "', '10', '$msgp', '" . $time . "')");
            }

            $db->query("UPDATE `support` SET `read` = '1' WHERE `id` = '$help[id]';");
            $_SESSION['message'] = lang('Сообщение успешно добавлено');

            header("Location: " . DIR_PANEL . "help.php?help=$help[id]");
            exit;
        }
    }
    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 "<a href='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo toOutput($help['name']);
    echo "</small></div><br />";

    echo '<div class="list-group-item-null list-group-item-grey">';
    echo "<i class='fa fa-support fa-fw'></i> " . toOutput($help['name']);
    echo " <small style='color: grey;'>" . date::times($help['time']) . "</small>\n";
    echo "</div>";

    echo '<div class="list-group-item-null">';
    echo toOutput($help['msg']) . '<hr>';
    $avtor = $db->get_row($db->query("SELECT * FROM `user` WHERE `id` = '$help[id_user]' LIMIT 1"));
    echo lang('Автор') . ": ";
    user($avtor['id']) . "<br />";

    echo "<span style='float: right;'>";

    if ($help['read'] != 2) {
        echo "<a href='?help=$help[id]&amp;close'><i class='fa fa-lock fa-fw'></i> " . lang('Закрыть') . "</a>";
    } elseif ($help['read'] == 2) {
        echo "<a href='?help=$help[id]&amp;open'><i class='fa fa-unlock fa-fw'></i> " . lang('Открыть') . "</a>";
    }
    echo "</span>";
    echo "</div>";

    if ($help['read'] == 2) {
        echo '<div class="list-group-item-null list-group-item-warning"><i class="fa fa-lock fa-fw"></i> ' . lang('Тикет закрыт') . '</div>';
    }

    echo "<div class='list-group-item-null list-group-item-grey'><i class='fa fa-comments-o fa-fw'></i> " . lang('Обсуждения') . "</div>";

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support_msg` WHERE `id_t` = '" . intval($_GET['help']) . "'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];
    $q = $db->query("SELECT * FROM `support_msg` WHERE `id_t` = '" . intval($_GET['help']) . "' ORDER BY `id` ASC LIMIT $start, $set[p_str]");

    if ($k_post == 0) {
        $doc->NoResult();
    }
    while ($post = $db->get_row($q)) {
        $ank = get_user($post['id_user']);

        echo "<table class='list-group-item-null'><tr><td class='icon14'>";
        if ($help['id_user'] == $post['id_user']) {
            echo avatar($ank['id'], '40', 'border-radius: 1px;');
        } else {
            echo "<img src='/style/icons/support.png' style='width: 40px;height: 40px;border-radius: 1px;' class='avatar'/>";
        }
        echo "</td><td class='null'>";
        echo "<span style = 'float:right;color: grey;'><small class='hint--left' data-hint='" . date::time($post['time']) . "'>" . date::timek($post['time']) . "</small></span>";

        if ($help['id_user'] == $post['id_user']) {
            echo user($ank['id']) . " <br /> ";
        } else {
            echo "<b style='color: green;'><i class='fa fa-support fa-fw'></i> " . lang('Техническая поддержка') . "</b> <br /> ";
        }
        echo toOutput($post['msg']);

        echo "</div>";
        echo "</td></tr></table><div class='hr'></div>";
    }

    if ($k_page > 1) {
        str("?help=" . intval($_GET['help']) . '&amp;', $k_page, $page);
    } // Вывод страниц

    if ($help['read'] != 2) {
        echo "<form method=\"post\" name='message' class='list-group-item-null' action=\"?help=" . intval($_GET['help']) . "&amp;page=$page\">\n";
        echo "" . lang('Сообщение') . ":<br />\n<textarea name=\"msg\" class='form-control'></textarea><br />\n";

        $doc->Button('btn btn-success btn-sm', null, 'check', 'Отправить');
        echo "</form>\n";
    }

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

if (isset($_GET['razd']) && $_GET['razd'] == 0) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Ошибка или уязвимость на сайте');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read`='$read' AND `razdel`='0'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='0' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=0&close&", $k_page, $page);
        }
        echo "<a href='?razd=0' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=0&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=0&akt&", $k_page, $page);
        }
        echo "<a href='?razd=0' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=0&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=0&", $k_page, $page);
        }
        echo "<a href='?razd=0&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=0&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 1) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Не могу разобраться');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read` = '$read' AND `razdel`='1'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='1' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=1&close&", $k_page, $page);
        }
        echo "<a href='?razd=1' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=1&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=1&akt&", $k_page, $page);
        }
        echo "<a href='?razd=1' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=1&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=1&", $k_page, $page);
        }
        echo "<a href='?razd=1&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=1&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 2) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Не работает');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read`='$read' AND `razdel`='2'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='2' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=2&close&", $k_page, $page);
        }
        echo "<a href='?razd=2' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=2&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=2&akt&", $k_page, $page);
        }
        echo "<a href='?razd=2' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=2&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=2&", $k_page, $page);
        }
        echo "<a href='?razd=2&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=2&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 3) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Меня оскорбляют');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read`='$read' AND `razdel`='3'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='3' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=3&close&", $k_page, $page);
        }
        echo "<a href='?razd=3' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=3&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=3&akt&", $k_page, $page);
        }
        echo "<a href='?razd=3' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=3&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=3&", $k_page, $page);
        }
        echo "<a href='?razd=3&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=3&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 4) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Выложены запрещенные файлы');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read`='$read' AND `razdel`='4'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='4' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=4&close&", $k_page, $page);
        }
        echo "<a href='?razd=4' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=4&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=4&akt&", $k_page, $page);
        }
        echo "<a href='?razd=4' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=4&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=4&", $k_page, $page);
        }
        echo "<a href='?razd=4&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=4&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 5) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Прошу обратить внимание');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read` = '$read' AND `razdel`='5'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='5' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=5&close&", $k_page, $page);
        }
        echo "<a href='?razd=5' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=5&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=5&akt&", $k_page, $page);
        }
        echo "<a href='?razd=5' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=5&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=5&", $k_page, $page);
        }
        echo "<a href='?razd=5&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=5&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    exit;
} elseif (isset($_GET['razd']) && $_GET['razd'] == 6) {
    if (isset($_GET['close'])) {
        $read = 2;
    } elseif (isset($_GET['akt'])) {
        $read = 1;
    } else {
        $read = 0;
    }

    #Навигация
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_PANEL . "help.php'>" . lang('Тикеты') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Другое');
    echo "</small></div><br />";

    if (isset($_GET['close'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Закрытые тикеты') . "</center></div>";
    } elseif (isset($_GET['akt'])) {
        echo "<div class='list-group-item-null'><center>" . lang('Активные тикеты') . "</center></div>";
    } else {
        echo "<div class='list-group-item-null'><center>" . lang('Новые тикеты') . "</center></div>";
    }

    $k_post = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `read` = '$read' AND `razdel`='6'");
    $k_post = $k_post['count'];
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];

    if ($k_post == 0) {
        $doc->NoResult();
    }
    $q = $db->query("SELECT * FROM `support` WHERE `read`='$read' AND `razdel`='6' ORDER BY id DESC LIMIT $start, $set[p_str]");
    while ($post = $db->get_array($q)) {
        echo "<div class='list-group-item-null'>\n";
        echo "<span style='float: right;color: grey;'>" . date::timek($post['time']) . "</span>\n";
        echo "<a href='?help=$post[id]'><i class='fa fa-support fa-fw'></i> " . toOutput($post['name']) . "</a><br />\n";
        echo "</div>\n";
        echo "<div class='hr'></div>";
    }

    if (isset($_GET['close'])) {
        if ($k_page > 1) {
            str("?razd=6&close&", $k_page, $page);
        }
        echo "<a href='?razd=6' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=6&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    } elseif (isset($_GET['akt'])) {
        if ($k_page > 1) {
            str("?razd=6&akt&", $k_page, $page);
        }
        echo "<a href='?razd=6' class='list-group-item-null list-group-item-grey'><i class='fa fa-history fa-fw'></i> " . lang('Новые тикеты') . "</a>\n";
        echo "<a href='?razd=6&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
    } else {
        if ($k_page > 1) {
            str("?razd=6&", $k_page, $page);
        }
        echo "<a href='?razd=6&close' class='list-group-item-null list-group-item-grey'><i class='fa fa-lock fa-fw'></i> " . lang('Закрытые тикеты') . "</a>\n";
        echo "<a href='?razd=6&akt' class='list-group-item-null list-group-item-grey'><i class='fa fa-unlock fa-fw'></i> " . lang('Активные тикеты') . "</a>\n";
    }

    include_once H . 'sys/inc/tfoot.php';
    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='" . DIR_PANEL . "'>" . lang('Панель управления') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Тикеты');
echo "</small></div><br />";

$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '0'");
$r0 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '0' AND `read`='0'");
$ra0 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '1'");
$r1 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '1' AND `read`='0'");
$ra1 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '2'");
$r2 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '2' AND `read`='0'");
$ra2 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '3'");
$r3 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '3' AND `read`='0'");
$ra3 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '4'");
$r4 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '4' AND `read`='0'");
$ra4 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '5'");
$r5 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '5' AND `read`='0'");
$ra5 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '6'");
$r6 = $r['count'];
$r = $db->super_query("SELECT COUNT(*) as count FROM `support` WHERE `razdel` = '6' AND `read`='0'");
$ra6 = $r['count'];

$doc->Link('list-group-item-null list-group-item-grey', '?razd=0', 'folder-o', "" . lang('Ошибка или уязвимость на сайте') . " <span class='tag tag-info right'>$r0 " . (($ra0 != 0) ? " +$ra0" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=1', 'folder-o', "" . lang('Не могу разобраться') . " <span class='tag tag-info right'>$r1 " . (($ra1 != 0) ? " +$ra1" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=2', 'folder-o', "" . lang('Не работает') . " <span class='tag tag-info right'>$r2 " . (($ra2 != 0) ? " +$ra2" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=3', 'folder-o', "" . lang('Меня оскорбляют') . " <span class='tag tag-info right'>$r3 " . (($ra3 != 0) ? " +$ra3" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=4', 'folder-o', "" . lang('Выложены запрещенные файлы') . " <span class='tag tag-info right'>$r4 " . (($ra4 != 0) ? " +$ra4" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=5', 'folder-o', "" . lang('Прошу обратить внимание') . " <span class='tag tag-info right'>$r5 " . (($ra5 != 0) ? " +$ra5" : "") . "</span>");
$doc->Link('list-group-item-null list-group-item-grey', '?razd=6', 'folder-o', "" . lang('Другое') . " <span class='tag tag-info right'>$r6 " . (($ra6 != 0) ? " +$ra6" : "") . "</span>");

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