Skip to content

Commit c77d409

Browse files
committed
up
1 parent 39603f3 commit c77d409

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

web/admin/setting/setting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def set_ipv6_status():
191191
ipv6_file = __file['ipv6']
192192
if os.path.exists(ipv6_file):
193193
os.remove(ipv6_file)
194+
mw.writeLog('面板设置', '关闭面板IPv6兼容!')
194195
mw.returnData('面板设置', '关闭面板IPv6兼容!')
195196
else:
196197
mw.writeFile(ipv6_file, 'True')
@@ -222,7 +223,7 @@ def set_port():
222223
# firewall_api.firewall_api().addAcceptPort(port)
223224
# firewall_api.firewall_api().firewallReload()
224225

225-
# system_api.system_api().restartMw()
226+
mw.restartMw()
226227

227228
return mw.returnJson(True, '端口保存成功!')
228229

web/thisdb/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
from .init import *
1212
from .option import *
1313
from .user import *
14+
from .sites import *

web/thisdb/option.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# Author: midoks <[email protected]>
99
# ---------------------------------------------------------------------------------
1010

11-
11+
import os
12+
import json
1213
import core.mw as mw
1314

1415
def getOption(name,
@@ -25,4 +26,33 @@ def getOption(name,
2526

2627
if len(data) == 0:
2728
return default
28-
return data
29+
return data
30+
31+
32+
def getOptionByJson(name,
33+
type: str | None = 'common',
34+
default : object | None = None
35+
) -> object:
36+
'''
37+
获取配置的值,返回对象类型
38+
:name -> str 名称 (必填)
39+
:type -> str 类型 (可选|默认common)
40+
:default -> str 默认值 (可选)
41+
'''
42+
data = mw.M('option').field('name').where('name=? and type=?',(name, type,)).getField('value')
43+
if len(data) == 0:
44+
return default
45+
if data is not None:
46+
return json.loads(data)
47+
48+
def setOption(name, value,
49+
type: str | None = 'common'
50+
) -> bool:
51+
'''
52+
设置配置的值
53+
:name -> str 名称 (必填)
54+
:value -> object值 (必填)
55+
:type -> str 类型 (可选|默认common)
56+
'''
57+
mw.M('option').field('name').where('name=? and type=?',(name, type,)).setField('value', value)
58+
return True

web/thisdb/sites.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# coding:utf-8
2+
3+
# ---------------------------------------------------------------------------------
4+
# MW-Linux面板
5+
# ---------------------------------------------------------------------------------
6+
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
7+
# ---------------------------------------------------------------------------------
8+
# Author: midoks <[email protected]>
9+
# ---------------------------------------------------------------------------------
10+
11+
import core.mw as mw
12+
13+
def getSitesCount():
14+
return mw.M('sites').count()
15+

web/utils/config.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from admin import model
1414

1515
import core.mw as mw
16+
import thisdb
1617

1718
def getUnauthStatus(
1819
code: str | None = '0'
@@ -44,15 +45,15 @@ def getGlobalVar():
4445
获取全局变量
4546
'''
4647
data = {}
47-
data['title'] = model.getOption('title', default='后羿面板')
48-
data['ip'] = model.getOption('server_ip', default='127.0.0.1')
48+
data['title'] = thisdb.getOption('title', default='后羿面板')
49+
data['ip'] = thisdb.getOption('server_ip', default='127.0.0.1')
4950

50-
data['site_path'] = model.getOption('site_path', default=mw.getFatherDir()+'/wwwroot')
51-
data['backup_path'] = model.getOption('backup_path', default=mw.getFatherDir()+'/backup')
52-
data['admin_path'] = '/'+model.getOption('admin_path', default='')
53-
data['debug'] = model.getOption('debug', default='close')
54-
data['admin_close'] = model.getOption('admin_close', default='no')
55-
data['site_count'] = model.getSitesCount()
51+
data['site_path'] = thisdb.getOption('site_path', default=mw.getFatherDir()+'/wwwroot')
52+
data['backup_path'] = thisdb.getOption('backup_path', default=mw.getFatherDir()+'/backup')
53+
data['admin_path'] = '/'+thisdb.getOption('admin_path', default='')
54+
data['debug'] = thisdb.getOption('debug', default='close')
55+
data['admin_close'] = thisdb.getOption('admin_close', default='no')
56+
data['site_count'] = thisdb.getSitesCount()
5657
data['port'] = mw.getHostPort()
5758

5859
__file = mw.getCommonFile()
@@ -62,16 +63,16 @@ def getGlobalVar():
6263
data['ipv6'] = ''
6364

6465
# 获取未认证状态信息
65-
unauthorized_status = model.getOption('unauthorized_status', default='0')
66+
unauthorized_status = thisdb.getOption('unauthorized_status', default='0')
6667
data['unauthorized_status'] = getUnauthStatus(code=unauthorized_status)
67-
data['basic_auth'] = model.getOptionByJson('basic_auth', default={'open':False})
68+
data['basic_auth'] = thisdb.getOptionByJson('basic_auth', default={'open':False})
6869

6970
# 服务器时间
7071
sformat = 'date +"%Y-%m-%d %H:%M:%S %Z %z"'
7172
data['systemdate'] = mw.execShell(sformat)[0].strip()
7273

7374

74-
data['hook_menu'] = model.getOptionByJson('hook_menu',type='hook',default=[])
75-
data['hook_global_static'] = model.getOptionByJson('hook_global_static',type='hook',default=[])
75+
data['hook_menu'] = thisdb.getOptionByJson('hook_menu',type='hook',default=[])
76+
data['hook_global_static'] = thisdb.getOptionByJson('hook_global_static',type='hook',default=[])
7677

7778
return data

0 commit comments

Comments
 (0)