Update functions.php

pull/13/head
qkqpttgf 2020-01-05 10:27:37 +08:00 committed by GitHub
parent b8590b2cdd
commit 5489238259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -448,9 +448,10 @@ function time_format($ISO)
function getConfig($str)
{
$s = file_get_contents('config.json');
if ($s!='') {
$envs = json_decode($s, true);
include 'config.php';
//$s = file_get_contents('config.json');
if ($configs!='') {
$envs = json_decode($configs, true);
if (isset($envs[$str])) return $envs[$str];
}
return '';
@ -491,14 +492,19 @@ function array_value_isnot_null($arr)
function setConfig($arr)
{
$envs = json_decode(file_get_contents('config.json'), true);
include 'config.php';
if ($configs!='') $envs = json_decode($configs, true);
foreach ($arr as $k1 => $v1) {
$envs[$k1] = $v1;
}
$envs = array_filter($envs, 'array_value_isnot_null');
ksort($envs);
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
return file_put_contents('config.json', json_encode($envs, JSON_PRETTY_PRINT));
$prestr = '<?php $configs=\'
';
$aftstr = '
\';';
return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
}
function get_thumbnails_url($path = '/')