|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?PHP 00002 00003 // Allows the admin to configure mnet stuff 00004 00005 require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); 00006 require_once($CFG->libdir.'/adminlib.php'); 00007 include_once($CFG->dirroot.'/mnet/lib.php'); 00008 00009 require_login(); 00010 admin_externalpage_setup('net'); 00011 00012 $context = get_context_instance(CONTEXT_SYSTEM); 00013 00014 require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions"); 00015 00016 $site = get_site(); 00017 $mnet = get_mnet_environment(); 00018 00019 if (!extension_loaded('openssl')) { 00020 echo $OUTPUT->header(); 00021 set_config('mnet_dispatcher_mode', 'off'); 00022 print_error('requiresopenssl', 'mnet'); 00023 } 00024 00025 if (!function_exists('curl_init') ) { 00026 echo $OUTPUT->header(); 00027 set_config('mnet_dispatcher_mode', 'off'); 00028 print_error('nocurl', 'mnet'); 00029 } 00030 00031 if (!isset($CFG->mnet_dispatcher_mode)) { 00032 set_config('mnet_dispatcher_mode', 'off'); 00033 } 00034 00036 if (($form = data_submitted()) && confirm_sesskey()) { 00037 if (!empty($form->submit) && $form->submit == get_string('savechanges')) { 00038 if (in_array($form->mode, array("off", "strict", "dangerous"))) { 00039 if (set_config('mnet_dispatcher_mode', $form->mode)) { 00040 redirect('index.php', get_string('changessaved')); 00041 } else { 00042 print_error('invalidaction', '', 'index.php'); 00043 } 00044 } 00045 } elseif (!empty($form->submit) && $form->submit == get_string('delete')) { 00046 $mnet->get_private_key(); 00047 $SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time(); 00048 00049 $formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes')); 00050 $formcancel = new single_button(new moodle_url('index.php', array()), get_string('no')); 00051 echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel); 00052 exit; 00053 } else { 00054 // We're deleting 00055 00056 00057 if (!isset($SESSION->mnet_confirm_delete_key)) { 00058 // fail - you're being attacked? 00059 } 00060 00061 $key = ''; 00062 $time = ''; 00063 @list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key); 00064 $mnet->get_private_key(); 00065 00066 if($time < time() - 60) { 00067 // fail - you're out of time. 00068 print_error ('deleteoutoftime', 'mnet', 'index.php'); 00069 exit; 00070 } 00071 00072 if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) { 00073 // fail - you're being attacked? 00074 print_error ('deletewrongkeyvalue', 'mnet', 'index.php'); 00075 exit; 00076 } 00077 00078 $mnet->replace_keys(); 00079 redirect('index.php', get_string('keydeleted','mnet')); 00080 exit; 00081 } 00082 } 00083 $hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC'); 00084 00085 echo $OUTPUT->header(); 00086 ?> 00087 <form method="post" action="index.php"> 00088 <table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0"> 00089 <tr> 00090 <td class="generalboxcontent"> 00091 <table cellpadding="9" cellspacing="0" > 00092 <tr valign="top"> 00093 <td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td> 00094 </tr> 00095 <tr valign="top"> 00096 <td align="right"><?php print_string('publickey', 'mnet'); ?>:</td> 00097 <td><pre><?php echo $mnet->public_key; ?></pre></td> 00098 </tr> 00099 <tr valign="top"> 00100 <td align="right"><?php print_string('expires', 'mnet'); ?>:</td> 00101 <td><?php echo userdate($mnet->public_key_expires); ?></td> 00102 </tr> 00103 </table> 00104 </td> 00105 </tr> 00106 </table> 00107 </form> 00108 <form method="post" action="index.php"> 00109 <table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0"> 00110 <tr> 00111 <td class="generalboxcontent"> 00112 <table cellpadding="9" cellspacing="0" > 00113 <tr valign="top"> 00114 <td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td> 00115 </tr> 00116 <tr valign="top"> 00117 <td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td> 00118 </tr> 00119 <tr valign="top"> 00120 <td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td> 00121 <td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" /> 00122 <input type="hidden" name="deleteKey" value="" /> 00123 <input type="submit" name="submit" value="<?php print_string('delete'); ?>" /> 00124 </td> 00125 </tr> 00126 </table> 00127 </td> 00128 </tr> 00129 </table> 00130 </form> 00131 00132 <?php 00133 echo $OUTPUT->footer();