1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* INJI CMS 5.0.0 dev |
5
|
|
|
* |
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
7
|
|
|
* @link http://inji.ru/ |
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
10
|
|
|
*/ |
11
|
|
|
//set locale |
12
|
|
|
setlocale(LC_ALL, 'ru_RU.UTF-8', 'rus_RUS.UTF-8', 'Russian_Russia.65001'); |
13
|
|
|
setlocale(LC_NUMERIC, 'C'); |
14
|
|
|
//default timezone |
15
|
|
|
date_default_timezone_set('Asia/Krasnoyarsk'); |
16
|
|
|
// time start |
17
|
|
|
define('INJI_TIME_START', microtime(true)); |
18
|
|
|
// system files dir |
19
|
|
|
define('INJI_SYSTEM_DIR', str_replace(DIRECTORY_SEPARATOR, '/', __DIR__) . '/system'); |
20
|
|
|
// apps files dir |
21
|
|
|
define('INJI_PROGRAM_DIR', str_replace(DIRECTORY_SEPARATOR, '/', __DIR__) . '/program'); |
22
|
|
|
// base dir for outputing system files and dirs |
23
|
|
|
define('INJI_BASE_DIR', str_replace(DIRECTORY_SEPARATOR, '/', __DIR__) . '/'); |
24
|
|
|
|
25
|
|
|
// check base config |
26
|
|
|
if (!file_exists(INJI_SYSTEM_DIR) || !is_dir(INJI_SYSTEM_DIR)) { |
27
|
|
|
INJI_SYSTEM_ERROR('Error in base config: INJI_SYSTEM_DIR not correct', true); |
28
|
|
|
} |
29
|
|
|
if (!file_exists(INJI_PROGRAM_DIR) || !is_dir(INJI_PROGRAM_DIR)) { |
30
|
|
|
INJI_SYSTEM_ERROR('Error in base config: INJI_PROGRAM_DIR not correct', true); |
31
|
|
|
} |
32
|
|
|
foreach ($_SERVER as $key => $item) { |
33
|
|
|
if (strpos($key, 'HTTP_AUTHORIZATION') !== false) { |
34
|
|
|
$auth = explode(':', base64_decode(substr($item, 6))); |
35
|
|
|
$_SERVER['PHP_AUTH_USER'] = $auth[0]; |
36
|
|
|
$_SERVER['PHP_AUTH_PW'] = isset($auth[1]) ? $auth[1] : ''; |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
require_once(INJI_SYSTEM_DIR . '/init.php'); |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* System error messages |
44
|
|
|
*/ |
45
|
|
|
function INJI_SYSTEM_ERROR($msg, $fatal = false) { |
46
|
|
|
if ($fatal) { |
47
|
|
|
exit("<div style = 'text-align:center;font-size:20px;margin-top:25%;'>{$msg}</div>"); |
|
|
|
|
48
|
|
|
} else { |
49
|
|
|
echo "<div style = 'text-align:center;font-size:20px;margin-top:25%;'>{$msg}</div>"; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.