summaryrefslogtreecommitdiff
path: root/inc/init.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-12-18 10:07:04 +0100
committerAndreas Gohr <andi@splitbrain.org>2010-12-18 10:07:04 +0100
commit5627186c2f8b450460892f0247dbbb5f8d4369b4 (patch)
tree6aae24db8d62d5a5586381b51a03832c9e3300c0 /inc/init.php
parent6ac2077a96f206f26714699c001c72f914bf7970 (diff)
downloadrpg-5627186c2f8b450460892f0247dbbb5f8d4369b4.tar.gz
rpg-5627186c2f8b450460892f0247dbbb5f8d4369b4.tar.bz2
more robust hostname detection
as discussed in http://www.freelists.org/post/dokuwiki/git-changes-20101209,7
Diffstat (limited to 'inc/init.php')
-rw-r--r--inc/init.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/inc/init.php b/inc/init.php
index ed4409729..3b438f15b 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -419,12 +419,16 @@ 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'])){
+ list($host,$port) = explode(':',$_SERVER['HTTP_HOST']);
+ }elseif(isset($_SERVER['SERVER_NAME'])){
+ list($host,$port) = explode(':',$_SERVER['SERVER_NAME']);
+ }else{
+ $host = php_uname('n');
+ $port = '';
+ }
+
+ if(!$port && isset($_SERVER['SERVER_PORT'])) {
$port = $_SERVER['SERVER_PORT'];
}
if(!is_ssl()){