diff options
Diffstat (limited to 'inc/init.php')
-rw-r--r-- | inc/init.php | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/inc/init.php b/inc/init.php index ed4409729..819d92bdc 100644 --- a/inc/init.php +++ b/inc/init.php @@ -5,13 +5,12 @@ // start timing Dokuwiki execution function delta_time($start=0) { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec+(float)$sec)-((float)$start); + return microtime(true)-((float)$start); } define('DOKU_START_TIME', delta_time()); global $config_cascade; -$config_cascade = ''; +$config_cascade = array(); // if available load a preload config file $preload = fullpath(dirname(__FILE__)).'/preload.php'; @@ -52,10 +51,9 @@ global $cache_authname; global $cache_metadata; $cache_metadata = array(); -//set the configuration cascade - but only if its not already been set in preload.php -if (empty($config_cascade)) { - include(DOKU_INC.'inc/config_cascade.php'); -} +// always include 'inc/config_cascade.php' +// previously in preload.php set fields of $config_cascade will be merged with the defaults +include(DOKU_INC.'inc/config_cascade.php'); //prepare config array() global $conf; @@ -276,6 +274,7 @@ function init_files(){ } # create title index (needs to have same length as page.idx) + /* $file = $conf['indexdir'].'/title.idx'; if(!@file_exists($file)){ $pages = file($conf['indexdir'].'/page.idx'); @@ -290,6 +289,7 @@ function init_files(){ nice_die("$file is not writable. Check your permissions settings!"); } } + */ } /** @@ -419,14 +419,27 @@ function getBaseURL($abs=null){ if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir; //split hostheader into host and port - $addr = explode(':',$_SERVER['HTTP_HOST']); - $host = $addr[0]; - $port = ''; - if (isset($addr[1])) { - $port = $addr[1]; - } elseif (isset($_SERVER['SERVER_PORT'])) { + if(isset($_SERVER['HTTP_HOST'])){ + $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; + }elseif(isset($_SERVER['SERVER_NAME'])){ + $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; + }else{ + $host = php_uname('n'); + $port = ''; + } + + if(!$port && isset($_SERVER['SERVER_PORT'])) { $port = $_SERVER['SERVER_PORT']; } + + if(is_null($port)){ + $port = ''; + } + if(!is_ssl()){ $proto = 'http://'; if ($port == '80') { |