forked from HenryHu/pybbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.py
105 lines (90 loc) · 2.31 KB
/
Config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python
from ConfigParser import *
from StringIO import *
from Log import Log
import datetime
class Config:
@staticmethod
def LoadConfig():
Config.parser = ConfigParser()
try:
sconff = open(CONFIG_FILE, "r")
except:
Log.warn("cannot open config file")
return
sconf = StringIO()
sconf.write("[sysconf]\n")
sconf.write(sconff.read())
sconf.seek(0)
Config.parser.readfp(sconf)
sconff.close()
sconf.close()
return
@staticmethod
def GetBoardsFile():
return BOARDS_FILE
@staticmethod
def GetInt(name, defval):
if (Config.parser.has_option('sysconf', name)):
return Config.parser.getint('sysconf', name)
else:
return defval
@staticmethod
def GetString(name, defval):
if (Config.parser.has_option('sysconf', name)):
val = Config.parser.get('sysconf', name)
if (val[0] == '"' and val.endswith('"')):
val = val[1:-1]
return val.decode('gbk')
else:
return defval
BBS_ROOT = '/home/bbs/'
BBS_XMPP_CERT_FILE = BBS_ROOT + "xmpp.crt"
BBS_XMPP_KEY_FILE = BBS_ROOT + "xmpp.key"
BOARDS_FILE = BBS_ROOT + '.BOARDS'
STRLEN = 80
ARTICLE_TITLE_LEN = 60
BM_LEN = 60
MAXBOARD = 400
CONFIG_FILE = BBS_ROOT + 'etc/sysconf.ini'
FILENAME_LEN = 20
OWNER_LEN = 30
SESSIONID_LEN = 32
REFRESH_TOKEN_LEN = 128
NAMELEN = 40
IDLEN = 12
MD5PASSLEN = 16
OLDPASSLEN = 14
MOBILE_NUMBER_LEN = 17
MAXCLUB = 128
MAXUSERS = 20000
MAX_MSG_SIZE = 1024
MAXFRIENDS = 400
MAXMESSAGE = 5
MAXSIGLINES = 6
IPLEN = 16
DEFAULTBOARD = "sysop"
BLESS_BOARD = "happy_birthday"
QUOTED_LINES = 10
MAXACTIVE = 8000
USHM_SIZE = MAXACTIVE + 10
UTMP_HASHSIZE = USHM_SIZE * 4
UCACHE_SEMLOCK = 0
LEN_FRIEND_EXP = 15
REFRESH_TIME = 30 # time between friend list update
USER_TITLE_LEN = 18 # used in UCache
SESSION_TIMEOUT = datetime.timedelta(30)
SESSION_TIMEOUT_SECONDS = 86400*30
XMPP_IDLE_TIME = 300
XMPP_LONG_IDLE_TIME = 1800
XMPP_UPDATE_TIME_INTERVAL = 10
XMPP_PING_TIME_INTERVAL = 60
PUBLIC_SHMKEY = 3700
MAX_ATTACHSIZE = 20 * 1024 * 1024
BMDEL_DECREASE = True
SYSMAIL_BOARD = "sysmail"
ADD_EDITMARK = True
SEARCH_COUNT_LIMIT = 20
MAIL_SIZE_LIMIT = -1
SEC_DELETED_OLDHOME = 3600 * 24 * 3
SELF_INTRO_MAX_LEN = 800