forked from munkireport/munkireport-php
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
executable file
·135 lines (109 loc) · 2.95 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
126
127
128
129
130
131
132
133
134
135
<?php
define( 'KISS', 1 );
// Front controller
define('FC', __FILE__ .'/' );
define('APP_ROOT', dirname(__FILE__) .'/' );
// Pass on https forward to $_SERVER['HTTPS']
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
{
$_SERVER['HTTPS'] = 'on';
}
// Load config
load_conf();
// Load conf (keeps variables out of global space)
function load_conf()
{
$conf = array();
$GLOBALS['conf'] =& $conf;
// Load default configuration
require_once(APP_ROOT . "config_default.php");
if ((include_once APP_ROOT . "config.php") !== 1)
{
fatal(APP_ROOT. "config.php is missing!<br>
Unfortunately, Munkireport does not work without it</p>");
}
// Convert auth_config to config item
if(isset($auth_config))
{
$conf['auth']['auth_config'] = $auth_config;
}
}
/**
* Get config item
* @param string config item
* @param string default value (optional)
* @author AvB
**/
function conf($cf_item, $default = '')
{
return array_key_exists($cf_item, $GLOBALS['conf']) ? $GLOBALS['conf'][$cf_item] : $default;
}
/**
* Get session item
* @param string session item
* @param string default value (optional)
* @author AvB
**/
function sess_get($sess_item, $default = '')
{
if (! isset($_SESSION))
{
return $default;
}
return array_key_exists($sess_item, $_SESSION) ? $_SESSION[$sess_item] : $default;
}
/**
* Set session item
* @param string session item
* @param string value
* @author AvB
**/
function sess_set($sess_item, $value)
{
if (! isset($_SESSION))
{
return false;
}
$_SESSION[$sess_item] = $value;
return true;
}
/**
* Fatal error, show message and die
*
* @author AvB
**/
function fatal($msg)
{
include('assets/html/fatal_error.html');
exit(1);
}
//===============================================
// Defines
//===============================================
define('INDEX_PAGE', conf('index_page'));
define('SYS_PATH', conf('system_path') );
define('APP_PATH', conf('application_path') );
define('VIEW_PATH', conf('view_path'));
define('MODULE_PATH', conf('module_path'));
define('CONTROLLER_PATH', conf('controller_path'));
define('EXT', '.php'); // Default extension
//===============================================
// Debug
//===============================================
ini_set('display_errors', conf('debug') ? 'On' : 'Off' );
error_reporting( conf('debug') ? E_ALL : 0 );
//===============================================
// Includes
//===============================================
require( SYS_PATH.'kissmvc.php' );
require( APP_PATH.'helpers/site_helper'.EXT );
//===============================================
// Timezone
//===============================================
date_default_timezone_set( conf('timezone') );
//set_exception_handler('uncaught_exception_handler');
//===============================================
// Start the controller
//===============================================
$uri_protocol = conf('uriProtocol');
new Engine($conf['routes'],'show','index',$conf['uri_protocol']);