diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-09-07 23:35:43 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-09-07 23:35:43 +0200 |
commit | e82e35266a7ac6c07c616136e5f5a6cf27432730 (patch) | |
tree | 450686023c7cfce731f676119e245d1092a3d984 | |
parent | df45e1b420905ab4293b733f28c142271ae0c092 (diff) | |
download | rpg-e82e35266a7ac6c07c616136e5f5a6cf27432730.tar.gz rpg-e82e35266a7ac6c07c616136e5f5a6cf27432730.tar.bz2 |
fixed handling of non standard ports
darcs-hash:20050907213543-7ad00-c411e9f5788bf2629ba8529c46d7247aff1a2305.gz
-rw-r--r-- | inc/init.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/inc/init.php b/inc/init.php index 904fa1726..092d023c3 100644 --- a/inc/init.php +++ b/inc/init.php @@ -176,24 +176,27 @@ function getBaseURL($abs=false){ //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']); + //split hostheader into host and port + list($host,$port) = explode(':',$_SERVER['HTTP_HOST']); + if(!$port) $port = $_SERVER['SERVER_PORT']; + if(!$port) $port = 80; // 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') { + if ($port == '80') { $port=''; } }else{ $proto = 'https://'; - if ($_SERVER['SERVER_PORT'] == '443') { + if ($port == '443') { $port=''; } } + if($port) $port = ':'.$port; + return $proto.$host.$port.$dir; } |