| 30 |
#include <regex.h> |
#include <regex.h> |
| 31 |
#include <unistd.h> |
#include <unistd.h> |
| 32 |
#include <mysql/mysql.h> |
#include <mysql/mysql.h> |
| 33 |
|
#include <sys/param.h> |
| 34 |
|
|
| 35 |
int bbs_login(void) |
int bbs_login(void) |
| 36 |
{ |
{ |
| 519 |
return -1; |
return -1; |
| 520 |
} |
} |
| 521 |
|
|
| 522 |
|
return 0; |
| 523 |
|
} |
| 524 |
|
|
| 525 |
|
int user_online_exp(MYSQL *db) |
| 526 |
|
{ |
| 527 |
|
char sql[SQL_BUFFER_LEN]; |
| 528 |
|
|
| 529 |
|
// +1 exp for every 5 minutes online since last logout |
| 530 |
|
// but at most 24 hours worth of exp can be gained in Telnet session |
| 531 |
|
snprintf(sql, sizeof(sql), |
| 532 |
|
"UPDATE user_pubinfo SET exp = exp + " |
| 533 |
|
"FLOOR((UNIX_TIMESTAMP() - GREATEST(IF(last_logout_dt IS NULL, 0, UNIX_TIMESTAMP(last_logout_dt)), %ld)) / 60 / 5), " |
| 534 |
|
"last_logout_dt = NOW() " |
| 535 |
|
"WHERE UID = %d", |
| 536 |
|
MAX(BBS_login_tm, time(NULL) - 60 * 60 * 24), |
| 537 |
|
BBS_priv.uid); |
| 538 |
|
if (mysql_query(db, sql) != 0) |
| 539 |
|
{ |
| 540 |
|
log_error("Update user_pubinfo error: %s\n", mysql_error(db)); |
| 541 |
|
return -1; |
| 542 |
|
} |
| 543 |
|
|
| 544 |
return 0; |
return 0; |
| 545 |
} |
} |
| 546 |
|
|