-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
113 lines (87 loc) · 2.81 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
<?php
// Define application path
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application/'));
// Define base path
defined('BASE_PATH')
|| define('BASE_PATH', realpath(dirname(__FILE__)));
// Define application environment
if(!defined('MOD_REWRITE')) {
if(getenv('MOD_REWRITE')) {
define('MOD_REWRITE', getenv('MOD_REWRITE') ? true : false);
} else if(isset($_SERVER['MOD_REWRITE'])) {
define('MOD_REWRITE', $_SERVER['APPLICATION_ENV'] ? true : false);
} else {
define('MOD_REWRITE', true);
}
}
// Define application environment
if(!defined('APPLICATION_ENV')) {
if(getenv('APPLICATION_ENV')) {
define('APPLICATION_ENV', getenv('APPLICATION_ENV'));
} else if(isset($_SERVER['APPLICATION_ENV']) && $_SERVER['APPLICATION_ENV']) {
define('APPLICATION_ENV', $_SERVER['APPLICATION_ENV']);
} else {
define('APPLICATION_ENV', 'production');
}
}
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../JO/v.0.9c/'),
realpath(APPLICATION_PATH . '/library/'),
get_include_path(),
)));
require_once 'JO/Application.php';
// Create application, bootstrap, and run
$application = new JO_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/application.ini',
isset($argv) ? $argv : null
);
// Set Config
$configs_files = glob(APPLICATION_PATH . '/config/config_*.ini');
if($configs_files) {
foreach($configs_files AS $file) {
$config = new JO_Config_Ini($file);
$application->setOptions($config->toArray());
JO_Registry::set(basename($file, '.ini'), $config->toArray());
}
}
// Set Routers links
$routers_files = glob(APPLICATION_PATH . '/config/routers/*.ini');
if($routers_files) {
foreach($routers_files AS $file) {
$config = new JO_Config_Ini($file, null, false, true);
$application->setOptions($config->toArray());
JO_Registry::set('routers_'.basename($file, '.ini'), $config->toArray());
}
}
//dispatch application
$application->dispatch();
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
switch ($errno) {
case E_USER_ERROR:
echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
echo "Aborting...<br />\n";
exit(1);
break;
case E_USER_WARNING:
echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
case E_USER_NOTICE:
echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
break;
default:
echo "Unknown error type: [$errno] $errstr<br />\n";
break;
}
/* Don't execute PHP internal error handler */
return true;
}