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 $adminroot = admin_get_root();
11 admin_externalpage_setup('net', $adminroot);
13 $context = get_context_instance(CONTEXT_SYSTEM
, SITEID
);
15 require_capability('moodle/site:config', $context, $USER->id
, true, "nopermissions");
18 if (!extension_loaded('openssl')) {
19 admin_externalpage_print_header($adminroot);
20 set_config('mnet_dispatcher_mode', 'off');
21 print_error('requiresopenssl', 'mnet', '', NULL, true);
24 if (!$site = get_site()) {
25 admin_externalpage_print_header($adminroot);
26 set_config('mnet_dispatcher_mode', 'off');
27 print_error('nosite', '', '', NULL, true);
30 if (!function_exists('curl_init') ) {
31 admin_externalpage_print_header($adminroot);
32 set_config('mnet_dispatcher_mode', 'off');
33 print_error('nocurl', 'mnet', '', NULL, true);
36 if (!isset($CFG->mnet_dispatcher_mode
)) {
37 set_config('mnet_dispatcher_mode', 'off');
40 /// If data submitted, process and store
41 if (($form = data_submitted()) && confirm_sesskey()) {
42 if (!empty($form->submit
) && $form->submit
== get_string('savechanges')) {
43 if (in_array($form->mode
, array("off", "strict", "promiscuous"))) {
44 if (set_config('mnet_dispatcher_mode', $form->mode
)) {
45 redirect('index.php', get_string('changessaved'));
47 error('Invalid action parameter.', 'index.php');
50 } elseif (!empty($form->submit
) && $form->submit
== get_string('delete')) {
51 $MNET->get_private_key();
52 $_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair
['keypair_PEM'])).':'.time();
53 notice_yesno(get_string("deletekeycheck", "mnet"),
54 "index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key
),
56 array('sesskey' => $USER->sesskey
),
65 if (!isset($_SESSION['mnet_confirm_delete_key'])) {
66 // fail - you're being attacked?
71 @list
($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
72 $MNET->get_private_key();
74 if($time < time() - 60) {
75 // fail - you're out of time.
76 print_error ('deleteoutoftime', 'mnet', 'index.php');
80 if ($key != md5(sha1($MNET->keypair
['keypair_PEM']))) {
81 // fail - you're being attacked?
82 print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
86 $MNET->replace_keys();
87 redirect('index.php', get_string('keydeleted','mnet'));
91 $hosts = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
93 admin_externalpage_print_header($adminroot);
96 <form method
="post" action
="index.php">
97 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
99 <td
class="generalboxcontent">
100 <table cellpadding
="9" cellspacing
="0" >
102 <td colspan
="2" class="header" cellpadding
="0"><?php
print_string('aboutyourhost', 'mnet'); ?
></td
>
105 <td align
="right"><?php
print_string('publickey', 'mnet'); ?
>:</td
>
106 <td
><pre
><?php
echo $MNET->public_key
; ?
></pre
></td
>
109 <td align
="right"><?php
print_string('expires', 'mnet'); ?
>:</td
>
110 <td
><?php
echo userdate($MNET->public_key_expires
); ?
></td
>
113 <td align
="right"><?php
print_string('net', 'mnet'); ?
>:</td
>
114 <td
><input type
="hidden" name
="sesskey" value
="<?php echo $USER->sesskey ?>" />
115 <input type
="radio" name
="mode" value
="off" <?php
echo ("off" == $CFG->mnet_dispatcher_mode
)?
'checked="true"' : '' ?
> /> <?php
print_string('off', 'mnet'); ?
> <br
/>
116 <input type
="radio" name
="mode" value
="strict" <?php
echo ("strict" == $CFG->mnet_dispatcher_mode
)?
'checked="true"' : '' ?
> /> <?php
print_string('on', 'mnet'); ?
><br
/>
117 <input type
="submit" name
="submit" value
="<?php print_string('savechanges'); ?>" />
125 <form method
="post" action
="index.php">
126 <table align
="center" width
="635" class="generalbox" border
="0" cellpadding
="5" cellspacing
="0">
128 <td
class="generalboxcontent">
129 <table cellpadding
="9" cellspacing
="0" >
131 <td colspan
="2" class="header" cellpadding
="0"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
134 <td colspan
="2" cellpadding
="0"><?php
print_string('expireyourkeyexplain', 'mnet'); ?
></td
>
137 <td align
="left" width
="10" nowrap
="nowrap"><?php
print_string('expireyourkey', 'mnet'); ?
></td
>
138 <td align
="left"><input type
="hidden" name
="sesskey" value
="<?php echo $USER->sesskey ?>" />
139 <input type
="hidden" name
="deleteKey" value
="" />
140 <input type
="submit" name
="submit" value
="<?php print_string('delete'); ?>" />
151 admin_externalpage_print_footer($adminroot);