-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
151 lines (135 loc) · 4.93 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
<?php
require_once "app/config/config.php";
require_once "app/controllers/HomeController.php";
require_once "app/controllers/ProductController.php";
require_once "app/controllers/FarmController.php";
require_once "app/controllers/AuthController.php";
require_once "app/controllers/PasswordController.php";
$request = $_SERVER["REQUEST_URI"];
// To use the 'match' statement you need PHP v8+
//-----------------------------------------------
match ((string) explode("?", $request)[0]) {
// HOME ROUTES
//------------
// Home (all products)
URL_SUB_FOLDER . "" => HomeController::home(),
URL_SUB_FOLDER . "/" => HomeController::home(),
URL_SUB_FOLDER . "/home" => HomeController::home(),
// My stuff
URL_SUB_FOLDER . "/myproducts" => HomeController::myproducts(),
URL_SUB_FOLDER . "/myfarms" => HomeController::myfarms(),
// PRODUCTS ROUTES
//----------------
URL_SUB_FOLDER . "/show" => ProductController::show(),
URL_SUB_FOLDER . "/edit" => ProductController::edit(),
URL_SUB_FOLDER . "/update" => ProductController::update(),
URL_SUB_FOLDER . "/new" => ProductController::new(),
URL_SUB_FOLDER . "/store" => ProductController::store(),
URL_SUB_FOLDER . "/delete" => ProductController::delete(),
// FARM ROUTES
//------------
URL_SUB_FOLDER . "/farm-edit" => FarmController::edit(),
URL_SUB_FOLDER . "/farm-update" => FarmController::update(),
URL_SUB_FOLDER . "/farm-new" => FarmController::new(),
URL_SUB_FOLDER . "/farm-store" => FarmController::store(),
URL_SUB_FOLDER . "/farm-delete" => FarmController::delete(),
// AUTH ROUTES
// -----------
URL_SUB_FOLDER . "/login" => AuthController::showLoginForm(),
URL_SUB_FOLDER . "/register" => AuthController::showRegisterForm(),
URL_SUB_FOLDER . "/logout" => AuthController::logout(),
URL_SUB_FOLDER . "/pw-forgot" => PasswordController::showForgotPasswordForm(),
URL_SUB_FOLDER . "/pw-reset" => PasswordController::showPasswordResetForm(),
URL_SUB_FOLDER . "/account" => AuthController::showAccount(),
// NOT FOUND
// ---------
default => require __DIR__ . "/app/views/404.php",
};
// If you don't have PHP v8, you can use the 'switch' statement
//-------------------------------------------------------------
// switch ($request) {
// // HOME ROUTES
// //------------
// case URL_SUB_FOLDER . "":
// HomeController::home();
// break;
// case URL_SUB_FOLDER . "/":
// HomeController::home();
// break;
// case strpos($request, "/home") == true:
// HomeController::home();
// break;
// case URL_SUB_FOLDER . "/myproducts":
// HomeController::myproducts();
// break;
// case URL_SUB_FOLDER . "/myfarms":
// HomeController::myfarms();
// break;
// // PRODUCT ROUTES
// // --------------
// // Show
// case strpos($request, "/show") == true:
// ProductController::show();
// break;
// // Edit
// case strpos($request, "/edit") == true:
// ProductController::edit();
// break;
// // Update
// case strpos($request, "/update") == true:
// ProductController::update();
// break;
// // New
// case strpos($request, "/new") == true:
// ProductController::new();
// break;
// case strpos($request, "/store") == true:
// ProductController::new();
// break;
// // Delete
// case strpos($request, "/delete") == true:
// ProductController::delete();
// break;
// // // FARM ROUTES
// // //------------
// case strpos($request, "/farm-edit") == true:
// FarmController::edit();
// break;
// case strpos($request, "/farm-update") == true:
// FarmController::update();
// break;
// case strpos($request, "/farm-new") == true:
// FarmController::new();
// break;
// case strpos($request, "/farm-store") == true:
// FarmController::store();
// break;
// case strpos($request, "/farm-delete") == true:
// FarmController::delete();
// break;
// // AUTH ROUTES
// // -----------
// case URL_SUB_FOLDER . "/login":
// AuthController::showLoginForm();
// break;
// case URL_SUB_FOLDER . "/register":
// AuthController::showRegisterForm();
// break;
// case URL_SUB_FOLDER . "/logout":
// AuthController::logout();
// break;
// case URL_SUB_FOLDER . "/pw-forgot":
// PasswordController::showForgotPasswordForm();
// break;
// case strpos($request, "/pw-reset") == true:
// PasswordController::showPasswordResetForm();
// break;
// case URL_SUB_FOLDER . "/account":
// AuthController::showAccount();
// break;
// // NOT FOUND
// default:
// http_response_code(404);
// require __DIR__ . "/app/views/404.php";
// break;
// }