-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
171 lines (130 loc) · 4.41 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
require('./Connection/Database.class.php');
require('./Security/ErrorRepository.class.php');
require('./Security/Security.class.php');
require('./Model/Flight.class.php');
require('./Model/User.class.php');
require('./Model/Reservation.class.php');
require('./Model/Airport.class.php');
require('./Model/ReservationFlight.class.php');
require('./Model/Promos.class.php');
require('./Model/UserFlight.class.php');
require('./Repositories/AirportRepository.class.php');
require('./Repositories/ReservationFlightRepository.class.php');
require('./Repositories/ReservationRepository.class.php');
require('./Repositories/UserRepository.class.php');
require('./Repositories/FlightRepository.class.php');
require('./Repositories/UserFlightRepository.class.php');
require('./View/FlightsListView.class.php');
require('./View/PromosListView.class.php');
require('./View/ReservationFlightsListView.class.php');
require('./View/ReservationsListView.class.php');
require('./View/brand.php');
require('./Controller/HomeController.class.php');
require('./Controller/ReservationsController.class.php');
require('./Controller/UserController.class.php');
require('./Controller/CartController.class.php');
require('./Controller/FlightsController.class.php');
require('./Controller/CalendarController.class.php');
require('./Controller/ErrorController.class.php');
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$split= explode("/", $uri);
if('/flight-test-date' != '/' . $split[1]){
include_once('./header.php');
}
if ('/accueil' === $uri || '/index.php' === $uri) {
HomeController::home();
}
elseif ('/connexion' === $uri) {
UserController::getLogin();
}
elseif ('/deconnexion' === $uri) {
Session::destroy();
UserController::getLogout();
}
elseif ('/inscription' === $uri) {
UserController::getSignup();
}
elseif ('/reservations' === '/' . $split[1]) {
Security::isloggedIn($_SESSION);
if (!preg_match("/^[0-9]+$/", $split[2])){
echo "<h4 class='text-center mt-4'>erreur</h4>";
} else {
ReservationsController::getList($split[2]);
}
}
elseif ('/reservation-validation' === '/' . $split[1]) {
if (!preg_match("/^[0-9]+$/", $split[2])){
echo "<h4 class='text-center mt-4'>erreur</h4>";
} else {
ReservationsController::getValidation($split[2]);
}
}
elseif ('/reservation-impossible' == $uri){
ReservationsController::impossible();
}
elseif ('/reservation-details' === '/' . $split[1]){
Security::isloggedIn($_SESSION);
if (!preg_match("/^[0-9]+$/", $split[2])){
echo "<h4 class='text-center mt-4'>erreur</h4>";
} else {
ReservationsController::getDetails($split[2]);
}
}
elseif ('/reservation-acceptee' == $uri){
Security::isloggedIn($_SESSION);
ReservationsController::success();
}
elseif ('/panier' === $uri) {
CartController::getList();
}
elseif ('/panier/valide' === $uri) {
Security::isloggedIn($_SESSION);
CartController::validate();
}
elseif ('/panier-suppression' === '/' . $split[1]){
Security::isloggedIn($_SESSION);
CartController::delete($split[2]);
}
elseif ('/vol-complet' == $uri){
Security::isloggedIn($_SESSION);
ReservationsController::full();
}
elseif ('/ajouter-vol' == $uri){
Security::isloggedInAdmin($_SESSION);
FlightsController::add();
}
elseif ('/vol-ajoute' == '/'.$split[1]){
Security::isloggedInAdmin($_SESSION);
if(empty($split[2]) || !is_int(intval($split[2]))){
ErrorRepository::toErrorPage();
}
FlightsController::addSuccess($split[2]);
}
elseif ('/calendrier' === $uri){
CalendarController::calendar();
}
elseif ('/date' == '/' . $split[1]){
//var_dump($split); die;
if (empty($split[2]) || empty($split[3]) || empty($split[4]) || !preg_match("/^[0-9]{1,4}$/", $split[4])){
echo "<h4 class='text-center mt-4'>erreur</h4>";
} else {
FlightsController::getDateFlights($split[2], $split[3], $split[4]);
}
}
elseif ('/flight-test-date' == '/' . $split[1]){
if (empty($split[2]) || empty($split[3]) || empty($split[4]) || !preg_match("/^[0-9]{1,4}$/", $split[4])){
echo "<h4 class='text-center mt-4'>erreur</h4>";
} else {
CalendarController::getMatchCalendar($split[2], $split[3], $split[4]);
}
}
elseif ('/erreur' === $uri){
echo "<h4 class='text-center mt-4'>erreur</h4>";
}
else {
HomeController::home();
}
if('/flight-test-date' != '/' . $split[1]){
include_once('./footer.php');
}