mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 + '<<EOF \n' + password + '\n' + password + '\nEOF'
|
||||
cmd = getServerDir() + '/bin/pure-pw passwd ' + username + \
|
||||
'<<EOF \n' + password + '\n' + password + '\nEOF'
|
||||
return public.execShell(cmd)
|
||||
|
||||
|
||||
@@ -327,17 +327,45 @@ def modFtp():
|
||||
return 'id missing'
|
||||
|
||||
if not 'name' in args:
|
||||
return 'username missing'
|
||||
return 'name missing'
|
||||
|
||||
if not 'password' in args:
|
||||
return 'password missing'
|
||||
|
||||
data = pftpMod(args['user'], args['password'])
|
||||
conn = pftpDB()
|
||||
data = pftpMod(args['name'], args['password'])
|
||||
pftpReload()
|
||||
|
||||
conn.where('id=?', (int(args['id']),)).save(
|
||||
'password', (args['password'],))
|
||||
# print data
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[0]
|
||||
|
||||
|
||||
def modFtpPort():
|
||||
import re
|
||||
args = getArgs()
|
||||
if not 'port' in args:
|
||||
return 'port missing'
|
||||
try:
|
||||
port = args['port']
|
||||
if int(port) < 1 or int(port) > 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'
|
||||
|
||||
@@ -74,7 +74,7 @@ function ftpList(page, search){
|
||||
content += '<th style="width:10%;">状态</th>';
|
||||
content += '<th>根目录</th>';
|
||||
content += '<th>备注</th>';
|
||||
content += '<th>操作(<a class="btlink" onclick="addFtp(0);">添加</a>|<a class="btlink" onclick="modFtpPort(0)">端口</a>)</th>';
|
||||
content += '<th>操作(<a class="btlink" onclick="addFtp(0);">添加</a>|<a class="btlink" onclick="modFtpPort(0,\''+rdata['info']['port']+'\')">端口</a>)</th>';
|
||||
content += '</tr></thead>';
|
||||
|
||||
content += '<tbody>';
|
||||
@@ -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: "<form class='bt-form pd20 pb70'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>默认端口</span>\
|
||||
<div class='info-r'><input class='bt-input-text mr5' type='text' id='ftpPort' name='ftp_port' style='width:330px' value='"+port+"'/></div>\
|
||||
</div>\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button id='ftp_port_close' type='button' class='btn btn-danger btn-sm btn-title'>关闭</button>\
|
||||
<button id='ftp_port_submit' type='button' class='btn btn-success btn-sm btn-title'>提交</button>\
|
||||
</div>\
|
||||
</form>",
|
||||
});
|
||||
|
||||
$('#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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user