modification du modele de student et de son controller pour rendre certaines methodes fonctionnel, début de modification du frontController pour rendre les connexion plus securisé

php
Patrick BRUGIERE 1 year ago
parent 899071b307
commit dbb85c2c68

@ -8,14 +8,15 @@ use model\MdlStudent;
class FrontController
{
public function __construct() {
public function __construct()
{
global $twig;
global $altorouterPath;
session_start();
//var_dump($_SESSION['login']);
//var_dump($_SESSION['roles']);
var_dump($_SESSION['login']);
var_dump($_SESSION['roles']);
try {
$router = new \AltoRouter();
@ -23,46 +24,58 @@ class FrontController
$router->map('GET', '/', 'AppController');
$router->map('GET|POST', '/[a:action]?', 'NULL');
$router->map( 'GET|POST', '/admin/[i:id]/[a:action]?', 'AdminController');
$router->map( 'GET|POST', '/teacher/[i:id]/[a:action]?', 'TeacherController');
$router->map( 'GET|POST', '/student/[i:id]/[a:action]?', 'StudentController');
$router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'AdminController');
$router->map('GET|POST', '/teacher/[i:id]/[a:action]?', 'TeacherController');
$router->map('GET|POST', '/student/[i:id]/[a:action]?', 'StudentController');
$match = $router->match();
if (!$match) { throw new Exception("Erreur 404");}
$controller = $match['target'] ?? null;
$action = Validation::val_action($match['params']['action'] ?? null);
switch ($action) {
case null:
$this->home();
break;
case 'login':
$this->login();
break;
case 'confirmLogin':
$this->confirmLogin();
break;
default :
$controller = '\\controller\\' . $controller;
$controller = new $controller;
if (is_callable(array($controller, $action)))
call_user_func_array(array($controller, $action), array($match['params']));
break;
if (!$match) {
throw new Exception("Erreur 404");
}
if ($match) {
//list($controller, $action) = explode('#', $match['target'] );
$controller = $match['target'] ?? null;
$action = Validation::val_action($match['params']['action'] ?? null);
$id = $match['params']['id'] ?? null;
print 'user Id received ' . $id . '<br>';
print 'controleur appelé ' . $controller . '<br>';
print $action . '<br>';
print $id . '<br>';
switch ($action) {
case null:
$this->home();
break;
case 'login':
$this->login();
break;
case 'confirmLogin':
$this->confirmLogin();
break;
default :
$controller = '\\controller\\' . $controller;
$controller = new $controller;
if (is_callable(array($controller, $action)))
call_user_func_array(array($controller, $action), array($match['params']));
break;
}
}
}
catch (Exception $e) {
$dVueEreur[] = $e->getMessage();
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
}
catch
(Exception $e) {
$dVueEreur[] = $e->getMessage();
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
}
}
public function home(): void {
global $twig;
echo $twig->render('home.html');

@ -12,8 +12,8 @@ class StudentController
{
global $twig;
$mdl = new MdlStudent();
$student = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]);
$voc = $mdl->getAll();
echo $twig->render('manageVocabListView.html', ['vocabularies' => $voc]);
}
@ -26,12 +26,13 @@ class StudentController
}
public function getByName($name): void
public function getByName(): void
{
global $twig;
$mdl = new MdlStudent();
$name = Validation::filter_str_simple($_GET['listName'] ?? null);
$vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]);
echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]);
}
public function showAccountInfos(): void {

@ -4,6 +4,8 @@ namespace model;
use gateway\UserGateway;
use gateway\VocabularyGateway;
use gateway\VocabularyListGateway;
class MdlStudent extends AbsModel
{
@ -14,7 +16,7 @@ class MdlStudent extends AbsModel
public function getAll():array{
global $twig;
$gtw = new VocabularyGateway();
$gtw = new VocabularyListGateway();
return $gtw->findAll();
/*
foreach ($data as $row){
@ -25,7 +27,7 @@ class MdlStudent extends AbsModel
}
public function getVocabByName(string $name):array{
$gtw = new VocabularyGateway();
$gtw = new VocabularyListGateway();
$res = $gtw->findByName($name);
return $res;
}

Loading…
Cancel
Save