nexmoe thumb

This commit is contained in:
qkqpttgf 2020-05-24 18:15:31 +08:00 committed by GitHub
parent 65fa8c290f
commit d344fa2245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 12 deletions

View File

@ -306,7 +306,7 @@ function main($path)
if (isset($_GET['thumbnails'])) { if (isset($_GET['thumbnails'])) {
if ($_SERVER['ishidden']<4) { if ($_SERVER['ishidden']<4) {
if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) { if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
return get_thumbnails_url($path); return get_thumbnails_url($path, $_GET['location']);
} else return output(json_encode($exts['img']),400); } else return output(json_encode($exts['img']),400);
} else return output('',401); } else return output('',401);
} }
@ -778,13 +778,13 @@ function time_format($ISO)
return date('Y-m-d H:i:s',strtotime($ISO . " UTC")); return date('Y-m-d H:i:s',strtotime($ISO . " UTC"));
} }
function get_thumbnails_url($path = '/') function get_thumbnails_url($path = '/', $location = 0)
{ {
$path1 = path_format($path); $path1 = path_format($path);
$path = path_format($_SERVER['list_path'] . path_format($path)); $path = path_format($_SERVER['list_path'] . path_format($path));
if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
$thumb_url = getcache('thumb_'.$path); $thumb_url = getcache('thumb_'.$path);
if ($thumb_url!='') return output($thumb_url); if ($thumb_url=='') {
$url = $_SERVER['api_url']; $url = $_SERVER['api_url'];
if ($path !== '/') { if ($path !== '/') {
$url .= ':' . $path; $url .= ':' . $path;
@ -794,7 +794,12 @@ function get_thumbnails_url($path = '/')
$files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); $files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
if (isset($files['url'])) { if (isset($files['url'])) {
savecache('thumb_'.$path, $files['url']); savecache('thumb_'.$path, $files['url']);
return output($files['url']); $thumb_url = $files['url'];
}
}
if ($thumb_url!='') {
if ($location) return output('', 302, [ 'Location' => $thumb_url ]);
else return output($thumb_url);
} }
return output('', 404); return output('', 404);
} }
@ -2108,6 +2113,8 @@ function render_list($path = '', $files = '')
} }
$html .= $tmp[1]; $html .= $tmp[1];
while (strpos($html, '<!--MaxPageNum-->')) $html = str_replace('<!--MaxPageNum-->', $maxpage, $html);
} else { } else {
while (strpos($html, '<!--MorePageStart-->')) { while (strpos($html, '<!--MorePageStart-->')) {
$tmp = splitfirst($html, '<!--MorePageStart-->'); $tmp = splitfirst($html, '<!--MorePageStart-->');