/[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.31 by sysadm, Mon Apr 28 03:30:59 2025 UTC Revision 1.41 by sysadm, Sat May 10 15:32:36 2025 UTC
# Line 1  Line 1 
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   ***************************************************************************/   ***************************************************************************/
16    
17    #include "bbs_main.h"
18  #include "bbs.h"  #include "bbs.h"
19    #include "welcome.h"
20    #include "login.h"
21    #include "user_priv.h"
22  #include "common.h"  #include "common.h"
23    #include "database.h"
24    #include "log.h"
25  #include "io.h"  #include "io.h"
26    #include "screen.h"
27  #include "menu.h"  #include "menu.h"
28  #include "bbs_cmd.h"  #include "bbs_cmd.h"
29    #include <unistd.h>
30  #include <time.h>  #include <time.h>
31  #include <string.h>  #include <string.h>
32    
 int bbs_main()  
 {  
         char temp[256];  
         int ret;  
   
         set_input_echo(0);  
   
         bbs_info();  
   
         // Welcome  
         bbs_welcome();  
   
         // Login  
         ret = bbs_login();  
         if (ret < 0)  
                 return -1;  
         log_std("User \"%s\"(%ld) login from %s:%d\n",  
                         BBS_username, BBS_priv.uid, hostaddr_client, port_client);  
         clearscr();  
   
         // BBS Top 10  
         strcpy(temp, app_home_dir);  
         strcat(temp, "data/bbs_top.txt");  
         display_file_ex(temp, 1, 1);  
   
         // Main  
         bbs_center();  
   
         // Logout  
         bbs_exit();  
         log_std("User logout\n");  
   
         return 0;  
 }  
   
33  int bbs_info()  int bbs_info()
34  {  {
35          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",
# Line 70  int bbs_info() Line 42  int bbs_info()
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);  
   
         sleep(1);  
46    
47          return 0;          return 0;
48  }  }
49    
50  int bbs_center()  int bbs_center()
51  {  {
52          int ch, result, redraw;          int ch;
         char temp[256];  
53          time_t t_last_action;          time_t t_last_action;
54    
55          BBS_last_access_tm = t_last_action = time(0);          BBS_last_access_tm = t_last_action = time(0);
# Line 96  int bbs_center() Line 61  int bbs_center()
61          show_bottom("");          show_bottom("");
62          display_menu(get_menu(&bbs_menu, "TOPMENU"));          display_menu(get_menu(&bbs_menu, "TOPMENU"));
63    
64          while (!SYS_exit)          while (!SYS_server_exit)
65          {          {
66                  ch = igetch();                  ch = igetch(0);
67    
68                  if (time(0) - t_last_action >= 10)                  if (time(0) - t_last_action >= 10)
69                  {                  {
# Line 110  int bbs_center() Line 75  int bbs_center()
75                  switch (ch)                  switch (ch)
76                  {                  {
77                  case KEY_NULL:                  case KEY_NULL:
                         return 0;  
78                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
79                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
80                          {                          {
81                                  return -1;                                  return 0;
82                          }                          }
83                          continue;                          continue;
84                  default:                  default:
                         redraw = 1;  
85                          switch (menu_control(&bbs_menu, ch))                          switch (menu_control(&bbs_menu, ch))
86                          {                          {
87                          case EXITBBS:                          case EXITBBS:
88                                  return 0;                                  return 0;
89                          case REDRAW:                          case REDRAW:
                                 break;  
                         case NOREDRAW:  
                         case UNKNOWN_CMD:  
                         default:  
                                 redraw = 0;  
                                 break;  
                         }  
                         if (redraw)  
                         {  
90                                  clearscr();                                  clearscr();
91                                  show_top("");                                  show_top("");
92                                  show_active_board();                                  show_active_board();
93                                  show_bottom("");                                  show_bottom("");
94                                  display_current_menu(&bbs_menu);                                  display_current_menu(&bbs_menu);
95                                    break;
96                            case NOREDRAW:
97                            case UNKNOWN_CMD:
98                            default:
99                                    break;
100                          }                          }
101                  }                  }
102                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(0);
# Line 145  int bbs_center() Line 104  int bbs_center()
104    
105          return 0;          return 0;
106  }  }
107    
108    int bbs_main()
109    {
110            int ret;
111    
112            set_input_echo(0);
113    
114            bbs_info();
115    
116            // Welcome
117            bbs_welcome();
118    
119            // Login
120            ret = bbs_login();
121            if (ret < 0)
122                    return -1;
123            log_std("User \"%s\"(%ld) login from %s:%d\n",
124                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
125            clearscr();
126    
127            // BBS Top 10
128            display_file_ex("./var/bbs_top.txt", 1, 1);
129    
130            // Main
131            bbs_center();
132    
133            // Logout
134            bbs_exit();
135            log_std("User logout\n");
136    
137            MYSQL *db = db_open();
138            if (db == NULL)
139            {
140                    return -1;
141            }
142    
143            user_online_del(db);
144    
145            mysql_close(db);
146    
147            return 0;
148    }


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

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