multy disks

pull/31/head
qkqpttgf 2020-02-20 12:15:49 +08:00 committed by GitHub
parent 73792a0fd4
commit 12a1dce640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 222 additions and 79 deletions

View File

@ -1,5 +1,18 @@
<?php <?php
$commonEnv = [
//'Region',
//'SecretId',
//'SecretKey',
//'admin',
'adminloginpage',
//'disktag',
'language',
'passfile',
'sitename',
'theme',
];
function printInput($event, $context) function printInput($event, $context)
{ {
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50); if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
@ -51,20 +64,61 @@ function GetPathSetting($event, $context)
return $path; return $path;
} }
function getConfig($str) function getConfig($str, $disktag = '')
{ {
global $innerEnv;
if ($disktag=='') $disktag = $_SERVER['disktag'];
if (in_array($str, $innerEnv)) {
return json_decode(getenv($disktag), true)[$str];
}
return getenv($str); return getenv($str);
} }
function setConfig($arr) function setConfig($arr, $disktag = '')
{ {
//$function_name, $Region, $Namespace, $SecretId, $SecretKey global $innerEnv;
$function_name = $_SERVER['function_name']; if ($disktag=='') $disktag = $_SERVER['disktag'];
$Region = $_SERVER['Region']; $disktags = explode("|",getConfig('disktag'));
$Namespace = $_SERVER['namespace']; $diskconfig = json_decode(getenv($disktag), true);
$SecretId = getConfig('SecretId'); $tmp = [];
$SecretKey = getConfig('SecretKey'); $indisk = 0;
return updateEnvironment($arr, $function_name, $Region, $Namespace, $SecretId, $SecretKey); $oparetdisk = 0;
foreach ($arr as $k => $v) {
if (in_array($k, $innerEnv)) {
$diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$oparetdisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$oparetdisk = 1;
} else {
$tmp[$k] = $v;
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($oparetdisk) {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = '';
}
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
//';
return updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
}
function WaitSCFStat()
{
$trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
} }
function get_refresh_token() function get_refresh_token()
@ -72,6 +126,8 @@ function get_refresh_token()
global $constStr; global $constStr;
$url = path_format($_SERVER['PHP_SELF'] . '/'); $url = path_format($_SERVER['PHP_SELF'] . '/');
if ($_GET['authorization_code'] && isset($_GET['code'])) { if ($_GET['authorization_code'] && isset($_GET['code'])) {
$_SERVER['disktag'] = $_COOKIE['disktag'];
config_oauth();
$tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']);
if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true);
if (isset($ret['refresh_token'])) { if (isset($ret['refresh_token'])) {
@ -88,15 +144,16 @@ function get_refresh_token()
Add t1-t'.--$i.' to environments.*/ Add t1-t'.--$i.' to environments.*/
$str .= ' $str .= '
<textarea readonly style="width: 95%">' . $tmptoken . '</textarea><br><br> <textarea readonly style="width: 95%">' . $tmptoken . '</textarea><br><br>
Adding refresh_token to Config. '.getconstStr('SavingToken').'
<script> <script>
var texta=document.getElementsByTagName(\'textarea\'); var texta=document.getElementsByTagName(\'textarea\');
for(i=0;i<texta.length;i++) { for(i=0;i<texta.length;i++) {
texta[i].style.height = texta[i].scrollHeight + \'px\'; texta[i].style.height = texta[i].scrollHeight + \'px\';
} }
document.cookie=\'language=; path=/\'; document.cookie=\'language=; path=/\';
document.cookie=\'disktag=; path=/\';
</script>'; </script>';
setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ]); setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ], $_COOKIE['disktag']);
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
$trynum = 0; $trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo ' while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
@ -105,10 +162,13 @@ function get_refresh_token()
<meta http-equiv="refresh" content="2;URL=' . $url . '">'; <meta http-equiv="refresh" content="2;URL=' . $url . '">';
return message($str, getconstStr('WaitJumpIndex')); return message($str, getconstStr('WaitJumpIndex'));
} }
return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']); return message('<pre>' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '</pre>', $tmp['stat']);
//return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500); //return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
} }
if ($_GET['install3']) { if ($_GET['install1']) {
$_SERVER['disk_oprating'] = $_COOKIE['disktag'];
$_SERVER['disktag'] = $_COOKIE['disktag'];
config_oauth();
if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') {
return message(' return message('
<a href="" id="a1">'.getconstStr('JumptoOffice').'</a> <a href="" id="a1">'.getconstStr('JumptoOffice').'</a>
@ -122,17 +182,20 @@ function get_refresh_token()
', getconstStr('Wait').' 1s', 201); ', getconstStr('Wait').' 1s', 201);
} }
} }
if ($_GET['install2']) { if ($_GET['install0']) {
// echo $_POST['Onedrive_ver']; if ($_POST['disktag_add']!='' && ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC')) {
if ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC') { $_SERVER['disktag'] = $_COOKIE['disktag'];
$tmp['disktag_add'] = $_POST['disktag_add'];
$tmp['diskname'] = $_POST['diskname'];
$tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; $tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
if ($_POST['Onedrive_ver']=='MSC') { if ($_POST['Onedrive_ver']=='MSC') {
$tmp['client_id'] = $_POST['client_id']; $tmp['client_id'] = $_POST['client_id'];
$tmp['client_secret'] = $_POST['client_secret']; $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret']));
//$_POST['client_secret'];
} }
$response = json_decode( setConfig($tmp), true )['Response']; $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response'];
$title = getconstStr('MayinEnv'); $title = getconstStr('MayinEnv');
$html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install3">'; $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk&install1">';
if (isset($response['Error'])) { if (isset($response['Error'])) {
$html = $response['Error']['Code'] . '<br> $html = $response['Error']['Code'] . '<br>
' . $response['Error']['Message'] . '<br><br> ' . $response['Error']['Message'] . '<br><br>
@ -145,6 +208,52 @@ namespace:' . $_SERVER['namespace'] . '<br>
return message($html, $title, 201); return message($html, $title, 201);
} }
} }
if ($constStr['language']!='zh-cn') {
$linklang='en-us';
} else $linklang='zh-cn';
$ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php";
$deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru);
$app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
$html = '
<form action="?AddDisk&install0" method="post" onsubmit="return notnull(this);">
'.getconstStr('OnedriveDiskTag').':<input type="text" name="disktag_add"><br>
'.getconstStr('OnedriveDiskName').':<input type="text" name="diskname"><br>
Onedrive_Ver<br>
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br>
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.getconstStr('OndriveVerCN').'</label><br>
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.getconstStr('OndriveVerMSC').'
<div id="secret" style="display:none">
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
client_secret:<input type="text" name="client_secret"><br>
client_id(12345678-90ab-cdef-ghij-klmnopqrstuv):<input type="text" name="client_id"><br>
</div>
</label><br>
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function notnull(t)
{
if (t.disktag_add.value==\'\') {
alert(\'input Disk Tag\');
return false;
}
var reg = /^[a-zA-Z]([-_a-zA-Z0-9]{1,20})$/;
if (!reg.test(t.disktag_add.value)) {
alert(\''.getconstStr('TagFormatAlert').'\');
return false;
}
document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/\';
return true;
}
</script>';
$title = 'Bind Onedrive';
return message($html, $title, 201);
}
function install()
{
global $constStr;
if ($_GET['install1']) { if ($_GET['install1']) {
if ($_POST['admin']!='') { if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
@ -159,8 +268,7 @@ namespace:' . $_SERVER['namespace'] . '<br>
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
} }
echo SetbaseConfig($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
$response = json_decode( updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (isset($response['Error'])) { if (isset($response['Error'])) {
$html = $response['Error']['Code'] . '<br> $html = $response['Error']['Code'] . '<br>
' . $response['Error']['Message'] . '<br><br> ' . $response['Error']['Message'] . '<br><br>
@ -170,34 +278,15 @@ namespace:' . $_SERVER['namespace'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
$title = 'Error'; $title = 'Error';
} else { } else {
if (needUpdate()) { $trynum = 0;
$trynum = 0; while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum; '.++$trynum;
//$response = json_decode( updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (needUpdate()) {
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201); return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
} }
if ($constStr['language']!='zh-cn') { return output('Jump<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
$linklang='en-us';
} else $linklang='zh-cn';
$ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php";
$deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru);
$app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
$html = '
<form action="?install2" method="post">
Onedrive_Ver<br>
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br>
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.getconstStr('OndriveVerCN').'</label><br>
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.getconstStr('OndriveVerMSC').'
<div id="secret" style="display:none">
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
client_secret:<input type="text" name="client_secret"><br>
client_id(12345678-90ab-cdef-ghij-klmnopqrstuv):<input type="text" name="client_id"><br>
</div>
</label><br>
<input type="submit" value="'.getconstStr('Submit').'">
</form>';
$title = 'Install';
} }
return message($html, $title, 201); return message($html, $title, 201);
} }
@ -215,7 +304,7 @@ language:<br>';
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br> <label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label>admin:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
@ -247,7 +336,7 @@ language:<br>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
return message($html, $title, 201); return message($html, $title, 201);
} }
$html .= 'refresh_token not exist, <a href="?install0">click to install.</a>'; $html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
} }
@ -305,9 +394,7 @@ function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $Secret
function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey) function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
{ {
//print_r($Envs); //print_r($Envs);
$trynum = 0; WaitSCFStat();
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key'] //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables']; $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
foreach ($tmp as $tmp1) { foreach ($tmp as $tmp1) {
@ -343,15 +430,34 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr)); return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
} }
function SetbaseConfig($function_name, $Region, $Namespace, $SecretId, $SecretKey) function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
{ {
echo json_encode($Envs,JSON_PRETTY_PRINT);
$trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
foreach ($tmp as $tmp1) {
$tmp_env[$tmp1['Key']] = $tmp1['Value'];
}
foreach ($Envs as $key1 => $value1) {
$tmp_env[$key1] = $value1;
}
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
$tmp_env['Region'] = $Region;
ksort($tmp_env);
$i = 0;
foreach ($tmp_env as $key1 => $value1) {
$tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
$tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
$i++;
}
$meth = 'POST'; $meth = 'POST';
$host = 'scf.tencentcloudapi.com'; $host = 'scf.tencentcloudapi.com';
$tmpdata['Action'] = 'UpdateFunctionConfiguration'; $tmpdata['Action'] = 'UpdateFunctionConfiguration';
$tmpdata['FunctionName'] = $function_name; $tmpdata['FunctionName'] = $function_name;
$tmpdata['Description'] = 'Onedrive index & manager in SCF.';
$tmpdata['MemorySize'] = 64;
$tmpdata['Timeout'] = 30;
$tmpdata['Namespace'] = $Namespace; $tmpdata['Namespace'] = $Namespace;
$tmpdata['Nonce'] = time(); $tmpdata['Nonce'] = time();
$tmpdata['Region'] = $Region; $tmpdata['Region'] = $Region;
@ -359,7 +465,11 @@ function SetbaseConfig($function_name, $Region, $Namespace, $SecretId, $SecretKe
$tmpdata['Timestamp'] = time(); $tmpdata['Timestamp'] = time();
$tmpdata['Token'] = ''; $tmpdata['Token'] = '';
$tmpdata['Version'] = '2018-04-16'; $tmpdata['Version'] = '2018-04-16';
$tmpdata['Description'] = 'Onedrive index and manager in SCF.';
$tmpdata['MemorySize'] = 64;
$tmpdata['Timeout'] = 30;
$data = ReorganizeDate($tmpdata); $data = ReorganizeDate($tmpdata);
echo $data;
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true)); $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
//echo urlencode($signStr); //echo urlencode($signStr);
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr)); return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
@ -367,6 +477,7 @@ function SetbaseConfig($function_name, $Region, $Namespace, $SecretId, $SecretKe
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey) function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey)
{ {
WaitSCFStat();
$meth = 'POST'; $meth = 'POST';
$host = 'scf.tencentcloudapi.com'; $host = 'scf.tencentcloudapi.com';
$tmpdata['Action'] = 'UpdateFunctionCode'; $tmpdata['Action'] = 'UpdateFunctionCode';
@ -391,13 +502,11 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
function EnvOpt($function_name, $needUpdate = 0) function EnvOpt($function_name, $needUpdate = 0)
{ {
global $constStr; global $constStr;
$constEnv = [ global $commonEnv;
//'admin', global $innerEnv;
'adminloginpage', 'domain_path', 'guestup_path', 'passfile', global $ShowedinnerEnv;
//'private_path', asort($commonEnv);
'public_path', 'sitename', 'language', 'theme' asort($ShowedinnerEnv);
];
asort($constEnv);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
if ($_POST['updateProgram']==getconstStr('updateProgram')) { if ($_POST['updateProgram']==getconstStr('updateProgram')) {
$response = json_decode(updateProgram($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response']; $response = json_decode(updateProgram($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response'];
@ -410,9 +519,7 @@ namespace:' . $namespace . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
$title = 'Error'; $title = 'Error';
} else { } else {
$trynum = 0; WaitSCFStat();
while( json_decode(getfunctioninfo($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
$html .= getconstStr('UpdateSuccess') . '<br> $html .= getconstStr('UpdateSuccess') . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
@ -420,11 +527,12 @@ namespace:' . $namespace . '<br>
return message($html, $title); return message($html, $title);
} }
if ($_POST['submit1']) { if ($_POST['submit1']) {
$_SERVER['disk_oprating'] = '';
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
if (in_array($k, $constEnv)) { if (in_array($k, $commonEnv)||in_array($k, $innerEnv)||$k=='disktag_del' || $k=='disktag_add') {
//if (!(getConfig($k)==''&&$v==''))
$tmp[$k] = $v; $tmp[$k] = $v;
} }
if ($k == 'disk') $_SERVER['disk_oprating'] = $v;
} }
/*if ($tmp['domain_path']!='') { /*if ($tmp['domain_path']!='') {
$tmp1 = explode("|",$tmp['domain_path']); $tmp1 = explode("|",$tmp['domain_path']);
@ -435,7 +543,7 @@ namespace:' . $namespace . '<br>
} }
$tmp['domain_path'] = $tmparr; $tmp['domain_path'] = $tmparr;
}*/ }*/
$response = json_decode( setConfig($tmp), true )['Response']; $response = json_decode( setConfig($tmp, $_SERVER['disk_oprating']), true )['Response'];
if (isset($response['Error'])) { if (isset($response['Error'])) {
$html = $response['Error']['Code'] . '<br> $html = $response['Error']['Code'] . '<br>
' . $response['Error']['Message'] . '<br><br> ' . $response['Error']['Message'] . '<br><br>
@ -445,11 +553,9 @@ namespace:' . $_SERVER['namespace'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
$title = 'Error'; $title = 'Error';
} else { } else {
$trynum = 0; WaitSCFStat();
while( json_decode(getfunctioninfo($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
//sleep(3); //sleep(3);
$html .= '<script>location.href=location.href</script>'; $html .= json_encode($response,JSON_PRETTY_PRINT).'<script>location.href=location.href</script>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
} }
return message($html, $title); return message($html, $title);
@ -460,7 +566,7 @@ namespace:' . $_SERVER['namespace'] . '<br>
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); $preurl = path_format($_SERVER['PHP_SELF'] . '/');
} }
$html .= ' $html .= '
<a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp; <a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp;<a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
if ($needUpdate) { if ($needUpdate) {
$html .= '<pre>' . $_SERVER['github_version'] . '</pre> $html .= '<pre>' . $_SERVER['github_version'] . '</pre>
@ -470,10 +576,13 @@ namespace:' . $_SERVER['namespace'] . '<br>
} else { } else {
$html .= getconstStr('NotNeedUpdate'); $html .= getconstStr('NotNeedUpdate');
} }
$html .= ' $html .= '<br>
<form action="" method="post"> <table border=1 width=100%>
<table border=1 width=100%>'; <form name="common" action="" method="post">
foreach ($constEnv as $key) { <tr>
<td colspan="2">'.getconstStr('PlatformConfig').'</td>
</tr>';
foreach ($commonEnv as $key) {
if ($key=='language') { if ($key=='language') {
$html .= ' $html .= '
<tr> <tr>
@ -522,8 +631,42 @@ namespace:' . $_SERVER['namespace'] . '<br>
<td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td> <td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
</tr>'; </tr>';
} }
$html .= '</table> $html .= '
<input type="submit" name="submit1" value="'.getconstStr('Setup').'"> <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
</form>'; </form>
</table><br>';
foreach (explode("|",getConfig('disktag')) as $disktag) {
if ($disktag!='') {
$html .= '
<table border=1 width=100%>
<form action="" method="post">
<tr>
<td colspan="2">'.$disktag.'
<input type="hidden" name="disktag_del" value="'.$disktag.'">
<input type="submit" name="submit1" value="'.getconstStr('DelDisk').'">
</td>
</tr>
</form>';
if (getConfig('refresh_token', $disktag)!='') {
$html .= '
<form name="'.$disktag.'" action="" method="post">
<input type="hidden" name="disk" value="'.$disktag.'">';
foreach ($ShowedinnerEnv as $key) {
$html .= '
<tr>
<td><label>' . $key . '</label></td>
<td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key, $disktag) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
</tr>';
}
$html .= '
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
</form>';
}
$html .= '
</table><br>';
}
}
$html .= '
<a href="?AddDisk">'.getconstStr('AddDisk').'</a>';
return message($html, getconstStr('Setup')); return message($html, getconstStr('Setup'));
} }