| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
|
#include "article_favor.h" |
| 18 |
#include "article_view_log.h" |
#include "article_view_log.h" |
| 19 |
#include "bbs.h" |
#include "bbs.h" |
| 20 |
#include "bbs_cmd.h" |
#include "bbs_cmd.h" |
| 39 |
|
|
| 40 |
int bbs_info() |
int bbs_info() |
| 41 |
{ |
{ |
| 42 |
prints("欢迎光临 \033[1;33m%s \033[32m[%s] \033[37m( %s )\r\n", |
prints("欢迎光临 \033[1;33m%s \033[32m[%s] \033[37m( %s )\033[m\r\n", |
| 43 |
BBS_name, BBS_server, APP_INFO); |
BBS_name, BBS_server, APP_INFO); |
| 44 |
|
|
| 45 |
return iflush(); |
return iflush(); |
| 181 |
return -1; |
return -1; |
| 182 |
} |
} |
| 183 |
|
|
| 184 |
if (user_online_del(db) < 0) |
if (user_online_exp(db) < 0) |
| 185 |
{ |
{ |
| 186 |
return -2; |
return -2; |
| 187 |
} |
} |
| 188 |
|
|
| 189 |
|
if (user_online_del(db) < 0) |
| 190 |
|
{ |
| 191 |
|
return -3; |
| 192 |
|
} |
| 193 |
|
|
| 194 |
mysql_close(db); |
mysql_close(db); |
| 195 |
|
|
| 196 |
display_file(DATA_GOODBYE, 1); |
display_file(DATA_GOODBYE, 1); |
| 197 |
|
|
| 198 |
log_common("User logout\n"); |
log_common("User [%s] logout\n", BBS_username); |
| 199 |
|
|
| 200 |
return 0; |
return 0; |
| 201 |
} |
} |
| 219 |
{ |
{ |
| 220 |
ch = igetch(100); |
ch = igetch(100); |
| 221 |
|
|
| 222 |
|
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 223 |
|
{ |
| 224 |
|
BBS_last_access_tm = time(NULL); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10) |
if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10) |
| 228 |
{ |
{ |
| 229 |
t_last_action = time(NULL); |
t_last_action = time(NULL); |
| 242 |
switch (ch) |
switch (ch) |
| 243 |
{ |
{ |
| 244 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 245 |
|
log_error("KEY_NULL\n"); |
| 246 |
return 0; |
return 0; |
| 247 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 248 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 249 |
{ |
{ |
| 250 |
|
log_error("User input timeout\n"); |
| 251 |
return 0; |
return 0; |
| 252 |
} |
} |
| 253 |
continue; |
continue; |
| 254 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 255 |
default: |
default: |
| 256 |
switch (menu_control(&bbs_menu, ch)) |
switch (menu_control(&bbs_menu, ch)) |
| 257 |
{ |
{ |
| 273 |
} |
} |
| 274 |
iflush(); |
iflush(); |
| 275 |
} |
} |
|
|
|
|
BBS_last_access_tm = time(NULL); |
|
| 276 |
} |
} |
| 277 |
|
|
| 278 |
return 0; |
return 0; |
| 335 |
{ |
{ |
| 336 |
prints("\033[1m%s 欢迎使用ssh方式访问 \033[1;33m按任意键继续...\033[m", BBS_username); |
prints("\033[1m%s 欢迎使用ssh方式访问 \033[1;33m按任意键继续...\033[m", BBS_username); |
| 337 |
iflush(); |
iflush(); |
| 338 |
|
igetch_reset(); |
| 339 |
igetch_t(MAX_DELAY_TIME); |
igetch_t(MAX_DELAY_TIME); |
| 340 |
} |
} |
| 341 |
else if (bbs_login() < 0) |
else if (bbs_login() < 0) |
| 342 |
{ |
{ |
| 343 |
goto cleanup; |
goto cleanup; |
| 344 |
} |
} |
| 345 |
|
log_common("User [%s] login\n", BBS_username); |
| 346 |
|
|
| 347 |
// Load article view log |
// Load article view log |
| 348 |
if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0) |
if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0) |
| 351 |
goto cleanup; |
goto cleanup; |
| 352 |
} |
} |
| 353 |
|
|
| 354 |
|
// Load article favorite |
| 355 |
|
if (article_favor_load(BBS_priv.uid, &BBS_article_favor, 0) < 0) |
| 356 |
|
{ |
| 357 |
|
log_error("article_favor_load() error\n"); |
| 358 |
|
goto cleanup; |
| 359 |
|
} |
| 360 |
|
|
| 361 |
// Init editor memory pool |
// Init editor memory pool |
| 362 |
if (editor_memory_pool_init() < 0) |
if (editor_memory_pool_init() < 0) |
| 363 |
{ |
{ |
| 382 |
log_error("article_view_log_save_inc() error\n"); |
log_error("article_view_log_save_inc() error\n"); |
| 383 |
} |
} |
| 384 |
|
|
| 385 |
|
// Save incremental article favorite |
| 386 |
|
if (article_favor_save_inc(&BBS_article_favor) < 0) |
| 387 |
|
{ |
| 388 |
|
log_error("article_favor_save_inc() error\n"); |
| 389 |
|
} |
| 390 |
|
|
| 391 |
cleanup: |
cleanup: |
| 392 |
// Cleanup editor memory pool |
// Cleanup editor memory pool |
| 393 |
editor_memory_pool_cleanup(); |
editor_memory_pool_cleanup(); |
| 395 |
// Unload article view log |
// Unload article view log |
| 396 |
article_view_log_unload(&BBS_article_view_log); |
article_view_log_unload(&BBS_article_view_log); |
| 397 |
|
|
| 398 |
|
// Unload article favor |
| 399 |
|
article_favor_unload(&BBS_article_favor); |
| 400 |
|
|
| 401 |
// Detach menu in shared memory |
// Detach menu in shared memory |
| 402 |
detach_menu_shm(&bbs_menu); |
detach_menu_shm(&bbs_menu); |
| 403 |
|
detach_menu_shm(&top10_menu); |
| 404 |
|
|
| 405 |
// Detach data pools shm |
// Detach data pools shm |
| 406 |
detach_section_list_shm(); |
detach_section_list_shm(); |