-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
36 lines (30 loc) · 1.21 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
setlocale(LC_ALL, 'ru_RU.UTF-8');
spl_autoload_register(function ($class) {
$base = "server-side/";
if (
file_exists($filename = $base . 'classes/controllers/' . $class . '.php') ||
file_exists($filename = $base . 'classes/models/' . $class . '.php') ||
file_exists($filename = $base . 'classes/utils/' . $class . '.php') ||
file_exists($filename = $base . 'classes/' . $class . '.php')
)
include_once $filename;
});
session_start();
if (isset($_GET['controller']) && isset($_GET['action'])) {
if (!isset($_SESSION['loggined']) && $_GET['controller'] != "users")
header('Location: /interview.html#!login/');
if (isset($_SESSION['loggined']) && $_GET['action'] == "login")
header('Location: /interview.html');
$controller = $_GET['controller'] . "_controller";
$action = $_GET['action'] . "_action";
try {
(new $controller())->$action($_POST);
} catch (Exception $e) {
echo "Controller or action are not exists";
echo var_dump($e);
}
} else
header('Location: /interview.html#!start/');