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 if (!extension_loaded('openssl')) {
18 admin_externalpage_print_header();
19 set_config('mnet_dispatcher_mode', 'off');
20 print_error('requiresopenssl', 'mnet', '', NULL, true);
23 if (!$site = get_site()) {
24 admin_externalpage_print_header();
25 set_config('mnet_dispatcher_mode', 'off');
26 print_error('nosite', '', '', NULL, true);
29 if (!function_exists('curl_init') ) {
30 admin_externalpage_print_header();
31 set_config('mnet_dispatcher_mode', 'off');
32 print_error('nocurl', 'mnet', '', NULL, true);
35 if (!isset($CFG->mnet_dispatcher_mode
)) {
36 set_config('mnet_dispatcher_mode', 'off');
39 /// If data submitted, process and store
40 if (($form = data_submitted()) && confirm_sesskey()) {
41 if (!empty($form->submit
) && $form->submit
== get_string('savechanges')) {
42 if (in_array($form->mode
, array("off", "strict", "dangerous"))) {
43 if (set_config('mnet_dispatcher_mode', $form->mode
)) {
44 redirect('index.php', get_string('changessaved'));
46 error('Invalid action parameter.', 'index.php');
49 } elseif (!empty($form->submit
) && $form->submit
== get_string('delete')) {
50 $MNET->get_private_key();
51 $_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair
['keypair_PEM'])).':'.time();
52 notice_yesno(get_string("deletekeycheck", "mnet"),
53 "index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key
),
55 array('sesskey' => $USER->sesskey
),
64 if (!isset($_SESSION['mnet_confirm_delete_key'])) {
65 // fail - you're being attacked?
70 @list
($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
71 $MNET->get_private_key();
73 if($time < time() - 60) {
74 // fail - you're out of time.
75 print_error ('deleteoutoftime', 'mnet', 'index.php');
79 if ($key != md5(sha1($MNET->keypair
['keypair_PEM']))) {
80 // fail - you're being attacked?
81 print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
85 $MNET->replace_keys();
86 redirect('index.php', get_string('keydeleted','mnet'));
90 $hosts = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
92 admin_externalpage_print_header();
95 <form method
="post" action
="index.php">
96 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
98 <td
class="generalboxcontent">
99 <table cellpadding
="9" cellspacing
="0" >
101 <td colspan
="2" class="header" cellpadding
="0"><?php
print_string('aboutyourhost', 'mnet'); ?
></td
>
104 <td align
="right"><?php
print_string('publickey', 'mnet'); ?
>:</td
>
105 <td
><pre
><?php
echo $MNET->public_key
; ?
></pre
></td
>
108 <td align
="right"><?php
print_string('expires', 'mnet'); ?
>:</td
>
109 <td
><?php
echo userdate($MNET->public_key_expires
); ?
></td
>
112 <td align
="right"><?php
print_string('net', 'mnet'); ?
>:</td
>
113 <td
><input type
="hidden" name
="sesskey" value
="<?php echo $USER->sesskey ?>" />
114 <input type
="radio" name
="mode" value
="off" <?php
echo ("off" == $CFG->mnet_dispatcher_mode
)?
'checked="checked"' : '' ?
> /> <?php
print_string('off', 'mnet'); ?
> <br
/>
115 <input type
="radio" name
="mode" value
="strict" <?php
echo ("strict" == $CFG->mnet_dispatcher_mode
)?
'checked="checked"' : '' ?
> /> <?php
print_string('on', 'mnet'); ?
><br
/>
116 <input type
="submit" name
="submit" value
="<?php print_string('savechanges'); ?>" />
124 <form method
="post" action
="index.php">
125 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
127 <td
class="generalboxcontent">
128 <table cellpadding
="9" cellspacing
="0" >
130 <td colspan
="2" class="header" cellpadding
="0"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
133 <td colspan
="2" cellpadding
="0"><?php
print_string('expireyourkeyexplain', 'mnet'); ?
></td
>
136 <td align
="left" width
="10" nowrap
="nowrap"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
137 <td align
="left"><input type
="hidden" name
="sesskey" value
="<?php echo $USER->sesskey ?>" />
138 <input type
="hidden" name
="deleteKey" value
="" />
139 <input type
="submit" name
="submit" value
="<?php print_string('delete'); ?>" />
150 admin_externalpage_print_footer();