Example #1
0
<?php

$host = explode('?', $_SERVER['REQUEST_URI'])[0];
$uri = explode('/', $host)[2];
// Проверка на уровень доступа
if (isset($_SESSION["event_admin"]) && isset($_SESSION["event_pass"])) {
    $access_granted = true;
} else {
    $access_granted = false;
}
if ($uri == '' or $uri == 'index.php') {
    // Главная страница
    $control = new EventsController();
    $response = $control->list_action();
} elseif ($uri == 'pupils' and isset($_REQUEST["event"])) {
    if (empty($_REQUEST['order_by'])) {
        $_REQUEST['order_by'] = 'id';
    }
    // Список зарег. пользователей
    $control = new UsersController();
    $response = $control->plist_action($_REQUEST["event"], $_REQUEST['order_by']);
} elseif ($uri == 'login') {
    // Форма входа
    $control = new UsersController();
    $response = $control->login_action();
} elseif ($uri == 'logout') {
    // Выход
    $control = new UsersController();
    $response = $control->logout_action();
} elseif ($uri == 'admin' and $access_granted) {
    // Административная часть