From: Brion Vibber Date: Mon, 27 Sep 2004 04:43:29 +0000 (+0000) Subject: Shut up PHP notification warnings about $_SERVER['SERVER_NAME'] X-Git-Tag: 1.5.0alpha1~1757 X-Git-Url: http://git.cyclocoop.org/geomaker.php?a=commitdiff_plain;h=5e6faed41f3fc598615a8c5f81dd37fa51c6ed6a;p=lhc%2Fweb%2Fwiklou.git Shut up PHP notification warnings about $_SERVER['SERVER_NAME'] being unaccessible from the command line. Fall back to $_SERVER['HOSTNAME'] or 'localhost' if not available. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d7049c613a..14072774ab 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -42,14 +42,22 @@ $wgMetaNamespace = FALSE; * @global string $wgServer */ $wgServer = ''; + +if( isset( $_SERVER['SERVER_NAME'] ) ) { + $wgServerName = $_SERVER['SERVER_NAME']; +} elseif( isset( $_SERVER['HOSTNAME'] ) ) { + $wgServerName = $_SERVER['HOSTNAME']; +} else { + # FIXME: Fall back on... something else? + $wgServerName = 'localhost'; +} + # check if server use https: $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; -if ( @$wgCommandLineMode ) { - $wgServer = $wgProto.'://localhost'; -} else { - $wgServer = $wgProto.'://' . $_SERVER['SERVER_NAME']; - if( $_SERVER['SERVER_PORT'] != 80 ) $wgServer .= ":" . $_SERVER['SERVER_PORT']; +$wgServer = $wgProto.'://' . $wgServerName; +if( isset( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] != 80 ) { + $wgServer .= ":" . $_SERVER['SERVER_PORT']; } unset($wgProto); @@ -118,7 +126,7 @@ $wgUploadBaseUrl = ""; * Default to wikiadmin@SERVER_NAME * @global string $wgEmergencyContact */ -$wgEmergencyContact = 'wikiadmin@' . $_SERVER['SERVER_NAME']; +$wgEmergencyContact = 'wikiadmin@' . $wgServerName; /** * Password reminder email address @@ -126,7 +134,7 @@ $wgEmergencyContact = 'wikiadmin@' . $_SERVER['SERVER_NAME']; * Default to apache@SERVER_NAME * @global string $wgPasswordSender */ -$wgPasswordSender = 'Wikipedia Mail '; +$wgPasswordSender = 'Wikipedia Mail '; /**