generated from Templates_CodeFirst/templateHtmlCss
Merge branch 'main' of https://codefirst.iut.uca.fr/git/lilian.breton/PHP_Project
commit
d89303c348
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Autoload{
|
||||||
|
private static ?Autoload $_instance = null;
|
||||||
|
|
||||||
|
public static function charger(){
|
||||||
|
if(self::$_instance != null){
|
||||||
|
throw new RuntimeException(sprintf("%s already start", __CLASS__));
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_instance = new self();
|
||||||
|
|
||||||
|
if(!spl_autoload_register(array(self::$_instance, '_autoload'))){
|
||||||
|
throw new RuntimeException('Could not stop autoload');
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function _autoload($class){
|
||||||
|
global $rep;
|
||||||
|
$filename = $class.'.php';
|
||||||
|
$dir = array('modeles/', 'config', 'controllers');
|
||||||
|
foreach ($dir as $d){
|
||||||
|
$file=$rep.$d.$filename;
|
||||||
|
if($file_exists($file)){
|
||||||
|
include $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,17 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$rep = __DIR__ . '/../';
|
||||||
|
|
||||||
$rep=__DIR__.'/../';
|
//$location = "Location : http://londres.uca.local/" Finir le chemin du public_html
|
||||||
|
|
||||||
$base="votre_base";
|
|
||||||
|
$base=""; //nom bdd
|
||||||
$login="";
|
$login="";
|
||||||
$mdp="";
|
$password="";
|
||||||
|
$dsn=""; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut)
|
||||||
|
|
||||||
|
|
||||||
$vues['erreur']='Vues/erreur.php';
|
$vues['erreur'] = 'Vues/erreur.php';
|
||||||
$vues['accueil']='Vues/accueil.php';
|
$vues['addList'] = 'Vues/addList.php';
|
||||||
$vues['signUp']='Vues/signUp.php';
|
$vues['addTask'] = 'Vues/addTask.php';
|
||||||
$vues['addList']='Vues/addList.php';
|
$vues['accueil'] = 'Vues/accueil.php';
|
||||||
$vues['addTask']='Vues/addTask.php';
|
$vues['accueilPrivate'] = 'Vues/accueilPrive.php';
|
||||||
$vues['accueilPrive']='Vues/accueilPrive.php';
|
$vues['connexion'] = 'Vues/connexion.php';
|
||||||
|
|
||||||
?>
|
?>
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class frontController {
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
global $rep, $vues;
|
||||||
|
session_start();
|
||||||
|
$dVueErreur = array();
|
||||||
|
$listActionUser=array('delete', 'update', 'ajouterListeU', 'supprimerListeU', 'modifierListeU', 'ajouterTacheU', 'supprimerTacheU', 'modifierTacheU'); // actions à rajouter
|
||||||
|
try{
|
||||||
|
$user = new mdlUser();
|
||||||
|
if (isset($_REQUEST['action'])){
|
||||||
|
$action = $_REQUEST['action'];
|
||||||
|
Validation::val_form($action, $dVueErreur);
|
||||||
|
}
|
||||||
|
if(in_array($action, $listActionUser)) {
|
||||||
|
new userController();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new visitorController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e){
|
||||||
|
$dVueErreur[] = "Erreur FrontController";
|
||||||
|
require $rep.$vues['erreur'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in new issue