From 2dc44a92d32345bbd906fb30539352c948fe47f5 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 11:17:45 +0800 Subject: [PATCH 01/12] fix scf update --- platform/scf.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/scf.php b/platform/scf.php index f01e57a..8d71b54 100644 --- a/platform/scf.php +++ b/platform/scf.php @@ -370,13 +370,14 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr)); } -function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source = '') +function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source) { WaitSCFStat(); $meth = 'POST'; $host = 'scf.tencentcloudapi.com'; $tmpdata['Action'] = 'UpdateFunctionCode'; - $tmpdata['Code.GitUrl'] = $source; + $tmpdata['Code.GitUrl'] = $source['url']; + $tmpdata['Code.GitBranch'] = $source['branch']; $tmpdata['CodeSource'] = 'Git'; $tmpdata['FunctionName'] = $function_name; $tmpdata['Handler'] = 'index.main_handler'; @@ -410,8 +411,8 @@ namespace:' . $_SERVER['namespace'] . '
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') { - //'https://github.com/qkqpttgf/OneManager-php/tree/v2-MultiDisk'; - $source = 'https://github.com/' . $auth . '/' . $project . '/tree/' . $branch; + $source['url'] = 'https://github.com/' . $auth . '/' . $project; + $source['branch'] = $branch; return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source), true)['Response']; } From a6211d338232254c34328618a335a06cbd3bc1e7 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 16:27:45 +0800 Subject: [PATCH 02/12] Update update.sh --- update.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index cb2c7ff..cc34856 100644 --- a/update.sh +++ b/update.sh @@ -1,12 +1,66 @@ #!bash +if [ $# -eq 0 ]; then + echo " +"$0" -i|u [-b branch] + i a new install with empty config. + u update use exist config. + b install the branch after parameter b, default master + +example: + "$0" -i + "$0" -u + "$0" -b master + "$0" -r -b master + "$0" -ib test +" +# exit + echo "############### +0, new install +1, update" + read -p "Input:" c + [ g"$c" == g"0" ] && install=1 + [ g"$c" == g"1" ] && update=1 +fi + +i=0 +para[$i]=$0 +for av in "$@" +do +#echo $av + ((i++)) + para[$i]=$av + if [ g"${av:0:1}" == g"-" ]; then + while [ g"$av" != g"" ] + do + ag=${av:0:1} + av=${av:1} + [ g"$ag" == g"b" ] && isbranch=1 + [ g"$ag" == g"i" ] && install=1 + [ g"$ag" == g"u" ] && update=1 + done + else + if [ g"$isbranch" == g"1" ]; then + branch="-b $av" + isbranch=0 + fi + fi +done + +if [ g"$install" != g"1" -a g"$update" != g"1" ]; then + echo "Not install & Not update, exit" + exit +fi +#echo $branch +#echo $install + gitsource='https://github.com/qkqpttgf/OneManager-php' OneManagerPath=`cd $(dirname $0);pwd -P` cd ${OneManagerPath} -git clone ${gitsource} -\mv -b config.php OneManager-php/ +git clone ${branch} ${gitsource} +[ g"$install" == g"1" ] || \mv -b config.php OneManager-php/ \mv -b OneManager-php/* ./ \mv -b OneManager-php/.[^.]* ./ rm -rf *~ From 0a78999463db0fcfa5d501935b982bce7557a571 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 16:33:55 +0800 Subject: [PATCH 03/12] Update update.sh --- update.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index cc34856..23cc7c2 100644 --- a/update.sh +++ b/update.sh @@ -47,12 +47,14 @@ do fi done +if [ g"$install" == g"1" -a g"$update" == g"1" ]; then + echo "Both install & update, exit" + exit +fi if [ g"$install" != g"1" -a g"$update" != g"1" ]; then echo "Not install & Not update, exit" exit fi -#echo $branch -#echo $install gitsource='https://github.com/qkqpttgf/OneManager-php' From a868d5df44ba609aae5b410a43e75d501b95be15 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:16:13 +0800 Subject: [PATCH 04/12] Update conststr.php --- conststr.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conststr.php b/conststr.php index c4f5df8..4403934 100644 --- a/conststr.php +++ b/conststr.php @@ -726,4 +726,12 @@ $constStr = [ 'ko-kr' => '캐시 플러시', 'fa' => 'رفرش cache', ], + 'VPSnotupdate' => [ + 'en-us' => 'In VPS can not update by a click! run update.sh', + 'zh-cn' => '在VPS中不能一键更新,可以运行update.sh', + ], + 'QueryBranchs' => [ + 'en-us' => 'Query Branchs', + 'zh-cn' => '查询分支', + ], ]; From 286046b82aaf701638cb4687d674c549ece802b4 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:18:08 +0800 Subject: [PATCH 05/12] use accept_language --- common.php | 72 ++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/common.php b/common.php index 7f3bb59..2967e4b 100644 --- a/common.php +++ b/common.php @@ -45,7 +45,7 @@ $CommonEnv = [ 'disktag', 'function_name', // used in heroku. 'hideFunctionalityFile', - 'language', + //'language', 'passfile', 'sitename', 'theme', @@ -62,7 +62,7 @@ $ShowedCommonEnv = [ //'disktag', //'function_name', // used in heroku. 'hideFunctionalityFile', - 'language', + //'language', 'passfile', 'sitename', 'theme', @@ -113,8 +113,11 @@ function main($path) global $exts; global $constStr; - if (isset($_COOKIE['language'])) $constStr['language'] = $_COOKIE['language']; - if (!$constStr['language']) $constStr['language'] = getConfig('language'); + if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) $constStr['language'] = $_SERVER['firstacceptlanguage']; + if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language']; + //if (!$constStr['language']) $constStr['language'] = getConfig('language'); + /*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].' + '.'lan:'.$constStr['language'];*/ if ($constStr['language']=='') $constStr['language'] = 'en-us'; $_SERVER['language'] = $constStr['language']; $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); @@ -274,28 +277,7 @@ function main($path) function get_access_token($refresh_token) { if (getConfig('Drive_ver')=='shareurl') { - -//if (!$files) $files['body'] = $arr['body']; - //$files['returnhead'] = $arr['returnhead']; - //$files['cookie'] = $arr['returnhead']['Set-Cookie']; -//return $files; - - /*$files['get'] = curl_request( - "https://mfedu-my.sharepoint.com/personal/ysun_ac_stu_office_gy/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments'&RootFolder=%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments%2F&TryNewExperienceSingle=TRUE", - '{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}', - ['Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => 'https://mfedu-my.sharepoint.com', 'Cookie' => $arr['returnhead']['Set-Cookie']], - 1); - $files['get']['body'] = json_decode($files['get']['body'], true); - $_SERVER['access_token'] = splitlast($files['get']['body']['ListSchema']['.driveAccessToken'],'=')[1]; - $_SERVER['api_url'] = $files['get']['body']['ListSchema']['.driveUrl'].'/root'; - - $files = json_decode( curl_request( $_SERVER['api_url'].'?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl,@content.downloadUrl)', false, ['Authorization' => 'Bearer ' . $_SERVER['access_token'], 'Accept' => 'application/json'] )['body'], true); - $files['children']['a']['file'] = $_SERVER['api_url']; - $files['children']['a']['name'] = $_SERVER['api_url']; -*/ $shareurl = getConfig('shareurl'); - //$url = 'https://mfedu-my.sharepoint.com/:f:/g/personal/ysun_ac_stu_office_gy/EpDIBOaYyExHjfu-PJA46icB40X0FKVwmn_9UDJsRvu3Ug?e=XyRZxP'; - //$url = 'https://2d2-my.sharepoint.com/:f:/g/personal/ysun_host_ac_cn/Ehy8pjSQSoZOtLDs4ZKPiGUBYFt26CjEwG6bw7W5vleNNQ?e=DLZcWF'; $tmp1 = splitlast($shareurl, '/')[0]; $account = splitlast($tmp1, '/')[1]; $tmp1 = splitlast($shareurl, ':')[0]; @@ -311,8 +293,8 @@ function get_access_token($refresh_token) $_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root'; if (!$_SERVER['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 access_token. response' . json_encode($ret)); - throw new Exception($response['stat'].', failed to get access_token.'.$response['body']); + error_log('failed to get share access_token. response' . json_encode($ret)); + throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']); } error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); savecache('access_token', $_SERVER['access_token']); @@ -362,14 +344,12 @@ function isHideFile($name) function getcache($str) { - //$cache = null; $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); return $cache->fetch($str); } function savecache($key, $value, $exp = 1800) { - //$cache = null; $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); $cache->save($key, $value, $exp); } @@ -434,8 +414,6 @@ function get_siteid($access_token) while ($url!=''&&$response['stat']!=200&&$i<4) { $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]); $i++; - //echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].' - //'; } if ($response['stat']!=200) { error_log('failed to get siteid. response' . json_encode($response)); @@ -505,7 +483,9 @@ function equal_replace($str, $add = false) 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; + $a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/') + $a2 = path_format(path_format(getConfig('guestup_path')).'/') + if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1; return 0; } @@ -957,18 +937,36 @@ function adminoperate($path) return $tmparr; } +function splitfirst($str, $split) +{ + $len = strlen($split); + $pos = strpos($str, $split); + if ($pos===false) { + $tmp[0] = $str; + $tmp[1] = ''; + } elseif ($pos>0) { + $tmp[0] = substr($str, 0, $pos); + $tmp[1] = substr($str, $pos+$len); + } else { + $tmp[0] = ''; + $tmp[1] = substr($str, $len); + } + return $tmp; +} + function splitlast($str, $split) { + $len = strlen($split); $pos = strrpos($str, $split); if ($pos===false) { $tmp[0] = $str; $tmp[1] = ''; } elseif ($pos>0) { $tmp[0] = substr($str, 0, $pos); - $tmp[1] = substr($str, $pos+1); + $tmp[1] = substr($str, $pos+$len); } else { $tmp[0] = ''; - $tmp[1] = substr($str, 1); + $tmp[1] = substr($str, $len); } return $tmp; } @@ -1612,14 +1610,14 @@ function EnvOpt($needUpdate = 0) '.getconstStr('AddDisk').'

'; if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) { $html .= ' -In VPS can not update by a click!
'; +'.getconstStr('VPSnotupdate').'
'; } else { $html .= '
- - + + From 8ca9a9d628c6cd649e440aaa0902be14388afac6 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:19:31 +0800 Subject: [PATCH 06/12] use accept_language --- platform/heroku.php | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/heroku.php b/platform/heroku.php index 36d3f77..4b8a2dc 100644 --- a/platform/heroku.php +++ b/platform/heroku.php @@ -2,6 +2,7 @@ function getpath() { + $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]); $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); $p = strpos($_SERVER['REQUEST_URI'],'?'); From 23ee2630efc3e96ab4802ef8f11360561858401d Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:20:19 +0800 Subject: [PATCH 07/12] use accept_language --- platform/normal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/normal.php b/platform/normal.php index 1e4e0d7..d944975 100644 --- a/platform/normal.php +++ b/platform/normal.php @@ -2,6 +2,7 @@ function getpath() { + $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]); $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); $p = strpos($_SERVER['REQUEST_URI'],'?'); if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); From 00023986b3386bf14c5a3946e00eb1dbd7b9ac2f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:21:00 +0800 Subject: [PATCH 08/12] use accept_language --- platform/scf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/scf.php b/platform/scf.php index 8d71b54..28dd39a 100644 --- a/platform/scf.php +++ b/platform/scf.php @@ -28,6 +28,7 @@ function GetGlobalVariable($event) function GetPathSetting($event, $context) { + $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]); $_SERVER['function_name'] = $context['function_name']; $_SERVER['namespace'] = $context['namespace']; $host_name = $event['headers']['host']; @@ -132,7 +133,6 @@ function install() setConfig($tmp); if (needUpdate()) { OnekeyUpate(); - //updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); return message('update to github version, reinstall.', 'Program updating', 201); } return output('Jump', 302); From f1a6d2821ec161e224e0683afbdc4631f066681c Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:23:58 +0800 Subject: [PATCH 09/12] Update common.php --- common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 2967e4b..66ca147 100644 --- a/common.php +++ b/common.php @@ -483,8 +483,8 @@ function equal_replace($str, $add = false) function is_guestup_path($path) { - $a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/') - $a2 = path_format(path_format(getConfig('guestup_path')).'/') + $a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/'); + $a2 = path_format(path_format(getConfig('guestup_path')).'/'); if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1; return 0; } From 89daee97cfc108be4e82e478c52558e1bedb29d7 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:32:08 +0800 Subject: [PATCH 10/12] Update common.php --- common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/common.php b/common.php index 66ca147..83658f3 100644 --- a/common.php +++ b/common.php @@ -1393,6 +1393,7 @@ function get_refresh_token()
From 5051a05adf94046195984dee080b4b9644ba7232 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:32:26 +0800 Subject: [PATCH 11/12] Update conststr.php --- conststr.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conststr.php b/conststr.php index 4403934..f5312b9 100644 --- a/conststr.php +++ b/conststr.php @@ -633,6 +633,10 @@ $constStr = [ 'ko-kr' => '중국 Onedrive', 'fa' => 'Onedrive در چین', ], + 'UseShareLink' => [ + 'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.', + 'zh-cn' => '对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方', + ], 'CustomIdSecret' => [ 'en-us' => 'Use custom client id & secret', 'zh-cn' => '自己申请应用ID与机密', From a244fb7ffbe16f3c87e64c05a47ac940e6ce59f3 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:37:51 +0800 Subject: [PATCH 12/12] Update version --- version | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/version b/version index 9bfcb61..e439bf6 100644 --- a/version +++ b/version @@ -1,7 +1,10 @@ +20200402-1830.17 +Oneclick update can select which branch to update. Now use the accept language instead of the language config. +一键更新可以选择哪个分支了。现在开始使用浏览器语言,抛弃language设置。 + 20200326-0001.16 You can add sharepoint site drive as a disk, you must reinstall after update. 可以将sharepoint网站添加成一个盘,由于结构改变,升级后只能重装。 - 20200321-1830.15 本次更新后,'index.html'功能在其它主题会导致bug。 文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。