--- lbbs/src/bbs_main.c 2025/07/05 01:02:34 1.77 +++ lbbs/src/bbs_main.c 2025/10/17 07:07:55 1.85 @@ -14,6 +14,7 @@ * * ***************************************************************************/ +#include "article_favor.h" #include "article_view_log.h" #include "bbs.h" #include "bbs_cmd.h" @@ -180,16 +181,21 @@ int bbs_logout(void) return -1; } - if (user_online_del(db) < 0) + if (user_online_exp(db) < 0) { return -2; } + if (user_online_del(db) < 0) + { + return -3; + } + mysql_close(db); display_file(DATA_GOODBYE, 1); - log_common("User logout\n"); + log_common("User [%s] logout\n", BBS_username); return 0; } @@ -213,6 +219,11 @@ int bbs_center() { ch = igetch(100); + if (ch != KEY_NULL && ch != KEY_TIMEOUT) + { + BBS_last_access_tm = time(NULL); + } + if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10) { t_last_action = time(NULL); @@ -231,15 +242,16 @@ int bbs_center() switch (ch) { case KEY_NULL: // broken pipe + log_error("KEY_NULL\n"); return 0; case KEY_TIMEOUT: if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) { + log_error("User input timeout\n"); return 0; } continue; case CR: - igetch_reset(); default: switch (menu_control(&bbs_menu, ch)) { @@ -261,8 +273,6 @@ int bbs_center() } iflush(); } - - BBS_last_access_tm = time(NULL); } return 0; @@ -325,12 +335,15 @@ int bbs_main() { prints("\033[1m%s 欢迎使用ssh方式访问 \033[1;33m按任意键继续...\033[m", BBS_username); iflush(); - igetch_t(MAX_DELAY_TIME); + igetch_reset(); + while (!SYS_server_exit && igetch_t(MAX_DELAY_TIME) == 0) + ; } else if (bbs_login() < 0) { goto cleanup; } + log_common("User [%s] login\n", BBS_username); // Load article view log if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0) @@ -339,6 +352,13 @@ int bbs_main() goto cleanup; } + // Load article favorite + if (article_favor_load(BBS_priv.uid, &BBS_article_favor, 0) < 0) + { + log_error("article_favor_load() error\n"); + goto cleanup; + } + // Init editor memory pool if (editor_memory_pool_init() < 0) { @@ -363,6 +383,12 @@ int bbs_main() log_error("article_view_log_save_inc() error\n"); } + // Save incremental article favorite + if (article_favor_save_inc(&BBS_article_favor) < 0) + { + log_error("article_favor_save_inc() error\n"); + } + cleanup: // Cleanup editor memory pool editor_memory_pool_cleanup(); @@ -370,8 +396,12 @@ cleanup: // Unload article view log article_view_log_unload(&BBS_article_view_log); + // Unload article favor + article_favor_unload(&BBS_article_favor); + // Detach menu in shared memory detach_menu_shm(&bbs_menu); + detach_menu_shm(&top10_menu); // Detach data pools shm detach_section_list_shm();