From a3b1430041ddfa6e4bc266f36170fd014df52391 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:40:14 +0800 Subject: [PATCH] scf get region --- platform/TencentSCF.php | 72 ++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/platform/TencentSCF.php b/platform/TencentSCF.php index 14b592b..8336994 100644 --- a/platform/TencentSCF.php +++ b/platform/TencentSCF.php @@ -33,20 +33,15 @@ function GetPathSetting($event, $context) $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]); $_SERVER['function_name'] = $context['function_name']; $_SERVER['namespace'] = $context['namespace']; + $_SERVER['Region'] = getenv('TENCENTCLOUD_REGION'); $host_name = $event['headers']['host']; $_SERVER['HTTP_HOST'] = $host_name; $serviceId = $event['requestContext']['serviceId']; if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) { $_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/'; - $_SERVER['Region'] = getenv('Region'); - if ($_SERVER['Region'] == '') { - $_SERVER['Region'] = substr($host_name, strpos($host_name, '.')+1); - $_SERVER['Region'] = substr($_SERVER['Region'], 0, strpos($_SERVER['Region'], '.')); - } $path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/')); } else { $_SERVER['base_path'] = $event['requestContext']['path']; - $_SERVER['Region'] = getenv('Region'); $path = substr($event['path'], strlen($event['requestContext']['path'])); } if (substr($path,-1)=='/') $path=substr($path,0,-1); @@ -154,27 +149,24 @@ function install() ', 302); } if ($_GET['install1']) { - //if ($_POST['admin']!='') { - //$tmp['language'] = $_POST['language']; - $tmp['Region'] = $_POST['Region']; - $tmp['timezone'] = $_COOKIE['timezone']; - $SecretId = getConfig('SecretId'); - if ($SecretId=='') { - $SecretId = $_POST['SecretId']; - $tmp['SecretId'] = $SecretId; - } - $SecretKey = getConfig('SecretKey'); - if ($SecretKey=='') { - $SecretKey = $_POST['SecretKey']; - $tmp['SecretKey'] = $SecretKey; - } - $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_POST['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; - if (api_error($response)) { - $html = api_error_msg($response); - $title = 'Error'; - return message($html, $title, 201); - } else { - $html .= ' + $tmp['timezone'] = $_COOKIE['timezone']; + $SecretId = getConfig('SecretId'); + if ($SecretId=='') { + $SecretId = $_POST['SecretId']; + $tmp['SecretId'] = $SecretId; + } + $SecretKey = getConfig('SecretKey'); + if ($SecretKey=='') { + $SecretKey = $_POST['SecretKey']; + $tmp['SecretKey'] = $SecretKey; + } + $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 201); + } else { + $html .= '

@@ -189,10 +181,9 @@ function install() return true; } '; - $title = getconstStr('SetAdminPassword'); - return message($html, $title, 201); - } - //} + $title = getconstStr('SetAdminPassword'); + return message($html, $title, 201); + } } if ($_GET['install0']) { $html .= ' @@ -207,21 +198,6 @@ language:
';

'; $html .= ' - (腾讯几个月了还不做出来,只能先弄选择了)