| 27 |
#include <errno.h> |
#include <errno.h> |
| 28 |
#include <ctype.h> |
#include <ctype.h> |
| 29 |
#include <string.h> |
#include <string.h> |
|
#include <mysql.h> |
|
| 30 |
#include <regex.h> |
#include <regex.h> |
| 31 |
#include <stdlib.h> |
#include <stdlib.h> |
| 32 |
#include <unistd.h> |
#include <unistd.h> |
| 33 |
|
#include <mysql/mysql.h> |
| 34 |
|
|
| 35 |
int bbs_login(MYSQL *db) |
int bbs_login(MYSQL *db) |
| 36 |
{ |
{ |
| 37 |
char username[BBS_username_max_len + 1]; |
char username[BBS_username_max_len + 1]; |
| 38 |
char password[BBS_password_max_len + 1]; |
char password[BBS_password_max_len + 1]; |
| 39 |
int count = 0; |
int i = 0; |
| 40 |
int ok = 0; |
int ok = 0; |
| 41 |
|
|
| 42 |
for (; !SYS_server_exit && !ok && count < 3; count++) |
for (; !SYS_server_exit && !ok && i < BBS_login_retry_times; i++) |
| 43 |
{ |
{ |
| 44 |
prints("\033[1;33mΗλΚδΘλΥΚΊΕ\033[m(ΚΤΣΓΗλΚδΘλ`\033[1;36mguest\033[m', " |
prints("\033[1;33mΗλΚδΘλΥΚΊΕ\033[m(ΚΤΣΓΗλΚδΘλ`\033[1;36mguest\033[m', " |
| 45 |
"ΧΆ²αΗλΚδΘλ`\033[1;31mnew\033[m'): "); |
"ΧΆ²αΗλΚδΘλ`\033[1;31mnew\033[m'): "); |
| 85 |
return -1; |
return -1; |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
log_std("User \"%s\"(%ld) login from %s:%d\n", |
log_common("User \"%s\"(%ld) login from %s:%d\n", |
| 89 |
BBS_username, BBS_priv.uid, hostaddr_client, port_client); |
BBS_username, BBS_priv.uid, hostaddr_client, port_client); |
| 90 |
|
|
| 91 |
return 0; |
return 0; |
| 92 |
} |
} |
| 93 |
|
|
| 94 |
int check_user(MYSQL *db, char *username, char *password) |
int check_user(MYSQL *db, const char *username, const char *password) |
| 95 |
{ |
{ |
| 96 |
MYSQL_RES *rs; |
MYSQL_RES *rs; |
| 97 |
MYSQL_ROW row; |
MYSQL_ROW row; |