fix: url 403 soon

pull/240/head
qkqpttgf 2021-03-04 22:08:16 +08:00 committed by GitHub
parent e07e036fb6
commit 86ddf9e388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 15 deletions

View File

@ -127,26 +127,21 @@ class Googledrive {
} else { } else {
if (isset($item['id'])&&$item['shared']!==true) $this->permission('create', $item['id']); if (isset($item['id'])&&$item['shared']!==true) $this->permission('create', $item['id']);
//$this->permission('delete', $files['id']); //$this->permission('delete', $files['id']);
if (!isset($item['downUrl'])) {
$res = curl('GET', $item['webContentLink'], '', '', 1);
$weblink = $res['returnhead']['Location'];
if ($weblink!==null) $item['downUrl'] = $weblink;
else error_log1('Cant get link:' . json_encode($res, JSON_PRETTY_PRINT));
}
//if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') { //if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') {
if (in_array(splitlast($item['name'],'.')[1], $exts['txt'])) { if (in_array(splitlast($item['name'],'.')[1], $exts['txt'])) {
if (!(isset($item['content'])&&$item['content']['stat']==200)) { if (!(isset($item['content'])&&$item['content']['stat']==200)) {
if (isset($item['downUrl'])) { //if (!isset($item['downUrl'])) {
$content1 = curl('GET', $item['downUrl']); $res = curl('GET', $item['webContentLink'], '', '', 1);
$item['content'] = $content1; $weblink = $res['returnhead']['Location'];
} //if ($weblink!==null) $item['downUrl'] = $weblink;
//else $content1 = $res; //else error_log1('Cant get link:' . json_encode($res, JSON_PRETTY_PRINT));
//if ($content1['stat']==302) {
// $content1 = curl('GET', $content1['returnhead']['Location'], '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"], 1);
//} //}
if ($res['stat']==302) {
$content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"], 1);
$item['content'] = $content1;
} else $content1 = $res;
//error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL); //error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL);
//$item['content'] = $content1;
$parent_folder['files'][$i] = $item; $parent_folder['files'][$i] = $item;
savecache('path_' . $path, $parent_folder, $this->disktag); savecache('path_' . $path, $parent_folder, $this->disktag);
} }