-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
79 lines (68 loc) · 2.41 KB
/
index.php
File metadata and controls
79 lines (68 loc) · 2.41 KB
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
<?php
/*
* This file is part of CM5 <http://code.0x0lab.org/p/cm5>.
*
* Copyright (c) 2010 Sque.
*
* CM5 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CM5 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CM5. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Sque - initial API and implementation
*/
// Security check for install folder
if (file_exists(__DIR__ . '/install')) {
$install_url = dirname($_SERVER['SCRIPT_NAME']) . "/install";
echo <<< EOF
<h1>ERROR: remove "install" folder before continuing...</h1>
If this is a fresh install visit: <a href="{$install_url}">install script</a>.<br/>
Otherwise if installation is finished remove completly "install" folder from the web server.
EOF;
exit;
}
require_once __DIR__ . '/bootstrap.php';
// DO NOT EDIT THIS FILE TO CHANGE DEFAULT PAGE
/**
* This file is here to act as url router. To edit actual web pages
* check /web folder. If you want a different global url behaviour
* then you should it here.
*/
// Include all sub directories under /web
function is_valid_sub($sub)
{
return is_file(__DIR__ . "/web/sub/$sub.php");
}
function include_sub($sub)
{
require __DIR__ . "/web/sub/$sub.php";
}
Stupid::add_rule('include_sub',
array('type' => 'url_path', 'chunk[1]' => '/^([\w]+)$/'),
array('type' => 'func', 'func' => 'is_valid_sub')
);
Stupid::set_default_action(array(CM5_Core::getInstance(), 'serve'));
try{
// Execute logic and return flush
Stupid::chain_reaction();
}catch (Exception404 $e) {
require __DIR__ . '/web/not_found.php';
}catch (Exception $e) {
header('HTTP/1.1 501 Internal server error ');
etag('h2', 'There was an Internal server error. The administrators have been notified. Sorry for the inconvenience.');
if (Layout::getActive())
Layout::getActive()->flush();
CM5_Logger::getInstance()->crit(get_class($e) . " : {$e->getMessage()} @ {$e->getFile()}:{$e->getLine()} ");
exit;
}
if (Layout::getActive())
Layout::getActive()->flush();