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

Diff of /lbbs/src/bbs.c

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

Revision 1.25 by sysadm, Wed Jun 18 02:29:54 2025 UTC Revision 1.37 by sysadm, Tue Nov 4 14:58:56 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                          bbs.c  -  description  /*
3                                                           -------------------   * bbs
4          Copyright            : (C) 2004-2025 by Leaflet   *   - BBS related common definitions
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "bbs.h"  #include "bbs.h"
10  #include "common.h"  #include "common.h"
11  #include "user_priv.h"  #include "user_priv.h"
12    #include <limits.h>
13  #include <stdio.h>  #include <stdio.h>
14  #include <signal.h>  #include <signal.h>
15  #include <time.h>  #include <time.h>
# Line 32  char BBS_address[BBS_address_max_len + 1 Line 25  char BBS_address[BBS_address_max_len + 1
25  in_port_t BBS_port[2] = {BBS_port_default, BBS_ssh_port_default};  in_port_t BBS_port[2] = {BBS_port_default, BBS_ssh_port_default};
26  int BBS_max_client = MAX_CLIENT_LIMIT;  int BBS_max_client = MAX_CLIENT_LIMIT;
27  int BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT;  int BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT;
28  int BBS_max_user = BBS_MAX_USER_LIMIT;  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日";
29  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000 1 1";  int BBS_sys_id = 1;
30    
31    const int BBS_section_list_load_interval = 1; // second
32    
33    // User
34    const int BBS_user_list_load_interval = 60;               // 1 minute
35    const int BBS_user_online_list_load_interval = 5; // 5 seconds
36    const int BBS_user_off_line = 900;                                // 15 minutes
37    
38  char BBS_username[BBS_username_max_len + 1];  char BBS_username[BBS_username_max_len + 1];
39  char BBS_nickname[BBS_nickname_max_len + 1];  char BBS_nickname[BBS_nickname_max_len + 1];
# Line 44  time_t BBS_login_tm; Line 44  time_t BBS_login_tm;
44  time_t BBS_last_access_tm;  time_t BBS_last_access_tm;
45    
46  char BBS_current_action[BBS_current_action_max_len + 1];  char BBS_current_action[BBS_current_action_max_len + 1];
47    time_t BBS_current_action_tm;
48    
49    const int BBS_current_action_refresh_interval = 60; // 1 minute
50    
51    static const int astro_dates[] = {
52            21, 20, 21, 21, 22, 22, 23, 24, 24, 24, 23, 22};
53    
54    static const char *astro_names[] = {
55            "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"};
56    
57    static const int BBS_user_level_points[] = {
58            INT_MIN, // 0
59            50,              // 1
60            200,     // 2
61            500,     // 3
62            1000,    // 4
63            2000,    // 5
64            5000,    // 6
65            10000,   // 7
66            20000,   // 8
67            30000,   // 9
68            50000,   // 10
69            60000,   // 11
70            70000,   // 12
71            80000,   // 13
72            90000,   // 14
73            100000,  // 15
74    };
75    
76    static const char *BBS_user_level_names[] = {
77            "新手上路", // 0
78            "初来乍练", // 1
79            "白手起家", // 2
80            "略懂一二", // 3
81            "小有作为", // 4
82            "对答如流", // 5
83            "精于此道", // 6
84            "博大精深", // 7
85            "登峰造极", // 8
86            "论坛砥柱", // 9
87            "☆☆☆☆☆",        // 10
88            "★☆☆☆☆",        // 11
89            "★★☆☆☆",        // 12
90            "★★★☆☆",        // 13
91            "★★★★☆",        // 14
92            "★★★★★",        // 15
93    };
94    
95    static const int BBS_user_level_cnt = sizeof(BBS_user_level_names) / sizeof(const char *);
96    
97    const char *get_astro_name(time_t birthday)
98    {
99            struct tm tm_birth;
100    
101            gmtime_r(&birthday, &tm_birth);
102    
103            if (tm_birth.tm_mday < astro_dates[tm_birth.tm_mon])
104            {
105                    return astro_names[tm_birth.tm_mon];
106            }
107    
108            return astro_names[tm_birth.tm_mon + 1];
109    }
110    
111    int get_user_level(int point)
112    {
113            int left;
114            int right;
115            int mid;
116    
117            left = 0;
118            right = BBS_user_level_cnt - 1;
119    
120            while (left < right)
121            {
122                    mid = (left + right) / 2;
123                    if (point < BBS_user_level_points[mid])
124                    {
125                            right = mid - 1;
126                    }
127                    else if (point > BBS_user_level_points[mid])
128                    {
129                            left = mid + 1;
130                    }
131                    else // if (point == user_level_points[mid])
132                    {
133                            left = mid;
134                            break;
135                    }
136            }
137    
138            if (point < BBS_user_level_points[left])
139            {
140                    left--;
141            }
142    
143            return left;
144    }
145    
146    const char *get_user_level_name(int level)
147    {
148            return BBS_user_level_names[level];
149    }
150    
151  char *setuserfile(char *buf, size_t len, const char *filename)  char *setuserfile(char *buf, size_t len, const char *filename)
152  {  {


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

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