-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
72 lines (60 loc) · 1.74 KB
/
init.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
<?php
session_start();
use CacaoFw\CacaoFw;
use CacaoFw\Utils;
global $u, $starttime;
$starttime = microtime(true);
// Windows fix
setlocale(LC_MONETARY, 'en_GB');
if (!function_exists("money_format")) {
function money_format($format, $number) {
return number_format($number, 2);
}
}
function cacaoClassLoader($class) {
$classPath = preg_split("/\\\\/", $class);
if ($classPath[0] === 'CacaoFw') {
// Load framework classes.
$path = join(array_splice($classPath, 1), "//");
$path = realpath(__DIR__ . '/' . $path . '.php');
if (file_exists($path)) {
require_once $path;
return;
}
} else if ($classPath[0] === 'App') {
// Load app classes.
$path = join(array_splice($classPath, 1), "//");
$path = realpath(__DIR__ . '/../app/src/' . $path . '.php');
if (file_exists($path)) {
require_once $path;
return;
}
} else {
$path = realpath(__DIR__ . '/../app/vendor/' . join($classPath, '/') . '.php');
if (file_exists($path)) {
require_once $path;
return;
}
}
}
function errorHandler($errno, $errstr, $errfile, $errline, array $errcontext) {
if (0 === error_reporting()) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
function string($name, $print = true, $langcode = null) {
global $LANG;
$result = $LANG->findString($name, $langcode);
if ($print) {
echo $result;
} else {
return $result;
}
}
require_once __DIR__ . '/../app/constants.php';
global $u;
set_error_handler('errorHandler');
spl_autoload_register('cacaoClassLoader');
$u = new Utils();
$cfw = new CacaoFw($u);