-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
93 lines (67 loc) · 1.82 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
<?php
/* Fichier principal : inclut les controllers */
$request = explode('/', $_GET['request']);
$size = count($request);
$urlRequest = '/' . implode('/', $request);
if ($size == 1) {
if ($request[0] == '') { // Homepage
include('controller/homepage.php');
exit();
}
if ($request[0] == 'favicon.png') { // Icône
header('Content-Type: image/png');
echo file_get_contents('static/favicon.png');
exit();
}
if ($request[0] == 'images') { // Gallerie d'images
include('controller/pictures/pictures.php');
exit();
}
if ($request[0] == 'robots.txt') { // Fichier robots.txt
include('controller/robots-txt.php');
exit();
}
if ($request[0] == 'sitemap.xml') {
include('controller/sitemap.php');
exit();
}
}
if ($size == 2) {
if ($request[0] == 'styles') { // Feuilles de styles
if ($request[1] == 'project.css') {
include('controller/project/project-styles.php');
exit();
}
if ($request[1] == 'pictures-styles.css') {
include('controller/pictures/styles.php');
exit();
}
}
if ($request[0] == 'scripts') { // Scripts
if ($request[1] == 'project.js') {
include('controller/project/project-script.php');
exit();
}
if ($request[1] == 'pictures-scripts.js') {
include('controller/pictures/scripts.php');
exit();
}
}
}
$regexPictures = '#^/([0-9]+-.*/)+ressources/([0-9]+)(s|m|l|r)-?.*\.(png|jpg|gif)$#';
if (preg_match($regexPictures, $urlRequest)) {
$infos = explode('\n', preg_replace($regexPictures, '$2\n$3', $urlRequest));
$URL = $urlRequest;
$RESOURCE_ID = $infos[0];
$RESOURCE_SIZE = $infos[1];
include('controller/picture.php');
exit();
}
if (preg_match('#^/([0-9]+-.*)+$#', $urlRequest)) { // Page de projet
$URL = $urlRequest;
$REQUEST = $request;
include('controller/project.php');
exit();
}
// La page n'existe pas
include('controller/errors/404.php');