[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/mnet/ -> index.php (source)

   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      require_login();
  10      admin_externalpage_setup('net');
  11  
  12      $context = context_system::instance();
  13  
  14      require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
  15  
  16      $site = get_site();
  17      $mnet = get_mnet_environment();
  18  
  19      if (!extension_loaded('openssl')) {
  20          echo $OUTPUT->header();
  21          set_config('mnet_dispatcher_mode', 'off');
  22          print_error('requiresopenssl', 'mnet');
  23      }
  24  
  25      if (!function_exists('curl_init') ) {
  26          echo $OUTPUT->header();
  27          set_config('mnet_dispatcher_mode', 'off');
  28          print_error('nocurl', 'mnet');
  29      }
  30  
  31      if (!isset($CFG->mnet_dispatcher_mode)) {
  32          set_config('mnet_dispatcher_mode', 'off');
  33      }
  34  
  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'));
  41                  } else {
  42                      print_error('invalidaction', '', 'index.php');
  43                  }
  44              }
  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();
  48  
  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);
  52              exit;
  53          } else {
  54              // We're deleting
  55  
  56  
  57              if (!isset($SESSION->mnet_confirm_delete_key)) {
  58                  // fail - you're being attacked?
  59              }
  60  
  61              $key = '';
  62              $time = '';
  63              @list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
  64              $mnet->get_private_key();
  65  
  66              if($time < time() - 60) {
  67                  // fail - you're out of time.
  68                  print_error ('deleteoutoftime', 'mnet', 'index.php');
  69                  exit;
  70              }
  71  
  72              if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
  73                  // fail - you're being attacked?
  74                  print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
  75                  exit;
  76              }
  77  
  78              $mnet->replace_keys();
  79              redirect('index.php', get_string('keydeleted','mnet'));
  80              exit;
  81          }
  82      }
  83      $hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');
  84  
  85      echo $OUTPUT->header();
  86  ?>
  87  <form method="post" action="index.php">
  88      <table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
  89          <tr>
  90              <td  class="generalboxcontent">
  91              <table cellpadding="9" cellspacing="0" >
  92                  <tr valign="top">
  93                      <td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td>
  94                  </tr>
  95                  <tr valign="top">
  96                      <td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
  97                      <td><pre><?php echo $mnet->public_key; ?></pre></td>
  98                  </tr>
  99                  <tr valign="top">
 100                      <td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
 101                      <td><?php echo userdate($mnet->public_key_expires); ?></td>
 102                  </tr>
 103              </table>
 104              </td>
 105          </tr>
 106      </table>
 107  </form>
 108  <form method="post" action="index.php">
 109      <table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
 110          <tr>
 111              <td  class="generalboxcontent">
 112              <table cellpadding="9" cellspacing="0" >
 113                  <tr valign="top">
 114                      <td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td>
 115                  </tr>
 116                  <tr valign="top">
 117                      <td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
 118                  </tr>
 119                  <tr valign="top">
 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'); ?>" />
 124                      </td>
 125                  </tr>
 126              </table>
 127              </td>
 128          </tr>
 129      </table>
 130  </form>
 131  
 132  <?php
 133  echo $OUTPUT->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1