forked from opentibiabr/myaac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
75 lines (58 loc) · 1.93 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
<?php
// few things we'll need
require '../common.php';
define('ADMIN_PANEL', true);
define('MYAAC_ADMIN', true);
if (file_exists(BASE . 'config.local.php')) {
require_once BASE . 'config.local.php';
}
if (file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) {
header('Location: ' . BASE_URL . 'install/');
throw new RuntimeException('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!');
}
$content = '';
// validate page
$page = $_GET['p'] ?? '';
if (empty($page) || preg_match("/[^a-zA-Z0-9_\-]/", $page))
$page = 'dashboard';
$page = strtolower($page);
define('PAGE', $page);
require SYSTEM . 'functions.php';
require SYSTEM . 'init.php';
if (config('env') === 'dev') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
// event system
require_once SYSTEM . 'hooks.php';
$hooks = new Hooks();
$hooks->load();
require SYSTEM . 'status.php';
require SYSTEM . 'login.php';
require SYSTEM . 'migrate.php';
require ADMIN . 'includes/functions.php';
$twig->addGlobal('config', $config);
$twig->addGlobal('status', $status);
// if we're not logged in - show login box
if (!$logged || !admin()) {
$page = 'login';
}
// include our page
$file = ADMIN . 'pages/' . $page . '.php';
if (!@file_exists($file)) {
$page = '404';
$file = SYSTEM . 'pages/404.php';
}
ob_start();
include($file);
$content .= ob_get_contents();
ob_end_clean();
// template
$template_path = 'template/';
require ADMIN . $template_path . 'template.php';
?>
<?php if ($config['pace_load']) { ?>
<script src="../admin/bootstrap/pace/pace.js"></script>
<link href="../admin/bootstrap/pace/themes/white/pace-theme-flash.css" rel="stylesheet"/>
<?php } ?>