mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 20:44:53 -04:00
Refactoring PHP init code.
This commit is contained in:
parent
5043a5188b
commit
b67c22f33b
5 changed files with 79 additions and 68 deletions
|
@ -10,11 +10,6 @@ function normalize_path($path, $trailing_slash = false) {
|
|||
}
|
||||
|
||||
define("APP_ABS_PATH", normalize_path(dirname(dirname(dirname(__FILE__)))));
|
||||
// define("APP_ABS_HREF", normalize_path(dirname(dirname(dirname(getenv("SCRIPT_NAME")))), true));
|
||||
define("APP_ABS_HREF", normalize_path(dirname(dirname(dirname(preg_replace('#^.*//#', '/', getenv("SCRIPT_NAME"))))), true)); // fixes lighttpd issues
|
||||
$url_parts = parse_url(getenv("REQUEST_URI"));
|
||||
define("ABS_HREF", normalize_path($url_parts["path"]), true);
|
||||
|
||||
|
||||
function normalized_require_once($lib) {
|
||||
|
||||
|
@ -22,25 +17,12 @@ function normalized_require_once($lib) {
|
|||
}
|
||||
|
||||
|
||||
/* Fast exit on version check */
|
||||
|
||||
if (array_key_exists("version", $_REQUEST)) {
|
||||
|
||||
echo json_encode(array("code" => 0, "version" => "{{pkg.version}}", "href" => APP_ABS_HREF));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/* Load Libs */
|
||||
/* Init */
|
||||
|
||||
normalized_require_once("/server/php/inc/util.php");
|
||||
normalized_require_once("/server/php/inc/App.php");
|
||||
normalized_require_once("/server/php/inc/Item.php");
|
||||
|
||||
|
||||
/* Init */
|
||||
|
||||
$app = new App(APP_ABS_PATH, APP_ABS_HREF, ABS_HREF);
|
||||
$app = App::from_env();
|
||||
|
||||
|
||||
/* Run */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue