From ed7b5f0908941f1bacef7e7c3a02c106a42cd5cc Mon Sep 17 00:00:00 2001 From: andi Date: Sat, 19 Feb 2005 11:20:55 +0100 Subject: added init.php - may have broken something! (related to #153) darcs-hash:20050219102055-9977f-575d654e742934c911ffab855d82aa91f198b5cf.gz --- inc/init.php | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 inc/init.php (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php new file mode 100644 index 000000000..9314008e1 --- /dev/null +++ b/inc/init.php @@ -0,0 +1,110 @@ + + */ +function remove_magic_quotes(&$array) { + foreach (array_keys($array) as $key) { + if (is_array($array[$key])) { + remove_magic_quotes($array[$key]); + }else { + $array[$key] = stripslashes($array[$key]); + } + } +} + +/** + * Returns the full absolute URL to the directory where + * DokuWiki is installed in (includes a trailing slash) + * + * @author Andreas Gohr + */ +function getBaseURL($abs=false){ + global $conf; + //if canonical url enabled always return absolute + if($conf['canonical']) $abs = true; + + $dir = dirname($_SERVER['PHP_SELF']).'/'; + + $dir = str_replace('\\','/',$dir); #bugfix for weird WIN behaviour + $dir = preg_replace('#//+#','/',$dir); + + //finish here for relative URLs + if(!$abs) return $dir; + + $port = ':'.$_SERVER['SERVER_PORT']; + //remove port from hostheader as sent by IE + $host = preg_replace('/:.*$/','',$_SERVER['HTTP_HOST']); + + // see if HTTPS is enabled - apache leaves this empty when not available, + // IIS sets it to 'off', 'false' and 'disabled' are just guessing + if (preg_match('/^(|off|false|disabled)$/i',$_SERVER['HTTPS'])){ + $proto = 'http://'; + if ($_SERVER['SERVER_PORT'] == '80') { + $port=''; + } + }else{ + $proto = 'https://'; + if ($_SERVER['SERVER_PORT'] == '443') { + $port=''; + } + } + + return $proto.$host.$port.$dir; +} + + +?> -- cgit v1.2.3