Merge pull request #65 from qkqpttgf/master

pull/98/head
Mr.Lin 2020-04-02 21:52:47 +08:00 committed by GitHub
commit a1495d1f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 38 deletions

View File

@ -45,7 +45,7 @@ $CommonEnv = [
'disktag', 'disktag',
'function_name', // used in heroku. 'function_name', // used in heroku.
'hideFunctionalityFile', 'hideFunctionalityFile',
'language', //'language',
'passfile', 'passfile',
'sitename', 'sitename',
'theme', 'theme',
@ -62,7 +62,7 @@ $ShowedCommonEnv = [
//'disktag', //'disktag',
//'function_name', // used in heroku. //'function_name', // used in heroku.
'hideFunctionalityFile', 'hideFunctionalityFile',
'language', //'language',
'passfile', 'passfile',
'sitename', 'sitename',
'theme', 'theme',
@ -113,8 +113,11 @@ function main($path)
global $exts; global $exts;
global $constStr; global $constStr;
if (isset($_COOKIE['language'])) $constStr['language'] = $_COOKIE['language']; if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) $constStr['language'] = $_SERVER['firstacceptlanguage'];
if (!$constStr['language']) $constStr['language'] = getConfig('language'); 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'; if ($constStr['language']=='') $constStr['language'] = 'en-us';
$_SERVER['language'] = $constStr['language']; $_SERVER['language'] = $constStr['language'];
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
@ -274,28 +277,7 @@ function main($path)
function get_access_token($refresh_token) function get_access_token($refresh_token)
{ {
if (getConfig('Drive_ver')=='shareurl') { 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'); $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]; $tmp1 = splitlast($shareurl, '/')[0];
$account = splitlast($tmp1, '/')[1]; $account = splitlast($tmp1, '/')[1];
$tmp1 = splitlast($shareurl, ':')[0]; $tmp1 = splitlast($shareurl, ':')[0];
@ -311,8 +293,8 @@ function get_access_token($refresh_token)
$_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root'; $_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
if (!$_SERVER['access_token']) { 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($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)); error_log('failed to get share 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 share access_token.'.$response['body']);
} }
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
savecache('access_token', $_SERVER['access_token']); savecache('access_token', $_SERVER['access_token']);
@ -362,14 +344,12 @@ function isHideFile($name)
function getcache($str) function getcache($str)
{ {
//$cache = null;
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
return $cache->fetch($str); return $cache->fetch($str);
} }
function savecache($key, $value, $exp = 1800) function savecache($key, $value, $exp = 1800)
{ {
//$cache = null;
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
$cache->save($key, $value, $exp); $cache->save($key, $value, $exp);
} }
@ -434,8 +414,6 @@ function get_siteid($access_token)
while ($url!=''&&$response['stat']!=200&&$i<4) { while ($url!=''&&$response['stat']!=200&&$i<4) {
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]); $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
$i++; $i++;
//echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
//';
} }
if ($response['stat']!=200) { if ($response['stat']!=200) {
error_log('failed to get siteid. response' . json_encode($response)); 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) 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; return 0;
} }
@ -957,18 +937,36 @@ function adminoperate($path)
return $tmparr; 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) function splitlast($str, $split)
{ {
$len = strlen($split);
$pos = strrpos($str, $split); $pos = strrpos($str, $split);
if ($pos===false) { if ($pos===false) {
$tmp[0] = $str; $tmp[0] = $str;
$tmp[1] = ''; $tmp[1] = '';
} elseif ($pos>0) { } elseif ($pos>0) {
$tmp[0] = substr($str, 0, $pos); $tmp[0] = substr($str, 0, $pos);
$tmp[1] = substr($str, $pos+1); $tmp[1] = substr($str, $pos+$len);
} else { } else {
$tmp[0] = ''; $tmp[0] = '';
$tmp[1] = substr($str, 1); $tmp[1] = substr($str, $len);
} }
return $tmp; return $tmp;
} }
@ -1395,6 +1393,7 @@ function get_refresh_token()
</div> </div>
<br> <br>
<div id="inputshareurl" style="display:none;margin:10px 35px"> <div id="inputshareurl" style="display:none;margin:10px 35px">
'.getconstStr('UseShareLink').'
<input type="text" name="shareurl" style="width:100%" placeholder="https://xxxx.sharepoint.com/:f:/g/personal/xxxxxxxx/mmmmmmmmm?e=XXXX"><br> <input type="text" name="shareurl" style="width:100%" placeholder="https://xxxx.sharepoint.com/:f:/g/personal/xxxxxxxx/mmmmmmmmm?e=XXXX"><br>
</div> </div>
<div id="morecustom"> <div id="morecustom">
@ -1612,14 +1611,14 @@ function EnvOpt($needUpdate = 0)
<a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>'; <a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>';
if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) { if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
$html .= ' $html .= '
In VPS can not update by a click!<br>'; '.getconstStr('VPSnotupdate').'<br>';
} else { } else {
$html .= ' $html .= '
<form name="updateform" action="" method="post"> <form name="updateform" action="" method="post">
<input type="text" name="auth" placeholder="auth" value="qkqpttgf"> <input type="text" name="auth" placeholder="auth" value="qkqpttgf">
<input type="text" name="project" placeholder="project" value="OneManager-php"> <input type="text" name="project" placeholder="project" value="OneManager-php">
<button onclick="querybranchs();return false">查询分支</button> <button onclick="querybranchs();return false">'.getconstStr('QueryBranchs').'</button>
<!--<input type="text" name="branch" placeholder="auth" value="master">--> <!--<input type="text" name="branch" placeholder="branch" value="master">-->
<select name="branch"> <select name="branch">
<option value="master">master</option> <option value="master">master</option>
</select> </select>

View File

@ -633,6 +633,10 @@ $constStr = [
'ko-kr' => '중국 Onedrive', 'ko-kr' => '중국 Onedrive',
'fa' => 'Onedrive در چین', 'fa' => 'Onedrive در چین',
], ],
'UseShareLink' => [
'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.',
'zh-cn' => '对一个Onedrive文件夹共享允许所有人编辑然后将共享链接填在下方',
],
'CustomIdSecret' => [ 'CustomIdSecret' => [
'en-us' => 'Use custom client id & secret', 'en-us' => 'Use custom client id & secret',
'zh-cn' => '自己申请应用ID与机密', 'zh-cn' => '自己申请应用ID与机密',
@ -726,4 +730,12 @@ $constStr = [
'ko-kr' => '캐시 플러시', 'ko-kr' => '캐시 플러시',
'fa' => 'رفرش cache', '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' => '查询分支',
],
]; ];

View File

@ -2,6 +2,7 @@
function getpath() function getpath()
{ {
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
$p = strpos($_SERVER['REQUEST_URI'],'?'); $p = strpos($_SERVER['REQUEST_URI'],'?');

View File

@ -2,6 +2,7 @@
function getpath() function getpath()
{ {
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
$p = strpos($_SERVER['REQUEST_URI'],'?'); $p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);

View File

@ -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 20200326-0001.16
You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>. You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>.
可以将sharepoint网站添加成一个盘<font color=red>由于结构改变,升级后只能重装</font>。 可以将sharepoint网站添加成一个盘<font color=red>由于结构改变,升级后只能重装</font>。
20200321-1830.15 20200321-1830.15
本次更新后,'index.html'功能在其它主题会导致bug。 本次更新后,'index.html'功能在其它主题会导致bug。
文本类文件将缓存添加hideFunctionalityFile开关在添加网盘时会显示已经在用的标签。 文本类文件将缓存添加hideFunctionalityFile开关在添加网盘时会显示已经在用的标签。