-
Notifications
You must be signed in to change notification settings - Fork 0
/
Routes.php
171 lines (145 loc) · 4.04 KB
/
Routes.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
169
170
171
<?php
// ROUTES DECLARATIONS
Route::set('index.php', function () {
Home::CreateView();
});
Route::set('shop', function () {
Shop::CreateView();
});
Route::set('product-detail', function () {
ProductDetail::CreateView();
});
Route::set('custom', function () {
Custom::CreateView();
});
Route::set('register', function () {
Register::CreateView();
});
Route::set('events', function () {
Events::CreateView();
});
Route::set('contact', function () {
Contact::CreateView();
});
Route::set('login', function () {
Login::CreateView();
});
Route::set('logout', function () {
Logout::loggingOut();
});
Route::set('admin', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
Admin::CreateView();
}
});
Route::set('cart', function () {
Cart::CreateView();
});
Route::set('validation', function () {
Validation::CreateView();
});
// ADMIN PAGES
Route::set('admin-products', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminProducts::CreateView();
}
});
Route::set('admin-product-manager', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminProductManager::CreateView();
}
});
Route::set('admin-product-edit', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminProductEditor::CreateView();
}
});
Route::set('admin-orders', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminOrders::CreateView();
}
});
Route::set('admin-users', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminUsers::CreateView();
}
});
Route::set('admin-events', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminEvents::CreateView();
}
});
Route::set('admin-event-manager', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminEventManager::CreateView();
}
});
Route::set('admin-event-edit', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
AdminEventEditor::CreateView();
}
});
// VIEW-LESS URL
//fictive route to generate the list of dice sorted by color
Route::set('ajax-color', function () {
$ajax = new Shop();
$ajax->sortByColor($_GET['colorName']);
});
// fictive route to delete a product from the admin-page
Route::set('delete-product', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
$delete = new AdminProducts();
$delete->deleteArticle($_GET['id']);
}
});
// fictive route to delete an event from the admin-page
Route::set('delete-event', function () {
if (!isset($_SESSION['user']) || $_SESSION['user']['rank'] != 'Admin') {
Login::CreateView();
} else {
$delete = new AdminEvents();
$delete->deleteEvent($_GET['id']);
}
});
// fictive route to empty the shopping cart
Route::set(
'empty-cart',
function () {
$cart = new Cart();
$cart->emptyCart();
}
);
// fictive route to signup for an event
Route::set('event-participate', function () {
if (empty($_SESSION['user'])) {
Login::CreateView();
} else {
try {
$event = new Events;
$event->registerToEvent($_GET['id']);
} catch (Exception $e) {
header("Refresh: 5;URL=./events");
echo "Vous êtes déjà inscrit à cet événement. Vous allez être automatiquement redirigé vers le site.";
}
}
});