登录次数超过5,就冻结用户blocked=1
- <?php
- if (!isset($_SESSION['AttemptsCounter'])) {
- $_SESSION['AttemptsCounter'] = 0;
- }
- if ((isset($_POST['UserNameEntryField']) AND $_POST['UserNameEntryField'] != '')) {
- /* if not logged in */
- $_SESSION['AttemptsCounter']++;
- // Show login screen
- if (!isset($_POST['UserNameEntryField']) or $_POST['UserNameEntryField'] == '') {
- include('includes/Login.php');
- exit;
- }
- $Auth_Result = getUserInfo($_POST['UserNameEntryField'], $_POST['Password']);
- // Populate session variables with data base results
- if (DB_num_rows($Auth_Result) > 0) {
- exit;
- } else { // Incorrect password
- // 5 login attempts, show failed login screen
- if (!isset($_SESSION['AttemptsCounter'])) {
- $_SESSION['AttemptsCounter'] = 0;
- } elseif ($_SESSION['AttemptsCounter'] >= 5 AND isset($_POST['UserNameEntryField'])) {
- /*User blocked from future accesses until sysadmin releases */
- $sql = "UPDATE www_users SET blocked=1 WHERE www_users.userid='{$_POST['UserNameEntryField']}'";
- DB_query($sql);
- die(include('includes/FailedLogin.php'));
- }
- die(include('includes/Login.php'));
- }
- }
- ?>
时间: 2024-10-31 11:41:25