fix: can edit config manually

pull/128/head
qkqpttgf 2020-08-21 15:39:31 +08:00 committed by GitHub
parent e67ff8736b
commit bc12e82c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -73,7 +73,8 @@ function getConfig($str, $disktag = '')
global $Base64Env; global $Base64Env;
//include 'config.php'; //include 'config.php';
$s = file_get_contents(__DIR__ . '/../config.php'); $s = file_get_contents(__DIR__ . '/../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)) {
@ -99,7 +100,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(__DIR__ . '/../config.php'); $s = file_get_contents(__DIR__ . '/../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;
@ -380,10 +382,8 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
copyFolder($coderoot, $outPath); copyFolder($coderoot, $outPath);
// 将配置写入 // 将配置写入
$prestr = '<?php $configs = \' $prestr = '<?php $configs = \'' . PHP_EOL;
'; $aftstr = PHP_EOL . '\';';
$aftstr = '
\';';
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr); file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
// 将目录中文件打包成zip // 将目录中文件打包成zip
@ -441,7 +441,8 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
return $response; return $response;
} }
$s = file_get_contents(__DIR__ . '/../config.php'); $s = file_get_contents(__DIR__ . '/../config.php');
$configs = substr($s, 18, -2); //$configs = substr($s, 18, -2);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $tmp_env = json_decode($configs, true); if ($configs!='') $tmp_env = json_decode($configs, true);
foreach ($Envs as $k => $v) { foreach ($Envs as $k => $v) {
$tmp_env[$k] = $v; $tmp_env[$k] = $v;