Moves init code to index file.

This commit is contained in:
Lars Jung 2012-10-27 04:29:55 +02:00
parent 32d7aa74e5
commit 6c00a8e669
2 changed files with 44 additions and 45 deletions

View File

@ -1,44 +0,0 @@
<?php
function normalize_path($path, $trailing_slash = false) {
$path = str_replace("\\", "/", $path);
return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($trailing_slash ? "/" : ""));
}
define("APP_ABS_PATH", normalize_path(dirname(dirname(dirname(dirname(__FILE__))))));
define("APP_ABS_HREF", normalize_path(dirname(dirname(dirname(getenv("SCRIPT_NAME")))), true));
define("ABS_HREF", normalize_path(preg_replace('/[^\\/]*$/', '', getenv("REQUEST_URI")), true));
function normalized_require_once($lib) {
require_once(APP_ABS_PATH . $lib);
}
normalized_require_once("/server/php/inc/util.php");
normalized_require_once("/server/php/inc/App.php");
normalized_require_once("/server/php/inc/Item.php");
$app = new App(APP_ABS_PATH, APP_ABS_HREF, ABS_HREF);
if (array_key_exists("action", $_REQUEST)) {
header("Content-type: application/json");
normalized_require_once("/server/php/inc/Api.php");
$api = new Api($app);
$api->apply();
json_fail(100, "unsupported request");
} else {
header("Content-type: text/html");
$HREF = $app->get_app_abs_href();
$FALLBACK = $app->get_no_js_fallback();
normalized_require_once("/server/php/inc/page.php");
}
?>

View File

@ -1 +1,44 @@
<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>
<?php
function normalize_path($path, $trailing_slash = false) {
$path = str_replace("\\", "/", $path);
return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($trailing_slash ? "/" : ""));
}
define("APP_ABS_PATH", normalize_path(dirname(dirname(dirname(__FILE__)))));
define("APP_ABS_HREF", normalize_path(dirname(dirname(dirname(getenv("SCRIPT_NAME")))), true));
define("ABS_HREF", normalize_path(preg_replace('/[^\\/]*$/', '', getenv("REQUEST_URI")), true));
function normalized_require_once($lib) {
require_once(APP_ABS_PATH . $lib);
}
normalized_require_once("/server/php/inc/util.php");
normalized_require_once("/server/php/inc/App.php");
normalized_require_once("/server/php/inc/Item.php");
$app = new App(APP_ABS_PATH, APP_ABS_HREF, ABS_HREF);
if (array_key_exists("action", $_REQUEST)) {
header("Content-type: application/json;charset=utf-8");
normalized_require_once("/server/php/inc/Api.php");
$api = new Api($app);
$api->apply();
json_fail(100, "unsupported request");
} else {
header("Content-type: text/html;charset=utf-8");
$HREF = $app->get_app_abs_href();
$FALLBACK = $app->get_no_js_fallback();
normalized_require_once("/server/php/inc/page.php");
}
?>