Skip to content

Commit

Permalink
try fix GBK txt preview
Browse files Browse the repository at this point in the history
  • Loading branch information
qkqpttgf authored May 13, 2021
1 parent 279055b commit fa7b27a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions disk/Onedrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,23 @@ public function list_files($path = '/')
}
}
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.';
}
}
}
Expand Down

0 comments on commit fa7b27a

Please sign in to comment.