-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
97 lines (78 loc) · 2.73 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// Definisci la costante per la root del sito
if (getenv('BASE_URL')) {
//Se si usa docker
define('ROOT', getenv('BASE_URL'));
} else {
define('ROOT', "http://" . $_SERVER['SERVER_NAME'] . "/BackendTemplateCinema");
}
session_start();
require_once __DIR__ . '/vendor/autoload.php';
//INCLUDE DB AND CONTROLLER CLASSES
use App\Controllers\MovieController;
use App\Controllers\HallController;
use App\Controllers\HallImagesController;
use App\Controllers\UserController;
use App\Controllers\ShowController;
use App\Controllers\ShowSeatsController;
use App\Controllers\CartController;
use App\Controllers\BillController;
// INIT CONTROLLERS
$movieController = new MovieController();
$hallController = new HallController();
$hallImagesController = new HallImagesController();
$userController = new UserController();
$showSeatsController = new ShowSeatsController();
$showController = new ShowController();
$cartController = new CartController();
$billController = new BillController();
//INIT Sendmailer
use App\Core\SendMailer;
$sendMailer = new SendMailer();
// Variable for route managing
$page = $_GET['page'] ?? 'home';
$subPage = $_GET['subPage'] ?? 'index';
// Mappa la route vuota o 'home' alla vista home.php
if ($page === '' || $page === 'home') {
$page = 'home';
}
// Include l'header
if ($page === 'admin') {
require_once "includes/admin_header.php";
} else {
require_once "includes/header.php";
// Contenuto principale
echo '<main class="">';
}
switch ($page) {
case 'signin':
case 'signup':
case 'logout':
// Pagine di autenticazione
include_once __DIR__ . "/resources/Views/auth/" . $page . ".php";
break;
case 'admin':
// Pagine di amministrazione
include_once __DIR__ . "/resources/Views/" . $page . "/" . $subPage . ".php";
break;
case 'home':
include_once __DIR__ . "/resources/Views/home.php";
break;
default:
// Routing generale
if (file_exists(__DIR__ . "/resources/Views/" . $page . ".php")) {
include_once __DIR__ . "/resources/Views/" . $page . ".php";
} else {
include_once __DIR__ . "/resources/Views/error/404.php";
}
break;
}
// Include il footer
if ($page === 'admin') {
require_once "includes/admin_footer.php";
} else {
require_once "includes/footer.php";
// Fine Contenuto principale
echo '</main>';
}
?>