/
index.php
59 lines (49 loc) · 1.49 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
<?php
/**
* PHPLucidFrame : Simple, Lightweight & yet Powerfull PHP Application Framework
* The request collector
*
* @package PHPLucidFrame\App
* @since PHPLucidFrame v 1.0.0
* @copyright Copyright (c), PHPLucidFrame.
* @link http://phplucidframe.com
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE
*/
use LucidFrame\Core\Middleware;
require_once '../lib/bootstrap.php';
Middleware::runBefore();
ob_start('_flush');
$basename = basename(_app('page'), '.php');
if ($basename != 'view') {
if ($basename == '401') {
_page401();
} elseif ($basename == '403') {
_page403();
} elseif ($basename == '404') {
_page404();
} else {
require _app('page');
}
}
if (_cfg('layoutMode') && _isAjax() === false) {
if (_isHttpPost()) {
$action = _ds(APP_ROOT, _cr(), 'action.php');
if (is_file($action) && file_exists($action)) {
require_once $action;
}
}
$layout = _i(_ds('inc', 'tpl', _app('view')->layout . '.php'));
if (is_file($layout) && file_exists($layout)) {
$viewData = _app('view')->data;
extract($viewData);
require_once $layout;
} else {
_header(500);
throw new \RuntimeException(sprintf('Layout file is missing: %s', _app('view')->layout . '.php'));
}
}
ob_end_flush();
Middleware::runAfter();