Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Add the function of redirecting to the folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeBottle committed Nov 14, 2021
1 parent 81f62f5 commit 1c98031
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ TheQueue会在游客对文件造成大量请求时防止并发情况出现,可

* 因为在[密码缓存过期](#pwdConfigUpdateInterval)的时候服务器要进行重新请求,故此时访问OdIndex页面**会比平常慢上一段时间**。咱的建议是设置一个crontab任务,每间隔一段时间访问一下网页以及时刷新密码配置。

* 访问目录时末尾一定要加上'/',比如你想访问Document目录,访问https://xxx/Document/ 才是正确的,如果访问 https://xxx/Document 会出现链接bug.
* 访问目录时末尾要加上'/',比如你想访问Document目录,访问https://xxx/Document/ 才是正确的,如果访问 https://xxx/Document 会帮你重定向到 https://xxx/Document.

* 如果特别特别久没有访问了,显示 **Failed to get accesstoken. Maybe refresh_token expired** ,需要更换refresh_token,**删掉生成的token.php,在index.php头部修改配置为自行重新获取的refreshtoken**即可.

Expand Down
30 changes: 18 additions & 12 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ function pagRequest($requestUrl, $queryUrl, $accessToken, $requestFolder)
}
return $resp;
}
function jump2folder()
{
global $config, $pathQuery;
header('Location: ' . ($config['rewrite'] ? $pathQuery . '/' : '?/' . $pathQuery . '/'));/*如果是目录没有带/的就跳转到有/*/
}
function handleRequest($url, $returnUrl = false, $requestForFile = false)
{
global $config, $ifRequestFolder;
Expand Down Expand Up @@ -341,11 +346,12 @@ function handleRequest($url, $returnUrl = false, $requestForFile = false)
/*渲染目录,2021.11.11修复空目录返回空白的bug*/
$render = renderFolderIndex(($data['value'] ? $data['value'] : []), parsePath($url));
return $render;
} else if (array_key_exists('folder', $data)) {/*没有value但有目录说明url末尾没有加/*/
return jump2folder();/*跳转到末尾有/的目录*/
} else {
$resp = json_decode($resp, true);
unset($resp['@odata.context']);/*防止泄露onedrive账号邮箱*/
$jsonArr['msg'] = 'Error response:' . var_export($resp, true);
return ($config['list_as_json'] ? json_encode($jsonArr, true) : 'Error response:' . var_export($resp, true));
unset($data['@odata.context']);/*防止泄露onedrive账号邮箱*/
$jsonArr['msg'] = 'Error response:' . var_export($data, true);
return ($config['list_as_json'] ? json_encode($jsonArr, true) : 'Error response:' . var_export($data, true));
}
} else if ($config['no_index']) {
return $config['no_index_print'];
Expand Down Expand Up @@ -807,23 +813,23 @@ function queueChecker($statu, $waiting = false, $id = false)
}
$self = basename($_SERVER['PHP_SELF']);
$pathQuery = str_ireplace($self, '', $pathQuery);
$requesturl = 'http://request.yes/' . $pathQuery;
$requestUrl = 'http://request.yes/' . $pathQuery;
/*Request Path ProcessorEnd*/

queueTimeCheck();/*检查是否超时*/

/*Cache Processor*/
$ifRequestFolder = substr(parsePath($requesturl), -1) == '/' ? true : false;/*如果请求路径以/结尾就算请求的是目录*/
$cachepath = '/' . $pathQuery;
if (!pwdChallenge()[0]) cacheClear($cachepath);/*如果没通过密码验证就删除缓存*/
$cache = cacheControl('read', $cachepath);
$ifRequestFolder = substr(parsePath($requestUrl), -1) == '/' ? true : false;/*如果请求路径以/结尾就算请求的是目录*/
$cachePath = '/' . $pathQuery;
if (!pwdChallenge()[0]) cacheClear($cachePath);/*如果没通过密码验证就删除缓存*/
$cache = cacheControl('read', $cachePath);
/*Cache Processor End*/

if (ifCacheStart() && !empty($cache[0]) && empty($pwdRqFolder)) {
$output = $ifRequestFolder ? $cache[0] : handleRequest($requesturl);
$output = $ifRequestFolder ? $cache[0] : handleRequest($requestUrl);
} else {
$output = handleRequest($requesturl);
if (ifCacheStart() && pwdChallenge()[0]) cacheControl('write', $cachepath, array($output));
$output = handleRequest($requestUrl);
if (ifCacheStart() && pwdChallenge()[0]) cacheControl('write', $cachePath, array($output));
}

if ($config['list_as_json']) header('Content-type:text/json;charset=utf-8');/*如果以Json返回就设定头*/
Expand Down

0 comments on commit 1c98031

Please sign in to comment.