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.
72 lines
2.2 KiB
72 lines
2.2 KiB
<?php
|
|
|
|
class ControllerAdministrator
|
|
{
|
|
|
|
function __construct()
|
|
{
|
|
global $dsn, $user, $pass, $vues;
|
|
session_start();
|
|
try {
|
|
$action = "";
|
|
if (isset($_REQUEST['action'])) {
|
|
$action = $_REQUEST['action'];
|
|
}
|
|
|
|
switch ($action) {
|
|
case "goToAdministratorConnexion":
|
|
require($vues['AdministratorConnexion']);
|
|
break;
|
|
case "goToAdministration":
|
|
require($vues['Administration']);
|
|
break;
|
|
case "verifValidation":
|
|
$this->validationConnexion();
|
|
break;
|
|
case "quitterAdministrator":
|
|
$Administrator->deconnexion();
|
|
header("location: index.php");
|
|
break;
|
|
case "AjouterQuestion":
|
|
case "SupprimerQuestion":
|
|
case "ModifierQuestion":
|
|
case "AjouterReponse":
|
|
case "SupprimerReponse":
|
|
case "ModifierReponse":
|
|
case "AjouterAdmin":
|
|
case "SupprimerAdmin":
|
|
default:
|
|
break;
|
|
}
|
|
} catch (PDOException $e) {
|
|
// $dataVueEreur[] = "Erreur inattendue!!! ";
|
|
// require(__DIR__.'/../vues/erreur.php');
|
|
} catch (Exception $e2) {
|
|
// $dataVueEreur[] = "Erreur inattendue!!! ";
|
|
// require ($rep.$vues['erreur']);
|
|
}
|
|
}
|
|
|
|
function validationConnexion()
|
|
{
|
|
global $vues;
|
|
$validation = new Validation();
|
|
$error = [];
|
|
$validation->val_form($_POST['name'], $_POST['password'], $error);
|
|
foreach ($error as $key) {
|
|
print($key);
|
|
}
|
|
|
|
if (empty($error)) {
|
|
$validation = $Administrator->connection($_POST['name'], $_POST['password']);
|
|
if (!empty($validation)) {
|
|
header("location: index.php?action=goToAdministratoristration");
|
|
} else {
|
|
header("location: index.php?action=goToAdministratorConnexion");
|
|
}
|
|
} else {
|
|
header("location: index.php?action=goToAdministratorConnexion");
|
|
}
|
|
}
|
|
}
|