-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
35 lines (31 loc) · 937 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// On va utiliser la session
session_start();
include("controllers/controller_parent.php");
/**** Dispatcher ****/
$strAction = $_GET['action'] ?? 'home';
$strCtrl = $_GET['ctrl'] ?? 'utrip';
$strFileName = "controllers/" . $strCtrl . "_controller.php";
$bool404 = false;
// Test si le fichier existe
if (file_exists($strFileName)) {
include($strFileName);
$strClassName = ucfirst($strCtrl) . "Ctrl";
// Test si le nom de la classe existe
if (class_exists($strClassName)) {
$objCtrl = new $strClassName();
// Test si la méthode existe dans l'objet controller
if (method_exists($objCtrl, $strAction)) {
$objCtrl->$strAction();
} else {
$bool404 = true;
}
} else {
$bool404 = true;
}
} else {
$bool404 = true;
}
if ($bool404) {
header('Location:index.php?action=show404&ctrl=error');
}