From 9437e90678e5cfc05952cac7a1b702ff8fb06a44 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 4 Jan 2019 14:20:30 +0800 Subject: [PATCH] update --- class/core/db.py | 1 + plugins/pureftp/index.py | 38 +++++++++++++++++++++++++---- plugins/pureftp/js/ftp.js | 50 +++++++++++++++++++++++++++++++++++---- 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/class/core/db.py b/class/core/db.py index 7d4df15cb..bda35a455 100755 --- a/class/core/db.py +++ b/class/core/db.py @@ -227,6 +227,7 @@ class Sql(): def execute(self, sql, param): # 执行SQL语句返回受影响行 self.__GetConn() + print sql, param try: result = self.__DB_CONN.execute(sql, param) self.__DB_CONN.commit() diff --git a/plugins/pureftp/index.py b/plugins/pureftp/index.py index fd1df68d2..b35283440 100755 --- a/plugins/pureftp/index.py +++ b/plugins/pureftp/index.py @@ -203,8 +203,8 @@ def pftpAdd(username, password, path): def pftpMod(username, password): user = pftpUser() - cmd = getServerDir() + '/bin/pure-pw passwd ' + username + ' -u ' + user + ' -d ' + \ - path + '< 65535: + return '端口范围不正确!' + file = file = getServerDir() + '/etc/pure-ftpd.conf' + conf = public.readFile(file) + rep = u"\n#?\s*Bind\s+[0-9]+\.[0-9]+\.[0-9]+\.+[0-9]+,([0-9]+)" + # preg_match(rep,conf,tmp) + conf = re.sub(rep, "\nBind 0.0.0.0," + port, conf) + public.writeFile(file, conf) + restart() + return 'ok' + except Exception as ex: + + return str(ex) + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -368,5 +396,7 @@ if __name__ == "__main__": print delFtp() elif func == 'mod_ftp': print modFtp() + elif func == 'mod_ftp_port': + print modFtpPort() else: print 'error' diff --git a/plugins/pureftp/js/ftp.js b/plugins/pureftp/js/ftp.js index c1b22db19..95cade763 100755 --- a/plugins/pureftp/js/ftp.js +++ b/plugins/pureftp/js/ftp.js @@ -74,7 +74,7 @@ function ftpList(page, search){ content += '状态'; content += '根目录'; content += '备注'; - content += '操作(添加|端口)'; + content += '操作(添加|端口)'; content += ''; content += ''; @@ -190,6 +190,44 @@ function ftpDelete(id,ftp_username){ }); } +function modFtpPort(type, port){ + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '修改FTP帐户端口', + content: "
\ +
\ + 默认端口\ +
\ +
\ +
\ + \ + \ +
\ +
", + }); + + $('#ftp_port_close').click(function(){ + $('.layui-layer-close1').click(); + }); + + $('#ftp_port_submit').click(function(){ + var port = $('#ftpPort').val(); + data = 'port='+port + ftpPost('mod_ftp_port', data,function(data){ + ftpList(); + if (data.data == 'ok'){ + layer.msg('修改成功!', {icon: 1}); + } else { + layer.msg(data.data, {icon: 2}); + } + $('.layui-layer-close1').click(); + }); + }); + +} + function ftpModPwd(id,name,password){ var index = layer.open({ @@ -220,10 +258,14 @@ function ftpModPwd(id,name,password){ }); $('#ftp_mod_submit').click(function(){ - console.log('123123'); - data='id='+id+'&name='+name+'&password='+password + pwd = $('#MyPassword').val(); + data='id='+id+'&name='+name+'&password='+pwd ftpPost('mod_ftp', data,function(data){ - console.log(data); + ftpList(); + if (data.data == 'ok'){ + layer.msg('修改成功!', {icon: 1}); + } + $('.layui-layer-close1').click(); }); }); }