OSDN Git Service

50a748e7caa4ac5a18f8629d868e875a1093a089
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / plugins / securityenforcer / index.php
1 <?php\r
2 \r
3 /*\r
4 \r
5 Admin area for NP_SecurityEnforcer\r
6 \r
7 */\r
8 \r
9         // if your 'plugin' directory is not in the default location,\r
10         // edit this variable to point to your site directory\r
11         // (where config.php is)\r
12         $strRel = '../../../';\r
13 \r
14         include($strRel . 'config.php');\r
15         if (!$member->isAdmin())\r
16                 doError('Insufficient Permissions.');\r
17                 \r
18 \r
19         include($DIR_LIBS . 'PLUGINADMIN.php');\r
20         // some functions\r
21         \r
22         function SE_unlockLogin($login) {\r
23                 sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($login)."'");\r
24         }\r
25         \r
26                 \r
27         // checks\r
28         \r
29 \r
30         \r
31         // create the admin area page\r
32         $oPluginAdmin = new PluginAdmin('SecurityEnforcer');\r
33         // add styles to the <HEAD>\r
34         $oPluginAdmin->start('');\r
35         \r
36         // if form to unlock is posted\r
37         if(postVar('action') == 'unlock') {\r
38                 if (!$manager->checkTicket()) \r
39                         doError('Invalid Ticket');\r
40                 $logins = postVar('unlock');\r
41                 $message = '';\r
42                 if(is_array($logins)) {\r
43                         foreach ($logins as $entity) {\r
44                                 SE_unlockLogin($entity);\r
45                                 $message .= '<br />' . $entity . _SECURITYENFORCER_ADMIN_UNLOCKED;\r
46                         }\r
47                 }\r
48         }               \r
49         $plug =& $oPluginAdmin->plugin;\r
50 \r
51         // page title\r
52         echo '<h2>Security Enforcer Administration</h2>';\r
53         \r
54         // error output\r
55         if($message) { echo "<p><strong>"; echo $message; echo "</strong></p>"; }\r
56                 \r
57         // generate table from all entries in the database\r
58         echo '<h3>'._SECURITYENFORCER_LOCKED_ENTITIES.'</h3>';\r
59         echo '<form action="' . $oPluginAdmin->plugin->getAdminURL() . '" method="POST">';\r
60         echo '<input type="hidden" name="action" value="unlock" />';\r
61         $manager->addTicketHidden();\r
62         echo '<table>';\r
63         echo '<tr><th>'._SECURITYENFORCER_ENTITY.'</th><th>Unlock?</th></tr>';\r
64         echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';\r
65         // do query to get all entries, loop\r
66         $result = sql_query("SELECT * FROM ".sql_table("plug_securityenforcer")." WHERE fails >= ".$plug->max_failed_login);\r
67         if(mysql_num_rows($result)) {\r
68                 while($row = mysql_fetch_assoc($result)) {\r
69                         echo '<tr>';\r
70                                 echo '<td>'.htmlspecialchars($row['login']).'</td>';\r
71                                 echo '<td><input type="checkbox" name="unlock[]" value="'.htmlspecialchars($row['login']).'" />'._SECURITYENFORCER_UNLOCK.'</td>';\r
72                         echo '</tr>';\r
73                 }\r
74         }\r
75         else {\r
76                 echo '<tr><td colspan="2"><strong>'._SECURITYENFORCER_ADMIN_NONE_LOCKED.'</strong></td></tr>';\r
77         }\r
78         echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';\r
79         echo '</table>';\r
80         echo '</form>';\r
81         \r
82         $oPluginAdmin->end();\r
83 \r
84 ?>