Add files via upload

pull/15/head
qkqpttgf 2020-02-18 21:57:38 +08:00 committed by GitHub
parent e2946ad471
commit a81339b87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 42 deletions

View File

@ -12,6 +12,18 @@ $innerEnv = [
'token_expires', 'token_expires',
]; ];
$ShowedinnerEnv = [
//'Onedrive_ver',
//'client_id',
//'client_secret',
'domain_path',
'guestup_path',
'diskname',
'public_path',
//'refresh_token',
//'token_expires',
];
function getcache($str) function getcache($str)
{ {
$cache = null; $cache = null;
@ -61,7 +73,8 @@ function config_oauth()
// MS Customer // MS Customer
// https://portal.azure.com // https://portal.azure.com
$_SERVER['client_id'] = getConfig('client_id'); $_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['oauth_url'] = 'https://login.microsoftonline.com/common/oauth2/v2.0/';
$_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root'; $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root';
$_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access'; $_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access';
@ -118,6 +131,16 @@ function spurlencode($str,$splite='')
return $tmp; 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) 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; if (path_format('/'.path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')==path_format('/'.path_format(getConfig('guestup_path')).'/')&&getConfig('guestup_path')!='') return 1;

View File

@ -61,13 +61,8 @@ function getConfig($str, $disktag = '')
function setConfig($arr, $disktag = '') function setConfig($arr, $disktag = '')
{ {
echo '进入设置:'.json_encode($arr,JSON_PRETTY_PRINT).'
';
global $innerEnv; global $innerEnv;
if ($disktag=='') $disktag = $_SERVER['disktag']; 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')); $disktags = explode("|",getConfig('disktag'));
$diskconfig = json_decode(getenv($disktag), true); $diskconfig = json_decode(getenv($disktag), true);
$tmp = []; $tmp = [];
@ -98,8 +93,8 @@ function setConfig($arr, $disktag = '')
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = ''; 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')); return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
} }
@ -169,7 +164,8 @@ function get_refresh_token()
$tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; $tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
if ($_POST['Onedrive_ver']=='MSC') { if ($_POST['Onedrive_ver']=='MSC') {
$tmp['client_id'] = $_POST['client_id']; $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']; $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response'];
$title = getconstStr('MayinEnv'); $title = getconstStr('MayinEnv');
@ -356,8 +352,9 @@ function EnvOpt($function_name, $needUpdate = 0)
global $constStr; global $constStr;
global $commonEnv; global $commonEnv;
global $innerEnv; global $innerEnv;
global $ShowedinnerEnv;
asort($commonEnv); asort($commonEnv);
asort($innerEnv); asort($ShowedinnerEnv);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
/*if ($_POST['updateProgram']==getconstStr('updateProgram')) { /*if ($_POST['updateProgram']==getconstStr('updateProgram')) {
$response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response'];
@ -416,7 +413,7 @@ namespace:' . $namespace . '<br>
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); $preurl = path_format($_SERVER['PHP_SELF'] . '/');
} }
$html .= ' $html .= '
<a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp; <a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp;<a href="/'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
/*if ($needUpdate) { /*if ($needUpdate) {
$html .= '<pre>' . $_SERVER['github_version'] . '</pre> $html .= '<pre>' . $_SERVER['github_version'] . '</pre>
@ -426,7 +423,7 @@ namespace:' . $namespace . '<br>
} else { } else {
$html .= getconstStr('NotNeedUpdate'); $html .= getconstStr('NotNeedUpdate');
}*/ }*/
$html .= ' $html .= '<br>
<table border=1 width=100%> <table border=1 width=100%>
<form name="common" action="" method="post"> <form name="common" action="" method="post">
<tr> <tr>
@ -496,10 +493,12 @@ namespace:' . $namespace . '<br>
<input type="submit" name="submit1" value="Del disk"> <input type="submit" name="submit1" value="Del disk">
</td> </td>
</tr> </tr>
</form> </form>';
if (getConfig('refresh_token', $disktag)!='') {
$html .= '
<form name="'.$disktag.'" action="" method="post"> <form name="'.$disktag.'" action="" method="post">
<input type="hidden" name="disk" value="'.$disktag.'">'; <input type="hidden" name="disk" value="'.$disktag.'">';
foreach ($innerEnv as $key) { foreach ($ShowedinnerEnv as $key) {
$html .= ' $html .= '
<tr> <tr>
<td><label>' . $key . '</label></td> <td><label>' . $key . '</label></td>
@ -508,7 +507,9 @@ namespace:' . $namespace . '<br>
} }
$html .= ' $html .= '
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr> <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
</form> </form>';
}
$html .= '
</table><br>'; </table><br>';
} }
} }

View File

@ -175,7 +175,8 @@ function get_refresh_token()
$tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; $tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
if ($_POST['Onedrive_ver']=='MSC') { if ($_POST['Onedrive_ver']=='MSC') {
$tmp['client_id'] = $_POST['client_id']; $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']); $response = setConfig($tmp, $_COOKIE['disktag']);
$title = getconstStr('MayinEnv'); $title = getconstStr('MayinEnv');
@ -325,8 +326,9 @@ function EnvOpt($function_name, $needUpdate = 0)
global $constStr; global $constStr;
global $commonEnv; global $commonEnv;
global $innerEnv; global $innerEnv;
global $ShowedinnerEnv;
asort($commonEnv); asort($commonEnv);
asort($innerEnv); asort($ShowedinnerEnv);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
/*if ($_POST['updateProgram']==getconstStr('updateProgram')) { /*if ($_POST['updateProgram']==getconstStr('updateProgram')) {
$response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response'];
@ -377,7 +379,7 @@ namespace:' . $namespace . '<br>
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); $preurl = path_format($_SERVER['PHP_SELF'] . '/');
} }
$html .= ' $html .= '
<a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp; <a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp;<a href="/'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
/*if ($needUpdate) { /*if ($needUpdate) {
$html .= '<pre>' . $_SERVER['github_version'] . '</pre> $html .= '<pre>' . $_SERVER['github_version'] . '</pre>
@ -387,7 +389,7 @@ namespace:' . $namespace . '<br>
} else { } else {
$html .= getconstStr('NotNeedUpdate'); $html .= getconstStr('NotNeedUpdate');
}*/ }*/
$html .= ' $html .= '<br>
<table border=1 width=100%> <table border=1 width=100%>
<form name="common" action="" method="post"> <form name="common" action="" method="post">
<tr> <tr>
@ -457,10 +459,12 @@ namespace:' . $namespace . '<br>
<input type="submit" name="submit1" value="Del disk"> <input type="submit" name="submit1" value="Del disk">
</td> </td>
</tr> </tr>
</form> </form>';
if (getConfig('refresh_token', $disktag)!='') {
$html .= '
<form name="'.$disktag.'" action="" method="post"> <form name="'.$disktag.'" action="" method="post">
<input type="hidden" name="disk" value="'.$disktag.'">'; <input type="hidden" name="disk" value="'.$disktag.'">';
foreach ($innerEnv as $key) { foreach ($ShowedinnerEnv as $key) {
$html .= ' $html .= '
<tr> <tr>
<td><label>' . $key . '</label></td> <td><label>' . $key . '</label></td>
@ -469,7 +473,9 @@ namespace:' . $namespace . '<br>
} }
$html .= ' $html .= '
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr> <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
</form> </form>';
}
$html .= '
</table><br>'; </table><br>';
} }
} }

View File

@ -76,13 +76,8 @@ function getConfig($str, $disktag = '')
function setConfig($arr, $disktag = '') function setConfig($arr, $disktag = '')
{ {
echo '进入设置:'.json_encode($arr,JSON_PRETTY_PRINT).'
';
global $innerEnv; global $innerEnv;
if ($disktag=='') $disktag = $_SERVER['disktag']; 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')); $disktags = explode("|",getConfig('disktag'));
$diskconfig = json_decode(getenv($disktag), true); $diskconfig = json_decode(getenv($disktag), true);
$tmp = []; $tmp = [];
@ -113,8 +108,8 @@ function setConfig($arr, $disktag = '')
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = ''; 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')); 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']; $tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
if ($_POST['Onedrive_ver']=='MSC') { if ($_POST['Onedrive_ver']=='MSC') {
$tmp['client_id'] = $_POST['client_id']; $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']; $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response'];
$title = getconstStr('MayinEnv'); $title = getconstStr('MayinEnv');
@ -508,8 +504,9 @@ function EnvOpt($function_name, $needUpdate = 0)
global $constStr; global $constStr;
global $commonEnv; global $commonEnv;
global $innerEnv; global $innerEnv;
global $ShowedinnerEnv;
asort($commonEnv); asort($commonEnv);
asort($innerEnv); asort($ShowedinnerEnv);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
if ($_POST['updateProgram']==getconstStr('updateProgram')) { if ($_POST['updateProgram']==getconstStr('updateProgram')) {
$response = json_decode(updateProgram($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response']; $response = json_decode(updateProgram($function_name, $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response'];
@ -569,7 +566,7 @@ namespace:' . $_SERVER['namespace'] . '<br>
$preurl = path_format($_SERVER['PHP_SELF'] . '/'); $preurl = path_format($_SERVER['PHP_SELF'] . '/');
} }
$html .= ' $html .= '
<a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp; <a href="'.$preurl.'">'.getconstStr('Back').'</a>&nbsp;&nbsp;&nbsp;<a href="/'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
if ($needUpdate) { if ($needUpdate) {
$html .= '<pre>' . $_SERVER['github_version'] . '</pre> $html .= '<pre>' . $_SERVER['github_version'] . '</pre>
@ -579,7 +576,7 @@ namespace:' . $_SERVER['namespace'] . '<br>
} else { } else {
$html .= getconstStr('NotNeedUpdate'); $html .= getconstStr('NotNeedUpdate');
} }
$html .= ' $html .= '<br>
<table border=1 width=100%> <table border=1 width=100%>
<form name="common" action="" method="post"> <form name="common" action="" method="post">
<tr> <tr>
@ -649,10 +646,12 @@ namespace:' . $_SERVER['namespace'] . '<br>
<input type="submit" name="submit1" value="Del disk"> <input type="submit" name="submit1" value="Del disk">
</td> </td>
</tr> </tr>
</form> </form>';
if (getConfig('refresh_token', $disktag)!='') {
$html .= '
<form name="'.$disktag.'" action="" method="post"> <form name="'.$disktag.'" action="" method="post">
<input type="hidden" name="disk" value="'.$disktag.'">'; <input type="hidden" name="disk" value="'.$disktag.'">';
foreach ($innerEnv as $key) { foreach ($ShowedinnerEnv as $key) {
$html .= ' $html .= '
<tr> <tr>
<td><label>' . $key . '</label></td> <td><label>' . $key . '</label></td>
@ -661,7 +660,9 @@ namespace:' . $_SERVER['namespace'] . '<br>
} }
$html .= ' $html .= '
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr> <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
</form> </form>';
}
$html .= '
</table><br>'; </table><br>';
} }
} }