| 1 |
/*************************************************************************** |
/*************************************************************************** |
| 2 |
bbs_main.c - description |
bbs_main.c - description |
| 3 |
------------------- |
------------------- |
| 4 |
begin : Mon Oct 18 2004 |
Copyright : (C) 2004-2025 by Leaflet |
| 5 |
copyright : (C) 2004 by Leaflet |
Email : leaflet@leafok.com |
|
email : leaflet@leafok.com |
|
| 6 |
***************************************************************************/ |
***************************************************************************/ |
| 7 |
|
|
| 8 |
/*************************************************************************** |
/*************************************************************************** |
| 9 |
* * |
* * |
| 10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
| 11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
| 12 |
* the Free Software Foundation; either version 2 of the License, or * |
* the Free Software Foundation; either version 3 of the License, or * |
| 13 |
* (at your option) any later version. * |
* (at your option) any later version. * |
| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 20 |
#include "login.h" |
#include "login.h" |
| 21 |
#include "user_priv.h" |
#include "user_priv.h" |
| 22 |
#include "common.h" |
#include "common.h" |
| 23 |
|
#include "database.h" |
| 24 |
#include "log.h" |
#include "log.h" |
| 25 |
#include "io.h" |
#include "io.h" |
| 26 |
#include "screen.h" |
#include "screen.h" |
| 42 |
|
|
| 43 |
int bbs_exit() |
int bbs_exit() |
| 44 |
{ |
{ |
| 45 |
char temp[256]; |
display_file_ex(DATA_GOODBYE, 1, 0); |
|
|
|
|
strcpy(temp, app_home_dir); |
|
|
strcat(temp, "data/goodbye.txt"); |
|
|
display_file_ex(temp, 1, 0); |
|
| 46 |
|
|
| 47 |
sleep(1); |
sleep(1); |
| 48 |
|
|
| 51 |
|
|
| 52 |
int bbs_center() |
int bbs_center() |
| 53 |
{ |
{ |
| 54 |
int ch, result, redraw; |
int ch, redraw; |
|
char temp[256]; |
|
| 55 |
time_t t_last_action; |
time_t t_last_action; |
| 56 |
|
|
| 57 |
BBS_last_access_tm = t_last_action = time(0); |
BBS_last_access_tm = t_last_action = time(0); |
| 63 |
show_bottom(""); |
show_bottom(""); |
| 64 |
display_menu(get_menu(&bbs_menu, "TOPMENU")); |
display_menu(get_menu(&bbs_menu, "TOPMENU")); |
| 65 |
|
|
| 66 |
while (!SYS_exit) |
while (!SYS_server_exit) |
| 67 |
{ |
{ |
| 68 |
ch = igetch(); |
ch = igetch(0); |
| 69 |
|
|
| 70 |
if (time(0) - t_last_action >= 10) |
if (time(0) - t_last_action >= 10) |
| 71 |
{ |
{ |
| 77 |
switch (ch) |
switch (ch) |
| 78 |
{ |
{ |
| 79 |
case KEY_NULL: |
case KEY_NULL: |
| 80 |
return 0; |
return -1; |
| 81 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 82 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 83 |
{ |
{ |
| 84 |
return -1; |
return 0; |
| 85 |
} |
} |
|
continue; |
|
| 86 |
default: |
default: |
| 87 |
redraw = 1; |
redraw = 1; |
| 88 |
switch (menu_control(&bbs_menu, ch)) |
switch (menu_control(&bbs_menu, ch)) |
| 114 |
|
|
| 115 |
int bbs_main() |
int bbs_main() |
| 116 |
{ |
{ |
|
char temp[256]; |
|
| 117 |
int ret; |
int ret; |
| 118 |
|
|
| 119 |
set_input_echo(0); |
set_input_echo(0); |
| 132 |
clearscr(); |
clearscr(); |
| 133 |
|
|
| 134 |
// BBS Top 10 |
// BBS Top 10 |
| 135 |
strcpy(temp, app_home_dir); |
display_file_ex("./var/bbs_top.txt", 1, 1); |
|
strcat(temp, "data/bbs_top.txt"); |
|
|
display_file_ex(temp, 1, 1); |
|
| 136 |
|
|
| 137 |
// Main |
// Main |
| 138 |
bbs_center(); |
bbs_center(); |
| 141 |
bbs_exit(); |
bbs_exit(); |
| 142 |
log_std("User logout\n"); |
log_std("User logout\n"); |
| 143 |
|
|
| 144 |
|
MYSQL *db = db_open(); |
| 145 |
|
if (db == NULL) |
| 146 |
|
{ |
| 147 |
|
return -1; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
user_online_del(db); |
| 151 |
|
|
| 152 |
|
mysql_close(db); |
| 153 |
|
|
| 154 |
return 0; |
return 0; |
| 155 |
} |
} |