parent
b7a820f49d
commit
7d5ece1532
@ -1,3 +1,11 @@
|
||||
#RewriteEngine On
|
||||
#
|
||||
#RewriteCond %{REQUEST_FILENAME} !-f
|
||||
#RewriteCond %{REQUEST_FILENAME} !-d
|
||||
#RewriteRule ^(.*)$ index.php/$1 [L]
|
||||
|
||||
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule . index.php [L]
|
||||
|
||||
|
@ -1,112 +1,103 @@
|
||||
<?php
|
||||
namespace App\controleur;
|
||||
|
||||
|
||||
namespace App\controleur;
|
||||
|
||||
use App\router\AltoRouter;
|
||||
use App\metier\Alumni;
|
||||
|
||||
use App\controleur\UtilisateurControleur;
|
||||
use App\controleur\MembreControleur;
|
||||
use App\controleur\AdminControleur;
|
||||
|
||||
class FrontControleur
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
||||
global $twig;
|
||||
session_start();
|
||||
|
||||
$router = new AltoRouter();
|
||||
|
||||
$router->setBasePath('/php');
|
||||
$router->setBasePath('/SAE_2A_FA-Reseau_ALICA/php');
|
||||
|
||||
$router->map('GET','/','UtilisateurControleur');
|
||||
$router->map('GET', '/', 'UtilisateurControleur');
|
||||
|
||||
$router->map('GET|POST','/user/[i:id]/[a:action]?','MembreControleur');
|
||||
$router->map('GET','/[a:action]?','UtilisateurControleur');
|
||||
|
||||
$router->map('GET|POST','/admin/[i:id]/[a:action]?','AdminControleur');
|
||||
$router->map('POST','/[a:action]?','UtilisateurControleur');
|
||||
|
||||
$id = 0;
|
||||
$router->map('GET', '/[a:action]?', 'UtilisateurControleur');
|
||||
|
||||
$router->map('GET|POST', '/user/[i:id]/[a:action]?', 'MembreControleur');
|
||||
|
||||
$router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'AdminControleur');
|
||||
|
||||
$id = 0;
|
||||
|
||||
$match = $router->match();
|
||||
|
||||
$action = array();
|
||||
|
||||
$id=array();
|
||||
$id = array();
|
||||
|
||||
$twig->render("accueil.html",[]);
|
||||
|
||||
if(!$match)
|
||||
{
|
||||
if (!$match) {
|
||||
|
||||
$dVueErreur[] = "Error 404 Page not found";
|
||||
global $twig;
|
||||
$dVueErreur[] = "Error 404 Page not found";
|
||||
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
|
||||
if($match)
|
||||
{
|
||||
if ($match) {
|
||||
|
||||
$controller = $match['target'] ?? NULL;
|
||||
$action = $match['params']['actions'] ?? NULL;
|
||||
$action = $match['params']['action'] ?? NULL;
|
||||
$id = $match['params']['id'] ?? NULL;
|
||||
|
||||
}
|
||||
try {
|
||||
if ($controller == "MembreControleur") {
|
||||
if ($_SESSION["utilisateur"] != NULL) {
|
||||
echo 'not implemented';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
$controller = new $controller;
|
||||
}
|
||||
catch (Error $error)
|
||||
{
|
||||
$dVueErreur = ['Erreur : Action inconnue'];
|
||||
$twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
if ($controller == "AdminControleur") {
|
||||
$Alumni = $_SESSION["utilisateur"];
|
||||
if ($Alumni->getRole() != "Admin") {
|
||||
$dVueErreur = ["Erreur : Vous n'avez pas les privileges pour cette action"];
|
||||
|
||||
}
|
||||
global $twig;
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$namespace = 'App\\Controleur\\';
|
||||
$controller = $namespace . $controller;
|
||||
$controller = new $controller();
|
||||
}
|
||||
|
||||
if (is_callable(array($controller, $action))) {
|
||||
call_user_func(array($controller, $action), $match['params']);
|
||||
} else {
|
||||
|
||||
$dVueErreur = ['Erreur : Action inconnue'];
|
||||
|
||||
echo $twig->render('accueil.html', ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
|
||||
} catch (Error $error) {
|
||||
$dVueErreur = ['Erreur : Action inconnue'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*class FrontControleur
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $twig;
|
||||
session_start();
|
||||
$dVueErreur = [];
|
||||
$actions = array(
|
||||
"Admin" => [
|
||||
"supprimerCompte", "consulterSignalement","supprimerOffre"
|
||||
],
|
||||
"Moderateur" => [
|
||||
//TODO
|
||||
],
|
||||
"Membre" => [
|
||||
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler",
|
||||
],
|
||||
"Utilisateur" => [
|
||||
|
||||
"connexion", "inscription", "accueil", "consulterProfilLimite", "publierOffre", "listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement"
|
||||
]
|
||||
);
|
||||
|
||||
$action = \App\config\Validation::nettoyerString($_GET["action"] ?? "");
|
||||
if(in_array($action,$actions['Admin'])) {
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"]!="admin") {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
} else{
|
||||
new AdminControleur();
|
||||
}
|
||||
}
|
||||
else if(in_array($action,$actions['Moderateur'])) {
|
||||
if (!isset($_SESSION["role"]) || ($_SESSION["role"]!="moderateur" && $_SESSION["role"]!="admin")) {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
} else{
|
||||
new ModerateurControleur();
|
||||
}
|
||||
}
|
||||
else if(in_array($action,$actions['Membre'])) {
|
||||
if (!isset($_SESSION["utilisateur"])) {
|
||||
$dVueErreur[] = 'Veuillez vous connecter';
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
} else{
|
||||
new MembreControleur();
|
||||
}
|
||||
}else{
|
||||
new UtilisateurControleur();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Offre {{ offre.getNom() }}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue