1 | <?php |
||
2 | |||
3 | /*if (count($_COOKIE) <= 50) { |
||
4 | foreach ($_COOKIE as $key => $val) { |
||
5 | if (!is_numeric($key) || !is_string($key)) { |
||
6 | continue; |
||
7 | } |
||
8 | setcookie('same-site-cookie', $key, ['samesite' => 'Lax']); |
||
9 | setcookie('cross-site-cookie', $key, ['samesite' => 'None', 'secure' => true]); |
||
10 | } |
||
11 | }*/ |
||
12 | |||
13 | header('X-Powered-By: L3n4r0x'); |
||
14 | |||
15 | //import configuration |
||
16 | include_once __DIR__ . '/config.php'; |
||
17 | |||
18 | use MVC\helper; |
||
19 | use MVC\router; |
||
20 | use MVC\themes; |
||
21 | |||
22 | // force redirect, this is our project, you can remove this |
||
23 | if ('103.146.203.101' == $_SERVER['HTTP_HOST'] && !LOCAL) { |
||
24 | header('Location: http://ns.webmanajemen.com' . $_SERVER['REQUEST_URI']); |
||
25 | // force https |
||
26 | if (isset($_SERVER['HTTPS']) && 'on' != $_SERVER['HTTPS']) { |
||
27 | header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
||
28 | } else { |
||
29 | // tell browser to access https only |
||
30 | header('Strict-Transport-Security: max-age=31536000'); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | // run DDOS protector |
||
35 | new \DDOS\runner(); |
||
36 | |||
37 | // start theme |
||
38 | $theme = new themes(); |
||
39 | |||
40 | ////// Custom maintenance start |
||
41 | //@todo disable maintenance mode for admin |
||
42 | //this maintenance applied on production mode (NON LOCALHOST) |
||
43 | if (!LOCAL) { //change this |
||
44 | if (isset($_REQUEST['release'])) { |
||
45 | \Cookie\helper::hours('release-maintenance', 'true', 1); |
||
46 | } |
||
47 | if (!isset($_COOKIE['release-maintenance'])) { |
||
48 | //maintenance(); //uncomment this to enable |
||
49 | } |
||
50 | } |
||
51 | ////// Custom maintenance end |
||
52 | |||
53 | ////// Zone Shutdown Start |
||
54 | $shut = get_conf()['app']['shutdown']; |
||
55 | if (!LOCAL) { // do shutdown if not localhost |
||
56 | $theme->shutdown($shut); |
||
57 | } |
||
58 | ////// Zone Shutdown End |
||
59 | |||
60 | ////// build template start |
||
61 | |||
62 | /** |
||
63 | * Template configuration. |
||
64 | */ |
||
65 | $template = get_conf()['app']['theme']; |
||
66 | /** |
||
67 | * Template stack builder. |
||
68 | * |
||
69 | * @todo exclude default template from scopes |
||
70 | */ |
||
71 | $template_stack = []; |
||
72 | if (!empty($template)) { |
||
73 | foreach ($template as $key => $value) { |
||
74 | if ('default' == $key) { |
||
75 | continue; |
||
76 | } |
||
77 | $template_stack[$key] = $value; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | // Set template by zone divider |
||
82 | $theme->setThemeByZones( |
||
83 | $template_stack, |
||
84 | get_conf()['app']['theme']['default'] |
||
85 | ); |
||
86 | |||
87 | ////// build template end |
||
88 | |||
89 | $application_folder = empty(CONFIG['app']['root']) ? __DIR__ : ROOT; |
||
90 | $view_folder = CONFIG['app']['views']; |
||
91 | // special access |
||
92 | switch (get_zone()) { |
||
93 | case 'load-asset': |
||
94 | // load static asset by ?src= |
||
95 | $parse = helper::parse_url2(helper::geturl()); |
||
96 | if (isset($parse['query']['src'])) { |
||
97 | helper::load_asset($parse['query']['src']); |
||
98 | exit; |
||
99 | } |
||
100 | break; |
||
101 | case 'superuser': // superuser framework |
||
102 | case 'server': //server framework |
||
103 | //set folder etc for root views |
||
104 | $view_folder = 'etc'; |
||
105 | break; |
||
106 | } |
||
107 | $view_folder = "{$application_folder}/{$view_folder}/"; |
||
108 | define('VIEWPATH', $view_folder); |
||
109 | |||
110 | $rc = new router(); |
||
111 | $view = helper::fixSlash(VIEWPATH . $rc->findRoute() . '.php'); |
||
0 ignored issues
–
show
|
|||
112 | |||
113 | // glype proxy |
||
114 | if ('index/bot/glype/admin' == str_replace('.php', '', $view)) { |
||
115 | include __DIR__ . '/bot/glype/admin.php'; |
||
116 | exit; |
||
117 | } |
||
118 | |||
119 | // start output buffering |
||
120 | ob_start(); |
||
121 | |||
122 | // default router |
||
123 | if (!realpath($view)) { |
||
124 | // if file not exists return 400 bad request |
||
125 | http_response_code(400); |
||
126 | $basename = basename($view, '.php'); |
||
127 | |||
128 | /** |
||
129 | * next index finder. |
||
130 | */ |
||
131 | $check_next_index = preg_replace('/\.php$/s', '', $view) . '/index.php'; |
||
132 | if ($check_next_index = realpath($check_next_index)) { |
||
133 | $check_next_index = \MVC\helper::fixSlash($check_next_index); |
||
134 | $check_next_index = preg_replace('/\.php$/s', '', $check_next_index); |
||
135 | if ($pos_views = strpos($check_next_index, '/views')) { |
||
136 | $check_next_index = substr($check_next_index, $pos_views + strlen('/views')); |
||
137 | } else if ($pos_views = strpos($check_next_index, '/etc')) { |
||
138 | $check_next_index = substr($check_next_index, $pos_views + strlen('/etc')); |
||
139 | } |
||
140 | die($router->redirect($check_next_index)); |
||
141 | } |
||
142 | |||
143 | ////// if router ended with slash (/) below codes will find next index.php or previous file php |
||
144 | ////// dashboard/ maybe to dashboard/index or dashboard.php if exists |
||
145 | |||
146 | /** |
||
147 | * Previous index finder. |
||
148 | */ |
||
149 | $check_prev_index = preg_replace('/\/index\.php$/s', '', $view) . '.php'; |
||
150 | if ($check_prev_index = realpath($check_prev_index)) { |
||
151 | $check_prev_index = \MVC\helper::fixSlash($check_prev_index); |
||
152 | $check_prev_index = preg_replace('/\.php$/s', '', $check_prev_index); |
||
153 | if ($pos_views = strpos($check_prev_index, '/views')) { |
||
154 | $check_prev_index = substr($check_prev_index, $pos_views + strlen('/views')); |
||
155 | } else if ($pos_views = strpos($check_prev_index, '/etc')) { |
||
156 | $check_prev_index = substr($check_prev_index, $pos_views + strlen('/etc')); |
||
157 | } |
||
158 | die($router->redirect($check_prev_index)); |
||
159 | } |
||
160 | |||
161 | // check if form controller is exist, then include them without rendering template |
||
162 | $form_c = substr($view, 0, -4) . '-f.php'; |
||
163 | if (file_exists($form_c)) { |
||
164 | http_response_code(200); |
||
165 | include $form_c; |
||
166 | die(); |
||
167 | } |
||
168 | |||
169 | // exit now |
||
170 | if ('development' != get_env()) { |
||
171 | // skip debug if environtment not development |
||
172 | $view = ''; |
||
173 | } |
||
174 | http_response_code(404); |
||
175 | include __DIR__ . '/404.php'; |
||
176 | } elseif ($view = realpath($view)) { |
||
177 | // if file exists, set as view |
||
178 | $theme->view($view); |
||
179 | /** |
||
180 | * @var bool render if Disabled Cache on browser |
||
181 | */ |
||
182 | $is_hard_reload = $router->is_hard_reload(); |
||
183 | /** |
||
184 | * @var bool force render if page cache not exists / expired |
||
185 | */ |
||
186 | $cache_expired = cache_expired(2); |
||
187 | /** |
||
188 | * @var bool disable cache based on meta |
||
189 | */ |
||
190 | $no_cache = !$theme->meta['cache']; |
||
191 | /** |
||
192 | * @var bool disable cache on CORS |
||
193 | */ |
||
194 | $cors = CORS; |
||
195 | /** |
||
196 | * @var bool temporarily disable on production |
||
197 | */ |
||
198 | $production = ('production' == get_env()); |
||
199 | /** |
||
200 | * @var bool Is refresh cache request |
||
201 | */ |
||
202 | $refreshCache = $router->is_header('Refresh-Cache'); |
||
203 | |||
204 | // set all indicator to integer for convert into boolean on next event |
||
205 | settype($is_hard_reload, 'integer'); |
||
206 | settype($no_cache, 'integer'); |
||
207 | settype($cache_expired, 'integer'); |
||
208 | settype($cors, 'integer'); |
||
209 | |||
210 | if ('development' == get_env()) { |
||
211 | // noindex on development mode, for SEO reasons |
||
212 | header('X-Robots-Tag: noindex, nofollow', true); |
||
213 | } |
||
214 | if (!CORS) { |
||
215 | //echo showAlert('bottom'); |
||
216 | } |
||
217 | |||
218 | // No Cache Mode |
||
219 | header('Cache-Status: no-cache(' . __LINE__ . "), hard({$is_hard_reload}), cache_expired({$cache_expired}), no_cache({$no_cache}), cors({$cors})", true); |
||
220 | |||
221 | // unminify html |
||
222 | $theme->render(); |
||
223 | |||
224 | // minified html |
||
225 | //render($theme); |
||
226 | |||
227 | // load admin tools |
||
228 | //$theme->load_admin_tools(); |
||
229 | } |
||
230 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.