From fda19b6103c99376b6da918396d13ce339052d9c Mon Sep 17 00:00:00 2001 From: dami Date: Fri, 18 Apr 2025 19:51:49 +0800 Subject: [PATCH 1/7] update --- plugins/tgbot/startup/extend/push_ad.py | 2 +- plugins/tgbot/startup/extend/push_notice_msg.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/tgbot/startup/extend/push_ad.py b/plugins/tgbot/startup/extend/push_ad.py index e2367efdc..6c64e2d59 100644 --- a/plugins/tgbot/startup/extend/push_ad.py +++ b/plugins/tgbot/startup/extend/push_ad.py @@ -53,7 +53,7 @@ def send_msg(bot, tag='ad', trigger_time=300): keyboard = [ [ types.InlineKeyboardButton( - text="跨链混币器Cce.Cash💰低手续费💰隔断溯源", url='https://cce.cash/#/main/home?MW') + text="跨链混币器Cce.Cash💰低手续费💰隔断溯源", url='https://cce.cash/exchange?s=_midoks') ], [ types.InlineKeyboardButton( diff --git a/plugins/tgbot/startup/extend/push_notice_msg.py b/plugins/tgbot/startup/extend/push_notice_msg.py index e0de4bde9..3fa810cff 100644 --- a/plugins/tgbot/startup/extend/push_notice_msg.py +++ b/plugins/tgbot/startup/extend/push_notice_msg.py @@ -62,7 +62,7 @@ def send_msg(bot, tag='ad', trigger_time=300): keyboard = [ [ types.InlineKeyboardButton( - text="跨链混币器Cce.Cash💰低手续费💰隔断溯源", url='https://cce.cash/#/main/home?MW') + text="跨链混币器Cce.Cash💰低手续费💰隔断溯源", url='https://cce.cash/exchange?s=_midoks') ], [ types.InlineKeyboardButton( From fba98f5ed6a903a7d9f9ed0eea5c90b5a6c57444 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 00:32:43 +0800 Subject: [PATCH 2/7] up --- panel_tools.py | 7 ++++++- web/utils/site_reflect.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 web/utils/site_reflect.py diff --git a/panel_tools.py b/panel_tools.py index e099bdd24..7bd5385a1 100755 --- a/panel_tools.py +++ b/panel_tools.py @@ -75,6 +75,7 @@ def mwcli(mw_input=0): '(26) 关闭二次验证', '(27) 查看防火墙信息', '(28) 自动识别防火墙端口到面板', + '(29) 自动识别配置站点信息', '(100) 开启PHP52显示', '(101) 关闭PHP52显示', '(200) 切换Linux系统软件源', @@ -102,7 +103,7 @@ def mwcli(mw_input=0): nums = [ 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, - 20, 21, 22, 23, 24, 25, 26, 27, 28, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 100, 101, 200, 201 ] @@ -238,6 +239,10 @@ def mwcli(mw_input=0): elif mw_input == 28: MwFirewall.instance().aIF() mw.echoInfo("执行自动识别防火墙端口到面板成功!") + elif mw_input == 29: + from utils.site_reflect import parse as MwParse + MwParse() + mw.echoInfo("自动识别配置站点信息成功!") elif mw_input == 100: php_conf = panel_dir + '/plugins/php/info.json' if os.path.exists(php_conf): diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py new file mode 100644 index 000000000..6e6c30d34 --- /dev/null +++ b/web/utils/site_reflect.py @@ -0,0 +1,23 @@ +# coding:utf-8 + +# --------------------------------------------------------------------------------- +# MW-Linux面板 +# --------------------------------------------------------------------------------- +# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved. +# --------------------------------------------------------------------------------- +# Author: midoks +# --------------------------------------------------------------------------------- + +import os +import sys +import re +import json +import time +import threading +import multiprocessing + +import core.mw as mw +import thisdb + +def parse(): + print('21') \ No newline at end of file From 449b4e6882cdbf210f526fded3f2aca87ca29426 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 01:43:59 +0800 Subject: [PATCH 3/7] Update site_reflect.py --- web/utils/site_reflect.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py index 6e6c30d34..738def4c6 100644 --- a/web/utils/site_reflect.py +++ b/web/utils/site_reflect.py @@ -20,4 +20,29 @@ import core.mw as mw import thisdb def parse(): - print('21') \ No newline at end of file + + sdir = mw.getServerDir() + nginx_conf = sdir + "/web_conf/nginx" + vhosts = nginx_conf+"/vhost" + + vh_list = os.listdir(vhosts) + + vail_list = [] + for f in vh_list: + if f.startswith("0."): + continue + if f.endswith("_bak"): + continue + if f.startswith("phpmyadmin"): + continue + if f.startswith("webstats"): + continue + vail_list.append(f) + + for vail_f in vail_list: + print(vail_f) + +def parseSite(domain): + print(domain) + + \ No newline at end of file From 85a85a83e4eb107f0ce287c9800f93e00e93f8e8 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 02:51:09 +0800 Subject: [PATCH 4/7] Update site_reflect.py --- web/utils/site_reflect.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py index 738def4c6..574861cf2 100644 --- a/web/utils/site_reflect.py +++ b/web/utils/site_reflect.py @@ -19,11 +19,14 @@ import multiprocessing import core.mw as mw import thisdb -def parse(): - +def getVhostDir(): sdir = mw.getServerDir() nginx_conf = sdir + "/web_conf/nginx" vhosts = nginx_conf+"/vhost" + return vhosts + +def parse(): + vhosts = getVhostDir() vh_list = os.listdir(vhosts) @@ -39,10 +42,14 @@ def parse(): continue vail_list.append(f) - for vail_f in vail_list: - print(vail_f) + for vail_domain in vail_list: + parseSite(vail_domain) + +def parseSite(d): + vhosts = getVhostDir() + domain = d.replace(".conf","") -def parseSite(domain): - print(domain) + dconf = vhosts+'/'+domain + print(domain,dconf) \ No newline at end of file From 891ba787e1b5588d6e5cec915699782e155b7d2d Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 17:53:40 +0800 Subject: [PATCH 5/7] Update site_reflect.py --- web/utils/site_reflect.py | 54 +++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py index 574861cf2..86140daa2 100644 --- a/web/utils/site_reflect.py +++ b/web/utils/site_reflect.py @@ -25,11 +25,42 @@ def getVhostDir(): vhosts = nginx_conf+"/vhost" return vhosts +def getRootDir(content): + pattern = r'\s*root\s*(.+);' + match = re.search(pattern, content) + if match: + return match.group(1) + return '' + +def getServerName(content): + pattern = r'\s*server_name\s*(.+);' + match = re.search(pattern, content) + if match: + content = match.group(1) + clist = content.strip().split(" "); + return clist + return [] + +def addDomain(site_id, site_name, domain): + d = domain.split(':') + port = '80' + name = d[0] + if len(d) == 2: + port = d[1] + + if thisdb.checkSitesDomainIsExist(name, port): + print('您添加的域名[{}:{}],已使用。请仔细检查!'.format(name, port)) + return True + + msg = mw.getInfo('网站[{1}]添加域名[{2}]成功!', (site_name, name)) + mw.writeLog('网站管理', msg) + thisdb.addDomain(site_id, name, port) + + return True + def parse(): vhosts = getVhostDir() - vh_list = os.listdir(vhosts) - vail_list = [] for f in vh_list: if f.startswith("0."): @@ -49,7 +80,20 @@ def parseSite(d): vhosts = getVhostDir() domain = d.replace(".conf","") - dconf = vhosts+'/'+domain - print(domain,dconf) + dconf = vhosts + '/' + d + content = mw.readFile(dconf) + + root_dir = getRootDir(content) + sn_list = getServerName(content) + + # print(domain,dconf) + # print(sn_list) + if thisdb.isSitesExist(domain): + print('您添加的站点[%s]已存在!' % domain) + else: + thisdb.addSites(domain, root_dir) + info = thisdb.getSitesByName(domain) + site_id = info['id'] - \ No newline at end of file + for sn in sn_list: + addDomain(site_id, d, domain) From 0b81a1402eb81407a83b93b5efa6e4874aefa263 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 17:54:05 +0800 Subject: [PATCH 6/7] Update site_reflect.py --- web/utils/site_reflect.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py index 86140daa2..0b3b8d585 100644 --- a/web/utils/site_reflect.py +++ b/web/utils/site_reflect.py @@ -51,11 +51,7 @@ def addDomain(site_id, site_name, domain): if thisdb.checkSitesDomainIsExist(name, port): print('您添加的域名[{}:{}],已使用。请仔细检查!'.format(name, port)) return True - - msg = mw.getInfo('网站[{1}]添加域名[{2}]成功!', (site_name, name)) - mw.writeLog('网站管理', msg) thisdb.addDomain(site_id, name, port) - return True def parse(): From d25e4b30934bd791b91ed3a65fd62a240c86c6e2 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 26 Apr 2025 18:14:29 +0800 Subject: [PATCH 7/7] =?UTF-8?q?0.17.0=E5=8D=87=E7=BA=A70.18.0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=90=8E=EF=BC=8C=E7=AB=99=E7=82=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/utils/site_reflect.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/utils/site_reflect.py b/web/utils/site_reflect.py index 0b3b8d585..fdb328922 100644 --- a/web/utils/site_reflect.py +++ b/web/utils/site_reflect.py @@ -42,12 +42,12 @@ def getServerName(content): return [] def addDomain(site_id, site_name, domain): + # print(site_id, site_name, domain) d = domain.split(':') port = '80' name = d[0] if len(d) == 2: port = d[1] - if thisdb.checkSitesDomainIsExist(name, port): print('您添加的域名[{}:{}],已使用。请仔细检查!'.format(name, port)) return True @@ -82,8 +82,6 @@ def parseSite(d): root_dir = getRootDir(content) sn_list = getServerName(content) - # print(domain,dconf) - # print(sn_list) if thisdb.isSitesExist(domain): print('您添加的站点[%s]已存在!' % domain) else: @@ -92,4 +90,4 @@ def parseSite(d): site_id = info['id'] for sn in sn_list: - addDomain(site_id, d, domain) + addDomain(site_id, d, sn)