Permalink
Browse files

MDL-15008: mnet/environment.php: Update wwwroot/ip_address when key i…

…s deleted/recreated.
  • Loading branch information...
cataluke
cataluke committed Jun 12, 2008
1 parent 2f2bcbc commit e47ac6818b9310d7900b4e515f340f5bb66a0972
Showing with 15 additions and 1 deletion.
  1. +15 −1 mnet/environment.php
View
@@ -150,14 +150,28 @@ function get_keypair() {
}
function replace_keys() {
global $DB;
global $DB, $CFG;
$this->keypair = array();
$this->keypair = mnet_generate_keypair();
$this->public_key = $this->keypair['certificate'];
$details = openssl_x509_parse($this->public_key);
$this->public_key_expires = $details['validTo_time_t'];
$this->wwwroot = $CFG->wwwroot;
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');
$DB->update_record('mnet_host', $this);

0 comments on commit e47ac68

Please sign in to comment.