| 20 |
#include "user_priv.h" |
#include "user_priv.h" |
| 21 |
#include "common.h" |
#include "common.h" |
| 22 |
#include "database.h" |
#include "database.h" |
| 23 |
|
#include "article_view_log.h" |
| 24 |
#include "log.h" |
#include "log.h" |
| 25 |
#include "io.h" |
#include "io.h" |
| 26 |
#include "screen.h" |
#include "screen.h" |
| 28 |
#include "bbs_cmd.h" |
#include "bbs_cmd.h" |
| 29 |
#include "section_list.h" |
#include "section_list.h" |
| 30 |
#include "trie_dict.h" |
#include "trie_dict.h" |
| 31 |
|
#include "editor.h" |
| 32 |
#include <unistd.h> |
#include <unistd.h> |
| 33 |
#include <time.h> |
#include <time.h> |
| 34 |
#include <string.h> |
#include <string.h> |
| 49 |
u_int32_t u_online = 0; |
u_int32_t u_online = 0; |
| 50 |
u_int32_t u_anonymous = 0; |
u_int32_t u_anonymous = 0; |
| 51 |
u_int32_t u_total = 0; |
u_int32_t u_total = 0; |
|
u_int32_t max_u_online = 0; |
|
| 52 |
u_int32_t u_login_count = 0; |
u_int32_t u_login_count = 0; |
| 53 |
|
|
| 54 |
MYSQL *db; |
MYSQL *db; |
| 147 |
|
|
| 148 |
mysql_close(db); |
mysql_close(db); |
| 149 |
|
|
|
// Log max user_online |
|
|
FILE *fin, *fout; |
|
|
if ((fin = fopen(VAR_MAX_USER_ONLINE, "r")) != NULL) |
|
|
{ |
|
|
fscanf(fin, "%d", &max_u_online); |
|
|
fclose(fin); |
|
|
} |
|
|
if (u_online > max_u_online) |
|
|
{ |
|
|
max_u_online = u_online; |
|
|
if ((fout = fopen(VAR_MAX_USER_ONLINE, "w")) == NULL) |
|
|
{ |
|
|
log_error("Open max_user_online.dat failed\n"); |
|
|
return -3; |
|
|
} |
|
|
fprintf(fout, "%d\n", max_u_online); |
|
|
fclose(fout); |
|
|
} |
|
|
|
|
| 150 |
// Count current user before login |
// Count current user before login |
| 151 |
u_online++; |
u_online++; |
| 152 |
u_anonymous++; |
u_anonymous++; |
| 153 |
|
|
| 154 |
// Display logo |
// Display logo |
| 155 |
display_file(DATA_WELCOME, 1, 2); |
display_file(DATA_WELCOME, 2); |
| 156 |
|
|
| 157 |
// Display welcome message |
// Display welcome message |
| 158 |
prints("\r\033[1;35m欢迎光临\033[33m 【 %s 】 \033[35mBBS\r\n" |
prints("\r\033[1;35m欢迎光临\033[33m 【 %s 】 \033[35mBBS\r\n" |
| 159 |
"\033[32m目前上站人数 [\033[36m%d/%d\033[32m] " |
"\033[32m目前上站人数 [\033[36m%d/%d\033[32m] " |
| 160 |
"匿名游客[\033[36m%d\033[32m] " |
"匿名游客[\033[36m%d\033[32m] " |
| 161 |
"注册用户数[\033[36m%d/%d\033[32m]\r\n" |
"注册用户数[\033[36m%d/%d\033[32m]\r\n" |
| 162 |
"从 [\033[36m%s\033[32m] 起,最高人数记录:" |
"从 [\033[36m%s\033[32m] 起,累计访问人次:[\033[36m%d\033[32m]\033[m\r\n", |
|
"[\033[36m%d\033[32m],累计访问人次:[\033[36m%d\033[32m]\033[m\r\n", |
|
| 163 |
BBS_name, u_online, BBS_max_client, u_anonymous, u_total, |
BBS_name, u_online, BBS_max_client, u_anonymous, u_total, |
| 164 |
BBS_max_user, BBS_start_dt, max_u_online, u_login_count); |
BBS_max_user, BBS_start_dt, u_login_count); |
| 165 |
|
|
| 166 |
iflush(); |
iflush(); |
| 167 |
|
|
| 185 |
|
|
| 186 |
mysql_close(db); |
mysql_close(db); |
| 187 |
|
|
| 188 |
display_file(DATA_GOODBYE, 1, 1); |
display_file(DATA_GOODBYE, 1); |
| 189 |
|
|
| 190 |
log_common("User logout\n"); |
log_common("User logout\n"); |
| 191 |
|
|
| 197 |
int ch; |
int ch; |
| 198 |
time_t t_last_action; |
time_t t_last_action; |
| 199 |
|
|
| 200 |
BBS_last_access_tm = t_last_action = time(0); |
BBS_last_access_tm = t_last_action = time(NULL); |
| 201 |
|
|
| 202 |
clearscr(); |
clearscr(); |
| 203 |
|
|
| 211 |
{ |
{ |
| 212 |
ch = igetch(100); |
ch = igetch(100); |
| 213 |
|
|
| 214 |
if (p_bbs_menu->choose_step == 0 && time(0) - t_last_action >= 10) |
if (p_bbs_menu->choose_step == 0 && time(NULL) - t_last_action >= 10) |
| 215 |
{ |
{ |
| 216 |
t_last_action = time(0); |
t_last_action = time(NULL); |
| 217 |
|
|
| 218 |
show_active_board(); |
show_active_board(); |
| 219 |
show_bottom(""); |
show_bottom(""); |
| 226 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 227 |
return 0; |
return 0; |
| 228 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 229 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 230 |
{ |
{ |
| 231 |
return 0; |
return 0; |
| 232 |
} |
} |
| 239 |
case EXITBBS: |
case EXITBBS: |
| 240 |
return 0; |
return 0; |
| 241 |
case REDRAW: |
case REDRAW: |
| 242 |
t_last_action = time(0); |
t_last_action = time(NULL); |
| 243 |
clearscr(); |
clearscr(); |
| 244 |
show_top("", BBS_name, ""); |
show_top("", BBS_name, ""); |
| 245 |
show_active_board(); |
show_active_board(); |
| 254 |
iflush(); |
iflush(); |
| 255 |
} |
} |
| 256 |
|
|
| 257 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 258 |
} |
} |
| 259 |
|
|
| 260 |
return 0; |
return 0; |
| 308 |
goto cleanup; |
goto cleanup; |
| 309 |
} |
} |
| 310 |
|
|
| 311 |
// Load article_view_log |
// Load article view log |
| 312 |
|
if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0) |
| 313 |
|
{ |
| 314 |
|
log_error("article_view_log_load() error\n"); |
| 315 |
|
goto cleanup; |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
// Init editor memory pool |
| 319 |
|
if (editor_memory_pool_init() < 0) |
| 320 |
|
{ |
| 321 |
|
log_error("editor_memory_pool_init() error\n"); |
| 322 |
|
goto cleanup; |
| 323 |
|
} |
| 324 |
|
|
| 325 |
clearscr(); |
clearscr(); |
| 326 |
|
|
| 327 |
// BBS Top 10 |
// BBS Top 10 |
| 328 |
display_file(VAR_BBS_TOP, 1, 1); |
display_file(VAR_BBS_TOP, 1); |
| 329 |
|
|
| 330 |
// Main |
// Main |
| 331 |
bbs_center(); |
bbs_center(); |
| 333 |
// Logout |
// Logout |
| 334 |
bbs_logout(); |
bbs_logout(); |
| 335 |
|
|
| 336 |
|
// Save incremental article view log |
| 337 |
|
if (article_view_log_save_inc(&BBS_article_view_log) < 0) |
| 338 |
|
{ |
| 339 |
|
log_error("article_view_log_save_inc() error\n"); |
| 340 |
|
} |
| 341 |
|
|
| 342 |
cleanup: |
cleanup: |
| 343 |
|
// Cleanup editor memory pool |
| 344 |
|
editor_memory_pool_cleanup(); |
| 345 |
|
|
| 346 |
|
// Unload article view log |
| 347 |
|
article_view_log_unload(&BBS_article_view_log); |
| 348 |
|
|
| 349 |
// Detach menu in shared memory |
// Detach menu in shared memory |
| 350 |
detach_menu_shm(p_bbs_menu); |
detach_menu_shm(p_bbs_menu); |
| 351 |
free(p_bbs_menu); |
free(p_bbs_menu); |