-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
133 lines (125 loc) · 5.02 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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="/img/logo.png">
<title>Need For Speed - WikiWorld</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="https://assets.quentium.fr/FA/pro.min.css">
</head>
<body>
<?php
// All include (always same page)
include('router/route.php');
include('include/display.php');
include('include/sql.php');
// List of menu elements
$menuList = ['Accueil', 'Voitures', 'Constructeurs', 'Favoris', 'Joueurs'];
$menuLink = ['/', '/cars', '/constructors', '/favorites', '/players'];
$menuIcon = ['home-lg-alt', 'car', 'industry-alt', 'heart', 'user'];
echo '<nav class="main-menu"><ul>';
// Loop menu elements
for ($i = 0; $i < count($menuList); $i++) {
echo '<a href="' . $menuLink[$i] . '">';
echo '<div class="menu-item">';
echo '<i class="fal fa-' . $menuIcon[$i] . '"></i>';
echo '<li>' . $menuList[$i] . '</li>';
echo '</div>';
echo '</a>';
}
echo '</ul></nav>';
?>
<div class="wrapper">
<header>
<img src="/img/logo_name.png" alt="">
<h1>WikiWorld</h1>
</header>
<?php
// Debug infos top right
echo '<div class="debug">';
echo 'PATH = ' . join('/', $url) . '<br>';
if (isset($_COOKIE['player_id'])) {
echo 'PLAYER_ID = ' . $_COOKIE['player_id'];
}
echo '</div>';
// Include home page
if (empty($url) || $url[0] === 'index.php') {
include('router/home.php');
} else {
// Include classic pages from the menu
if (in_array('/' . $url[0], $menuLink)) {
include('router/' . $url[0] . '.php');
} else {
// Switch case for specific pages handling
switch ($url[0]) {
case 'car':
if (isset($url[1])) {
$carId = (intval($url[1]) === 0 ? 1 : intval($url[1]));
include('router/car.php');
} else {
include('router/404.php');
}
break;
case 'constructor':
if (isset($url[1])) {
$constructorId = (intval($url[1]) === 0 ? 1 : intval($url[1]));
include('router/constructor.php');
} else {
include('router/404.php');
}
break;
case 'player':
if (isset($url[1])) {
$playerId = (intval($url[1]) === 0 ? 1 : intval($url[1]));
include('router/player.php');
} else {
include('router/404.php');
}
break;
case 'edit':
if (isset($url[2])) {
$editType = $url[1];
$editId = (intval($url[2]) === 0 ? 1 : intval($url[2]));
if ($url[1] === 'favorite') {
if (isset($url[3])) {
$editId2 = (intval($url[3]) === 0 ? 1 : intval($url[3]));
} else {
include('router/404.php');
break;
}
}
include('router/edit.php');
} else {
include('router/404.php');
}
break;
case 'delete':
if (isset($url[2])) {
$removeType = $url[1];
$removeId = (intval($url[2]) === 0 ? 1 : intval($url[2]));
if ($url[1] === 'favorite') {
if (isset($url[3])) {
$removeId2 = (intval($url[3]) === 0 ? 1 : intval($url[3]));
} else {
include('router/404.php');
break;
}
}
include('router/delete.php');
} else {
include('router/404.php');
}
break;
// Return 404 page if fails
default:
include('router/404.php');
break;
}
}
}
?>
<footer><i class="fal fa-copyright"></i> Réalisé par Quentin Lienhardt</footer>
</div>
</body>
</html>