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.
39 lines
1.2 KiB
39 lines
1.2 KiB
<?php
|
|
class FrontController
|
|
{
|
|
function __construct()
|
|
{
|
|
try {
|
|
global $error, $view, $rep;
|
|
session_start();
|
|
// Check role permissions
|
|
echo "FrontController1\n";
|
|
if (isset($_SESSION['role'])) {
|
|
$role = $_SESSION['role'];
|
|
} else {
|
|
$role = "visitor";
|
|
}
|
|
// Check if action exists
|
|
echo "FrontController2\n";
|
|
$action = $_REQUEST['action'];
|
|
echo $action . "\n";
|
|
if ($role == "user") {
|
|
if ($action == NULL) {
|
|
new UserController();
|
|
}
|
|
// else if (method_exists('UserModel', $action) == false) {
|
|
// $error = "Action non valide " . $action;
|
|
// require($rep . $view['erreur']);
|
|
else {
|
|
new UserController();
|
|
}
|
|
} else {
|
|
echo "FrontController3\n";
|
|
new VisitorController();
|
|
}
|
|
} catch (Exception $e) {
|
|
$error = $e->getMessage();
|
|
require($rep . $view['erreur']);
|
|
}
|
|
}
|
|
} |