| 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" |
| 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') |
| 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 |
} |
} |
| 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 |
{ |
{ |
| 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]) >= BBS_allowed_login_failures_per_account) |
| 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 |
} |
} |