-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.php
33 lines (29 loc) · 913 Bytes
/
routes.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
<?php
function call($action, $controller) {
$objController = new $controller;
global $authorized;
if ($authorized) {
$objController->{$action}()->afficher();
} else {
http_response_code(401);
echo "<h1>401: Not Authorized</h1>";
}
}
$controllers = glob("Controllers/*.php");
foreach ($controllers as &$controllerTempo){
$controllerTempo = substr(substr($controllerTempo, 0, -4),12);
}
unset($controllerTempo);
$controller .= 'Controller';
if (in_array($controller, $controllers)) {
require_once('Controllers/' . $controller .'.php');
if (in_array($action, get_class_methods($controller))) {
call($action, $controller);
} else {
require_once('Controllers/autresController.php');
call('erreur', 'autresController');
}
} else {
require_once('Controllers/autresController.php');
call( 'erreur', 'autresController');
}