fix: can edit config manually

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

View File

@ -58,7 +58,8 @@ function getConfig($str, $disktag = '')
global $Base64Env;
//include '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 (in_array($str, $InnerEnv)) {
@ -84,7 +85,8 @@ function setConfig($arr, $disktag = '')
if ($disktag=='') $disktag = $_SERVER['disktag'];
//include '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);
$disktags = explode("|",getConfig('disktag'));
$indisk = 0;
@ -370,10 +372,8 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
copyFolder($coderoot, $outPath);
// 将配置写入
$prestr = '<?php $configs = \'
';
$aftstr = '
\';';
$prestr = '<?php $configs = \'' . PHP_EOL;
$aftstr = PHP_EOL . '\';';
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
// 将目录中文件打包成zip
@ -444,7 +444,8 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey);
$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);
foreach ($Envs as $k => $v) {
$envs[$k] = $v;