fix: some system can not edit config manually

pull/128/head
qkqpttgf 2020-08-21 14:35:07 +08:00 committed by GitHub
parent 36df71a77c
commit fe765192e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -9,7 +9,8 @@ function getpath()
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI']; else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) ); $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return substr($path, 1); return $path;
//return substr($path, 1);
//return spurlencode($path, '/'); //return spurlencode($path, '/');
} }
@ -44,7 +45,8 @@ function getConfig($str, $disktag = '')
global $Base64Env; global $Base64Env;
//include 'config.php'; //include 'config.php';
$s = file_get_contents('config.php'); $s = file_get_contents('config.php');
$configs = substr($s, 18, -2); //$configs = substr($s, 18, -2);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') { if ($configs!='') {
$envs = json_decode($configs, true); $envs = json_decode($configs, true);
if (in_array($str, $InnerEnv)) { if (in_array($str, $InnerEnv)) {
@ -70,7 +72,8 @@ function setConfig($arr, $disktag = '')
if ($disktag=='') $disktag = $_SERVER['disktag']; if ($disktag=='') $disktag = $_SERVER['disktag'];
//include 'config.php'; //include 'config.php';
$s = file_get_contents('config.php'); $s = file_get_contents('config.php');
$configs = substr($s, 18, -2); //$configs = substr($s, 18, -2);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $envs = json_decode($configs, true); if ($configs!='') $envs = json_decode($configs, true);
$disktags = explode("|",getConfig('disktag')); $disktags = explode("|",getConfig('disktag'));
$indisk = 0; $indisk = 0;
@ -107,10 +110,8 @@ function setConfig($arr, $disktag = '')
$envs = array_filter($envs, 'array_value_isnot_null'); $envs = array_filter($envs, 'array_value_isnot_null');
ksort($envs); ksort($envs);
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
$prestr = '<?php $configs = \' $prestr = '<?php $configs = \'' . PHP_EOL;
'; $aftstr = PHP_EOL . '\';';
$aftstr = '
\';';
return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr); return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
} }