2014-06-18 16:30:04 +08:00
|
|
|
<?php
|
2007-01-04 02:33:51 +00:00
|
|
|
|
|
|
|
// Allows the admin to configure mnet stuff
|
|
|
|
|
2016-02-26 17:47:58 +11:00
|
|
|
require(__DIR__.'/../../config.php');
|
2007-01-04 02:33:51 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
include_once($CFG->dirroot.'/mnet/lib.php');
|
|
|
|
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_setup('net');
|
2007-01-04 02:33:51 +00:00
|
|
|
|
2012-07-23 14:33:02 +08:00
|
|
|
$context = context_system::instance();
|
2007-01-04 02:33:51 +00:00
|
|
|
|
|
|
|
|
2009-11-01 09:21:41 +00:00
|
|
|
$site = get_site();
|
2010-02-02 03:13:40 +00:00
|
|
|
$mnet = get_mnet_environment();
|
2007-01-05 08:46:10 +00:00
|
|
|
|
|
|
|
if (!extension_loaded('openssl')) {
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2007-01-09 12:31:09 +00:00
|
|
|
set_config('mnet_dispatcher_mode', 'off');
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('requiresopenssl', 'mnet');
|
2007-01-04 02:33:51 +00:00
|
|
|
}
|
|
|
|
|
2007-01-05 08:46:10 +00:00
|
|
|
if (!function_exists('curl_init') ) {
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2007-01-09 12:31:09 +00:00
|
|
|
set_config('mnet_dispatcher_mode', 'off');
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('nocurl', 'mnet');
|
2007-01-04 06:19:56 +00:00
|
|
|
}
|
|
|
|
|
2007-01-09 12:31:09 +00:00
|
|
|
if (!isset($CFG->mnet_dispatcher_mode)) {
|
|
|
|
set_config('mnet_dispatcher_mode', 'off');
|
|
|
|
}
|
2007-01-04 02:33:51 +00:00
|
|
|
|
|
|
|
/// If data submitted, process and store
|
2008-06-09 16:53:30 +00:00
|
|
|
if (($form = data_submitted()) && confirm_sesskey()) {
|
2007-01-04 03:37:42 +00:00
|
|
|
if (!empty($form->submit) && $form->submit == get_string('savechanges')) {
|
2007-08-02 05:27:06 +00:00
|
|
|
if (in_array($form->mode, array("off", "strict", "dangerous"))) {
|
2007-01-04 03:37:42 +00:00
|
|
|
if (set_config('mnet_dispatcher_mode', $form->mode)) {
|
|
|
|
redirect('index.php', get_string('changessaved'));
|
|
|
|
} else {
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('invalidaction', '', 'index.php');
|
2007-01-04 03:37:42 +00:00
|
|
|
}
|
2007-01-04 02:33:51 +00:00
|
|
|
}
|
2007-01-04 03:37:42 +00:00
|
|
|
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
2010-02-02 03:13:40 +00:00
|
|
|
$mnet->get_private_key();
|
|
|
|
$SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time();
|
2009-08-20 08:39:07 +00:00
|
|
|
|
2010-02-02 03:13:40 +00:00
|
|
|
$formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes'));
|
2010-01-28 07:25:42 +00:00
|
|
|
$formcancel = new single_button(new moodle_url('index.php', array()), get_string('no'));
|
2022-12-01 13:51:03 +07:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2009-08-20 08:39:07 +00:00
|
|
|
echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel);
|
2022-12-01 13:51:03 +07:00
|
|
|
echo $OUTPUT->footer();
|
2007-01-04 03:37:42 +00:00
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
// We're deleting
|
2009-11-01 10:32:02 +00:00
|
|
|
|
2022-12-01 13:51:03 +07:00
|
|
|
// If no/cancel then redirect back to the network setting page.
|
|
|
|
if (!isset($form->confirm)) {
|
|
|
|
redirect(
|
|
|
|
new moodle_url('/admin/mnet/index.php'),
|
|
|
|
get_string('keydeletedcancelled', 'mnet'),
|
|
|
|
null,
|
|
|
|
\core\output\notification::NOTIFY_SUCCESS
|
|
|
|
);
|
|
|
|
}
|
2009-11-01 10:32:02 +00:00
|
|
|
|
2008-06-25 17:31:23 +00:00
|
|
|
if (!isset($SESSION->mnet_confirm_delete_key)) {
|
2007-01-04 03:37:42 +00:00
|
|
|
// fail - you're being attacked?
|
|
|
|
}
|
|
|
|
|
|
|
|
$key = '';
|
|
|
|
$time = '';
|
2008-06-25 17:31:23 +00:00
|
|
|
@list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
|
2010-02-02 03:13:40 +00:00
|
|
|
$mnet->get_private_key();
|
2007-01-04 03:37:42 +00:00
|
|
|
|
|
|
|
if($time < time() - 60) {
|
|
|
|
// fail - you're out of time.
|
2022-12-01 13:51:03 +07:00
|
|
|
redirect(
|
|
|
|
new moodle_url('/admin/mnet/index.php'),
|
|
|
|
get_string('deleteoutoftime', 'mnet'),
|
|
|
|
null,
|
|
|
|
\core\output\notification::NOTIFY_WARNING
|
|
|
|
);
|
2007-01-04 03:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 03:13:40 +00:00
|
|
|
if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
|
2007-01-04 03:37:42 +00:00
|
|
|
// fail - you're being attacked?
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception ('deletewrongkeyvalue', 'mnet', 'index.php');
|
2007-01-04 03:37:42 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2010-02-02 03:13:40 +00:00
|
|
|
$mnet->replace_keys();
|
2007-01-04 03:37:42 +00:00
|
|
|
redirect('index.php', get_string('keydeleted','mnet'));
|
2007-01-04 02:33:51 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-31 11:41:26 +00:00
|
|
|
$hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');
|
2007-01-04 05:16:21 +00:00
|
|
|
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2007-01-04 05:16:21 +00:00
|
|
|
?>
|
|
|
|
<form method="post" action="index.php">
|
2013-01-20 21:52:09 +00:00
|
|
|
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
2007-01-04 05:16:21 +00:00
|
|
|
<tr>
|
|
|
|
<td class="generalboxcontent">
|
|
|
|
<table cellpadding="9" cellspacing="0" >
|
|
|
|
<tr valign="top">
|
2010-09-17 10:33:40 +00:00
|
|
|
<td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td>
|
2007-01-04 05:16:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr valign="top">
|
2007-01-05 05:58:39 +00:00
|
|
|
<td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
|
2010-02-02 03:13:40 +00:00
|
|
|
<td><pre><?php echo $mnet->public_key; ?></pre></td>
|
2007-01-04 05:16:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr valign="top">
|
2007-01-15 09:14:41 +00:00
|
|
|
<td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
|
2010-02-02 03:13:40 +00:00
|
|
|
<td><?php echo userdate($mnet->public_key_expires); ?></td>
|
2007-01-15 09:14:41 +00:00
|
|
|
</tr>
|
2007-01-04 05:16:21 +00:00
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<form method="post" action="index.php">
|
2013-01-20 21:52:09 +00:00
|
|
|
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
2007-01-04 05:16:21 +00:00
|
|
|
<tr>
|
|
|
|
<td class="generalboxcontent">
|
|
|
|
<table cellpadding="9" cellspacing="0" >
|
|
|
|
<tr valign="top">
|
2010-09-17 10:33:40 +00:00
|
|
|
<td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
2007-01-04 05:16:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr valign="top">
|
2010-09-17 10:33:40 +00:00
|
|
|
<td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
|
2007-01-04 05:16:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr valign="top">
|
2007-01-04 06:13:20 +00:00
|
|
|
<td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
2009-01-02 10:36:25 +00:00
|
|
|
<td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
2007-01-04 05:16:21 +00:00
|
|
|
<input type="hidden" name="deleteKey" value="" />
|
|
|
|
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|