forked from totoCZ/Runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.routing.php
53 lines (42 loc) · 844 Bytes
/
index.routing.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
<?php
$pg = $_GET['page'];
if (!$user->isLoggedIn()) {
if ($pg != 'index'
&& $pg != 'login'
&& $pg != 'public'
&& $pg != 'service-trace'
&& $pg != 'service-show'
&& $pg != 'status-show'
&& $pg != 'api-status.json'
&& $pg != 'api-history.json') {
redir('login');
}
}
// ACTIONS
if ($pg == 'logout')
$user->logout(TRUE);
// SECURITY
if(!preg_match("/^[a-z-.]+$/", $pg)) {
redir('index');
}
if($_GET['locale'] != 'api') {
// Normal router.
require './head.php';
$f = './ctrl/' . $pg . '.php';
if (file_exists($f)) {
require $f;
}
else {
redir('index');
}
require './foot.php';
} else {
// API router.
header('Content-type: application/json; charset=UTF-8');
header('Access-Control-Allow-Origin: *');
require './func.api.php';
$f = './ctrl/' . $pg . '.php';
if (file_exists($f))
require $f;
}
?>