commit
423ccda51d
|
@ -1,5 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$Base64Env = [
|
||||||
|
//'APIKey', // used in heroku.
|
||||||
|
//'Region', // used in SCF.
|
||||||
|
//'SecretId', // used in SCF.
|
||||||
|
//'SecretKey', // used in SCF.
|
||||||
|
//'admin',
|
||||||
|
//'adminloginpage',
|
||||||
|
'background',
|
||||||
|
//'disktag',
|
||||||
|
//'function_name', // used in heroku.
|
||||||
|
//'language',
|
||||||
|
//'passfile',
|
||||||
|
'sitename',
|
||||||
|
//'theme',
|
||||||
|
//'Onedrive_ver',
|
||||||
|
//'client_id',
|
||||||
|
'client_secret',
|
||||||
|
'domain_path',
|
||||||
|
'guestup_path',
|
||||||
|
'diskname',
|
||||||
|
'public_path',
|
||||||
|
//'refresh_token',
|
||||||
|
//'token_expires',
|
||||||
|
];
|
||||||
|
|
||||||
$CommonEnv = [
|
$CommonEnv = [
|
||||||
'APIKey', // used in heroku.
|
'APIKey', // used in heroku.
|
||||||
'Region', // used in SCF.
|
'Region', // used in SCF.
|
||||||
|
@ -105,8 +130,7 @@ 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'] = base64_decode(equal_replace(getConfig('client_secret'),1));
|
$_SERVER['client_secret'] = getConfig('client_secret');
|
||||||
//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';
|
||||||
|
@ -167,7 +191,9 @@ function equal_replace($str, $add = false)
|
||||||
{
|
{
|
||||||
if ($add) {
|
if ($add) {
|
||||||
while(strlen($str)%4) $str .= '=';
|
while(strlen($str)%4) $str .= '=';
|
||||||
|
$str = urldecode(base64_decode($str));
|
||||||
} else {
|
} else {
|
||||||
|
$str = base64_encode(urlencode($str));
|
||||||
while(substr($str,-1)=='=') $str=substr($str,0,-1);
|
while(substr($str,-1)=='=') $str=substr($str,0,-1);
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
|
@ -254,14 +280,14 @@ function gethiddenpass($path,$passfile)
|
||||||
$passwordf=explode("\n",$arr['body']);
|
$passwordf=explode("\n",$arr['body']);
|
||||||
$password=$passwordf[0];
|
$password=$passwordf[0];
|
||||||
$password=md5($password);
|
$password=md5($password);
|
||||||
savecache($path . '/password', $password);
|
savecache('path_' . $path . '/?password', $password);
|
||||||
return $password;
|
return $password;
|
||||||
} else {
|
} else {
|
||||||
//return md5('DefaultP@sswordWhenNetworkError');
|
//return md5('DefaultP@sswordWhenNetworkError');
|
||||||
return md5( md5(time()).rand(1000,9999) );
|
return md5( md5(time()).rand(1000,9999) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
savecache($path . '/password', 'null');
|
savecache('path_' . $path . '/?password', 'null');
|
||||||
if ($path !== '' ) {
|
if ($path !== '' ) {
|
||||||
$path = substr($path,0,strrpos($path,'/'));
|
$path = substr($path,0,strrpos($path,'/'));
|
||||||
return gethiddenpass($path,$passfile);
|
return gethiddenpass($path,$passfile);
|
||||||
|
@ -523,6 +549,7 @@ function main($path)
|
||||||
$response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
|
$response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
|
||||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||||
if (!isset($ret['access_token'])) {
|
if (!isset($ret['access_token'])) {
|
||||||
|
error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token);
|
||||||
error_log('failed to get access_token. response' . json_encode($ret));
|
error_log('failed to get access_token. response' . json_encode($ret));
|
||||||
throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
|
throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
|
||||||
}
|
}
|
||||||
|
@ -536,6 +563,7 @@ function main($path)
|
||||||
if ($_SERVER['ajax']) {
|
if ($_SERVER['ajax']) {
|
||||||
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
||||||
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
||||||
|
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
|
||||||
$tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']);
|
$tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']);
|
||||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||||
|
|
|
@ -40,16 +40,20 @@ function getGET()
|
||||||
function getConfig($str, $disktag = '')
|
function getConfig($str, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
if (in_array($str, $InnerEnv)) {
|
if (in_array($str, $InnerEnv)) {
|
||||||
return json_decode(getenv($disktag), true)[$str];
|
if (in_array($str, $Base64Env)) return equal_replace(json_decode(getenv($disktag), true)[$str],1);
|
||||||
|
else return json_decode(getenv($disktag), true)[$str];
|
||||||
}
|
}
|
||||||
return getenv($str);
|
if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
|
||||||
|
else return getenv($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfig($arr, $disktag = '')
|
function setConfig($arr, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
$disktags = explode("|",getConfig('disktag'));
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
$diskconfig = json_decode(getenv($disktag), true);
|
$diskconfig = json_decode(getenv($disktag), true);
|
||||||
|
@ -58,7 +62,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$oparetdisk = 0;
|
$oparetdisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
$diskconfig[$k] = $v;
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
$indisk = 1;
|
$indisk = 1;
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
array_push($disktags, $v);
|
array_push($disktags, $v);
|
||||||
|
@ -68,7 +73,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$tmp[$v] = '';
|
$tmp[$v] = '';
|
||||||
$oparetdisk = 1;
|
$oparetdisk = 1;
|
||||||
} else {
|
} else {
|
||||||
$tmp[$k] = $v;
|
if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($indisk) {
|
if ($indisk) {
|
||||||
|
@ -158,7 +164,7 @@ 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'] = equal_replace(base64_encode($_POST['client_secret']));
|
$tmp['client_secret'] = $_POST['client_secret'];
|
||||||
//$_POST['client_secret'];
|
//$_POST['client_secret'];
|
||||||
}
|
}
|
||||||
$response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response'];
|
$response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response'];
|
||||||
|
|
|
@ -39,6 +39,7 @@ function getGET()
|
||||||
function getConfig($str, $disktag = '')
|
function getConfig($str, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
//include 'config.php';
|
//include 'config.php';
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
$s = file_get_contents('config.php');
|
$s = file_get_contents('config.php');
|
||||||
|
@ -46,8 +47,12 @@ function getConfig($str, $disktag = '')
|
||||||
if ($configs!='') {
|
if ($configs!='') {
|
||||||
$envs = json_decode($configs, true);
|
$envs = json_decode($configs, true);
|
||||||
if (in_array($str, $InnerEnv)) {
|
if (in_array($str, $InnerEnv)) {
|
||||||
if (isset($envs[$disktag][$str])) return $envs[$disktag][$str];
|
if (in_array($str, $Base64Env)) return equal_replace($envs[$disktag][$str],1);
|
||||||
} else if (isset($envs[$str])) return $envs[$str];
|
else return $envs[$disktag][$str];
|
||||||
|
} else {
|
||||||
|
if (in_array($str, $Base64Env)) return equal_replace($envs[$str],1);
|
||||||
|
else return $envs[$str];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -55,6 +60,7 @@ function getConfig($str, $disktag = '')
|
||||||
function setConfig($arr, $disktag = '')
|
function setConfig($arr, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
//include 'config.php';
|
//include 'config.php';
|
||||||
$s = file_get_contents('config.php');
|
$s = file_get_contents('config.php');
|
||||||
|
@ -65,7 +71,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$operatedisk = 0;
|
$operatedisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
$envs[$disktag][$k] = $v;
|
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = equal_replace($v);
|
||||||
|
else $envs[$disktag][$k] = $v;
|
||||||
/*$diskconfig[$k] = $v;
|
/*$diskconfig[$k] = $v;
|
||||||
$indisk = 1;*/
|
$indisk = 1;*/
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
|
@ -76,7 +83,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$envs[$v] = '';
|
$envs[$v] = '';
|
||||||
$operatedisk = 1;
|
$operatedisk = 1;
|
||||||
} else {
|
} else {
|
||||||
$envs[$k] = $v;
|
if (in_array($k, $Base64Env)) $envs[$k] = equal_replace($v);
|
||||||
|
else $envs[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if ($indisk) {
|
/*if ($indisk) {
|
||||||
|
@ -171,8 +179,7 @@ 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'] = equal_replace(base64_encode($_POST['client_secret']));
|
$tmp['client_secret'] = $_POST['client_secret'];
|
||||||
//$_POST['client_secret'];
|
|
||||||
}
|
}
|
||||||
$response = setConfig($tmp, $_COOKIE['disktag']);
|
$response = setConfig($tmp, $_COOKIE['disktag']);
|
||||||
$title = getconstStr('MayinEnv');
|
$title = getconstStr('MayinEnv');
|
||||||
|
|
|
@ -54,16 +54,20 @@ function GetPathSetting($event, $context)
|
||||||
function getConfig($str, $disktag = '')
|
function getConfig($str, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
if (in_array($str, $InnerEnv)) {
|
if (in_array($str, $InnerEnv)) {
|
||||||
return json_decode(getenv($disktag), true)[$str];
|
if (in_array($str, $Base64Env)) return equal_replace(json_decode(getenv($disktag), true)[$str],1);
|
||||||
|
else return json_decode(getenv($disktag), true)[$str];
|
||||||
}
|
}
|
||||||
return getenv($str);
|
if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
|
||||||
|
else return getenv($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfig($arr, $disktag = '')
|
function setConfig($arr, $disktag = '')
|
||||||
{
|
{
|
||||||
global $InnerEnv;
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
$disktags = explode("|",getConfig('disktag'));
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
$diskconfig = json_decode(getenv($disktag), true);
|
$diskconfig = json_decode(getenv($disktag), true);
|
||||||
|
@ -72,7 +76,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$oparetdisk = 0;
|
$oparetdisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
$diskconfig[$k] = $v;
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
$indisk = 1;
|
$indisk = 1;
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
array_push($disktags, $v);
|
array_push($disktags, $v);
|
||||||
|
@ -82,7 +87,8 @@ function setConfig($arr, $disktag = '')
|
||||||
$tmp[$v] = '';
|
$tmp[$v] = '';
|
||||||
$oparetdisk = 1;
|
$oparetdisk = 1;
|
||||||
} else {
|
} else {
|
||||||
$tmp[$k] = $v;
|
if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($indisk) {
|
if ($indisk) {
|
||||||
|
@ -180,8 +186,7 @@ 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'] = equal_replace(base64_encode($_POST['client_secret']));
|
$tmp['client_secret'] = $_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');
|
||||||
|
@ -276,7 +281,6 @@ namespace:' . $_SERVER['namespace'] . '<br>
|
||||||
$trynum = 0;
|
$trynum = 0;
|
||||||
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
||||||
'.++$trynum;
|
'.++$trynum;
|
||||||
//$response = json_decode( updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
|
|
||||||
if (needUpdate()) {
|
if (needUpdate()) {
|
||||||
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
|
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
|
||||||
return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||||
|
|
5
version
5
version
|
@ -1,7 +1,10 @@
|
||||||
|
20200229-1300.13
|
||||||
|
In SCF, some config can input Special symbols now, like ?&= 。
|
||||||
|
在SCF中,某些配置可以输入特殊符号了,像background可以用?&=之类的了。
|
||||||
|
|
||||||
20200225-1310.12
|
20200225-1310.12
|
||||||
Can update by one click any time. fix bugs: special tag, reupload.
|
Can update by one click any time. fix bugs: special tag, reupload.
|
||||||
可以不管版本直接一键更新(覆盖)了。修复可以使用特殊onedrive标签的bug,修复断网续传的问题。
|
可以不管版本直接一键更新(覆盖)了。修复可以使用特殊onedrive标签的bug,修复断网续传的问题。
|
||||||
|
|
||||||
20200222-2130.11
|
20200222-2130.11
|
||||||
you can set background now. fix bug: 2nd disk upload.
|
you can set background now. fix bug: 2nd disk upload.
|
||||||
可以设置背景图片了。第2个盘上传后链接不对。
|
可以设置背景图片了。第2个盘上传后链接不对。
|
||||||
|
|
Loading…
Reference in New Issue