/[LeafOK_CVS]/lbbs/src/bbs_main.c
ViewVC logotype

Diff of /lbbs/src/bbs_main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.66 by sysadm, Sat Jun 7 08:38:50 2025 UTC Revision 1.73 by sysadm, Sat Jun 21 02:15:18 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17  #include "bbs_main.h"  #include "article_view_log.h"
18  #include "bbs.h"  #include "bbs.h"
19  #include "login.h"  #include "bbs_cmd.h"
20  #include "user_priv.h"  #include "bbs_main.h"
21  #include "common.h"  #include "common.h"
22  #include "database.h"  #include "database.h"
23  #include "log.h"  #include "editor.h"
24  #include "io.h"  #include "io.h"
25  #include "screen.h"  #include "log.h"
26    #include "login.h"
27  #include "menu.h"  #include "menu.h"
28  #include "bbs_cmd.h"  #include "screen.h"
29  #include "section_list.h"  #include "section_list.h"
30  #include "trie_dict.h"  #include "trie_dict.h"
31  #include <unistd.h>  #include "user_priv.h"
 #include <time.h>  
 #include <string.h>  
32  #include <stdlib.h>  #include <stdlib.h>
33    #include <string.h>
34    #include <time.h>
35    #include <unistd.h>
36    
37  int bbs_info()  int bbs_info()
38  {  {
39          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
40                     BBS_name, BBS_server, APP_NAME_VER);                     BBS_name, BBS_server, APP_INFO);
41    
42          return iflush();          return iflush();
43  }  }
# Line 150  int bbs_welcome(void) Line 152  int bbs_welcome(void)
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"
# Line 183  int bbs_logout(void) Line 185  int bbs_logout(void)
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    
# Line 195  int bbs_center() Line 197  int bbs_center()
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    
# Line 209  int bbs_center() Line 211  int bbs_center()
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("");
# Line 219  int bbs_center() Line 221  int bbs_center()
221                          iflush();                          iflush();
222                  }                  }
223    
224                    if (user_online_update("MENU") < 0)
225                    {
226                            log_error("user_online_update(MENU) error\n");
227                    }
228    
229                  switch (ch)                  switch (ch)
230                  {                  {
231                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
232                          return 0;                          return 0;
233                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
234                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
235                          {                          {
236                                  return 0;                                  return 0;
237                          }                          }
# Line 237  int bbs_center() Line 244  int bbs_center()
244                          case EXITBBS:                          case EXITBBS:
245                                  return 0;                                  return 0;
246                          case REDRAW:                          case REDRAW:
247                                  t_last_action = time(0);                                  t_last_action = time(NULL);
248                                  clearscr();                                  clearscr();
249                                  show_top("", BBS_name, "");                                  show_top("", BBS_name, "");
250                                  show_active_board();                                  show_active_board();
# Line 252  int bbs_center() Line 259  int bbs_center()
259                          iflush();                          iflush();
260                  }                  }
261    
262                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
263          }          }
264    
265          return 0;          return 0;
# Line 306  int bbs_main() Line 313  int bbs_main()
313                  goto cleanup;                  goto cleanup;
314          }          }
315    
316          // Load article_view_log          // Load article view log
317            if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0)
318            {
319                    log_error("article_view_log_load() error\n");
320                    goto cleanup;
321            }
322    
323            // Init editor memory pool
324            if (editor_memory_pool_init() < 0)
325            {
326                    log_error("editor_memory_pool_init() error\n");
327                    goto cleanup;
328            }
329    
330          clearscr();          clearscr();
331    
332          // BBS Top 10          // BBS Top 10
333          display_file(VAR_BBS_TOP, 1, 1);          display_file(VAR_BBS_TOP, 1);
334    
335          // Main          // Main
336          bbs_center();          bbs_center();
# Line 319  int bbs_main() Line 338  int bbs_main()
338          // Logout          // Logout
339          bbs_logout();          bbs_logout();
340    
341            // Save incremental article view log
342            if (article_view_log_save_inc(&BBS_article_view_log) < 0)
343            {
344                    log_error("article_view_log_save_inc() error\n");
345            }
346    
347  cleanup:  cleanup:
348            // Cleanup editor memory pool
349            editor_memory_pool_cleanup();
350    
351            // Unload article view log
352            article_view_log_unload(&BBS_article_view_log);
353    
354          // Detach menu in shared memory          // Detach menu in shared memory
355          detach_menu_shm(p_bbs_menu);          detach_menu_shm(p_bbs_menu);
356          free(p_bbs_menu);          free(p_bbs_menu);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1