forked from wodim/fearqdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
125 lines (111 loc) · 2.98 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
<?php
/*
fearqdb - quote database system
Copyright (C) 2011-2012 David Martí <neikokz at gmail dot com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$start = microtime(true);
require('init.php');
if ($settings->no_rewrite) {
$request = isset($_GET['m']) ? $_GET['m'] : 'page';
} else {
$request = $_SERVER['REQUEST_URI'];
$query = strpos($request, '?');
if ($query !== false) {
$request = substr($request, 0, $query);
}
}
$request = preg_replace(sprintf('/^%s/', preg_quote($settings->base_url, '/')), '', $request);
$params = explode('/', $request);
if (strpos($request, '/') === 0) {
array_shift($params);
}
foreach ($params as $k => $v) {
$params[$k] = urldecode($v);
}
$params[0] = isset($params[0]) ? $params[0] : 'page';
switch ($params[0]) {
case 'robots.txt':
$module = 'robots';
require(modules_dir.'leftovers.php');
break;
case 'opensearch.xml':
$module = 'opensearch';
require(modules_dir.'leftovers.php');
break;
case 'favicon.ico':
$module = 'favicon';
require(modules_dir.'leftovers.php');
break;
case 'admin':
require(modules_dir.'admin.php');
break;
case 'submit':
require(modules_dir.'submit.php');
break;
case 'quote':
require(modules_dir.'quote.php');
break;
case 'random':
require(modules_dir.'random.php');
break;
case 'submit':
require(modules_dir.'submit.php');
break;
case 'rss':
require(modules_dir.'rss.php');
break;
case 'api':
require(modules_dir.'api.php');
break;
case 'search':
require(modules_dir.'search.php');
break;
case 'panel':
require(modules_dir.'panel.php');
break;
case 'topics':
require(modules_dir.'topics.php');
break;
case '_':
require(modules_dir.'statics.php');
break;
case 'userlogin':
case 'login':
case 'logout':
$module = 'session';
require(modules_dir.'login.php');
break;
case 'page':
$module = 'list';
require(modules_dir.'list.php');
break;
default:
if (!$params[0]) {
$module = 'list';
$session->home = true;
require(modules_dir.'list.php');
} else {
$module = 'quote';
require(modules_dir.'quote.php');
}
}
if (!isset($module)) {
$module = $params[0];
}
$session->hit();
echo $html->output;
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
printf('<!-- %.4f seconds, %d queries -->', microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $db->num_queries);
} else {
printf('<!-- %.4f seconds, %d queries -->', microtime(true) - $start, $db->num_queries);
}