未验证 提交 41d37f6b 编写于 作者: Q qkqpttgf 提交者: GitHub

Merge pull request #321 from qkqpttgf/GBKpreview

GBKpreview
......@@ -76,7 +76,7 @@ class Aliyundrive {
$tmp['list'][$filename]['name'] = $file['name'];
$tmp['list'][$filename]['time'] = $file['updated_at'];
$tmp['list'][$filename]['size'] = $file['size'];
$tmp['childcount']++;
//$tmp['childcount']++;
}
} elseif (isset($files['code'])||isset($files['error'])) {
return $files;
......@@ -90,8 +90,6 @@ class Aliyundrive {
global $exts;
while (substr($path, -1)=='/') $path = substr($path, 0, -1);
if ($path == '') $path = '/';
//$files = getcache('path_' . $path, $this->disktag);
//if (!$files) {
if (!($files = getcache('path_' . $path, $this->disktag))) {
if ($path == '/' || $path == '') {
$files = $this->fileList('root');
......@@ -113,22 +111,33 @@ class Aliyundrive {
$files['time'] = $item['updated_at'];
$files['size'] = $item['size'];
} else $files = $item;
}
}
//echo $files['name'];
}
if ($files['type']=='file') {
if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$header['Referer'] = 'https://www.aliyundrive.com/';
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
$content1 = curl('GET', $files['download_url'], '', $header);
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
if (in_array(strtolower(splitlast($files['name'],'.')[1]), $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$header['Referer'] = 'https://www.aliyundrive.com/';
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
$content1 = curl('GET', $files['download_url'], '', $header);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
//error_log1('body : ' . $content1['body'] . PHP_EOL);
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
}
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
error_log1($files['name'] . ' : ' . json_encode($files['content']) . PHP_EOL);
//error_log1($files['name'] . ' : ' . json_encode($files['content']) . PHP_EOL);
}
}
if (!$files) {
......@@ -177,8 +186,8 @@ class Aliyundrive {
$header["content-type"] = "application/json; charset=utf-8";
$header['authorization'] = 'Bearer ' . $this->access_token;
$data['limit'] = 50;
$data['marker'] = NULL;
$data['limit'] = 200;
$data['marker'] = null;
$data['drive_id'] = $this->driveId;
$data['parent_file_id'] = $parent_file_id;
$data['image_thumbnail_process'] = 'image/resize,w_160/format,jpeg';
......@@ -190,7 +199,19 @@ class Aliyundrive {
$res = curl('POST', $url, json_encode($data), $header);
//error_log1($res['stat'] . $res['body']);
if ($res['stat']==200) return json_decode($res['body'], true);
if ($res['stat']==200) {
$body = json_decode($res['body'], true);
$body1 = $body;
while ($body1['next_marker']!='') {
$data['marker'] = $body1['next_marker'];
$res1 = null;
$res1 = curl('POST', $url, json_encode($data), $header);
$body1 = json_decode($res1['body'], true);
$body['items'] = array_merge($body['items'], $body1['items']);
}
return $body;
//return json_decode($res['body'], true);
}
else return $res;
}
......
......@@ -128,21 +128,33 @@ class Googledrive {
//$this->permission('delete', $files['id']);
//if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') {
if (in_array(splitlast($item['name'],'.')[1], $exts['txt'])) {
if (!(isset($item['content'])&&$item['content']['stat']==200)) {
//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 ($res['stat']==302) {
$content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"]);
$item['content'] = $content1;
}// else $content1 = $res;
//error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL);
$parent_folder['files'][$i] = $item;
savecache('path_' . $path, $parent_folder, $this->disktag);
if (in_array(strtolower(splitlast($item['name'],'.')[1]), $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($item['content'])&&$item['content']['stat']==200)) {
//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 ($res['stat']==302) {
$content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
$item['content'] = $content1;
}// else $content1 = $res;
//error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL);
$parent_folder['files'][$i] = $item;
savecache('path_' . $path, $parent_folder, $this->disktag);
}
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
}
//}
......
......@@ -100,11 +100,23 @@ class Onedrive {
}
}
if (isset($files['file'])) {
if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$content1 = curl('GET', $files[$this->DownurlStrName]);
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
if (in_array(strtolower(splitlast($files['name'],'.')[1]), $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$content1 = curl('GET', $files[$this->DownurlStrName]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
}
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册