Skip to content

Commit

Permalink
Merge pull request #393 from midoks/dev
Browse files Browse the repository at this point in the history
0.13.3
  • Loading branch information
midoks authored Mar 16, 2023
2 parents 8849001 + f3d83ad commit 265e17b
Show file tree
Hide file tree
Showing 33 changed files with 798 additions and 95 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,11 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.13.2

* supervisor添加重启功能。
* 加入滚动写入日志 mw.writeFileLog方法。
* mysql导出优化优化。
* 添加tgbot插件[仅测试]
* TelegramBot机器人通知-加入配置。
* mariadb更新版本。
* 在线文件编辑优化。
### 版本更新 0.13.3

* tgbot插件[增加扩展功能]
* ssl功能优化。
* 网站统计-计划任务归档优化。

### JSDelivr安装地址

Expand Down
3 changes: 1 addition & 2 deletions class/core/cert_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ def requestsPost(self, url, data, timeout):
response = urllib.request.urlopen(req, timeout=timeout)
return response
except Exception as ex:

self.getError()
# self.getError()
raise Exception("requestsPost: {}".format(self.getError(str(ex))))

def getRequestJson(self, response):
Expand Down
104 changes: 99 additions & 5 deletions class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class config_api:

__version = '0.13.2'
__version = '0.13.3'
__api_addr = 'data/api.json'

def __init__(self):
Expand Down Expand Up @@ -348,7 +348,23 @@ def getPanelSslData(self):
keyPath = 'ssl/private.pem'
certPath = 'ssl/cert.pem'
if not os.path.exists(certPath):
mw.createSSL()
# 不再自动生成证书
# mw.createSSL()
cert['privateKey'] = ''
cert['is_https'] = ''
cert['certPem'] = ''
cert['rep'] = os.path.exists('ssl/input.pl')
cert['info'] = {'endtime': 0, 'subject': '无',
'notAfter': '无', 'notBefore': '无', 'issuer': '无'}
return cert

panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
if not os.path.exists(panel_ssl):
cert['is_https'] = ''
else:
ssl_data = mw.readFile(panel_ssl)
if ssl_data.find('$server_port !~ 443') != -1:
cert['is_https'] = 'checked'

cert['privateKey'] = mw.readFile(keyPath)
cert['certPem'] = mw.readFile(certPath)
Expand Down Expand Up @@ -380,13 +396,86 @@ def savePanelSslApi(self):
mw.writeFile('ssl/input.pl', 'True')
return mw.returnJson(True, '证书已保存!')

# 设置面板SSL证书设置
def setPanelHttpToHttpsApi(self):

bind_domain = 'data/bind_domain.pl'
if not os.path.exists(bind_domain):
return mw.returnJson(False, '先要绑定域名!')

keyPath = 'ssl/private.pem'
if not os.path.exists(keyPath):
return mw.returnJson(False, '未申请SSL证书!')

is_https = request.form.get('https', '').strip()

panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
if not os.path.exists(panel_ssl):
return mw.returnJson(False, '未开启面板SSL!')

if is_https == 'false':
conf = mw.readFile(panel_ssl)
if conf:
if conf.find('ssl_certificate') == -1:
return mw.returnJson(False, '当前未开启SSL')
to = "#error_page 404/404.html;\n\
#HTTP_TO_HTTPS_START\n\
if ($server_port !~ 443){\n\
rewrite ^(/.*)$ https://$host$1 permanent;\n\
}\n\
#HTTP_TO_HTTPS_END"
conf = conf.replace('#error_page 404/404.html;', to)
mw.writeFile(panel_ssl, conf)
else:
conf = mw.readFile(panel_ssl)
if conf:
rep = "\n\s*#HTTP_TO_HTTPS_START(.|\n){1,300}#HTTP_TO_HTTPS_END"
conf = re.sub(rep, '', conf)
rep = "\s+if.+server_port.+\n.+\n\s+\s*}"
conf = re.sub(rep, '', conf)
mw.writeFile(panel_ssl, conf)

mw.restartWeb()

action = '开启'
if is_https == 'true':
action = '关闭'
return mw.returnJson(True, action + 'HTTPS跳转成功!')

# 删除面板证书
def delPanelSslApi(self):
bind_domain = 'data/bind_domain.pl'
if not os.path.exists(bind_domain):
return mw.returnJson(False, '未绑定域名!')

siteName = mw.readFile(bind_domain).strip()

src_letpath = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName

dst_letpath = mw.getRunDir() + '/ssl'
dst_csrpath = dst_letpath + '/cert.pem'
dst_keypath = dst_letpath + '/private.pem'

if os.path.exists(src_letpath) or os.path.exists(dst_csrpath):
if os.path.exists(src_letpath):
mw.execShell('rm -rf ' + src_letpath)
if os.path.exists(dst_csrpath):
mw.execShell('rm -rf ' + dst_csrpath)
if os.path.exists(dst_keypath):
mw.execShell('rm -rf ' + dst_keypath)
# mw.restartWeb()
return mw.returnJson(True, '已经删除SSL!')

# mw.restartWeb()
return mw.returnJson(False, '已经不存在SSL!')

# 申请面板let证书
def applyPanelLetSslApi(self):

# check domain is bind?
bind_domain = 'data/bind_domain.pl'
if not os.path.exists(bind_domain):
return mw.returnJson(False, '未绑定域名!')
return mw.returnJson(False, '先要绑定域名!')

siteName = mw.readFile(bind_domain).strip()
auth_to = mw.getRunDir() + "/tmp"
Expand All @@ -404,6 +493,8 @@ def applyPanelLetSslApi(self):
dst_csrpath = dst_letpath + '/cert.pem'
dst_keypath = dst_letpath + '/private.pem'

is_already_apply = False

if not os.path.exists(src_letpath):
import cert_api
data = cert_api.cert_api().applyCertApi(to_args)
Expand All @@ -415,6 +506,8 @@ def applyPanelLetSslApi(self):
msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
return mw.returnJson(data['status'], msg, data['msg'])
else:
is_already_apply = True

mw.buildSoftLink(src_csrpath, dst_csrpath, True)
mw.buildSoftLink(src_keypath, dst_keypath, True)
Expand All @@ -426,6 +519,9 @@ def applyPanelLetSslApi(self):
if os.path.exists(tmp_well_know):
mw.execShell('rm -rf ' + tmp_well_know)

if is_already_apply:
return mw.returnJson(True, '重复申请!', data)

return mw.returnJson(True, '申请成功!', data)

def setPanelDomainApi(self):
Expand Down Expand Up @@ -509,8 +605,6 @@ def setPanelSslApi(self):
return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
else:
try:
if not os.path.exists('ssl/input.ssl'):
mw.createSSL()
mw.writeFile(sslConf, 'True')

keyPath = mw.getRunDir() + '/ssl/private.pem'
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/js/mariadb.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ function myLogs(){
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
'+line_status+'\
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
</p>';
$(".soft-man-con").html(limitCon);

Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql-apt/js/mysql-apt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ function myLogs(){
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
'+line_status+'\
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
</p>';
$(".soft-man-con").html(limitCon);

Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql-yum/js/mysql-yum.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ function myLogs(){
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
'+line_status+'\
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
</p>';
$(".soft-man-con").html(limitCon);

Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<p onclick="masterOrSlaveConf($('.plugin_version').attr('version'))">主从配置</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con" style="height: 530px; overflow: auto;"></div>
<div class="soft-man-con"></div>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/js/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ function myLogs(){
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
'+line_status+'\
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
</p>';
$(".soft-man-con").html(limitCon);

Expand Down
1 change: 1 addition & 0 deletions plugins/phpmyadmin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

</div>
<script type="text/javascript">
resetPluginWinHeight(500);
$.getScript( "/plugins/file?name=phpmyadmin&f=js/phpmyadmin.js", function(){
pluginService('phpmyadmin');
});
Expand Down
3 changes: 2 additions & 1 deletion plugins/tgbot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<p class="bgw" onclick="pluginService('tgbot');">服务</p>
<p onclick="pluginInitD('tgbot');">自启动</p>
<p onclick="botConf();">Bot配置</p>
<p onclick="botExtList();">扩展列表</p>
<p onclick="pluginLogs('tgbot','','run_log');">日志</p>
</div>
<div class="bt-w-con pd15">
Expand All @@ -18,7 +19,7 @@
}
</style>
<script type="text/javascript">
resetPluginWinHeight(300);
resetPluginWinHeight(350);
$.getScript( "/plugins/file?name=tgbot&f=js/tgbot.js", function(){
pluginService('tgbot');
});
Expand Down
Loading

0 comments on commit 265e17b

Please sign in to comment.