From 85fb91171b1a417b65cd6d53461740e7da94c420 Mon Sep 17 00:00:00 2001 From: "Mr.Lin" Date: Thu, 2 Apr 2020 21:52:24 +0800 Subject: [PATCH] Update scf.php --- platform/scf.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/scf.php b/platform/scf.php index fe87503..28dd39a 100644 --- a/platform/scf.php +++ b/platform/scf.php @@ -28,6 +28,7 @@ function GetGlobalVariable($event) 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']; $host_name = $event['headers']['host']; @@ -132,7 +133,6 @@ function install() setConfig($tmp); if (needUpdate()) { OnekeyUpate(); - //updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); return message('update to github version, reinstall.', 'Program updating', 201); } return output('Jump', 302); @@ -370,13 +370,14 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr)); } -function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source = '') +function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source) { WaitSCFStat(); $meth = 'POST'; $host = 'scf.tencentcloudapi.com'; $tmpdata['Action'] = 'UpdateFunctionCode'; - $tmpdata['Code.GitUrl'] = $source; + $tmpdata['Code.GitUrl'] = $source['url']; + $tmpdata['Code.GitBranch'] = $source['branch']; $tmpdata['CodeSource'] = 'Git'; $tmpdata['FunctionName'] = $function_name; $tmpdata['Handler'] = 'index.main_handler'; @@ -408,10 +409,10 @@ namespace:' . $_SERVER['namespace'] . '
'; } -function OnekeyUpate($auth = 'ldxw', $project = 'OneManager-php', $branch = 'master') +function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') { - //'https://github.com/ldxw/OneManager-php/tree/v2-MultiDisk'; - $source = 'https://github.com/' . $auth . '/' . $project . '/tree/' . $branch; + $source['url'] = 'https://github.com/' . $auth . '/' . $project; + $source['branch'] = $branch; return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source), true)['Response']; }