Skip to content

Commit

Permalink
6.9.9-3
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Sep 5, 2019
1 parent 1370874 commit 847f044
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 67 deletions.
13 changes: 8 additions & 5 deletions BTPanel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def files(pdata = None):
defs = ('CheckExistsFiles','GetExecLog','GetSearch','ExecShell','GetExecShellMsg','UploadFile','GetDir','CreateFile','CreateDir','DeleteDir','DeleteFile',
'CopyFile','CopyDir','MvFile','GetFileBody','SaveFileBody','Zip','UnZip','SearchFiles','upload','read_history',
'GetFileAccess','SetFileAccess','GetDirSize','SetBatchData','BatchPaste','install_rar','get_path_size',
'DownloadFile','GetTaskSpeed','CloseLogs','InstallSoft','UninstallSoft','SaveTmpFile','GetTmpFile','del_files_store','add_files_store','get_files_store','del_files_store_types','add_files_store_types'
'DownloadFile','GetTaskSpeed','CloseLogs','InstallSoft','UninstallSoft','SaveTmpFile','GetTmpFile','del_files_store','add_files_store','get_files_store','del_files_store_types','add_files_store_types',
'RemoveTask','ActionTask','Re_Recycle_bin','Get_Recycle_bin','Del_Recycle_bin','Close_Recycle_bin','Recycle_bin')
return publicObject(filesObject,defs,None,pdata);

Expand Down Expand Up @@ -1108,10 +1108,13 @@ def get_input():
if key in exludes: continue
data[key] = str(request.form.get(key,''))
except:
post = request.form.to_dict()
for key in post.keys():
if key in exludes: continue
data[key] = str(post[key])
try:
post = request.form.to_dict()
for key in post.keys():
if key in exludes: continue
data[key] = str(post[key])
except:
pass

if not hasattr(data,'data'): data.data = []
return data
Expand Down
3 changes: 1 addition & 2 deletions BTPanel/static/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ function GetFiles(Path,sort) {
}
shtml += '</ul>';
}
shtml += '<li style="text-align: center;"><a href="javascript: ;" onclick="set_file_store(\'' + rdata.path + '\')">+ 管理</a></li></ul></div>'
shtml += '<li style="text-align: center;"><a href="javascript: ;" onclick="set_file_store(\'' + rdata.PATH + '\')">+ 管理</a></li></ul></div>'

BarTools += shtml;

Expand Down Expand Up @@ -1811,7 +1811,6 @@ function set_file_store(path) {

if (rRet.status) {
set_file_store(path)

GetFiles(path)
}
bt.msg(rRet);
Expand Down
14 changes: 10 additions & 4 deletions class/abnormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ def php_server(self,get):
for i in php_count:
get.sName = 'php-%s.%s'%(i[0],i[1])
mysql = self.__plugin.get_soft_find(get)
php={}
php['version']=i
php['status']=mysql['status']
ret.append(php)
if not mysql:
php={}
php['version']=i
php['status']=False
ret.append(php)
else:
php = {}
php['version'] = i
php['status'] = mysql['status']
ret.append(php)
else:
return ret
else:
Expand Down
101 changes: 60 additions & 41 deletions class/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,18 @@ def get_phpmyadmin_ssl(self,get):
return {"status":True,"port":port}
return {"status":False,"port":""}

# 修改php ssl端口
# 获取phpmyadmin ssl状态
def get_phpmyadmin_ssl(self,get):
import re
conf_file = self.get_phpmyadmin_conf()
conf = public.readFile(conf_file["conf_file"])
rep = conf_file["rep"]
if conf:
port = re.search(rep, conf).group(1)
return {"status":True,"port":port}
return {"status":False,"port":""}

# 修改php ssl端口
def change_phpmyadmin_ssl_port(self,get):
import re
try:
Expand All @@ -771,48 +782,54 @@ def change_phpmyadmin_ssl_port(self,get):
return public.returnMsg(False, '端口范围不正确')
except:
return public.returnMsg(False, '端口格式不正确')
filename = self.get_phpmyadmin_conf()
conf = public.readFile(filename["conf_file"])
if conf:
for i in ["nginx","apache"]:
file = "/www/server/panel/vhost/{}/phpmyadmin.conf".format(i)
conf = public.readFile(file)
if not conf:
return public.returnMsg(False,"没有找到{}配置文件,请尝试关闭ssl端口设置后再打开".format(i))
rulePort = ['80', '443', '21', '20', '8080', '8081', '8089', '11211', '6379']
if get.port in rulePort:
return public.returnMsg(False, 'AJAX_PHPMYADMIN_PORT_ERR')
if public.get_webserver() == 'nginx':
rep = "listen\s+([0-9]+)\s*;"
oldPort = re.search(rep, conf).groups()[0]
conf = re.sub(rep, 'listen ' + get.port + ';\n', conf)
if i == "nginx":
if not os.path.exists("/www/server/panel/vhost/apache/phpmyadmin.conf"):
return public.returnMsg(False, "没有找到 apache phpmyadmin ssl 配置文件,请尝试关闭ssl端口设置后再打开")
rep = "listen\s*([0-9]+)\s*.*;"
oldPort = re.search(rep, conf)
if not oldPort:
return public.returnMsg(False, '没有检测到 nginx phpmyadmin监听的端口,请确认是否手动修改过文件')
oldPort = oldPort.groups()[0]
conf = re.sub(rep, 'listen ' + get.port + ' ssl;', conf)
else:
rep = "Listen\s+([0-9]+)\s*\n"
oldPort = re.search(rep, conf).groups()[0]
rep = "Listen\s*([0-9]+)\s*\n"
oldPort = re.search(rep, conf)
if not oldPort:
return public.returnMsg(False, '没有检测到 apache phpmyadmin监听的端口,请确认是否手动修改过文件')
oldPort = oldPort.groups()[0]
conf = re.sub(rep, "Listen " + get.port + "\n", conf, 1)
rep = "VirtualHost\s+\*:[0-9]+"
rep = "VirtualHost\s*\*:[0-9]+"
conf = re.sub(rep, "VirtualHost *:" + get.port, conf, 1)

if oldPort == get.port: return public.returnMsg(False, 'SOFT_PHPVERSION_ERR_PORT')

public.writeFile(filename["conf_file"], conf)
import firewalls
get.ps = public.getMsg('SOFT_PHPVERSION_PS');
fw = firewalls.firewalls();
fw.AddAcceptPort(get);
public.serviceReload();
public.WriteLog('TYPE_SOFT', 'SOFT_PHPMYADMIN_PORT', (get.port,))
get.id = public.M('firewall').where('port=?', (oldPort,)).getField('id');
get.port = oldPort;
fw.DelAcceptPort(get);
return public.returnMsg(True, 'SET_PORT_SUCCESS');
else:
return public.returnMsg(False, '设置端口错误,请先开启 PhoMyAdmin SSL 后再设置');
public.writeFile(file, conf)
public.serviceReload()
if i=="apache":
import firewalls
get.ps = public.getMsg('SOFT_PHPVERSION_PS')
fw = firewalls.firewalls()
fw.AddAcceptPort(get)
public.serviceReload()
public.WriteLog('TYPE_SOFT', 'SOFT_PHPMYADMIN_PORT', (get.port,))
get.id = public.M('firewall').where('port=?', (oldPort,)).getField('id')
get.port = oldPort
fw.DelAcceptPort(get)
return public.returnMsg(True, 'SET_PORT_SUCCESS')

# 设置phpmyadmin ssl
def set_phpmyadmin_ssl(self,get):
if not os.path.exists("/www/server/panel/ssl/certificate.pem"):
return public.returnMsg(False,'面板证书不存在,请申请面板证书后再试')
filename = self.__get_webserver_conffile()
if get.v == "1":
# nginx配置文件
if "nginx" in filename:
ssl_conf = """server
ssl_conf = """server
{
listen 887 ssl;
server_name phpmyadmin;
Expand Down Expand Up @@ -844,14 +861,13 @@ def set_phpmyadmin_ssl(self,get):
}
access_log /www/wwwlogs/access.log;
}"""
public.writeFile("/www/server/panel/vhost/nginx/phpmyadmin.conf",ssl_conf)
else:
import panelPlugin
get.sName = "phpmyadmin"
v = panelPlugin.panelPlugin().get_soft_find(get)
public.writeFile("/tmp/2",str(v["ext"]["phpversion"]))
# apache配置
ssl_conf = '''Listen 887
public.writeFile("/www/server/panel/vhost/nginx/phpmyadmin.conf",ssl_conf)
import panelPlugin
get.sName = "phpmyadmin"
v = panelPlugin.panelPlugin().get_soft_find(get)
public.writeFile("/tmp/2",str(v["ext"]["phpversion"]))
# apache配置
ssl_conf = '''Listen 887
<VirtualHost *:887>
ServerAdmin [email protected]
DocumentRoot "/www/server/phpmyadmin"
Expand Down Expand Up @@ -888,14 +904,17 @@ def set_phpmyadmin_ssl(self,get):
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>'''.format(v["ext"]["phpversion"])
public.writeFile("/www/server/panel/vhost/apache/phpmyadmin.conf", ssl_conf)
public.writeFile("/www/server/panel/vhost/apache/phpmyadmin.conf", ssl_conf)
else:
if "nginx" in filename:
if os.path.exists("/www/server/panel/vhost/nginx/phpmyadmin.conf"):
os.remove("/www/server/panel/vhost/nginx/phpmyadmin.conf")
else:
if os.path.exists("/www/server/panel/vhost/apache/phpmyadmin.conf"):
os.remove("/www/server/panel/vhost/apache/phpmyadmin.conf")
public.serviceReload()
return public.returnMsg(True, '关闭成功')
public.serviceReload()
return public.returnMsg(True,'开启成功')
return public.returnMsg(True,'开启成功,请手动放行phpmyadmin ssl端口')


#设置PHPMyAdmin
def setPHPMyAdmin(self,get):
Expand Down
29 changes: 17 additions & 12 deletions class/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ def UploadFile(self,get):

#上传文件2
def upload(self,args):
if sys.version_info[0] == 2:
args.f_name = args.f_name.encode('utf-8')
args.f_path = args.f_path.encode('utf-8')
if not 'f_name' in args:
args.f_name = request.form.get('f_name')
args.f_path = request.form.get('f_path')
args.f_size = request.form.get('f_size')
args.f_start = request.form.get('f_start')

if sys.version_info[0] == 2:
args.f_name = args.f_name.encode('utf-8')
args.f_path = args.f_path.encode('utf-8')

if args.f_name.find('./') != -1 or args.f_path.find('./') != -1:
return public.returnMsg(False,'错误的参数')
if not os.path.exists(args.f_path):
Expand Down Expand Up @@ -666,6 +667,7 @@ def CheckExistsFiles(self,get):
data = [];
filesx = [];
if not hasattr(get,'filename'):
if not 'selected' in session: return []
filesx = json.loads(session['selected']['data']);
else:
filesx.append(get.filename);
Expand All @@ -692,6 +694,7 @@ def GetFileBody(self,get) :
public.writeFile(get.path,'');

if os.path.getsize(get.path) > 2097152: return public.returnMsg(False,u'不能在线编辑大于2MB的文件!');
if not os.path.isfile(get.path): return public.returnMsg(False,'这不是一个文件!')
fp = open(get.path,'rb')
data = {}
data['status'] = True
Expand Down Expand Up @@ -723,11 +726,7 @@ def GetFileBody(self,get) :
else:
data['data'] = srcBody.decode(data['encoding'])
else:
if sys.version_info[0] == 2:
data['data'] = srcBody.decode('utf-8').encode('utf-8');
else:
data['data'] = srcBody.decode('utf-8')
data['encoding'] = u'utf-8';
return public.returnMsg(False,'打开文件失败,文件可能被其它进程占用!')
if hasattr(get,'filename'): get.path = get.filename
data['historys'] = self.get_history(get.path)
return data;
Expand Down Expand Up @@ -975,6 +974,7 @@ def BatchPaste(self,get):
import shutil
if sys.version_info[0] == 2: get.path = get.path.encode('utf-8');
if not self.CheckDir(get.path): return public.returnMsg(False,'FILE_DANGER');
if not 'selected' in session: return public.returnMsg(False,'操作失败,请重新操作复制或剪切过程')
i = 0;
myfiles = json.loads(session['selected']['data'])
l = len(myfiles);
Expand Down Expand Up @@ -1307,6 +1307,7 @@ def set_store_data(self,data):
#添加收藏夹分类
def add_files_store_types(self,get):
file_type = get.file_type
if sys.version_info[0] == 2: file_type = file_type.decode('utf-8')
data = self.get_store_data()
if file_type in data: return public.returnMsg(False,'请勿重复添加分类!')

Expand All @@ -1317,11 +1318,14 @@ def add_files_store_types(self,get):
#删除收藏夹分类
def del_files_store_types(self,get):
file_type = get.file_type
if sys.version_info[0] == 2: file_type = file_type.decode('utf-8')
if file_type == '默认分类': return public.returnMsg(False,'默认分类不可被删除!')
data = self.get_store_data()
del data[file_type]
self.set_store_data(data)
return public.returnMsg(True,'删除[' + file_type + ']成功!')
if file_type in data:
del data[file_type]
self.set_store_data(data)
return public.returnMsg(True,'删除[' + file_type + ']成功!')
return public.returnMsg(False,'删除[' + file_type + ']失败!')

#获取收藏夹
def get_files_store(self,get):
Expand All @@ -1344,6 +1348,7 @@ def get_files_store(self,get):
#添加收藏夹
def add_files_store(self,get):
file_type = get.file_type
if sys.version_info[0] == 2: file_type = file_type.decode('utf-8')
path = get.path
if not os.path.exists(path): return public.returnMsg(False,'文件或目录不存在!')

Expand All @@ -1357,8 +1362,8 @@ def add_files_store(self,get):
#删除收藏夹
def del_files_store(self,get):
file_type = get.file_type
if sys.version_info[0] == 2: file_type = file_type.decode('utf-8')
path = get.path

data = self.get_store_data()
if not file_type in data: return public.returnMsg(False,'找不到此收藏夹分类!')
data[file_type].remove(path)
Expand Down
2 changes: 1 addition & 1 deletion class/plugin_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def depTotal(self,id):
#获取进度
def GetSpeed(self,get):
try:
if not os.path.exists(self.logPath): public.returnMsg(False,'当前没有部署任务!');
if not os.path.exists(self.logPath): return public.returnMsg(False,'当前没有部署任务!');
return json.loads(public.readFile(self.logPath));
except:
return {'name':'准备部署','total':0,'used':0,'pre':0,'speed':0}
Expand Down
7 changes: 5 additions & 2 deletions class/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,13 @@ def GetHost(port = False):
if not host_tmp:
if request.url_root:
tmp = re.findall("(https|http)://([\w:\.-]+)",request.url_root)
if tmp: host_tmp = tmp[0]
if tmp: host_tmp = tmp[0][1]
if not host_tmp:
host_tmp = GetLocalIp() + ':' + readFile('data/port.pl').strip()
if host_tmp.find(':') == -1: host_tmp += ':80';
try:
if host_tmp.find(':') == -1: host_tmp += ':80';
except:
host_tmp = "127.0.0.1:8888"
h = host_tmp.split(':')
if port: return h[1]
return h[0]
Expand Down

0 comments on commit 847f044

Please sign in to comment.