exit; } } } else { $credentials = $mnet_peer->check_credentials($mnet_peer->public_key); } // PREVENT DUPLICATE RECORDS /////////////////////////////////////////// if ('input' == $form->step) { if (isset($mnet_peer->id) && $mnet_peer->id > 0) { print_error("hostexists", 'mnet', 'peers.php?step=update&hostid=' . $mnet_peer->id, $mnet_peer->id); } } if ('input' == $form->step) { include './mnet_review.html'; } elseif ('commit' == $form->step) { $bool = $mnet_peer->commit(); if ($bool) { redirect('peers.php?step=update&hostid=' . $mnet_peer->id, get_string('changessaved')); } else { print_error('invalidaction', 'error', 'index.php'); } } } } elseif (is_int($hostid)) { $mnet_peer = new mnet_peer(); $mnet_peer->set_id($hostid); $currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application); if ($currentkey == $mnet_peer->public_key) { unset($currentkey); } $form = new stdClass();
if ($peer->id == $CFG->mnet_all_hosts_id || $peer->id == $CFG->mnet_localhost_id) { continue; } $application = $DB->get_record('mnet_application', array('id' => $peer->applicationid)); $mnet_peer = new mnet_peer(); $mnet_peer->set_wwwroot($peer->wwwroot); // get the sessions for each vmoodle that have same ID Number // we use a force parameter to force fetching the key remotely anyway $currentkey = mnet_get_public_key($mnet_peer->wwwroot, $application, 1); if ($currentkey) { $mnet_peer->public_key = clean_param($currentkey, PARAM_PEM); $mnet_peer->updateparams = new StdClass(); $mnet_peer->updateparams->public_key = clean_param($currentkey, PARAM_PEM); $mnet_peer->public_key_expires = $mnet_peer->check_common_name($currentkey); $mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($currentkey); $mnet_peer->commit(); mtrace('My key renewed at ' . $peer->wwwroot . ' till ' . userdate($mnet_peer->public_key_expires)); $trace .= userdate(time()) . ' KEY RENEW from ' . $CFG->wwwroot . ' to ' . $peer->wwwroot . " suceeded\n"; } else { mtrace('Failed renewing key with ' . $peer->wwwroot . "\n"); $trace .= userdate(time()) . ' KEY RENEW from ' . $CFG->wwwroot . ' to ' . $peer->wwwroot . " failed\n"; } } } set_config('mnet_autorenew_haveto', 0); $trace .= userdate(time()) . ' RESET KEY RENEW on ' . $CFG->wwwroot . "\n"; /// record trace in trace file if ($CFG->tracevmoodlekeyrenew) { if ($TRACE = fopen($CFG->dataroot . '/vmoodle_renew.log', 'w+')) { fputs($TRACE, $trace); fclose($TRACE);
/** * Accepts a public key from a new remote host and returns the public key for * this host. If 'register all hosts' is turned on, it will bootstrap a record * for the remote host in the mnet_host table (if it's not already there) * * @param string $function XML-RPC requires this but we don't... discard! * @param array $params Array of parameters * $params[0] is the remote wwwroot * $params[1] is the remote public key * @return string The XML-RPC response */ function mnet_keyswap($function, $params) { global $CFG; $return = array(); $mnet = get_mnet_environment(); if (!empty($CFG->mnet_register_allhosts)) { $mnet_peer = new mnet_peer(); @list($wwwroot, $pubkey, $application) = each($params); $keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application); if ($keyok) { $mnet_peer->commit(); } } return $mnet->public_key; }
$strpreview = get_string("preview"); $strchoose = get_string("choose"); $strinfo = get_string("info"); $strtheme = get_string("theme"); $strthemesaved = get_string("themesaved"); $strscreenshot = get_string("screenshot"); $stroldtheme = get_string("oldtheme"); $report = array(); $unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name if ($choose) { if (confirm_sesskey()) { if ($choose == $unlikely_name) { $mnet_peer->force_theme = 1; $mnet_peer->theme = ''; if ($mnet_peer->commit()) { $report = array(get_string('themesaved'), 'informationbox'); } else { $report = array(get_string('themesavederror', 'mnet'), 'errorbox'); } } elseif (!is_dir($CFG->themedir . '/' . $choose) || !file_exists($CFG->themedir . '/' . $choose . '/config.php')) { echo 'CHOOSE -' . $choose . ' ' . $CFG->themedir . '/' . $choose . '/config.php'; $report = array('This theme is not installed!' . '3', 'errorbox'); } else { $mnet_peer->force_theme = 1; $mnet_peer->theme = $choose; if ($mnet_peer->commit()) { $report = array(get_string('themesaved') . '1', 'informationbox'); } else { $report = array(get_string('themesavederror', 'mnet') . '2', 'errorbox'); }
/** * Accepts a public key from a new remote host and returns the public key for * this host. If 'register all hosts' is turned on, it will bootstrap a record * for the remote host in the mnet_host table (if it's not already there) * * @param string $function XML-RPC requires this but we don't... discard! * @param array $params Array of parameters * $params[0] is the remote wwwroot * $params[1] is the remote public key * @return string The XML-RPC response */ function mnet_keyswap($function, $params) { global $CFG, $MNET; $return = array(); if (!empty($CFG->mnet_register_allhosts)) { $mnet_peer = new mnet_peer(); $keyok = $mnet_peer->bootstrap($params[0], $params[1]); if ($keyok) { $mnet_peer->commit(); } } return $MNET->public_key; }
/** * NOT WORKING * reimplementation of system.keyswapcall with capability of forcing the local renew * */ function mnetadmin_keyswap($function, $params) { global $CFG, $MNET; $return = array(); $wwwroot = $params[0]; $pubkey = $params[1]; $application = $params[2]; $forcerenew = $params[3]; if ($forcerenew == 0) { // standard keyswap for first key recording if (!empty($CFG->mnet_register_allhosts)) { $mnet_peer = new mnet_peer(); $keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application); if ($keyok) { $mnet_peer->commit(); } } } else { $mnet_peer = new mnet_peer(); // we can only renew hosts that we know something about. if ($mnet_peer->set_wwwroot($wwwroot)) { $mnet_peer->public_key = clean_param($pubkey, PARAM_PEM); $mnet_peer->public_key_expires = $mnet_peer->check_common_name($pubkey); $mnet_peer->updateparams->public_key = clean_param($pubkey, PARAM_PEM); $mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($pubkey); $mnet_peer->commit(); } else { return false; // avoid giving our key to unkown hosts. } } return $MNET->public_key; }