1 <?php
2
3 if(!defined('GEN_START')) {
4 http_response_code(404);
5 die();
6 }
7
8 ob_start();
9 require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'log.php';
10 include_once DIR_SYS . 'external' . DIRECTORY_SEPARATOR . 'kint' . DIRECTORY_SEPARATOR . '_main.php';
11 require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'handler.php';
12
13 spl_autoload_register('\Alo\Handler::autoloader');
14 set_error_handler('\Alo\Handler::error', ini_get('error_reporting'));
15 set_exception_handler('\Alo\Handler::ecxeption');
16
17 18 19 20 21 22 23 24 25
26 function get(&$var) {
27 return isset($var) ? $var : null;
28 }
29
30 31 32 33 34
35 function debug() {
36 if(!Kint::enabled()) {
37 return null;
38 } else {
39 ob_start();
40 $args = func_get_args();
41 call_user_func_array(['Kint', 'dump'], $args);
42
43 return ob_get_clean();
44 }
45 }
46
47 48 49 50 51 52
53 function server_is_windows() {
54 return substr(strtoupper(php_uname('s')), 0, 3) === 'WIN';
55 }
56
57 58 59 60 61
62 function lite_debug() {
63 if(!Kint::enabled()) {
64 return '';
65 } else {
66 ob_start();
67 $argv = func_get_args();
68 echo '<pre>';
69 foreach($argv as $k => $v) {
70 $k && print("\n\n");
71 echo kintLite($v);
72 }
73 echo '</pre>' . "\n";
74
75 return ob_get_clean();
76 }
77 }
78
79 80 81 82 83 84 85 86 87
88 function timestamp_precise($microtime = null) {
89 if(!$microtime) {
90 $microtime = microtime(true);
91 }
92 $t = explode('.', $microtime);
93
94 return date('Y-m-d H:i:s', $t[0]) . ':' . round($t[1] / 10);
95 }
96
97 if(!function_exists('getallheaders')) {
98
99 100 101 102 103 104
105 function getallheaders() {
106 $headers = [];
107 foreach($_SERVER as $name => $value) {
108 if(substr($name, 0, 5) == 'HTTP_') {
109 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
110 }
111 }
112
113 return $headers;
114 }
115 }
116
117 118 119 120 121 122 123 124 125
126 function escape_html5($str) {
127 return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5);
128 }
129
130 131 132 133 134 135 136
137 function includeifexists($path) {
138 if(file_exists($path)) {
139 include $path;
140
141 return true;
142 }
143
144 return false;
145 }
146
147 148 149 150 151 152 153
154 function includeonceifexists($path) {
155 if(file_exists($path)) {
156 include_once $path;
157
158 return true;
159 }
160
161 return false;
162 }
163
164 require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'alo.php';
165
166 includeonceifexists(DIR_APP . 'core' . DIRECTORY_SEPARATOR . 'autoload.php');
167
168 if(!defined('PHPUNIT_RUNNING')) {
169 Alo::$router = new Alo\Controller\Router();
170 Alo::$router->init();
171 }