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

41 lines
1.3 KiB

<?php
class FrontController
{
function __construct()
{
try {
global $error, $view, $rep;
session_start();
echo "front controller\n";
// Check role permissions
if (isset($_SESSION['role'])) {
$role = $_SESSION['role'];
} else {
$role = "visitor";
}
// Check if action exists
$action = $_REQUEST['action'];
if ($role == "user") {
if ($action == NULL) {
echo "User controller1\n";
new UserController();
}
// else if (method_exists('UserModel', $action) == false) {
// $error = "Action non valide " . $action;
// require($rep . $view['erreur']);
else {
echo "User controller1\n";
new UserController();
}
} else {
echo "Visitort controller1\n";
require("View/src/pages/Main.php");
echo "Visitort controller1\n";
// new VisitorController();
}
} catch (Exception $e) {
$error = $e->getMessage();
require($rep . $view['erreur']);
}
}
}