From fa00fd422e80df65c43c109efb708cbfd30d8219 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Jan 2020 14:05:23 +0800 Subject: [PATCH] Update functions.php --- functions.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index d37dabb..427f34e 100644 --- a/functions.php +++ b/functions.php @@ -419,8 +419,11 @@ function time_format($ISO) function getConfig($str) { - $envs = json_decode(file_get_contents('config.json')); - return $envs[$str]; + $s = file_get_contents('config.json'); + if ($s!='') { + $envs = json_decode($s, true); + return $envs[$str]; + } else return ''; } function array_value_isnot_null($arr) @@ -438,3 +441,18 @@ function setConfig($arr) ksort($envs); return file_put_contents('config.json', json_encode($envs, JSON_PRETTY_PRINT)); } + +function get_thumbnails_url($path = '/') +{ + $path1 = path_format($path); + $path = path_format($_SERVER['list_path'] . path_format($path)); + $url = $_SERVER['api_url']; + if ($path !== '/') { + $url .= ':' . $path; + if (substr($url,-1)=='/') $url=substr($url,0,-1); + } + $url .= ':/thumbnails/0/medium'; + $files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]), true); + if (isset($files['url'])) return output($files['url']); + return output('', 404); +}