7 * Admin area for NP_SecurityEnforcer
11 * if your 'plugin' directory is not in the default location,
12 * edit this variable to point to your site directory
13 * (where config.php is)
15 $strRel = '../../../';
17 include($strRel . 'config.php');
18 if (!$member->isAdmin())
20 doError('Insufficient Permissions.');
23 include_libs('PLUGINADMIN.php');
26 function SE_unlockLogin($login)
28 sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".sql_real_escape_string($login)."'");
31 // create the admin area page
32 $oPluginAdmin = new PluginAdmin('SecurityEnforcer');
33 // add styles to the <HEAD>
34 $oPluginAdmin->start('');
36 // if form to unlock is posted
37 if ( postVar('action') == 'unlock' )
39 if ( !$manager->checkTicket() )
41 doError('Invalid Ticket');
43 $logins = postVar('unlock');
45 if( is_array($logins) )
47 foreach ( $logins as $entity )
49 SE_unlockLogin($entity);
50 $message .= '<br />' . $entity . _SECURITYENFORCER_ADMIN_UNLOCKED;
54 $plug =& $oPluginAdmin->plugin;
57 echo '<h2>'._SECURITYENFORCER_ADMIN_TITLE.'</h2>';
60 if ( isset($message) )
62 echo "<p><strong>{$message}</strong></p>\n";
65 // generate table from all entries in the database
66 echo '<h3>'._SECURITYENFORCER_LOCKED_ENTITIES.'</h3>';
67 echo '<form action="' . $oPluginAdmin->plugin->getAdminURL() . '" method="POST">';
68 echo '<input type="hidden" name="action" value="unlock" />';
69 $manager->addTicketHidden();
71 echo '<tr><th>'._SECURITYENFORCER_ENTITY.'</th><th>'._SECURITYENFORCER_UNLOCK.'?</th></tr>';
72 echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
73 // do query to get all entries, loop
74 $result = sql_query("SELECT * FROM ".sql_table("plug_securityenforcer")." WHERE fails >= ".$plug->max_failed_login);
75 if ( sql_num_rows($result) )
77 while( $row = sql_fetch_assoc($result) )
80 echo '<td>'.ENTITY::hsc($row['login']).'</td>';
81 echo '<td><input type="checkbox" name="unlock[]" value="'.ENTITY::hsc($row['login']).'" />'._SECURITYENFORCER_UNLOCK.'</td>';
87 echo '<tr><td colspan="2"><strong>'._SECURITYENFORCER_ADMIN_NONE_LOCKED.'</strong></td></tr>';
89 echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';