More PHP refactorings. Fixes text preview.

This commit is contained in:
Lars Jung 2012-10-06 14:29:24 +02:00
parent 838a346c29
commit 029872a212
8 changed files with 141 additions and 134 deletions

View file

@ -0,0 +1,24 @@
<?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));
function normalized_require_once($lib) {
require_once(APP_ABS_PATH . $lib);
}
normalized_require_once("/conf/config.php");
normalized_require_once("/server/php/inc/App.php");
normalized_require_once("/server/php/inc/Entry.php");
normalized_require_once("/server/php/inc/util.php");
$APP = new H5ai(APP_ABS_PATH, APP_ABS_HREF);
?>