稍微完善一下日志记录;分享页面取消token验证;修复开启下载验证之后,后台文件打开失败的bug

master
Abbey 5 years ago
parent 3f55e13e1f
commit 618883d530
  1. 11
      app/front/views.py
  2. 12
      app/templates/admin/manage/manage.html
  3. 2
      app/utils/aes.py
  4. 9
      app/utils/file_os.py
  5. 2
      config.py
  6. 1
      update.sh

@ -143,13 +143,15 @@ def show(fileid,user,action='download',token=None):
name=GetName(fileid)
ext=name.split('.')[-1].lower()
url=request.url.replace(':80','').replace(':443','').encode('utf-8').split('?')[0]
url='/'.join(url.split('/')[:3])+'/'+urllib.quote('/'.join(url.split('/')[3:]))
inner_url='/'+urllib.quote('/'.join(url.split('/')[3:]))
if GetConfig("verify_url")=="True":
url=url+'?token='+token
if token is None:
return abort(403)
elif VerifyToken(token,path)==False:
return abort(403)
if action!='share':
if token is None:
return abort(403)
elif VerifyToken(token,path)==False:
return abort(403)
if request.method=='POST' or action=='share':
InfoLogger().print_r(u'share page:{}'.format(path))
if ext in GetConfig('show_redirect').split(','):
@ -176,7 +178,6 @@ def show(fileid,user,action='download',token=None):
downloadUrl,play_url=GetDownloadUrl(fileid,user)
resp=MakeResponse(redirect(downloadUrl))
return resp
InfoLogger().print_r('action:{}'.format(action))
if name=='.password':
resp=MakeResponse(abort(404))
if 'no-referrer' in GetConfig('allow_site').split(',') or sum([i in referrer for i in GetConfig('allow_site').split(',')])>0:

@ -129,9 +129,13 @@ a:hover {
</label>
</td>
<td class="file">
<a href="{{url_for('front.index',path=path+'/'+data['name'])|safe}}" target="_blank" class="mdui-list-item">
{%if GetConfig("verify_url")=="True"%}
<a href="{{url_for('front.index',path=data['path'],token=GenerateToken(data['path']))}}" target="_blank" class="mdui-list-item">
{%else%}
<a href="{{url_for('front.index',path=data['path'])}}" target="_blank" class="mdui-list-item">
{%endif%}
<i class="mdui-icon material-icons">{{file_ico(data)}}</i> {{data['name']}}
</a>
</a>
</td>
<td>{{data['lastModtime']}}</td>
<td>
@ -169,7 +173,11 @@ $$(function() {
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
{%if GetConfig("verify_url")=="True"%}
content: $$(this).attr('href')+"&action=share" //iframe的url
{%else%}
content: $$(this).attr('href')+"?action=share" //iframe的url
{%endif%}
});
return false;
});

@ -57,9 +57,7 @@ def reverse_token(token):
return token.replace('plus','+').replace('xiegang','/').replace('equal','=')
def VerifyToken(token,filepath):
print token
token=reverse_token(token)
print token
path=filepath.split(':')[-1]
ae=AesCls(GetConfig("password"))
msg=ae.decrypt(token)

@ -80,8 +80,7 @@ def CreateFolder(folder_name,grand_path,user=GetConfig('default_pan')):
mon_db.items.insert_one(item)
return True
else:
ErrorLogger().print_r(data.get('error').get('msg'))
InfoLogger().print_r(data.get('error').get('msg'))
InfoLogger().print_r('创建文件夹失败:{}'.format(data.get('error').get('message')))
return False
def CreateFile(filename,path,content,user=GetConfig('default_pan')):
@ -115,6 +114,7 @@ def CreateFile(filename,path,content,user=GetConfig('default_pan')):
else:
info['status']=0
info['msg']=data.get('error').get('message')
InfoLogger().print_r('创建文件失败:{}'.format(data.get('error').get('message')))
return info
def EditFile(fileid,content,user=GetConfig('default_pan')):
@ -146,6 +146,7 @@ def EditFile(fileid,content,user=GetConfig('default_pan')):
else:
info['status']=0
info['msg']=data.get('error').get('message')
InfoLogger().print_r('编辑文件失败:{}'.format(data.get('error').get('message')))
except Exception as e:
exstr = traceback.format_exc()
ErrorLogger().print_r(exstr)
@ -199,7 +200,7 @@ def MoveFile(fileid,new_folder_path,user=GetConfig('default_pan')):
redis_client.delete(key)
return True
else:
InfoLogger().print_r(data.get('error').get('msg'))
InfoLogger().print_r('移动文件失败:{}'.format(data.get('error').get('message')))
return False
def ReName(fileid,new_name,user=GetConfig('default_pan')):
@ -236,5 +237,5 @@ def ReName(fileid,new_name,user=GetConfig('default_pan')):
mon_db.items.find_one_and_update({'id':file['id']},{'$set':new_value})
return True
else:
InfoLogger().print_r(data.get('error').get('msg'))
InfoLogger().print_r('重命名失败:{}'.format(data.get('error').get('message')))
return False

@ -14,7 +14,7 @@ class config:
if REDIS_PASSWORD!='':
CACHE_REDIS_PASSWORD=REDIS_PASSWORD
SEND_FILE_MAX_AGE_DEFAULT=timedelta(seconds=1)
version='4.190613'
version='4.190614'
@staticmethod
def init_app(app):

@ -180,6 +180,7 @@ echo "2019.05.28更新版本:修复开启负债均衡之后,文件名有特
echo "2019.05.29更新版本:支持自定义线程数"
echo "2019.05.31更新版本:新增功能:1)下载链接验证开关;优化:1)aria2信息不对时,无法添加任务"
echo "2019.06.13更新版本:新增功能:文件展示设置"
echo "2019.06.14更新版本:稍微完善一下日志记录;分享页面取消token验证;修复开启下载验证之后,后台文件打开失败的bug"
echo "---------------------------------------------------------------"
echo "更新完成!"
echo "如果网站无法访问,请检查config.py!"

Loading…
Cancel
Save