Update common.php

pull/41/head
qkqpttgf 2020-03-21 18:12:59 +08:00 committed by GitHub
parent e229f6594d
commit 7f567beb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 14 deletions

View File

@ -859,7 +859,7 @@ function splitlast($str, $split)
$tmp[1] = substr($str, $pos+1); $tmp[1] = substr($str, $pos+1);
} else { } else {
$tmp[0] = ''; $tmp[0] = '';
$tmp[1] = $str; $tmp[1] = substr($str, 1);
} }
return $tmp; return $tmp;
} }
@ -941,23 +941,22 @@ function fetch_files($path = '/')
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0 // https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http // https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer // https://developer.microsoft.com/zh-cn/graph/graph-explorer
$pos = strrpos($path, '/'); $pos = splitlast($path, '/');
if ($pos>1) { $parentpath = $pos[0];
$parentpath = substr($path, 0, $pos); $filename = $pos[1];
$filename = strtolower(substr($path, $pos+1)); if ($parentfiles = getcache('path_' . $parentpath. '/')) {
if ($parentfiles = getcache('path_' . $parentpath. '/')) { if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) {
if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) { if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) { if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { $content1 = curl_request($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl']);
$content1 = curl_request($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl']); $parentfiles['children'][$filename]['content'] = $content1;
$parentfiles['children'][$filename]['content'] = $content1; savecache('path_' . $parentpath. '/', $parentfiles);
savecache('path_' . $parentpath. '/', $parentfiles);
}
} }
return $parentfiles['children'][$filename];
} }
return $parentfiles['children'][$filename];
} }
} }
$url = $_SERVER['api_url']; $url = $_SERVER['api_url'];
if ($path !== '/') { if ($path !== '/') {
$url .= ':' . $path; $url .= ':' . $path;