Update functions.php

pull/13/head
qkqpttgf 2020-01-01 14:05:23 +08:00 committed by GitHub
parent 0fbacf2608
commit fa00fd422e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 2 deletions

View File

@ -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);
}