-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.php
63 lines (56 loc) · 1.1 KB
/
variables.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
<?php
// Реврайт
if (isset($_GET['route'])) {
$temp = explode('/',$_GET['route']);
if ($temp[0] == 'admin') {
Core::$CONT = Core::$CONT.'/admin';
Core::$SKIN = 'admin';
unset($temp[0]);
}
$i = 0;
foreach($temp as $k=>$v) {
if ($i == 0) {
if (!empty($v)) {
$_GET['module'] = $v;
}
} elseif ($i == 1) {
if (!empty($v)) {
$_GET['page'] = $v;
}
} else {
$_GET['key'.($k-1)] = $v;
}
++$i;
}
unset($_GET['route']);
}
if(!isset($_GET['module'])) {
$_GET['module'] = 'static';
} else {
$res = dbq("
SELECT *
FROM `pages`
WHERE `module` = '".mres($_GET['module'])."'
LIMIT 1
");
if (!mysqli_num_rows($res)) {
header("Location: /404");
exit();
} else {
$staticpage = mysqli_fetch_assoc($res);
if ($staticpage['static'] == 1) {
$_GET['module'] = 'staticpage';
$_GET['page'] = 'main';
}
}
}
if(!isset($_GET['page'])) {
$_GET['page'] = 'main';
}
if (!preg_match('#^[a-z-_]*$#iu',$_GET['page'])) {
header("Location: /404");
exit();
}
if (isset($_POST)) {
$_POST = trimAll($_POST);
}