-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
42 lines (31 loc) · 1.04 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
37
38
39
40
41
42
<?php
session_start();
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
$route = explode('/', $_GET['__route']);
$controller = $route[0];
$method = $route[1];
try {
//Если не авторизован то показываем форму
if(\App\Classes\Auth::checkAuth() == false AND $controller != 'LogController') {
$controller='LogController';
$method='actionAuthForm';
}
//Если все ок. можно показать остальные страницы.
if (true == empty($controller)) {
$controller = 'App\\Controllers\\Main';
$method = 'actionShow';
}
else {
$controller = 'App\\Controllers\\' . $controller;
}
if (false == method_exists($controller, $method)) {
throw new Exception('<br>index:<br>Метод ' . $method . ' класса ' . $controller . ' ненайден.');
}
$ctrl = new $controller();
$ctrl->$method();
}
catch (Exception $e)
{
echo $e->getMessage();
}