mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -15,10 +15,13 @@ from flask import request
|
||||
|
||||
class config_api:
|
||||
|
||||
__version = '0.0.1'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
##### ----- start ----- ###
|
||||
|
||||
def syncDateApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发系统不必同步时间!')
|
||||
@@ -95,6 +98,9 @@ class config_api:
|
||||
|
||||
##### ----- end ----- ###
|
||||
|
||||
def getVersion(self):
|
||||
return self.__version
|
||||
|
||||
def get(self):
|
||||
|
||||
data = {}
|
||||
|
||||
@@ -83,8 +83,65 @@ class files_api:
|
||||
page = request.args.get('p', '1').strip().lower()
|
||||
row = request.args.get('showRow', '10')
|
||||
return self.getDir(path, int(page), int(row), search)
|
||||
|
||||
def createFileApi(self):
|
||||
file = request.form.get('path', '').encode('utf-8')
|
||||
try:
|
||||
if not self.checkFileName(file):
|
||||
return public.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
if os.path.exists(file):
|
||||
return public.returnJson(False, '指定文件已存在!')
|
||||
_path = os.path.dirname(file)
|
||||
if not os.path.exists(_path):
|
||||
os.makedirs(_path)
|
||||
open(file, 'w+').close()
|
||||
self.setFileAccept(file)
|
||||
# public.WriteLog('TYPE_FILE', 'FILE_CREATE_SUCCESS', (get.path,))
|
||||
return public.returnJson(True, '文件创建成功!')
|
||||
except Exception as e:
|
||||
# print str(e)
|
||||
return public.returnJson(True, '文件创建失败!')
|
||||
|
||||
def createDirApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
try:
|
||||
if not self.checkFileName(path):
|
||||
return public.returnJson(False, '目录名中不能包含特殊字符!')
|
||||
if os.path.exists(path):
|
||||
return public.returnJson(False, '指定目录已存在!')
|
||||
os.makedirs(path)
|
||||
self.setFileAccept(path)
|
||||
# public.writeLog('TYPE_FILE', 'DIR_CREATE_SUCCESS', (get.path,))
|
||||
return public.returnJson(True, '目录创建成功!')
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '目录创建失败!')
|
||||
|
||||
def downloadFileApi(self):
|
||||
import db
|
||||
import time
|
||||
url = request.form.get('url', '').encode('utf-8')
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
|
||||
isTask = public.getRootDir() + '/tmp/panelTask.pl'
|
||||
execstr = url + '|bt|' + path + '/' + filename
|
||||
public.M('tasks').add('name,type,status,addtime,execstr',
|
||||
('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
|
||||
public.writeFile(isTask, 'True')
|
||||
self.setFileAccept(path + '/' + filename)
|
||||
return public.returnJson(True, '已将下载任务添加到队列!')
|
||||
##### ----- end ----- ###
|
||||
|
||||
def checkFileName(self, filename):
|
||||
# 检测文件名
|
||||
nots = ['\\', '&', '*', '|', ';']
|
||||
if filename.find('/') != -1:
|
||||
filename = filename.split('/')[-1]
|
||||
for n in nots:
|
||||
if n in filename:
|
||||
return False
|
||||
return True
|
||||
|
||||
def setFileAccept(self, filename):
|
||||
auth = 'www:www'
|
||||
if public.getOs() == 'darwin':
|
||||
|
||||
+2
-1
@@ -26,10 +26,11 @@ from flask_session import Session
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import db
|
||||
import public
|
||||
import config_api
|
||||
|
||||
|
||||
app = Flask(__name__, template_folder='templates/default')
|
||||
app.config.version = '0.0.1'
|
||||
app.config.version = config_api.config_api().getVersion()
|
||||
# app.config['SECRET_KEY'] = os.urandom(24)
|
||||
# app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:]
|
||||
app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:]
|
||||
|
||||
+26
-25
@@ -479,8 +479,8 @@ function getFiles(Path) {
|
||||
'+lan.files.new+' <span class="caret"></span>\
|
||||
</button>\
|
||||
<ul class="dropdown-menu">\
|
||||
<li><a href="javascript:CreateFile(0,\'' + Path + '\');">'+lan.files.new_empty_file+'</a></li>\
|
||||
<li><a href="javascript:CreateDir(0,\'' + Path + '\');">'+lan.files.new_dir+'</a></li>\
|
||||
<li><a href="javascript:createFile(0,\'' + Path + '\');">'+lan.files.new_empty_file+'</a></li>\
|
||||
<li><a href="javascript:createDir(0,\'' + Path + '\');">'+lan.files.new_dir+'</a></li>\
|
||||
</ul>\
|
||||
</div>';
|
||||
if (rdata.PATH != '/') {
|
||||
@@ -789,7 +789,7 @@ function getDisk() {
|
||||
for (var i = 0; i < rdata.length; i++) {
|
||||
LBody += "<span onclick=\"getFiles('" + rdata[i].path + "')\"><span class='glyphicon glyphicon-hdd'></span> " + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")</span>";
|
||||
}
|
||||
var trash = '<span id="recycle_bin" onclick="Recycle_bin(\'open\')" title="'+lan.files.recycle_bin_title+'" style="position: absolute; border-color: #ccc; right: 77px;"><span class="glyphicon glyphicon-trash"></span> '+lan.files.recycle_bin_title+'</span>';
|
||||
var trash = '<span id="recycle_bin" onclick="Recycle_bin(\'open\')" title="回收站" style="position: absolute; border-color: #ccc; right: 77px;"><span class="glyphicon glyphicon-trash"></span> 回收站</span>';
|
||||
$("#comlist").html(LBody+trash);
|
||||
isDiskWidth();
|
||||
},'json');
|
||||
@@ -819,14 +819,14 @@ function BackDir() {
|
||||
setTimeout('PathPlaceBtn(getCookie("Path"));',200);
|
||||
}
|
||||
//新建文件
|
||||
function CreateFile(type, path) {
|
||||
function createFile(type, path) {
|
||||
if (type == 1) {
|
||||
var fileName = $("#newFileName").val();
|
||||
layer.msg(lan.public.the, {
|
||||
icon: 16,
|
||||
time: 10000
|
||||
});
|
||||
$.post('/files?action=CreateFile', 'path=' + encodeURIComponent(path + '/' + fileName), function(rdata) {
|
||||
$.post('/files/create_file', 'path=' + encodeURIComponent(path + '/' + fileName), function(rdata) {
|
||||
layer.closeAll();
|
||||
layer.msg(rdata.msg, {
|
||||
icon: rdata.status ? 1 : 2
|
||||
@@ -835,7 +835,7 @@ function CreateFile(type, path) {
|
||||
getFiles($("#DirPathPlace input").val());
|
||||
onlineEditFile(0,path + '/' + fileName);
|
||||
}
|
||||
});
|
||||
},'json');
|
||||
return;
|
||||
}
|
||||
layer.open({
|
||||
@@ -846,33 +846,33 @@ function CreateFile(type, path) {
|
||||
title: lan.files.new_empty_file,
|
||||
content: '<div class="bt-form pd20 pb70">\
|
||||
<div class="line">\
|
||||
<input type="text" class="bt-input-text" name="Name" id="newFileName" value="" placeholder="'+lan.files.file_name+'" style="width:100%" />\
|
||||
<input type="text" class="bt-input-text" name="Name" id="newFileName" value="" placeholder="文件名" style="width:100%" />\
|
||||
</div>\
|
||||
<div class="bt-form-submit-btn">\
|
||||
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">'+lan.public.close+'</button>\
|
||||
<button id="CreateFileBtn" type="button" class="btn btn-success btn-sm" onclick="CreateFile(1,\'' + path + '\')">'+lan.files.new+'</button>\
|
||||
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">关闭</button>\
|
||||
<button id="createFileBtn" type="button" class="btn btn-success btn-sm" onclick="createFile(1,\'' + path + '\')">新建</button>\
|
||||
</div>\
|
||||
</div>'
|
||||
});
|
||||
$("#newFileName").focus().keyup(function(e){
|
||||
if(e.keyCode == 13) $("#CreateFileBtn").click();
|
||||
if(e.keyCode == 13) $("#createFileBtn").click();
|
||||
});
|
||||
}
|
||||
//新建目录
|
||||
function CreateDir(type, path) {
|
||||
function createDir(type, path) {
|
||||
if (type == 1) {
|
||||
var dirName = $("#newDirName").val();
|
||||
layer.msg(lan.public.the, {
|
||||
icon: 16,
|
||||
time: 10000
|
||||
});
|
||||
$.post('/files?action=CreateDir', 'path=' + encodeURIComponent(path + '/' + dirName), function(rdata) {
|
||||
$.post('/files/create_dir', 'path=' + encodeURIComponent(path + '/' + dirName), function(rdata) {
|
||||
layer.closeAll();
|
||||
layer.msg(rdata.msg, {
|
||||
icon: rdata.status ? 1 : 2
|
||||
});
|
||||
getFiles($("#DirPathPlace input").val());
|
||||
});
|
||||
},'json');
|
||||
return;
|
||||
}
|
||||
layer.open({
|
||||
@@ -883,16 +883,16 @@ function CreateDir(type, path) {
|
||||
title: lan.files.new_dir,
|
||||
content: '<div class="bt-form pd20 pb70">\
|
||||
<div class="line">\
|
||||
<input type="text" class="bt-input-text" name="Name" id="newDirName" value="" placeholder="'+lan.files.dir_name+'" style="width:100%" />\
|
||||
<input type="text" class="bt-input-text" name="Name" id="newDirName" value="" placeholder="目录名称" style="width:100%" />\
|
||||
</div>\
|
||||
<div class="bt-form-submit-btn">\
|
||||
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>\
|
||||
<button type="button" id="CreateDirBtn" class="btn btn-success btn-sm btn-title" onclick="CreateDir(1,\'' + path + '\')">'+lan.files.new+'</button>\
|
||||
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">关闭</button>\
|
||||
<button type="button" id="createDirBtn" class="btn btn-success btn-sm btn-title" onclick="createDir(1,\'' + path + '\')">新建</button>\
|
||||
</div>\
|
||||
</div>'
|
||||
});
|
||||
$("#newDirName").focus().keyup(function(e){
|
||||
if(e.keyCode == 13) $("#CreateDirBtn").click();
|
||||
if(e.keyCode == 13) $("#createDirBtn").click();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ function ReloadFiles(){
|
||||
}
|
||||
|
||||
//下载文件
|
||||
function DownloadFile(action){
|
||||
function downloadFile(action){
|
||||
|
||||
if(action == 1){
|
||||
var fUrl = $("#mUrl").val();
|
||||
@@ -954,12 +954,12 @@ function DownloadFile(action){
|
||||
fname = encodeURIComponent($("#dfilename").val());
|
||||
layer.closeAll();
|
||||
layer.msg(lan.files.down_task,{time:0,icon:16,shade: [0.3, '#000']});
|
||||
$.post('/files?action=DownloadFile','path='+fpath+'&url='+fUrl+'&filename='+fname,function(rdata){
|
||||
$.post('/files/download_file','path='+fpath+'&url='+fUrl+'&filename='+fname,function(rdata){
|
||||
layer.closeAll();
|
||||
getFiles(fpath);
|
||||
GetTaskCount();
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||
});
|
||||
},'json');
|
||||
return;
|
||||
}
|
||||
var path = $("#DirPathPlace input").val();
|
||||
@@ -971,17 +971,17 @@ function DownloadFile(action){
|
||||
title: lan.files.down_title,
|
||||
content: '<form class="bt-form pd20 pb70">\
|
||||
<div class="line">\
|
||||
<span class="tname">'+lan.files.down_url+':</span><input type="text" class="bt-input-text" name="url" id="mUrl" value="" placeholder="'+lan.files.down_url+'" style="width:330px" />\
|
||||
<span class="tname">URL地址:</span><input type="text" class="bt-input-text" name="url" id="mUrl" placeholder="URL地址" style="width:330px" />\
|
||||
</div>\
|
||||
<div class="line">\
|
||||
<span class="tname ">'+lan.files.down_to+':</span><input type="text" class="bt-input-text" name="path" id="dpath" value="'+path+'" placeholder="'+lan.files.down_to+'" style="width:330px" />\
|
||||
<span class="tname ">下载到:</span><input type="text" class="bt-input-text" name="path" id="dpath" value="'+path+'" placeholder="下载到" style="width:330px" />\
|
||||
</div>\
|
||||
<div class="line">\
|
||||
<span class="tname">'+lan.files.file_name+':</span><input type="text" class="bt-input-text" name="filename" id="dfilename" value="" placeholder="'+lan.files.down_save+'" style="width:330px" />\
|
||||
<span class="tname">文件名:</span><input type="text" class="bt-input-text" name="filename" id="dfilename" value="" placeholder="文件名" style="width:330px" />\
|
||||
</div>\
|
||||
<div class="bt-form-submit-btn">\
|
||||
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">'+lan.public.close+'</button>\
|
||||
<button type="button" id="dlok" class="btn btn-success btn-sm dlok" onclick="DownloadFile(1)">'+lan.public.ok+'</button>\
|
||||
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">关闭</button>\
|
||||
<button type="button" id="dlok" class="btn btn-success btn-sm dlok" onclick="downloadFile(1)">确定</button>\
|
||||
</div>\
|
||||
</form>'
|
||||
});
|
||||
@@ -1550,6 +1550,7 @@ $("#DirPathPlace input").keyup(function(e){
|
||||
getFiles($(this).val());
|
||||
}
|
||||
});
|
||||
|
||||
function PathPlaceBtn(path){
|
||||
var html = '';
|
||||
var title = '';
|
||||
|
||||
@@ -96,6 +96,4 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/app/config.js?v={{config.version}}"></script>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -8,32 +8,32 @@
|
||||
<div class="ptb15">
|
||||
<div class="clearfix">
|
||||
<div class="pull-left">
|
||||
<button id="backBtn" class="backBtn btn btn-default btn-sm glyphicon glyphicon-arrow-left pull-left" title="$tData['lan']['BTN1']" onClick="BackDir()"></button>
|
||||
<button class="backBtn refreshBtn btn btn-default btn-sm glyphicon glyphicon-refresh pull-right" title="$tData['lan']['BTN2']" style="margin-left:-1px;"></button>
|
||||
<button id="backBtn" class="backBtn btn btn-default btn-sm glyphicon glyphicon-arrow-left pull-left" title="" onClick="BackDir()"></button>
|
||||
<button class="backBtn refreshBtn btn btn-default btn-sm glyphicon glyphicon-refresh pull-right" title="" style="margin-left:-1px;"></button>
|
||||
<span id='DirPathPlace' class="pull-left"><input id="fileInputPath" type="text"></span>
|
||||
<span id='PathPlaceBtn' class="pull-left"></span>
|
||||
</div>
|
||||
<div class="pull-left mlr15" style="line-height:26px"><span id='DirInfo'></span></div>
|
||||
<div class="search pull-right" style="position: absolute; top: 6px; right: 5px;">
|
||||
<form target="hid" onsubmit='GetFiles(1)'>
|
||||
<form target="hid" onsubmit='getFiles(1)'>
|
||||
<input type="text" id="SearchValue" class="ser-text pull-left" placeholder="" />
|
||||
<button type="button" class="ser-sub pull-left" onclick='GetFiles(1)'></button>
|
||||
<button type="button" class="ser-sub pull-left" onclick='getFiles(1)'></button>
|
||||
</form>
|
||||
<iframe name='hid' id="hid" style="display:none"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix ptb10">
|
||||
<button class="btn btn-default btn-sm pull-left" onclick="UploadFiles()">上传</button>
|
||||
<button class="btn btn-default btn-sm pull-left" onclick="DownloadFile()" title="$tData['lan']['TI1']" style="margin:0 5px">远程下载</button>
|
||||
<button class="btn btn-default btn-sm pull-left" onclick="uploadFiles()">上传</button>
|
||||
<button class="btn btn-default btn-sm pull-left" onclick="downloadFile()" title="$tData['lan']['TI1']" style="margin:0 5px">远程下载</button>
|
||||
<span id='BarTools'></span>
|
||||
<span id='Batch' style="background-color:#fff;position:absolute;right:190px;z-index:10"></span>
|
||||
<span id='comlist' class="comlist"></span>
|
||||
<div class="btn-group btn-group-sm pull-right" style="margin-right:5px;">
|
||||
<button id="set_icon" title="$tData['lan']['TI2']" type="button" class="btn btn-default">
|
||||
<button id="set_icon" type="button" class="btn btn-default">
|
||||
<i class="glyphicon glyphicon-th"></i>
|
||||
</button>
|
||||
<button id="set_list" title="$tData['lan']['TI3']" type="button" class="btn btn-default active">
|
||||
<button id="set_list" type="button" class="btn btn-default active">
|
||||
<i class="glyphicon glyphicon-th-list"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user