From: donal72 Date: Mon, 26 Mar 2007 22:51:37 +0000 (+0000) Subject: Patch for upgrade breakage on IIS (and maybe other non-Apache webservers) MDL-8926 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=dd9f1b7df5482716a702aac74ffc279cb5e4b88f;p=moodle.git Patch for upgrade breakage on IIS (and maybe other non-Apache webservers) MDL-8926 --- diff --git a/mnet/environment.php b/mnet/environment.php index 1fd7dda4c3..6fc97a2ecf 100644 --- a/mnet/environment.php +++ b/mnet/environment.php @@ -32,7 +32,18 @@ class mnet_environment { if (empty($CFG->mnet_localhost_id) ) { $this->wwwroot = $CFG->wwwroot; - $this->ip_address = $_SERVER['SERVER_ADDR']; + if(empty($_SERVER['SERVER_ADDR'])) { + // SERVER_ADDR is only returned by Apache-like webservers + $my_hostname = mnet_get_hostname_from_uri($CFG->wwwroot); + $my_ip = gethostbyname($my_hostname); // Returns unmodified hostname on failure. DOH! + if($my_ip == $my_hostname) { + $this->ip_address = 'UNKNOWN'; + } else { + $this->ip_address = $my_ip; + } + } else { + $this->ip_address = $_SERVER['SERVER_ADDR']; + } $this->id = insert_record('mnet_host', $this, true); set_config('mnet_localhost_id', $this->id);