-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
68 lines (52 loc) · 1.71 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
<?php
require_once './workspace/urls.php';
require_once './workspace/settings.php';
$request = $_SERVER['REQUEST_URI'];
$url = str_replace($settings["baseDir"], "", $request);
require_once './workspace/views.php';
$exis = 0;
for ($i=0; $i < sizeof($urlpatterns); $i++) {
$pattern = $urlpatterns[$i];
$getreq = explode("/", $pattern['path']);
$urlreq = explode("/", $url);
if (sizeof($getreq) == sizeof($urlreq)) {
if (str_contains($pattern['path'], "[str:") || str_contains($pattern['path'], "[num:")) {
$getpat = explode("/", $pattern['path']);
$urlpat = explode("/", $url);
$urlheaders = [];
$urlvars = [];
$nya = 0;
for ($j = 0; $j < sizeof($getpat); $j++) {
if (str_contains($getpat[$j], "[str:") || str_contains($getpat[$j], "[num:")) {
array_push($urlheaders, $getpat[$j]);
array_push($urlvars, $urlpat[$j]);
} else {
if ($urlpat[$j] == $getpat[$j]) {
$nya++;
} else {
$nya = 0;
}
}
}
if ($nya > 0) {
$views[$pattern['view']](...$urlvars);
$exis++;
break;
} else {
$exis = 0;
}
} else {
if ($url == $pattern['path']) {
$views[$pattern['view']]();
$exis++;
break;
} else {
$exis = 0;
}
}
}
}
if($exis == 0) {
redirect("404");
}
?>