[ Index ]

PHP Cross Reference of Nucleus CMS v3.51 code documentation

title

Body

[close]

/nucleus/plugins/securityenforcer/ -> index.php (source)

   1  <?php
   2  
   3  /*

   4  

   5  Admin area for NP_SecurityEnforcer

   6  

   7  */
   8  
   9      // if your 'plugin' directory is not in the default location,

  10      // edit this variable to point to your site directory

  11      // (where config.php is)

  12      $strRel = '../../../';
  13  
  14      include ($strRel . 'config.php');
  15      if (!$member->isAdmin())
  16          doError('Insufficient Permissions.');
  17          
  18  
  19      include ($DIR_LIBS . 'PLUGINADMIN.php');
  20      // some functions

  21      
  22  	function SE_unlockLogin($login) {
  23          sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($login)."'");
  24      }
  25      
  26          
  27      // checks

  28      
  29  
  30      
  31      // create the admin area page

  32      $oPluginAdmin = new PluginAdmin('SecurityEnforcer');
  33      // add styles to the <HEAD>

  34      $oPluginAdmin->start('');
  35      
  36      // if form to unlock is posted

  37      if(postVar('action') == 'unlock') {
  38          if (!$manager->checkTicket()) 
  39              doError('Invalid Ticket');
  40          $logins = postVar('unlock');
  41          $message = '';
  42          if(is_array($logins)) {
  43              foreach ($logins as $entity) {
  44                  SE_unlockLogin($entity);
  45                  $message .= '<br />' . $entity . _SECURITYENFORCER_ADMIN_UNLOCKED;
  46              }
  47          }
  48      }        
  49      $plug =& $oPluginAdmin->plugin;
  50  
  51      // page title

  52      echo '<h2>'._SECURITYENFORCER_ADMIN_TITLE.'</h2>';
  53      
  54      // error output

  55      if($message) { echo "<p><strong>"; echo $message; echo "</strong></p>"; }
  56          
  57      // generate table from all entries in the database

  58      echo '<h3>'._SECURITYENFORCER_LOCKED_ENTITIES.'</h3>';
  59      echo '<form action="' . $oPluginAdmin->plugin->getAdminURL() . '" method="POST">';
  60      echo '<input type="hidden" name="action" value="unlock" />';
  61      $manager->addTicketHidden();
  62      echo '<table>';
  63      echo '<tr><th>'._SECURITYENFORCER_ENTITY.'</th><th>'._SECURITYENFORCER_UNLOCK.'?</th></tr>';
  64      echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
  65      // do query to get all entries, loop

  66      $result = sql_query("SELECT * FROM ".sql_table("plug_securityenforcer")." WHERE fails >= ".$plug->max_failed_login);
  67      if(sql_num_rows($result)) {
  68          while($row = sql_fetch_assoc($result)) {
  69              echo '<tr>';
  70                    echo '<td>'.htmlspecialchars($row['login']).'</td>';
  71                    echo '<td><input type="checkbox" name="unlock[]" value="'.htmlspecialchars($row['login']).'" />'._SECURITYENFORCER_UNLOCK.'</td>';
  72              echo '</tr>';
  73          }
  74      }
  75      else {
  76          echo '<tr><td colspan="2"><strong>'._SECURITYENFORCER_ADMIN_NONE_LOCKED.'</strong></td></tr>';
  77      }
  78      echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
  79      echo '</table>';
  80      echo '</form>';
  81      
  82      $oPluginAdmin->end();
  83  
  84  ?>


Generated: Sun Aug 1 03:56:06 2010
Open Source related documentation for developers.