Skip to content

Commit

Permalink
more robust hostname detection
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Dec 18, 2010
1 parent 6ac2077 commit 5627186
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions inc/init.php
Expand Up @@ -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()){
Expand Down

0 comments on commit 5627186

Please sign in to comment.