Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 // Allows the admin to configure mnet stuff 4 5 require(__DIR__.'/../../config.php'); 6 require_once($CFG->libdir.'/adminlib.php'); 7 include_once($CFG->dirroot.'/mnet/lib.php'); 8 9 admin_externalpage_setup('net'); 10 11 $context = context_system::instance(); 12 13 14 $site = get_site(); 15 $mnet = get_mnet_environment(); 16 17 if (!extension_loaded('openssl')) { 18 echo $OUTPUT->header(); 19 set_config('mnet_dispatcher_mode', 'off'); 20 print_error('requiresopenssl', 'mnet'); 21 } 22 23 if (!function_exists('curl_init') ) { 24 echo $OUTPUT->header(); 25 set_config('mnet_dispatcher_mode', 'off'); 26 print_error('nocurl', 'mnet'); 27 } 28 29 if (!isset($CFG->mnet_dispatcher_mode)) { 30 set_config('mnet_dispatcher_mode', 'off'); 31 } 32 33 /// If data submitted, process and store 34 if (($form = data_submitted()) && confirm_sesskey()) { 35 if (!empty($form->submit) && $form->submit == get_string('savechanges')) { 36 if (in_array($form->mode, array("off", "strict", "dangerous"))) { 37 if (set_config('mnet_dispatcher_mode', $form->mode)) { 38 redirect('index.php', get_string('changessaved')); 39 } else { 40 print_error('invalidaction', '', 'index.php'); 41 } 42 } 43 } elseif (!empty($form->submit) && $form->submit == get_string('delete')) { 44 $mnet->get_private_key(); 45 $SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time(); 46 47 $formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes')); 48 $formcancel = new single_button(new moodle_url('index.php', array()), get_string('no')); 49 50 echo $OUTPUT->header(); 51 echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel); 52 echo $OUTPUT->footer(); 53 exit; 54 } else { 55 // We're deleting 56 57 // If no/cancel then redirect back to the network setting page. 58 if (!isset($form->confirm)) { 59 redirect( 60 new moodle_url('/admin/mnet/index.php'), 61 get_string('keydeletedcancelled', 'mnet'), 62 null, 63 \core\output\notification::NOTIFY_SUCCESS 64 ); 65 } 66 67 if (!isset($SESSION->mnet_confirm_delete_key)) { 68 // fail - you're being attacked? 69 } 70 71 $key = ''; 72 $time = ''; 73 @list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key); 74 $mnet->get_private_key(); 75 76 if($time < time() - 60) { 77 // fail - you're out of time. 78 redirect( 79 new moodle_url('/admin/mnet/index.php'), 80 get_string('deleteoutoftime', 'mnet'), 81 null, 82 \core\output\notification::NOTIFY_WARNING 83 ); 84 } 85 86 if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) { 87 // fail - you're being attacked? 88 print_error ('deletewrongkeyvalue', 'mnet', 'index.php'); 89 exit; 90 } 91 92 $mnet->replace_keys(); 93 redirect('index.php', get_string('keydeleted','mnet')); 94 } 95 } 96 $hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC'); 97 98 echo $OUTPUT->header(); 99 echo $OUTPUT->render(mnet_get_deprecation_notice()); 100 ?> 101 <form method="post" action="index.php"> 102 <table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0"> 103 <tr> 104 <td class="generalboxcontent"> 105 <table cellpadding="9" cellspacing="0" > 106 <tr valign="top"> 107 <td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td> 108 </tr> 109 <tr valign="top"> 110 <td align="right"><?php print_string('publickey', 'mnet'); ?>:</td> 111 <td><pre><?php echo $mnet->public_key; ?></pre></td> 112 </tr> 113 <tr valign="top"> 114 <td align="right"><?php print_string('expires', 'mnet'); ?>:</td> 115 <td><?php echo userdate($mnet->public_key_expires); ?></td> 116 </tr> 117 </table> 118 </td> 119 </tr> 120 </table> 121 </form> 122 <form method="post" action="index.php"> 123 <table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0"> 124 <tr> 125 <td class="generalboxcontent"> 126 <table cellpadding="9" cellspacing="0" > 127 <tr valign="top"> 128 <td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td> 129 </tr> 130 <tr valign="top"> 131 <td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td> 132 </tr> 133 <tr valign="top"> 134 <td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td> 135 <td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" /> 136 <input type="hidden" name="deleteKey" value="" /> 137 <input type="submit" name="submit" value="<?php print_string('delete'); ?>" /> 138 </td> 139 </tr> 140 </table> 141 </td> 142 </tr> 143 </table> 144 </form> 145 146 <?php 147 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body