/[LeafOK_CVS]/lbbs/src/login.c
ViewVC logotype

Diff of /lbbs/src/login.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.49 by sysadm, Wed Jul 2 04:17:33 2025 UTC Revision 1.52 by sysadm, Sun Sep 28 12:25:14 2025 UTC
# Line 18  Line 18 
18  #include "common.h"  #include "common.h"
19  #include "database.h"  #include "database.h"
20  #include "io.h"  #include "io.h"
21    #include "ip_mask.h"
22  #include "log.h"  #include "log.h"
23  #include "login.h"  #include "login.h"
24  #include "screen.h"  #include "screen.h"
# Line 59  int bbs_login(void) Line 60  int bbs_login(void)
60                  {                  {
61                          display_file(DATA_REGISTER, 1);                          display_file(DATA_REGISTER, 1);
62    
63                          return 0;                          return -1;
64                  }                  }
65    
66                  if (username[0] != '\0')                  if (username[0] != '\0')
# Line 179  int check_user(const char *username, con Line 180  int check_user(const char *username, con
180          }          }
181          if ((row = mysql_fetch_row(rs)))          if ((row = mysql_fetch_row(rs)))
182          {          {
183                  if (atoi(row[0]) > BBS_allowed_login_failures_within_interval)                  if (atoi(row[0]) >= BBS_allowed_login_failures_within_interval)
184                  {                  {
185                          prints("\033[1;31m来源存在多次失败登陆尝试,请稍后再试\033[m\r\n");                          prints("\033[1;31m来源存在多次失败登陆尝试,请稍后再试,或使用Web方式访问\033[m\r\n");
186                          ret = 1;                          ret = 1;
187                          goto cleanup;                          goto cleanup;
188                  }                  }
# Line 189  int check_user(const char *username, con Line 190  int check_user(const char *username, con
190          mysql_free_result(rs);          mysql_free_result(rs);
191          rs = NULL;          rs = NULL;
192    
193          // Failed login attempts against the current username during certain time period          // Failed login attempts against the current username since last successful login
194          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
195                           "SELECT COUNT(*) AS err_count FROM user_err_login_log "                           "SELECT COUNT(*) AS err_count FROM user_err_login_log "
196                           "WHERE username = '%s' AND login_dt >= SUBDATE(NOW(), INTERVAL 1 DAY)",                           "LEFT JOIN user_list ON user_err_login_log.username = user_list.username "
197                             "LEFT JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID "
198                             "WHERE user_err_login_log.username = '%s' "
199                             "AND (user_err_login_log.login_dt >= user_pubinfo.last_login_dt "
200                             "OR user_pubinfo.last_login_dt IS NULL)",
201                           username);                           username);
202          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
203          {          {
# Line 208  int check_user(const char *username, con Line 213  int check_user(const char *username, con
213          }          }
214          if ((row = mysql_fetch_row(rs)))          if ((row = mysql_fetch_row(rs)))
215          {          {
216                  if (atoi(row[0]) >= 5)                  if (atoi(row[0]) >= 3)
217                  {                  {
218                          prints("\033[1;31m账户存在多次失败登陆尝试,请使用Web方式登录\033[m\r\n");                          prints("\033[1;31m账户存在多次失败登陆尝试,请使用Web方式登录解锁\033[m\r\n");
219                          ret = 1;                          ret = 1;
220                          goto cleanup;                          goto cleanup;
221                  }                  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1