OSDN Git Service

MARGE:masterブランチのマージ(マージできない分について、データベースハンドラーを書き換え)
[nucleus-jp/nucleus-next.git] / nucleus / plugins / securityenforcer / index.php
1 <?php
2 /* 
3 * @version $Id$
4 */
5
6 /*
7  * Admin area for NP_SecurityEnforcer
8  */
9
10 /*
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)
14  */
15 $strRel = '../../../';
16
17 include($strRel . 'config.php');
18 if (!$member->isAdmin())
19 {
20         doError('Insufficient Permissions.');
21 }
22         
23 include_libs('PLUGINADMIN.php');
24
25 // some functions
26 function SE_unlockLogin($login)
27 {
28         DB::execute('DELETE FROM '.sql_table('plug_securityenforcer').' WHERE login='.DB::quoteValue($login));
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 {
39         if ( !$manager->checkTicket() )
40         {
41                 doError('Invalid Ticket');
42         }
43         $logins = postVar('unlock');
44         $message = '';
45         if( is_array($logins) )
46         {
47                 foreach ( $logins as $entity )
48                 {
49                         SE_unlockLogin($entity);
50                         $message .= '<br />' . $entity . _SECURITYENFORCER_ADMIN_UNLOCKED;
51                 }
52         }
53 }
54 $plug =& $oPluginAdmin->plugin;
55
56 // page title
57 echo '<h2>'._SECURITYENFORCER_ADMIN_TITLE.'</h2>';
58
59 // error output
60 if ( isset($message) )
61 {
62         echo "<p><strong>{$message}</strong></p>\n";
63 }
64
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();
70 echo '<table>';
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 = DB::getResult("SELECT * FROM ".sql_table("plug_securityenforcer")." WHERE fails >= ".$plug->max_failed_login);
75 if ( $result->rowCount() )
76 {
77         foreach ( $result as $row )
78         {
79                 echo '<tr>';
80                 echo '<td>'.Entity::hsc($row['login']).'</td>';
81                 echo '<td><input type="checkbox" name="unlock[]" value="'.Entity::hsc($row['login']).'" />'._SECURITYENFORCER_UNLOCK.'</td>';
82                 echo '</tr>';
83         }
84 }
85 else
86 {
87         echo '<tr><td colspan="2"><strong>'._SECURITYENFORCER_ADMIN_NONE_LOCKED.'</strong></td></tr>';
88 }
89 echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
90 echo '</table>';
91 echo '</form>';
92
93 $oPluginAdmin->end();