3 // Allows the admin to configure mnet stuff
5 require_once(dirname(dirname(dirname(__FILE__
))) . '/config.php');
6 require_once($CFG->libdir
.'/adminlib.php');
7 include_once($CFG->dirroot
.'/mnet/lib.php');
10 admin_externalpage_setup('net');
12 $context = get_context_instance(CONTEXT_SYSTEM
);
14 require_capability('moodle/site:config', $context, $USER->id
, true, "nopermissions");
17 $mnet = get_mnet_environment();
19 if (!extension_loaded('openssl')) {
20 echo $OUTPUT->header();
21 set_config('mnet_dispatcher_mode', 'off');
22 print_error('requiresopenssl', 'mnet');
25 if (!function_exists('curl_init') ) {
26 echo $OUTPUT->header();
27 set_config('mnet_dispatcher_mode', 'off');
28 print_error('nocurl', 'mnet');
31 if (!isset($CFG->mnet_dispatcher_mode
)) {
32 set_config('mnet_dispatcher_mode', 'off');
35 /// If data submitted, process and store
36 if (($form = data_submitted()) && confirm_sesskey()) {
37 if (!empty($form->submit
) && $form->submit
== get_string('savechanges')) {
38 if (in_array($form->mode
, array("off", "strict", "dangerous"))) {
39 if (set_config('mnet_dispatcher_mode', $form->mode
)) {
40 redirect('index.php', get_string('changessaved'));
42 print_error('invalidaction', '', 'index.php');
45 } elseif (!empty($form->submit
) && $form->submit
== get_string('delete')) {
46 $mnet->get_private_key();
47 $SESSION->mnet_confirm_delete_key
= md5(sha1($mnet->keypair
['keypair_PEM'])).':'.time();
49 $formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key
))), get_string('yes'));
50 $formcancel = new single_button(new moodle_url('index.php', array()), get_string('no'));
51 echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel);
57 if (!isset($SESSION->mnet_confirm_delete_key
)) {
58 // fail - you're being attacked?
63 @list
($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key
);
64 $mnet->get_private_key();
66 if($time < time() - 60) {
67 // fail - you're out of time.
68 print_error ('deleteoutoftime', 'mnet', 'index.php');
72 if ($key != md5(sha1($mnet->keypair
['keypair_PEM']))) {
73 // fail - you're being attacked?
74 print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
78 $mnet->replace_keys();
79 redirect('index.php', get_string('keydeleted','mnet'));
83 $hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id
), 'wwwroot ASC');
85 echo $OUTPUT->header();
87 <form method
="post" action
="index.php">
88 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
90 <td
class="generalboxcontent">
91 <table cellpadding
="9" cellspacing
="0" >
93 <td colspan
="2" class="header"><?php
print_string('aboutyourhost', 'mnet'); ?
></td
>
96 <td align
="right"><?php
print_string('publickey', 'mnet'); ?
>:</td
>
97 <td
><pre
><?php
echo $mnet->public_key
; ?
></pre
></td
>
100 <td align
="right"><?php
print_string('expires', 'mnet'); ?
>:</td
>
101 <td
><?php
echo userdate($mnet->public_key_expires
); ?
></td
>
108 <form method
="post" action
="index.php">
109 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
111 <td
class="generalboxcontent">
112 <table cellpadding
="9" cellspacing
="0" >
114 <td colspan
="2" class="header"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
117 <td colspan
="2"><?php
print_string('expireyourkeyexplain', 'mnet'); ?
></td
>
120 <td align
="left" width
="10" nowrap
="nowrap"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
121 <td align
="left"><input type
="hidden" name
="sesskey" value
="<?php echo sesskey() ?>" />
122 <input type
="hidden" name
="deleteKey" value
="" />
123 <input type
="submit" name
="submit" value
="<?php print_string('delete'); ?>" />
133 echo $OUTPUT->footer();