Skip to content

Commit

Permalink
Merge pull request #525 from VBill/update-aliyun-fc-check
Browse files Browse the repository at this point in the history
fix: check aliyun fc with official env var
  • Loading branch information
qkqpttgf authored Jan 27, 2022
2 parents dc462d8 + 79c35da commit c6f8c1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ function changedrivetype(d) {
$canOneKeyUpate = 1;
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
$canOneKeyUpate = 1;
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
} elseif (isset($_SERVER['FC_FUNC_CODE_PATH'])) {
$canOneKeyUpate = 1;
} elseif (isset($_SERVER['BCE_CFC_RUNTIME_NAME'])&&$_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
$canOneKeyUpate = 1;
Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php';
else include 'platform/TencentSCF_env.php';
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
} elseif (isset($_SERVER['FC_FUNC_CODE_PATH'])) {
include 'platform/AliyunFC.php';
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
} elseif (isset($_SERVER['_APP_SHARE_DIR']) && $_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
//if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php';
//else include 'platform/HuaweiFG_env.php';
echo 'FG' . PHP_EOL;
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
} elseif (isset($_SERVER['BCE_CFC_RUNTIME_NAME']) && $_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
include 'platform/BaiduCFC.php';
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
include 'platform/Heroku.php';
Expand Down Expand Up @@ -106,7 +106,7 @@ function main_handler($event, $context)
// Aliyun FC & Huawei FG & Baidu CFC
function handler($event, $context)
{
if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
if (isset($_SERVER['FC_FUNC_CODE_PATH'])) {
// Aliyun FC
set_error_handler("myErrorHandler");
$tmp = array(
Expand All @@ -130,7 +130,7 @@ function handler($event, $context)

$re = main($path);

return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['isBase64Encoded']?base64_decode($re['body']):$re['body']);
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], ($re['isBase64Encoded']?base64_decode($re['body']):$re['body']));

} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
// Huawei FG
Expand Down
2 changes: 1 addition & 1 deletion platform/AliyunFC.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function GetPathSetting($event, $context)
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0];
$_SERVER['FC_FUNC_CODE_PATH'] = getenv('FC_FUNC_CODE_PATH');
$_SERVER['REQUEST_METHOD'] = $event['method'];
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
return $path;
//return spurlencode($path, '/');
}
Expand Down

0 comments on commit c6f8c1c

Please sign in to comment.