forked from redditbooru/reddit-booru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·66 lines (47 loc) · 1.8 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
<?php
/**
* dxprog.com PHP library
*/
// Used to keep track of page generation time
$_begin = microtime (true);
// Include base libraries
require_once('./lib/aal.php');
// Start the session
Lib\Session::start();
// Define our globals
$GLOBALS['_content'] = null;
$GLOBALS['_sidebars'] = null;
// Handle URL and templating things
$found = Lib\Url::Rewrite('config/rewrites.json');
$GLOBALS['_baseURI'] = current(explode('?', Lib\Url::getRawUrl()));
Lib\Display::setTheme('.');
Lib\Display::setLayout('main');
// Warm up the test buck stuff
Lib\TestBucket::initialize();
// Handle URL rewrites
if (!$found) {
// If the rewriter couldn't come up with anything,
header('HTTP/1.1 404 Content Not Found');
Lib\Display::showError(404, 'Sorry, but we couldn\'t find what you were looking for.');
} else {
// Check to see which page must be included
$_page = isset($_GET['page']) ? $_GET['page'] : 'redditbooru';
// Make sure that there exists a page for the request
if (!is_readable('./controller/' . $_page . '.php')) {
header('HTTP/1.1 404 Content Not Found');
Lib\Display::showError(404, 'Sorry, but we couldn\'t find what you were looking for.');
} else {
// Include the config file if it exists
if (file_exists('./config/config.' . $_page . '.php')) {
include('./config/config.' . $_page . '.php');
}
// Turn control over to the requested page
call_user_func(array('Controller\\' . $_page, 'render'));
}
}
// Render the page to output
Lib\Display::render();
// Calculate the amount of time it took to generate the page
$genTime = microtime (true) - $GLOBALS['_begin'];
echo "<!--\n\tGenerated in ", $genTime, " seconds.\n\tDB hits - ", Lib\Db::$callCount, ".\n\tMax memory used - ", memory_get_peak_usage(), "\n-->";
Api\DxApi::clean();