From 599653847414bd175d13ddfbae02b3ceb70b00e7 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Thu, 31 Jul 2008 15:00:35 +0000 Subject: [PATCH] MDL-15148 In fact, getting IP lookup too from MDL-15008 by Lue Hudson. --- mnet/environment.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mnet/environment.php b/mnet/environment.php index 8734cc73f..ff0b6d1c8 100644 --- a/mnet/environment.php +++ b/mnet/environment.php @@ -155,7 +155,18 @@ class mnet_environment { $this->wwwroot = $CFG->wwwroot; $details = openssl_x509_parse($this->public_key); $this->public_key_expires = $details['validTo_time_t']; - + 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']; + } set_config('openssl', implode('@@@@@@@@', $this->keypair), 'mnet'); update_record('mnet_host', $this); -- 2.11.4.GIT