check txtfile charset

pull/556/head
qkqpttgf 2022-02-18 16:13:38 +08:00 committed by GitHub
parent eb1319119a
commit e209d98ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 5 deletions

View File

@ -57,9 +57,27 @@ class Onedrive {
if (isset($parentfiles['children'][$filename][$this->DownurlStrName])) {
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]);
$parentfiles['children'][$filename]['content'] = $content1;
savecache('path_' . $parentpath, $parentfiles, $this->disktag);
//$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]);
//$parentfiles['children'][$filename]['content'] = $content1;
//savecache('path_' . $parentpath, $parentfiles, $this->disktag);
if ($$parentfiles['children'][$filename]['size']<1024*1024) {
if (!(isset($$parentfiles['children'][$filename]['content'])&&$$parentfiles['children'][$filename]['content']['stat']==200)) {
$content1 = curl('GET', $$parentfiles['children'][$filename][$this->DownurlStrName]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$txtcode = chkTxtCode($content1['body']);
if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']) $content1['body'] = $tmp['body'];
}
$$parentfiles['children'][$filename]['content'] = $content1;
savecache('path_' . $path, $$parentfiles['children'][$filename], $this->disktag);
}
} else {
$$parentfiles['children'][$filename]['content']['stat'] = 202;
$$parentfiles['children'][$filename]['content']['body'] = 'File too large.';
}
}
}
return $this->files_format($parentfiles['children'][$filename]);
@ -107,9 +125,10 @@ class Onedrive {
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$txtcode = chkTxtCode($content1['body']);
if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
if ($tmp['body']) $content1['body'] = $tmp['body'];
}
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);