/[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.30 by sysadm, Thu Jun 23 16:43:21 2005 UTC Revision 1.35 by sysadm, Sun May 4 14:54:55 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            bbs_main.c  -  description                                                    bbs_main.c  -  description
3                               -------------------                                                           -------------------
4      begin                : Mon Oct 18 2004          begin                : Mon Oct 18 2004
5      copyright            : (C) 2004 by Leaflet          copyright            : (C) 2004 by Leaflet
6      email                : leaflet@leafok.com          email                : leaflet@leafok.com
7   ***************************************************************************/   ***************************************************************************/
8    
9  /***************************************************************************  /***************************************************************************
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18    #include "bbs_main.h"
19  #include "bbs.h"  #include "bbs.h"
20    #include "welcome.h"
21    #include "login.h"
22    #include "user_priv.h"
23  #include "common.h"  #include "common.h"
24    #include "database.h"
25    #include "log.h"
26  #include "io.h"  #include "io.h"
27    #include "screen.h"
28  #include "menu.h"  #include "menu.h"
29  #include "bbs_cmd.h"  #include "bbs_cmd.h"
30    #include <unistd.h>
31  #include <time.h>  #include <time.h>
32  #include <string.h>  #include <string.h>
33    
34  int  int bbs_info()
 bbs_main ()  
35  {  {
36    char temp[256];          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
37    int ret;                     BBS_name, BBS_server, app_version);
38    
39    set_input_echo (0);          iflush();
40    
41    bbs_info ();          return 0;
42    }
   //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);  
43    
44    //Main  int bbs_exit()
45    bbs_center ();  {
46            display_file_ex(DATA_GOODBYE, 1, 0);
47    
48    //Logout          sleep(1);
   bbs_exit ();  
   log_std ("User logout\n");  
49    
50    return 0;          return 0;
51  }  }
52    
53  int  int bbs_center()
 bbs_info ()  
54  {  {
55    prints ("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",          int ch, redraw;
56            BBS_name, BBS_server, app_version);          time_t t_last_action;
57    
58    iflush ();          BBS_last_access_tm = t_last_action = time(0);
59    
60    return 0;          clearscr();
 }  
61    
62  int          show_top("");
63  bbs_exit ()          show_active_board();
64  {          show_bottom("");
65    char temp[256];          display_menu(get_menu(&bbs_menu, "TOPMENU"));
66    
67    strcpy (temp, app_home_dir);          while (!SYS_exit)
68    strcat (temp, "data/goodbye.txt");          {
69    display_file_ex (temp, 1, 0);                  ch = igetch(0);
70    
71    sleep (1);                  if (time(0) - t_last_action >= 10)
72                    {
73                            t_last_action = time(0);
74                            show_active_board();
75                            show_bottom("");
76                    }
77    
78                    switch (ch)
79                    {
80                    case KEY_NULL:
81                            return 0;
82                    case KEY_TIMEOUT:
83                            if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
84                            {
85                                    return -1;
86                            }
87                            continue;
88                    default:
89                            redraw = 1;
90                            switch (menu_control(&bbs_menu, ch))
91                            {
92                            case EXITBBS:
93                                    return 0;
94                            case REDRAW:
95                                    break;
96                            case NOREDRAW:
97                            case UNKNOWN_CMD:
98                            default:
99                                    redraw = 0;
100                                    break;
101                            }
102                            if (redraw)
103                            {
104                                    clearscr();
105                                    show_top("");
106                                    show_active_board();
107                                    show_bottom("");
108                                    display_current_menu(&bbs_menu);
109                            }
110                    }
111                    BBS_last_access_tm = time(0);
112            }
113    
114    return 0;          return 0;
115  }  }
116    
117  int  int bbs_main()
 bbs_center ()  
118  {  {
119    int ch, result, redraw;          int ret;
   char temp[256];  
   time_t t_last_action;  
120    
121    BBS_last_access_tm = t_last_action = time (0);          set_input_echo(0);
122    
123    clearscr ();          bbs_info();
124    
125    show_top ("");          // Welcome
126    show_active_board ();          bbs_welcome();
   show_bottom ("");  
   display_menu (get_menu (&bbs_menu, "TOPMENU"));  
127    
128    while (!SYS_exit)          // Login
129      {          ret = bbs_login();
130        ch = igetch ();          if (ret < 0)
131                    return -1;
132            log_std("User \"%s\"(%ld) login from %s:%d\n",
133                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
134            clearscr();
135    
136        if (time (0) - t_last_action >= 10)          // BBS Top 10
137          {          display_file_ex("./var/bbs_top.txt", 1, 1);
138            t_last_action = time (0);  
139            show_active_board ();          // Main
140            show_bottom ("");          bbs_center();
         }  
141    
142        switch (ch)          // Logout
143            bbs_exit();
144            log_std("User logout\n");
145    
146            MYSQL *db = db_open();
147            if (db == NULL)
148          {          {
149          case KEY_NULL:                  return -1;
           return 0;  
         case KEY_TIMEOUT:  
           if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME)  
             {  
               return -1;  
             }  
           continue;  
         default:  
           redraw = 1;  
           switch (menu_control (&bbs_menu, ch))  
             {  
             case EXITBBS:  
               return 0;  
             case REDRAW:  
               break;  
             case NOREDRAW:  
             case UNKNOWN_CMD:  
             default:  
               redraw = 0;  
               break;  
             }  
           if (redraw)  
             {  
               clearscr ();  
               show_top ("");  
               show_active_board ();  
               show_bottom ("");  
               display_current_menu (&bbs_menu);  
             }  
150          }          }
       BBS_last_access_tm = time (0);  
     }  
151    
152    return 0;          user_online_del(db);
153    
154            mysql_close(db);
155    
156            return 0;
157  }  }


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

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