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.
Scripted/WEB/Controller/FrontController.php

39 lines
1.2 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 {
$_REQUEST['action'] = $action;
new VisitorController();
}
} catch (Exception $e) {
$error = $e->getMessage();
require($rep . $view['erreur']);
}
}
}