/[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.38 by sysadm, Sat May 10 02:14:46 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    
33  int  int bbs_info()
 bbs_main ()  
34  {  {
35    char temp[256];          prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",
36    int ret;                     BBS_name, BBS_server, app_version);
37    
38    set_input_echo (0);          iflush();
39    
40    bbs_info ();          return 0;
41    }
   //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);  
42    
43    //Main  int bbs_exit()
44    bbs_center ();  {
45            display_file_ex(DATA_GOODBYE, 1, 0);
46    
47    //Logout          sleep(1);
   bbs_exit ();  
   log_std ("User logout\n");  
48    
49    return 0;          return 0;
50  }  }
51    
52  int  int bbs_center()
 bbs_info ()  
53  {  {
54    prints ("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s]  \033[37m( %s )\r\n",          int ch, redraw;
55            BBS_name, BBS_server, app_version);          time_t t_last_action;
56    
57    iflush ();          BBS_last_access_tm = t_last_action = time(0);
58    
59    return 0;          clearscr();
 }  
60    
61  int          show_top("");
62  bbs_exit ()          show_active_board();
63  {          show_bottom("");
64    char temp[256];          display_menu(get_menu(&bbs_menu, "TOPMENU"));
65    
66    strcpy (temp, app_home_dir);          while (!SYS_server_exit)
67    strcat (temp, "data/goodbye.txt");          {
68    display_file_ex (temp, 1, 0);                  ch = igetch(0);
69    
70    sleep (1);                  if (time(0) - t_last_action >= 10)
71                    {
72                            t_last_action = time(0);
73                            show_active_board();
74                            show_bottom("");
75                    }
76    
77                    switch (ch)
78                    {
79                    case KEY_NULL:
80                            return -1;
81                    case KEY_TIMEOUT:
82                            if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)
83                            {
84                                    return 0;
85                            }
86                    default:
87                            redraw = 1;
88                            switch (menu_control(&bbs_menu, ch))
89                            {
90                            case EXITBBS:
91                                    return 0;
92                            case REDRAW:
93                                    break;
94                            case NOREDRAW:
95                            case UNKNOWN_CMD:
96                            default:
97                                    redraw = 0;
98                                    break;
99                            }
100                            if (redraw)
101                            {
102                                    clearscr();
103                                    show_top("");
104                                    show_active_board();
105                                    show_bottom("");
106                                    display_current_menu(&bbs_menu);
107                            }
108                    }
109                    BBS_last_access_tm = time(0);
110            }
111    
112    return 0;          return 0;
113  }  }
114    
115  int  int bbs_main()
 bbs_center ()  
116  {  {
117    int ch, result, redraw;          int ret;
   char temp[256];  
   time_t t_last_action;  
118    
119    BBS_last_access_tm = t_last_action = time (0);          set_input_echo(0);
120    
121    clearscr ();          bbs_info();
122    
123    show_top ("");          // Welcome
124    show_active_board ();          bbs_welcome();
   show_bottom ("");  
   display_menu (get_menu (&bbs_menu, "TOPMENU"));  
125    
126    while (!SYS_exit)          // Login
127      {          ret = bbs_login();
128        ch = igetch ();          if (ret < 0)
129                    return -1;
130            log_std("User \"%s\"(%ld) login from %s:%d\n",
131                            BBS_username, BBS_priv.uid, hostaddr_client, port_client);
132            clearscr();
133    
134        if (time (0) - t_last_action >= 10)          // BBS Top 10
135          {          display_file_ex("./var/bbs_top.txt", 1, 1);
136            t_last_action = time (0);  
137            show_active_board ();          // Main
138            show_bottom ("");          bbs_center();
         }  
139    
140        switch (ch)          // Logout
141            bbs_exit();
142            log_std("User logout\n");
143    
144            MYSQL *db = db_open();
145            if (db == NULL)
146          {          {
147          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);  
             }  
148          }          }
       BBS_last_access_tm = time (0);  
     }  
149    
150    return 0;          user_online_del(db);
151    
152            mysql_close(db);
153    
154            return 0;
155  }  }


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

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