/[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.93 by sysadm, Tue Oct 21 06:24:51 2025 UTC Revision 1.94 by sysadm, Sat Nov 1 10:35:42 2025 UTC
# Line 50  int bbs_welcome(void) Line 50  int bbs_welcome(void)
50  {  {
51          char sql[SQL_BUFFER_LEN];          char sql[SQL_BUFFER_LEN];
52    
53          u_int32_t u_online = 0;          int u_online = 0;
54          u_int32_t u_anonymous = 0;          int u_anonymous = 0;
55          u_int32_t u_total = 0;          int u_total = 0;
56          u_int32_t u_login_count = 0;          int u_login_count = 0;
57    
58          MYSQL *db;          MYSQL *db;
59          MYSQL_RES *rs;          MYSQL_RES *rs;
60          MYSQL_ROW row;          MYSQL_ROW row;
61    
62          db = db_open();          if (get_user_online_list_count(&u_online, &u_anonymous) < 0)
         if (db == NULL)  
         {  
                 return -1;  
         }  
   
         snprintf(sql, sizeof(sql),  
                          "SELECT COUNT(*) AS cc FROM "  
                          "(SELECT DISTINCT SID FROM user_online "  
                          "WHERE last_tm >= SUBDATE(NOW(), INTERVAL %d SECOND)) AS t1",  
                          BBS_user_off_line);  
         if (mysql_query(db, sql) != 0)  
         {  
                 log_error("Query user_online error: %s\n", mysql_error(db));  
                 mysql_close(db);  
                 return -2;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
63          {          {
64                  log_error("Get user_online data failed\n");                  log_error("get_user_online_list_count() error\n");
65                  mysql_close(db);                  u_online = 0;
                 return -2;  
66          }          }
67          if ((row = mysql_fetch_row(rs)))          u_online += u_anonymous;
68            u_online++; // current user
69            if (BBS_priv.uid == 0)
70          {          {
71                  u_online = (u_int32_t)atoi(row[0]);                  u_anonymous++;
72          }          }
         mysql_free_result(rs);  
73    
74          snprintf(sql, sizeof(sql),          if (get_user_list_count(&u_total) < 0)
                          "SELECT COUNT(*) AS cc FROM "  
                          "(SELECT DISTINCT SID FROM user_online "  
                          "WHERE UID = 0 AND last_tm >= SUBDATE(NOW(), INTERVAL %d SECOND)) AS t1",  
                          BBS_user_off_line);  
         if (mysql_query(db, sql) != 0)  
         {  
                 log_error("Query user_online error: %s\n", mysql_error(db));  
                 mysql_close(db);  
                 return -2;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
75          {          {
76                  log_error("Get user_online data failed\n");                  log_error("get_user_list_count() error\n");
77                  mysql_close(db);                  u_total = 0;
                 return -2;  
         }  
         if ((row = mysql_fetch_row(rs)))  
         {  
                 u_anonymous = (u_int32_t)atoi(row[0]);  
78          }          }
         mysql_free_result(rs);  
79    
80          snprintf(sql, sizeof(sql), "SELECT COUNT(UID) AS cc FROM user_list WHERE enable");          db = db_open();
81          if (mysql_query(db, sql) != 0)          if (db == NULL)
         {  
                 log_error("Query user_list error: %s\n", mysql_error(db));  
                 mysql_close(db);  
                 return -2;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
         {  
                 log_error("Get user_list data failed\n");  
                 mysql_close(db);  
                 return -2;  
         }  
         if ((row = mysql_fetch_row(rs)))  
82          {          {
83                  u_total = (u_int32_t)atoi(row[0]);                  return -1;
84          }          }
         mysql_free_result(rs);  
85    
86          snprintf(sql, sizeof(sql), "SELECT ID FROM user_login_log ORDER BY ID LIMIT 1");          snprintf(sql, sizeof(sql), "SELECT ID FROM user_login_log ORDER BY ID LIMIT 1");
87          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
# Line 145  int bbs_welcome(void) Line 98  int bbs_welcome(void)
98          }          }
99          if ((row = mysql_fetch_row(rs)))          if ((row = mysql_fetch_row(rs)))
100          {          {
101                  u_login_count = (u_int32_t)atoi(row[0]);                  u_login_count = atoi(row[0]);
102          }          }
103          mysql_free_result(rs);          mysql_free_result(rs);
104    
105          mysql_close(db);          mysql_close(db);
106    
         // Count current user before login  
         u_online++;  
         u_anonymous++;  
   
107          // Display logo          // Display logo
108          display_file(DATA_WELCOME, 2);          display_file(DATA_WELCOME, 2);
109    


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

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