You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.7 KiB
50 lines
1.7 KiB
<?php
|
|
class FrontController
|
|
{
|
|
function __construct()
|
|
{
|
|
try {
|
|
global $error, $view, $rep;
|
|
$nettoyage = new Nettoyage();
|
|
session_start();
|
|
// Check role permissions
|
|
if (isset($_SESSION['role'])) {
|
|
$role = $nettoyage->clean($_SESSION['role']);
|
|
} else {
|
|
$role = "visitor";
|
|
}
|
|
// Check if action exists
|
|
$action = $nettoyage->clean($_REQUEST['action']);
|
|
if ($role == "user") {
|
|
if ($action == NULL) {
|
|
$_REQUEST['action'] = $action;
|
|
new UserController();
|
|
} else if (method_exists('UserController', $action) == false) {
|
|
$error = "Action non valide " . $action;
|
|
require($rep . $view['erreur']);
|
|
} else {
|
|
$_REQUEST['action'] = $action;
|
|
new UserController();
|
|
}
|
|
}
|
|
else if ($role == "admin") {
|
|
if ($action == NULL) {
|
|
$_REQUEST['action'] = $action;
|
|
new AdminController();
|
|
} else if (method_exists('AdminController', $action) == false) {
|
|
$error = "Action non valide " . $action;
|
|
require($rep . $view['erreur']);
|
|
} else {
|
|
$_REQUEST['action'] = $action;
|
|
new AdminController();
|
|
}
|
|
} else {
|
|
$_REQUEST['action'] = $action;
|
|
new VisitorController();
|
|
}
|
|
} catch (Exception $e) {
|
|
$error = $e->getMessage();
|
|
require($rep . $view['erreur']);
|
|
}
|
|
}
|
|
} |