use BasicAuth in encrypted folder. fix: error_log in SCF

pull/194/head
root 2021-01-16 17:12:03 +08:00
parent 5e49a44ec1
commit 34599a6e71
13 changed files with 133 additions and 93 deletions

View File

@ -475,7 +475,7 @@ function filecache($disktag)
$tag = str_replace(':', '_', $tag);
$tag = str_replace('\\', '_', $tag);
}
// error_log('DIR:' . $dir . ' TAG: ' . $tag);
// error_log1('DIR:' . $dir . ' TAG: ' . $tag);
$cache = new \Doctrine\Common\Cache\FilesystemCache($dir, $tag);
return $cache;
}
@ -575,6 +575,11 @@ function base64y_decode($str)
return $str;
}
function error_log1($str)
{
error_log($str);
}
function is_guestup_path($path)
{
if (getConfig('guestup_path', $_SERVER['disktag'])!='') {
@ -683,6 +688,13 @@ function comppass($pass)
return 2;
}
if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
//$_SERVER['PHP_AUTH_USER']
if ($_SERVER['PHP_AUTH_PW'] !== '') if (md5($_SERVER['PHP_AUTH_PW']) === $pass ) {
date_default_timezone_set('UTC');
$_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
date_default_timezone_set(get_timezone($_SERVER['timezone']));
return 2;
}
return 4;
}
@ -1492,7 +1504,7 @@ function render_list($path = '', $files = [])
$file_path = $theme;
$tmp = curl('GET', $file_path, false, [], 1);
if ($tmp['stat']==302) {
error_log(json_encode($tmp));
error_log1(json_encode($tmp));
$tmp = curl('GET', $tmp["returnhead"]["Location"]);
}
if (!!$tmp['body']) $html = $tmp['body'];
@ -1603,6 +1615,16 @@ function render_list($path = '', $files = [])
}
if ($_SERVER['ishidden']==4) {
// 加密状态
// Basic Auth
return output('Need password.', 401, ['WWW-Authenticate'=>'Basic realm="Secure Area"']);
/*$tmp[1] = 'a';
while ($tmp[1]!='') {
$tmp = splitfirst($html, '<!--ListStart-->');
$html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--ListEnd-->');
$html .= $tmp[1];
}*/
$tmp[1] = 'a';
while ($tmp[1]!='') {
$tmp = splitfirst($html, '<!--IsFileStart-->');
@ -1617,13 +1639,6 @@ function render_list($path = '', $files = [])
$tmp = splitfirst($tmp[1], '<!--IsFolderEnd-->');
$html .= $tmp[1];
}
/*$tmp[1] = 'a';
while ($tmp[1]!='') {
$tmp = splitfirst($html, '<!--ListStart-->');
$html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--ListEnd-->');
$html .= $tmp[1];
}*/
$tmp[1] = 'a';
while ($tmp[1]!='') {
$tmp = splitfirst($html, '<!--IsNotHiddenStart-->');
@ -1891,7 +1906,7 @@ function render_list($path = '', $files = [])
if ($ext==$key1) {
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
}
//error_log('file:'.$file['name'].':'.$key1);
//error_log1('file:'.$file['name'].':'.$key1);
if (!strpos($FolderListStr, '<!--IconValue-->')) break;
}
if (strpos($FolderListStr, '<!--IconValue-->')) $FolderListStr = str_replace('<!--IconValue-->', $IconValues['default'], $FolderListStr);

View File

@ -78,7 +78,7 @@ class Aliyundrive {
} elseif (isset($files['code'])) {
return $files;
}
//error_log(json_encode($tmp));
//error_log1(json_encode($tmp));
return $tmp;
}
@ -91,7 +91,7 @@ class Aliyundrive {
//if (!($files = getcache('path_' . $path, $this->disktag))) {
if ($path == '/' || $path == '') {
$files = $this->fileList('root');
//error_log('root_id' . $files['id']);
//error_log1('root_id' . $files['id']);
$files['file_id'] = 'root';
$files['type'] = 'folder';
} else {
@ -136,7 +136,7 @@ class Aliyundrive {
savecache('path_' . $path, $files, $this->disktag, 600);
}
//}
//error_log('path:' . $path . ', files:' . json_encode($files));
//error_log1('path:' . $path . ', files:' . json_encode($files));
return $files;
}
@ -191,7 +191,7 @@ class Aliyundrive {
$result = curl('POST', $url, json_encode($data), $header);
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
//error_log('decode:' . json_encode($result));
//error_log1('decode:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//return output($result['body'], $result['stat']);
}
@ -211,7 +211,7 @@ class Aliyundrive {
$result = curl('POST', $url, json_encode($data), $header);
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
//error_log('result:' . json_encode($result));
//error_log1('result:' . json_encode($result));
//return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
$res = json_decode($result['body'], true)['responses'][0];
if (isset($res['status'])) return output($res['id'], $res['status']);
@ -224,7 +224,7 @@ class Aliyundrive {
}
if (!$folder['id']) {
$res = $this->list_path($folder['path']);
//error_log('res:' . json_encode($res));
//error_log1('res:' . json_encode($res));
$folder['id'] = $res['file_id'];
}
$tmp = '/tmp/' . $passfilename;
@ -233,7 +233,7 @@ class Aliyundrive {
$result = $this->tmpfileCreate($folder['id'], $tmp, $passfilename);
if ($result['stat']==201) {
//error_log('1,url:' . $url .' res:' . json_encode($result));
//error_log1('1,url:' . $url .' res:' . json_encode($result));
$res = json_decode($result['body'], true);
$url = $res['part_info_list'][0]['upload_url'];
if (!$url) { // 无url应该算秒传
@ -249,13 +249,13 @@ class Aliyundrive {
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
}
//error_log('2,url:' . $url .' res:' . json_encode($result));
//error_log1('2,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
public function Move($file, $folder) {
if (!$folder['id']) {
$res = $this->list_path($folder['path']);
//error_log('res:' . json_encode($res));
//error_log1('res:' . json_encode($res));
$folder['id'] = $res['file_id'];
}
@ -276,13 +276,13 @@ class Aliyundrive {
$result = curl('POST', $url, json_encode($data), $header);
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
//error_log('result:' . json_encode($result));
//error_log1('result:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
public function Copy($file) {
if (!$file['id']) {
$oldfile = $this->list_path($file['path'] . '/' . $file['name']);
//error_log('res:' . json_encode($res));
//error_log1('res:' . json_encode($res));
//$file['id'] = $res['file_id'];
} else {
$oldfile = $this->fileGet($file['id']);
@ -308,7 +308,7 @@ class Aliyundrive {
$result = curl('POST', $url, json_encode($data), $header);
if ($result['stat']==201) {
//error_log('1,url:' . $url .' res:' . json_encode($result));
//error_log1('1,url:' . $url .' res:' . json_encode($result));
$res = json_decode($result['body'], true);
$url = $res['part_info_list'][0]['upload_url'];
if (!$url) { // 无url应该算秒传
@ -326,7 +326,7 @@ class Aliyundrive {
else return output('success', 0);
}*/
}
//error_log('2,url:' . $url .' res:' . json_encode($result));
//error_log1('2,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
public function Edit($file, $content) {
@ -343,7 +343,7 @@ class Aliyundrive {
$result = $this->tmpfileCreate($this->list_path($folderpath)['file_id'], $tmp1, $filename);
if ($result['stat']==201) {
//error_log('1,url:' . $url .' res:' . json_encode($result));
//error_log1('1,url:' . $url .' res:' . json_encode($result));
$res = json_decode($result['body'], true);
$url = $res['part_info_list'][0]['upload_url'];
if (!$url) { // 无url应该算秒传
@ -360,18 +360,18 @@ class Aliyundrive {
else return output('success', 0);
}
}
//error_log('2,url:' . $url .' res:' . json_encode($result));
//error_log1('2,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
public function Create($folder, $type, $name, $content = '') {
if (!$folder['id']) {
$res = $this->list_path($folder['path']);
//error_log('res:' . json_encode($res));
//error_log1('res:' . json_encode($res));
$folder['id'] = $res['file_id'];
}
if ($type=='folder') {
$result = $this->folderCreate($folder['id'], $name);
//error_log('res:' . json_encode($result));
//error_log1('res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
if ($type=='file') {
@ -381,32 +381,32 @@ class Aliyundrive {
$result = $this->tmpfileCreate($folder['id'], $tmp, $name);
if ($result['stat']==201) {
//error_log('1,url:' . $url .' res:' . json_encode($result));
//error_log1('1,url:' . $url .' res:' . json_encode($result));
$res = json_decode($result['body'], true);
if (isset($res['exist'])&&$res['exist']!=false) {
// 已经有
//error_log('exist:' . json_encode($res));
//error_log1('exist:' . json_encode($res));
return output('{"type":"file","name":"' . $name . '", "exist":true}', 200);
}
if (isset($res['rapid_upload'])&&$res['rapid_upload']!=false) {
// 秒传
//error_log('rapid up:' . json_encode($res));
//error_log1('rapid up:' . json_encode($res));
return output('{"type":"file","name":"' . $name . '", "rapid_upload":true}', 200);
}
$url = $res['part_info_list'][0]['upload_url'];
$file_id = $res['file_id'];
$upload_id = $res['upload_id'];
$result = curl('PUT', $url, $content, [], 1);
//error_log('2,url:' . $url .' res:' . json_encode($result));
//error_log1('2,url:' . $url .' res:' . json_encode($result));
if ($result['stat']==200) { // 块1传好
$tmp1['part_number'] = 1;
$tmp1['etag'] = $result['returnhead']['ETag'];
$result = $this->fileComplete($file_id, $upload_id, [ $tmp1 ]);
//error_log('3,url:' . $url .' res:' . json_encode($result));
//error_log1('3,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
}
//error_log('4,url:' . $url .' res:' . json_encode($result));
//error_log1('4,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
}
return output('Type not folder or file.', 500);
@ -539,20 +539,20 @@ class Aliyundrive {
$parent_file_id = $parent['file_id'];
} else {
$res = $this->folderCreate($this->list_path($path)['file_id'], $fileinfo['path']);
//error_log($res['body']);
//error_log1($res['body']);
$parent_file_id = json_decode($res['body'], true)['file_id'];
}
$response = $this->fileCreate($parent_file_id, $filename, $_POST['filesha1'], $fileinfo['size']);
$res = json_decode($response['body'], true);
if (isset($res['exist'])) {
// 已经有
//error_log('exist:' . json_encode($res));
//error_log1('exist:' . json_encode($res));
return output(json_encode($this->files_format(json_decode($response['body'], true))), $response['stat']);
//return output('{"type":"file","name":"' . $_POST['upbigfilename'] . '", "exist":true}', 200);
}
if (isset($res['rapid_upload'])&&$res['rapid_upload']!=false) {
// 秒传
//error_log('rapid up:' . json_encode($res));
//error_log1('rapid up:' . json_encode($res));
return output(json_encode($this->files_format(json_decode($response['body'], true))), $response['stat']);
//return output('{"type":"file","name":"' . $_POST['upbigfilename'] . '", "rapid upload":true}', 200);
}
@ -694,10 +694,10 @@ class Aliyundrive {
$response = curl('POST', $this->auth_url, json_encode($tmp1), ["content-type"=>"application/json; charset=utf-8"]);
$p++;
}
error_log(json_encode($response));
error_log1(json_encode($response));
if ($response['stat']==200) $ret = json_decode($response['body'], true);
if (!isset($ret['access_token'])) {
error_log('failed to get [' . $this->disktag . '] access_token. response' . json_encode($ret));
error_log1('failed to get [' . $this->disktag . '] access_token. response' . json_encode($ret));
$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
$response['body'] .= '\nfailed to get [' . $this->disktag . '] access_token.';
return $response;
@ -705,7 +705,7 @@ class Aliyundrive {
$tmp = $ret;
$tmp['access_token'] = '******';
$tmp['refresh_token'] = '******';
error_log('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
error_log1('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
$this->access_token = $ret['access_token'];
savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300);
if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ], $this->disktag);
@ -713,4 +713,4 @@ class Aliyundrive {
}
return true;
}
}
}

View File

@ -118,7 +118,7 @@ class Onedrive {
$files['error']['stat'] = $arr['stat'];
}
} else {
//error_log($arr['body']);
//error_log1($arr['body']);
$files = json_decode($arr['body'], true);
if (isset($files['error'])) {
$files['error']['stat'] = $arr['stat'];
@ -128,7 +128,7 @@ class Onedrive {
$files['error']['message'] = 'unknownError';
}
//$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
//error_log(json_encode($files, JSON_PRETTY_PRINT));
//error_log1(json_encode($files, JSON_PRETTY_PRINT));
}
}
//echo '<pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
@ -172,7 +172,7 @@ class Onedrive {
} elseif (isset($files['error'])) {
return $files;
}
//error_log(json_encode($tmp));
//error_log1(json_encode($tmp));
return $tmp;
}
@ -463,7 +463,7 @@ class Onedrive {
$api = $this->api_url . '/me/followedSites';
$arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ]);
if (!($arr['stat']==200||$arr['stat']==403||$arr['stat']==400)) return message($arr['stat'] . json_encode(json_decode($arr['body']), JSON_PRETTY_PRINT), 'Get followedSites', $arr['stat']);
error_log($arr['body']);
error_log1($arr['body']);
$sites = json_decode($arr['body'], true)['value'];
$title = 'Select Disk';
@ -717,8 +717,8 @@ class Onedrive {
}
if ($response['stat']==200) $ret = json_decode($response['body'], true);
if (!isset($ret['access_token'])) {
error_log($this->oauth_url . 'token' . '?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret . '&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . substr($refresh_token, 0, 20) . '******' . substr($refresh_token, -20));
error_log('failed to get [' . $this->disktag . '] access_token. response' . json_encode($ret));
error_log1($this->oauth_url . 'token' . '?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret . '&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . substr($refresh_token, 0, 20) . '******' . substr($refresh_token, -20));
error_log1('failed to get [' . $this->disktag . '] access_token. response' . json_encode($ret));
$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
$response['body'] .= '\nfailed to get [' . $this->disktag . '] access_token.';
return $response;
@ -727,7 +727,7 @@ class Onedrive {
$tmp = $ret;
$tmp['access_token'] = '******';
$tmp['refresh_token'] = '******';
error_log('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
error_log1('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
$this->access_token = $ret['access_token'];
savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300);
if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ], $this->disktag);
@ -757,7 +757,7 @@ class Onedrive {
$i++;
}
if ($response['stat']!=200) {
error_log('failed to get siteid. response' . json_encode($response));
error_log1('failed to get siteid. response' . json_encode($response));
$response['body'] .= '\nfailed to get siteid.';
return $response;
//throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
@ -767,7 +767,7 @@ class Onedrive {
public function del_upload_cache($path)
{
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
error_log1('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
$tmp = splitlast($_GET['filename'], '/');
if ($tmp[1]!='') {
$filename = $tmp[0] . '/.' . $_GET['filelastModified'] . '_' . $_GET['filesize'] . '_' . $tmp[1] . '.tmp';
@ -905,11 +905,11 @@ class Onedrive {
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
//$response['Location'] = curl_getinfo($ch);
curl_close($ch);
error_log($response['stat'].'
error_log1($response['stat'].'
'.$response['body'].'
'.$url.'
');
return $response;
}
}
}

View File

@ -37,8 +37,8 @@ class Sharelink extends Onedrive {
$this->access_token = splitlast($ret['ListSchema']['.driveAccessToken'],'=')[1];
$this->api_url = $ret['ListSchema']['.driveUrl'].'/root';
if (!$this->access_token) {
error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
error_log('failed to get share access_token. response' . json_encode($ret));
error_log1($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
error_log1('failed to get share access_token. response' . json_encode($ret));
$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
$response['body'] .= '\nfailed to get shareurl access_token.';
return $response;
@ -46,7 +46,7 @@ class Sharelink extends Onedrive {
}
//$tmp = $ret;
//$tmp['access_token'] = '******';
//error_log('['.$this->disktag.'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
//error_log1('['.$this->disktag.'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
savecache('access_token', $this->access_token, $this->disktag);
$tmp1 = null;
if (getConfig('shareapiurl', $this->disktag)!=$this->api_url) $tmp1['shareapiurl'] = $this->api_url;
@ -56,4 +56,4 @@ class Sharelink extends Onedrive {
}
return true;
}
}
}

View File

@ -15,8 +15,6 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
//else include 'platform/HuaweiFG_env.php';
echo 'FG' . PHP_EOL;
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
//set_include_path(get_include_path() . PATH_SEPARATOR . '/opt/php');
//include 'BaiduBce.phar';
include 'platform/BaiduCFC.php';
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
include 'platform/Heroku.php';
@ -136,28 +134,3 @@ function handler($event, $context)
}
}
// used by Aliyun FC
function myErrorHandler($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno)) {
return false;
}
switch ($errno) {
case E_USER_ERROR:
$errInfo = array(
"errorMessage" => $errstr,
"errorType" => \ServerlessFC\friendly_error_type($errno),
"stackTrace" => array(
"file" => $errfile,
"line" => $errline,
),
);
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
break;
default: // E_USER_WARNING | E_USER_NOTICE
break;
}
return true;
}

View File

@ -28,6 +28,11 @@ function GetGlobalVariable($event)
$pos = strpos($cookievalues,"=");
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
if (isset($event['headers']['Authorization'])) {
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['Authorization'][0], 'Basic ')[1]), ':');
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
}
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
}
@ -454,3 +459,25 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@closedir($path);
}
function myErrorHandler($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno)) {
return false;
}
switch ($errno) {
case E_USER_ERROR:
$errInfo = array(
"errorMessage" => $errstr,
"errorType" => \ServerlessFC\friendly_error_type($errno),
"stackTrace" => array(
"file" => $errfile,
"line" => $errline,
),
);
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
break;
default: // E_USER_WARNING | E_USER_NOTICE
break;
}
return true;
}

View File

@ -27,6 +27,11 @@ function GetGlobalVariable($event)
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
$_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['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
}

View File

@ -15,14 +15,14 @@ function getpath()
function getGET()
{
//error_log('POST' . json_encode($_POST));
//error_log1('POST' . json_encode($_POST));
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
//error_log('RAW' . $tmpdata);
//error_log1('RAW' . $tmpdata);
} else {
$tmpdata = file_get_contents('php://input');
//error_log('PHPINPUT' . $tmpdata);
//error_log1('PHPINPUT' . $tmpdata);
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
@ -30,7 +30,7 @@ function getGET()
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
//error_log('POSTformPHPINPUT' . json_encode($_POST));
//error_log1('POSTformPHPINPUT' . json_encode($_POST));
}
}
$p = strpos($_SERVER['REQUEST_URI'],'?');
@ -117,9 +117,9 @@ function setConfig($arr, $disktag = '')
}
}
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
//';
return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
}
function install()
@ -227,7 +227,7 @@ function HerokuAPI($method, $url, $data = '', $apikey)
foreach ($headers as $headerName => $headerVal) {
$sendHeaders[] = $headerName . ': ' . $headerVal;
}
error_log($method . $url . $data . $apikey);
error_log1($method . $url . $data . $apikey);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
@ -242,7 +242,7 @@ function HerokuAPI($method, $url, $data = '', $apikey)
$response['body'] = curl_exec($ch);
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
error_log($response['stat'].'
error_log1($response['stat'].'
'.$response['body'].'
');
return $response;

View File

@ -40,6 +40,11 @@ function GetGlobalVariable($event)
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
$_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['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
}

View File

@ -40,6 +40,11 @@ function GetGlobalVariable($event)
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
$_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['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
}

View File

@ -316,7 +316,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
break;
}
}
//error_log($outPath);
//error_log1($outPath);
if ($outPath=='') return 0;
//unlink($outPath.'/config.php');

View File

@ -24,6 +24,11 @@ function GetGlobalVariable($event)
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
$_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['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
$_SERVER['USER'] = 'qcloud';
}

View File

@ -24,6 +24,11 @@ function GetGlobalVariable($event)
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
$_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['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
$_SERVER['USER'] = 'qcloud';
}
@ -392,7 +397,7 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
return updateProgram($function_name, $Region, $namespace, $SecretId, $SecretKey, $source);
$tmp1['Response']['Error']['Message'] = $codeurl;
error_log($tmp1['Response']['Error']['Message']);
error_log1($tmp1['Response']['Error']['Message']);
return json_encode($tmp1);
}
@ -535,7 +540,7 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
// .' -H "X-TC-Version: '.$version.'"'
// .' -H "X-TC-Region: '.$region.'"'
// ." -d '".$payload."'";
//error_log( $curl.PHP_EOL );
//error_log1( $curl.PHP_EOL );
//return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
$headers['Authorization'] = $authorization;
$headers['Content-Type'] = 'application/json; charset=utf-8';