|
@@ -46,7 +46,7 @@ class Common(object):
|
|
|
|
|
|
self.service = Demeter.service('convert')
|
|
|
|
|
|
- self.referer = self.request.headers['referer']
|
|
|
+ self.referer = self.request.headers.get("Referer")
|
|
|
self.host = Demeter.host(self.data['site']['link'])
|
|
|
|
|
|
if not self.referer:
|
|
@@ -56,7 +56,7 @@ class Common(object):
|
|
|
self.out('验证失败')
|
|
|
|
|
|
|
|
|
- self.param = self.service.signature(self.data['site']['id'], appid, self.data['site']['appsecret'], timestamp, nonce, file, file_id, uid)
|
|
|
+ self.param = self.service.signature(self.data['site']['id'], appid, self.data['site']['appsecret'], timestamp, nonce, file, file_id, uid, status)
|
|
|
|
|
|
if not self.param:
|
|
|
self.out('验证失败')
|
|
@@ -65,6 +65,7 @@ class Common(object):
|
|
|
self.out('验证失败')
|
|
|
|
|
|
if status == 1:
|
|
|
+ file_type = self.input('file_type')
|
|
|
file = self.service.update(self.data['site']['id'], self.data['site']['appid'], file, file_id, file_type, uid)
|
|
|
else:
|
|
|
file = self.service.get(self.data['site']['id'], self.data['site']['appid'], file);
|
|
@@ -175,8 +176,6 @@ class convert_path(Load):
|
|
|
config = Demeter.config['redis']
|
|
|
redis.rpush(config['name'], file['id'])
|
|
|
|
|
|
- del self.data['site']['token']
|
|
|
-
|
|
|
url = self.request.protocol + "://" + self.request.host
|
|
|
|
|
|
self.data['file'] = {
|
|
@@ -187,7 +186,7 @@ class convert_path(Load):
|
|
|
'file' : file['key']
|
|
|
}
|
|
|
|
|
|
- self.out('yes', self.data)
|
|
|
+ self.out('yes', self.data['file'])
|
|
|
|
|
|
# 获取信息 后端接口,token不允许暴露
|
|
|
class get_path(Load):
|
|
@@ -198,15 +197,13 @@ class get_path(Load):
|
|
|
self.data = {}
|
|
|
file = Common.signature(self, 2)
|
|
|
|
|
|
- del self.data['site']['token']
|
|
|
-
|
|
|
url = self.request.protocol + "://" + self.request.host
|
|
|
|
|
|
self.data['file'] = {
|
|
|
#'id' : file['id'],
|
|
|
'status' : file['status'],
|
|
|
'url' : url + file['url'],
|
|
|
- 'pic' : url + file['url'] + '.jpg',
|
|
|
+ 'img' : url + file['url'] + '.jpg',
|
|
|
'page' : file['page'],
|
|
|
'ext' : file['ext'],
|
|
|
'name' : file['name'],
|
|
@@ -214,7 +211,7 @@ class get_path(Load):
|
|
|
'size' : file['size']
|
|
|
}
|
|
|
|
|
|
- self.out('yes', self.data)
|
|
|
+ self.out('yes', self.data['file'])
|
|
|
|
|
|
# 授权用户可以访问html的接口 后端接口,token不允许暴露
|
|
|
class auth_path(Load):
|
|
@@ -238,14 +235,16 @@ class view_path(Load):
|
|
|
|
|
|
appid = self.input('appid')
|
|
|
nonce = self.input('nonce')
|
|
|
+ timestamp = self.input('timestamp')
|
|
|
signature = self.input('signature')
|
|
|
file = self.input('file')
|
|
|
+ file_id = self.input('file_id')
|
|
|
uid = self.input('uid')
|
|
|
page = self.input('page')
|
|
|
path = self.input('path')
|
|
|
|
|
|
self.data = {}
|
|
|
- file = Common.signature(self, 2)
|
|
|
+ file = Common.signature(self, 11)
|
|
|
|
|
|
if page:
|
|
|
url = self.request.protocol + "://" + self.request.host
|
|
@@ -277,14 +276,13 @@ class view_path(Load):
|
|
|
content = re.sub(pattern, '', content)
|
|
|
|
|
|
path = path.replace(Demeter.path + 'runtime', '')
|
|
|
- url = url + '/main/view?path=' + str(path) + '&file=' + file['key'] + '&nonce=' + nonce + '&appid=' + appid + '&signature=' + signature + '&uid=' + uid + '&page='
|
|
|
+ url = url + '/main/view?path=' + str(path) + '&file=' + file['key'] + '&file_id=' + file_id + '×tamp=' + timestamp + '&nonce=' + nonce + '&appid=' + appid + '&signature=' + signature + '&uid=' + uid + '&page='
|
|
|
content = content.replace('data-page-url="', 'data-page-url="' + url)
|
|
|
|
|
|
- script = '<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>'
|
|
|
- script = script + '<script>document.domain="'+self.host+'";$(function(){var e = pdf2htmlEX.defaultViewer;var page = e.pages.length;var original_height = 0;var height = e.container.clientHeight;for(var i in e.pages){height = height + e.pages[i].original_height;original_height = e.pages[i].original_height;};parent.setHeight(height, original_height, page)})</script>'
|
|
|
+ script = script + '<script>document.domain="'+self.host+'";</script>'
|
|
|
content = content.replace('</body>', script + '</body>')
|
|
|
|
|
|
- style = '<style>#page-container{background-color: white;background-image: none;}#sidebar{background-color: white;background-image: none;}.pf{border:1px solid #bababa;box-shadow:none}</style>'
|
|
|
+ style = '<style>body{zoom:100%;}#page-container{background-color: white;background-image: none;overflow: hidden;}#sidebar{background-color: white;background-image: none;}.pf{margin-top:0px;margin-bottom:0px;border:0px solid #bababa;box-shadow:none}</style>'
|
|
|
|
|
|
content = content.replace('</head>', style + '<head>')
|
|
|
|