From a81339b87fe421a211edc4e8bf6cbdbb4c7a1b42 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 18 Feb 2020 21:57:38 +0800 Subject: [PATCH] Add files via upload --- function/common.php | 25 ++++++++++++++++++++++++- function/heroku.php | 33 +++++++++++++++++---------------- function/normal.php | 24 +++++++++++++++--------- function/scf.php | 33 +++++++++++++++++---------------- 4 files changed, 73 insertions(+), 42 deletions(-) diff --git a/function/common.php b/function/common.php index d5aac40..5d0cea3 100644 --- a/function/common.php +++ b/function/common.php @@ -12,6 +12,18 @@ $innerEnv = [ 'token_expires', ]; +$ShowedinnerEnv = [ + //'Onedrive_ver', + //'client_id', + //'client_secret', + 'domain_path', + 'guestup_path', + 'diskname', + 'public_path', + //'refresh_token', + //'token_expires', +]; + function getcache($str) { $cache = null; @@ -61,7 +73,8 @@ function config_oauth() // MS Customer // https://portal.azure.com $_SERVER['client_id'] = getConfig('client_id'); - $_SERVER['client_secret'] = getConfig('client_secret'); + $_SERVER['client_secret'] = base64_decode(equal_replace(getenv('client_secret'),1)); + //getConfig('client_secret'); $_SERVER['oauth_url'] = 'https://login.microsoftonline.com/common/oauth2/v2.0/'; $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root'; $_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access'; @@ -118,6 +131,16 @@ function spurlencode($str,$splite='') return $tmp; } +function equal_replace($str, $add = false) +{ + if ($add) { + while(strlen($str)%4) $str .= '='; + } else { + while(substr($str,-1)=='=') $str=substr($str,0,-1); + } + return $str; +} + function is_guestup_path($path) { if (path_format('/'.path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')==path_format('/'.path_format(getConfig('guestup_path')).'/')&&getConfig('guestup_path')!='') return 1; diff --git a/function/heroku.php b/function/heroku.php index add6ba7..3dcb01d 100644 --- a/function/heroku.php +++ b/function/heroku.php @@ -61,13 +61,8 @@ function getConfig($str, $disktag = '') function setConfig($arr, $disktag = '') { - echo '进入设置:'.json_encode($arr,JSON_PRETTY_PRINT).' -'; global $innerEnv; if ($disktag=='') $disktag = $_SERVER['disktag']; - //$disktags = json_decode(getConfig('disktag'), true); - //if ($_SERVER['disk_oprating']) $disktag = $_SERVER['disk_oprating']; - //else $disktag = $_SERVER['disktag']; $disktags = explode("|",getConfig('disktag')); $diskconfig = json_decode(getenv($disktag), true); $tmp = []; @@ -98,8 +93,8 @@ function setConfig($arr, $disktag = '') if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); else $tmp['disktag'] = ''; } - echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' -'; +// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' +//'; return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey')); } @@ -169,7 +164,8 @@ function get_refresh_token() $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; if ($_POST['Onedrive_ver']=='MSC') { $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = $_POST['client_secret']; + $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); + //$_POST['client_secret']; } $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response']; $title = getconstStr('MayinEnv'); @@ -356,8 +352,9 @@ function EnvOpt($function_name, $needUpdate = 0) global $constStr; global $commonEnv; global $innerEnv; + global $ShowedinnerEnv; asort($commonEnv); - asort($innerEnv); + asort($ShowedinnerEnv); $html = 'OneManager '.getconstStr('Setup').''; /*if ($_POST['updateProgram']==getconstStr('updateProgram')) { $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; @@ -416,7 +413,7 @@ namespace:' . $namespace . '
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); } $html .= ' - '.getconstStr('Back').'    + '.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
Github
'; /*if ($needUpdate) { $html .= '
' . $_SERVER['github_version'] . '
@@ -426,7 +423,7 @@ namespace:' . $namespace . '
} else { $html .= getconstStr('NotNeedUpdate'); }*/ - $html .= ' + $html .= '
@@ -496,19 +493,23 @@ namespace:' . $namespace . '
- + '; + if (getConfig('refresh_token', $disktag)!='') { + $html .= ' '; - foreach ($innerEnv as $key) { - $html .= ' + foreach ($ShowedinnerEnv as $key) { + $html .= ' '; + } + $html .= ' + + '; } $html .= ' - -

'; } } diff --git a/function/normal.php b/function/normal.php index d3699e1..cab51f7 100644 --- a/function/normal.php +++ b/function/normal.php @@ -175,7 +175,8 @@ function get_refresh_token() $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; if ($_POST['Onedrive_ver']=='MSC') { $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = $_POST['client_secret']; + $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); + //$_POST['client_secret']; } $response = setConfig($tmp, $_COOKIE['disktag']); $title = getconstStr('MayinEnv'); @@ -325,8 +326,9 @@ function EnvOpt($function_name, $needUpdate = 0) global $constStr; global $commonEnv; global $innerEnv; + global $ShowedinnerEnv; asort($commonEnv); - asort($innerEnv); + asort($ShowedinnerEnv); $html = 'OneManager '.getconstStr('Setup').''; /*if ($_POST['updateProgram']==getconstStr('updateProgram')) { $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; @@ -377,7 +379,7 @@ namespace:' . $namespace . '
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); } $html .= ' - '.getconstStr('Back').'    + '.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
Github
'; /*if ($needUpdate) { $html .= '
' . $_SERVER['github_version'] . '
@@ -387,7 +389,7 @@ namespace:' . $namespace . '
} else { $html .= getconstStr('NotNeedUpdate'); }*/ - $html .= ' + $html .= '
@@ -457,19 +459,23 @@ namespace:' . $namespace . '
- + '; + if (getConfig('refresh_token', $disktag)!='') { + $html .= ' '; - foreach ($innerEnv as $key) { - $html .= ' + foreach ($ShowedinnerEnv as $key) { + $html .= ' '; + } + $html .= ' + + '; } $html .= ' - -

'; } } diff --git a/function/scf.php b/function/scf.php index 134d769..f29d391 100644 --- a/function/scf.php +++ b/function/scf.php @@ -76,13 +76,8 @@ function getConfig($str, $disktag = '') function setConfig($arr, $disktag = '') { - echo '进入设置:'.json_encode($arr,JSON_PRETTY_PRINT).' -'; global $innerEnv; if ($disktag=='') $disktag = $_SERVER['disktag']; - //$disktags = json_decode(getConfig('disktag'), true); - //if ($_SERVER['disk_oprating']) $disktag = $_SERVER['disk_oprating']; - //else $disktag = $_SERVER['disktag']; $disktags = explode("|",getConfig('disktag')); $diskconfig = json_decode(getenv($disktag), true); $tmp = []; @@ -113,8 +108,8 @@ function setConfig($arr, $disktag = '') if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); else $tmp['disktag'] = ''; } - echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' -'; + //echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' +//'; return updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')); } @@ -194,7 +189,8 @@ function get_refresh_token() $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; if ($_POST['Onedrive_ver']=='MSC') { $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = $_POST['client_secret']; + $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); + //$_POST['client_secret']; } $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response']; $title = getconstStr('MayinEnv'); @@ -508,8 +504,9 @@ function EnvOpt($function_name, $needUpdate = 0) global $constStr; global $commonEnv; global $innerEnv; + global $ShowedinnerEnv; asort($commonEnv); - asort($innerEnv); + asort($ShowedinnerEnv); $html = 'OneManager '.getconstStr('Setup').''; if ($_POST['updateProgram']==getconstStr('updateProgram')) { $response = json_decode(updateProgram($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response']; @@ -569,7 +566,7 @@ namespace:' . $_SERVER['namespace'] . '
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); } $html .= ' - '.getconstStr('Back').'    + '.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
Github
'; if ($needUpdate) { $html .= '
' . $_SERVER['github_version'] . '
@@ -579,7 +576,7 @@ namespace:' . $_SERVER['namespace'] . '
} else { $html .= getconstStr('NotNeedUpdate'); } - $html .= ' + $html .= '
@@ -649,19 +646,23 @@ namespace:' . $_SERVER['namespace'] . '
- + '; + if (getConfig('refresh_token', $disktag)!='') { + $html .= ' '; - foreach ($innerEnv as $key) { - $html .= ' + foreach ($ShowedinnerEnv as $key) { + $html .= ' '; + } + $html .= ' + + '; } $html .= ' - -

'; } }