getRequestID();
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
$tmp['AccessKey'] = $context->getAccessKey();
$tmp['SecretKey'] = $context->getSecretKey();
$tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
$tmp['FunctionName'] = $context->getFunctionName();
$tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
$tmp['Version'] = $context->getVersion();
$tmp['MemorySize'] = $context->getMemorySize();
$tmp['CPUNumber'] = $context->getCPUNumber();
$tmp['ProjectID'] = $context->getProjectID();
$tmp['Package'] = $context->getPackage();
$tmp['Token'] = $context->getToken();
$tmp['Logger'] = $context->getLogger();
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
';
}
function GetGlobalVariable($event)
{
$_GET = $event['queryStringParameters'];
$postbody = explode("&",$event['body']);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
$cookiebody = explode("; ",$event['headers']['cookie']);
foreach ($cookiebody as $cookievalues) {
$pos = strpos($cookievalues,"=");
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
}
function GetPathSetting($event, $context)
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
$_SERVER['function_name'] = $context->getFunctionName();
$_SERVER['ProjectID'] = $context->getProjectID();
$host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name;
$path = path_format('/' . $event['pathParameters']['']);
$path = str_replace('+', '%2B', $path);
$_SERVER['base_path'] = path_format($event['path']);
if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/';
} else {
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, strlen($_SERVER['base_path'])-strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
}
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
if (isset($event['headers']['authorization'])) {
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
}
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
return $path;
}
function getConfig($str, $disktag = '')
{
global $contextUserData;
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$env = json_decode($contextUserData->getUserData($disktag), true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode($contextUserData->getUserData($str));
else return $contextUserData->getUserData($str);
}
return '';
}
function setConfig($arr, $disktag = '')
{
global $contextUserData;
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|",getConfig('disktag'));
$diskconfig = json_decode($contextUserData->getUserData($disktag), true);
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tmp[$newtag] = getConfig($v);
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($v);
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
$tmp[$arr['disktag_rename']] = '';
} else {
$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).'
//';
$response = updateEnvironment($tmp, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
return $response;
}
function install()
{
global $constStr;
global $contextUserData;
if ($_GET['install2']) {
$tmp['admin'] = $_POST['admin'];
$response = setConfigResponse( setConfig($tmp) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
}
if (needUpdate()) {
OnekeyUpate();
return message('update to github version, reinstall.
', 'Program updating', 201);
}
return output('Jump
', 302);
}
if ($_GET['install1']) {
//if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = $_POST['HW_urn'];
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response'];
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
} else {
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '
' . getconstStr('Home') . '';
$title = 'Reinstall';
return message($html, $title, 201);
}
$html .= '