| 27 |
char temp[256]; |
char temp[256]; |
| 28 |
|
|
| 29 |
strcpy (temp, app_home_dir); |
strcpy (temp, app_home_dir); |
| 30 |
strcat (temp, "data/login_error.dat"); |
strcat (temp, "data/login_error.txt"); |
| 31 |
display_file (temp); |
display_file (temp); |
| 32 |
|
|
| 33 |
sleep (1); |
sleep (1); |
| 53 |
count++; |
count++; |
| 54 |
|
|
| 55 |
if (strcmp (username, "guest") == 0) |
if (strcmp (username, "guest") == 0) |
| 56 |
return 1; |
{ |
| 57 |
|
load_guest_info (); |
| 58 |
|
return 0; |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
if (strcmp (username, "new") == 0) |
| 62 |
|
{ |
| 63 |
|
if (user_register () == 0) |
| 64 |
|
return 0; |
| 65 |
|
else |
| 66 |
|
return -2; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
if (strlen (username) > 0) |
if (strlen (username) > 0) |
| 70 |
{ |
{ |
| 74 |
|
|
| 75 |
str_input (password, 19, 1); |
str_input (password, 19, 1); |
| 76 |
|
|
| 77 |
ok = (check_user (username, password) == 0); |
ok = (check_user (username, password) == 0); |
| 78 |
} |
} |
| 79 |
if (count >= 3 && !ok) |
if (count >= 3 && !ok) |
| 80 |
{ |
{ |
| 145 |
sprintf (sql, |
sprintf (sql, |
| 146 |
"insert delayed into user_err_login_log" |
"insert delayed into user_err_login_log" |
| 147 |
"(username,password,login_dt,login_ip) values" |
"(username,password,login_dt,login_ip) values" |
| 148 |
"('%s','%s',now(),'%s')", |
"('%s','%s',now(),'%s')", username, password, hostaddr_client); |
|
username, password, hostaddr_client); |
|
| 149 |
if (mysql_query (db, sql) != 0) |
if (mysql_query (db, sql) != 0) |
| 150 |
{ |
{ |
| 151 |
log_error ("Insert into user_err_login_log failed\n"); |
log_error ("Insert into user_err_login_log failed\n"); |
| 160 |
} |
} |
| 161 |
mysql_free_result (rs); |
mysql_free_result (rs); |
| 162 |
|
|
| 163 |
BBS_passwd_complex = verify_pass_complexity(password, username, 6); |
BBS_passwd_complex = verify_pass_complexity (password, username, 6); |
| 164 |
|
|
| 165 |
ret = load_user_info (db, BBS_uid); |
ret = load_user_info (db, BBS_uid); |
| 166 |
|
|
|
mysql_close (db); |
|
|
|
|
| 167 |
switch (ret) |
switch (ret) |
| 168 |
{ |
{ |
| 169 |
case 0: //Login successfully |
case 0: //Login successfully |
| 177 |
case -2: //Unused |
case -2: //Unused |
| 178 |
return 0; |
return 0; |
| 179 |
break; |
break; |
| 180 |
case -3: |
case -3: //Dead |
| 181 |
prints ("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n"); |
prints ("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n"); |
| 182 |
iflush (); |
iflush (); |
| 183 |
return 1; |
return 1; |
| 185 |
return -2; |
return -2; |
| 186 |
} |
} |
| 187 |
|
|
| 188 |
|
mysql_close (db); |
| 189 |
|
|
| 190 |
return 0; |
return 0; |
| 191 |
} |
} |
| 192 |
|
|
| 250 |
mysql_free_result (rs); |
mysql_free_result (rs); |
| 251 |
|
|
| 252 |
sprintf (sql, |
sprintf (sql, |
| 253 |
"insert delayed into user_login_log" |
"insert delayed into user_login_log" |
| 254 |
"(uid,login_dt,login_ip) values(%ld" |
"(uid,login_dt,login_ip) values(%ld" |
| 255 |
",now(),'%s')", |
",now(),'%s')", BBS_uid, hostaddr_client); |
|
BBS_uid, hostaddr_client); |
|
| 256 |
if (mysql_query (db, sql) != 0) |
if (mysql_query (db, sql) != 0) |
| 257 |
{ |
{ |
| 258 |
log_error ("Insert into user_login_log failed\n"); |
log_error ("Insert into user_login_log failed\n"); |
| 260 |
} |
} |
| 261 |
|
|
| 262 |
load_priv (db, &BBS_priv, BBS_uid, BBS_auth_uid, |
load_priv (db, &BBS_priv, BBS_uid, BBS_auth_uid, |
| 263 |
(!BBS_passwd_complex ? S_MAN_M : S_NONE) | |
(!BBS_passwd_complex ? S_MAN_M : S_NONE) | |
| 264 |
(BBS_auth_uid ? S_NONE : S_MAIL)); |
(BBS_auth_uid ? S_NONE : S_MAIL)); |
| 265 |
|
|
| 266 |
BBS_last_access_tm = BBS_login_tm = time (0); |
BBS_last_access_tm = BBS_login_tm = time (0); |
| 267 |
BBS_last_sub_tm = time (0) - 60; |
BBS_last_sub_tm = time (0) - 60; |
| 268 |
|
|
| 269 |
sprintf (sql, |
sprintf (sql, |
| 270 |
"update user_pubinfo set visit_count=visit_count+1," |
"update user_pubinfo set visit_count=visit_count+1," |
| 271 |
"last_login_dt=now() where uid=%ld", BBS_uid); |
"last_login_dt=now() where uid=%ld", BBS_uid); |
| 272 |
if (mysql_query (db, sql) != 0) |
if (mysql_query (db, sql) != 0) |
| 273 |
{ |
{ |
| 274 |
log_error ("Update user_pubinfo failed\n"); |
log_error ("Update user_pubinfo failed\n"); |
| 277 |
|
|
| 278 |
return 0; |
return 0; |
| 279 |
} |
} |
| 280 |
|
|
| 281 |
|
int |
| 282 |
|
load_guest_info (MYSQL * db, long int BBS_uid) |
| 283 |
|
{ |
| 284 |
|
MYSQL_RES *rs; |
| 285 |
|
MYSQL_ROW row; |
| 286 |
|
|
| 287 |
|
db = (MYSQL *) db_open (); |
| 288 |
|
if (db == NULL) |
| 289 |
|
{ |
| 290 |
|
return -1; |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
load_priv (db, &BBS_priv, 0, 0, S_NONE); |
| 294 |
|
|
| 295 |
|
BBS_last_access_tm = BBS_login_tm = time (0); |
| 296 |
|
BBS_last_sub_tm = time (0) - 60; |
| 297 |
|
|
| 298 |
|
mysql_close (db); |
| 299 |
|
|
| 300 |
|
return 0; |
| 301 |
|
} |