@@ -69,9 +69,9 @@ private function init()
69
69
}, E_ALL );
70
70
71
71
$ this ->request_uri = \filter_input (\INPUT_SERVER , 'REQUEST_URI ' , \FILTER_SANITIZE_ENCODED );
72
- $ this ->request_uri = preg_replace ( ' ([/ \\ \]+) ' , ' / ' , urldecode ($ this ->request_uri ));
72
+ $ this ->request_uri = $ this -> format_unix ( urldecode ($ this ->request_uri ));
73
73
74
- $ this ->physical_file = preg_replace ( ' ([/ \\ \]+) ' , ' / ' , $ _SERVER ['SCRIPT_FILENAME ' ]);
74
+ $ this ->physical_file = $ this -> format_unix ( $ _SERVER ['SCRIPT_FILENAME ' ]);
75
75
$ this ->extension = strrev (strstr (strrev ($ this ->physical_file ), '. ' , TRUE ));
76
76
77
77
$ this ->last_modified = time ();
@@ -239,6 +239,16 @@ function process_request()
239
239
240
240
}
241
241
242
+ /**
243
+ * Format to UNIX path
244
+ * @param string $str
245
+ * @return mixed
246
+ */
247
+ private function format_unix ($ str = "" )
248
+ {
249
+ return preg_replace ('([/ \\\]+) ' , '/ ' , $ str );
250
+ }
251
+
242
252
/**
243
253
* Serve your application
244
254
*/
@@ -257,6 +267,12 @@ function console_output()
257
267
}
258
268
259
269
chdir ($ _SERVER ['DOCUMENT_ROOT ' ]);
270
+
271
+ if (ini_get ('auto_prepend_file ' ) && !in_array (realpath (ini_get ('auto_prepend_file ' )), get_included_files (), true )) {
272
+
273
+ include (ini_get ('auto_prepend_file ' ));
274
+
275
+ }
260
276
261
277
$ uri_path = $ this ->URI_no_query ();
262
278
$ uri_filepath = $ _SERVER ['DOCUMENT_ROOT ' ] . '/ ' . urldecode (substr ($ uri_path , 1 ));
@@ -311,14 +327,14 @@ function console_output()
311
327
}
312
328
313
329
$ load_index = $ _SERVER ['DOCUMENT_ROOT ' ] . "/ " . $ this ->indexPath ;
314
- $ load_index = preg_replace ( ' ([/ \\ \]+) ' , ' / ' , trim ($ load_index ));
330
+ $ load_index = $ this -> format_unix ( trim ($ load_index ));
315
331
316
332
/**
317
333
* Fix server globals
318
334
*/
319
- $ _SERVER ['SCRIPT_NAME ' ] = DIRECTORY_SEPARATOR . $ this ->indexPath ;
320
- $ _SERVER ['PHP_SELF ' ] = DIRECTORY_SEPARATOR . $ this ->indexPath ;
321
- $ _SERVER ['SCRIPT_FILENAME ' ] = $ _SERVER ['DOCUMENT_ROOT ' ] . DIRECTORY_SEPARATOR . $ this ->indexPath ;
335
+ $ _SERVER ['SCRIPT_NAME ' ] = $ this -> format_unix ( DIRECTORY_SEPARATOR . $ this ->indexPath ) ;
336
+ $ _SERVER ['PHP_SELF ' ] = $ this -> format_unix ( DIRECTORY_SEPARATOR . $ this ->indexPath ) ;
337
+ $ _SERVER ['SCRIPT_FILENAME ' ] = $ this -> format_unix ( $ _SERVER ['DOCUMENT_ROOT ' ] . DIRECTORY_SEPARATOR . $ this ->indexPath ) ;
322
338
323
339
if (!file_exists ($ load_index )) {
324
340
0 commit comments