| 18 |
#include "bbs.h" |
#include "bbs.h" |
| 19 |
#include "common.h" |
#include "common.h" |
| 20 |
|
|
| 21 |
|
void |
| 22 |
|
login_fail () |
| 23 |
|
{ |
| 24 |
|
char temp[256]; |
| 25 |
|
|
| 26 |
|
strcpy (temp, app_home_dir); |
| 27 |
|
strcat (temp, "data/login_error.dat"); |
| 28 |
|
display_file (temp); |
| 29 |
|
} |
| 30 |
|
|
| 31 |
int |
int |
| 32 |
bbs_login() |
bbs_login () |
| 33 |
{ |
{ |
| 34 |
|
char username[20], password[20]; |
| 35 |
|
int count, ok; |
| 36 |
|
|
| 37 |
|
//Input username |
| 38 |
|
count = 0; |
| 39 |
|
ok = 0; |
| 40 |
|
while (!ok) |
| 41 |
|
{ |
| 42 |
|
printf |
| 43 |
|
("\033[1;33m请输入帐号\033[m(试用请输入 `\033[1;36mguest\033[m', " |
| 44 |
|
"注册请输入`\033[1;31mnew\033[m'): "); |
| 45 |
|
fflush (stdout); |
| 46 |
|
|
| 47 |
|
str_input (username, 19, 0); |
| 48 |
|
count++; |
| 49 |
|
|
| 50 |
|
if (strcmp (username, "guest") == 0) |
| 51 |
|
return 1; |
| 52 |
|
|
| 53 |
|
if (strlen (username) > 0) |
| 54 |
|
{ |
| 55 |
|
//Input password |
| 56 |
|
printf ("\033[1;37m请输入密码\033[m: "); |
| 57 |
|
fflush (stdout); |
| 58 |
|
|
| 59 |
|
str_input (password, 19, 0); |
| 60 |
|
|
| 61 |
|
if (strlen (password) > 0) |
| 62 |
|
{ |
| 63 |
|
ok = check_user (username, password); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
if (!ok) |
| 67 |
|
{ |
| 68 |
|
printf ("\033[1;31m错误的用户名或密码...\r\n"); |
| 69 |
|
fflush (stdout); |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
|
if (count >= 3) |
| 73 |
|
{ |
| 74 |
|
login_fail (); |
| 75 |
|
return -1; |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
|
| 79 |
return 0; |
return 0; |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
|
int |
| 83 |
|
check_user(char *username, char *password) |
| 84 |
|
{ |
| 85 |
|
return 1; |
| 86 |
|
} |