From ee23cd636fd705f81083a996380aee3360fb3656 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 6 Sep 2021 20:21:18 +0800 Subject: [PATCH 1/5] chang ' to " #418 , --- theme/classic.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index 3188f68..1a41e31 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -601,12 +601,12 @@ }); } } - addVideos(['']); + addVideos([""]); pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js'; var loadingTask = pdfjsLib.getDocument({ - url: '', + url: "", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/", cMapPacked: true, rangeChunkSize: 65535 From 8dea16da7855117590fecb2476a09a2b1a90252f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Sep 2021 05:03:36 +0000 Subject: [PATCH 2/5] add littleFileCacheTime --- common.php | 12 ++++++++++++ conststr.php | 2 ++ index.php | 9 ++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common.php b/common.php index fd601a6..d3c5449 100644 --- a/common.php +++ b/common.php @@ -38,6 +38,7 @@ $EnvConfigs = [ 'useBasicAuth' => 0b010, 'referrer' => 0b011, 'forceHttps' => 0b010, + 'littleFileCacheTime' => 0b010, 'Driver' => 0b100, 'client_id' => 0b100, @@ -392,6 +393,17 @@ function main($path) $url = $files['url']; if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']); else { + $littleFileCacheTime = getConfig('littleFileCacheTime'); + if ($files['size']<1024*1024 && !!$littleFileCacheTime) { + if ($littleFileCacheTime>1) $littleFileCacheTime *= 3600; + else $littleFileCacheTime = 3600; + return output( + base64_encode(file_get_contents($files['url'])), + 200, + ['Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $littleFileCacheTime], + true + ); + } if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; $header['Location'] = $url; $domainforproxy = ''; diff --git a/conststr.php b/conststr.php index 00de5af..b3a6db3 100644 --- a/conststr.php +++ b/conststr.php @@ -105,6 +105,7 @@ $constStr = [ 'background' => 'Set an url as background photo.', 'backgroundm' => 'Set an url as background in mobile phone.', 'forceHttps' => 'if 1, force to redirect to https when visit via http.', + 'littleFileCacheTime' => 'Unit is hour, if set this, little file<1M will through program and cache in explorer, otherwise, default 302 to Microsoft', 'theme' => 'Select theme for guest.', 'timezone' => 'Set default timezone.', 'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.', @@ -133,6 +134,7 @@ $constStr = [ 'background' => '设置一个url作为背景。', 'backgroundm' => '设置一个url作为手机端用的背景。', 'forceHttps' => '0或1。如果设置为1,会强制跳https', + 'littleFileCacheTime' => '单位是小时,如果设置,小于1M的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软', 'theme' => '为游客选择一个主题。', 'timezone' => '设置默认时区。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', diff --git a/index.php b/index.php index a2d9bd1..1c78c03 100644 --- a/index.php +++ b/index.php @@ -30,7 +30,8 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { header($headerName . ': ' . $headerVal, true); } http_response_code($re['statusCode']); - echo $re['body']; + if ($re['isBase64Encoded']) echo base64_decode($re['body']); + else echo $re['body']; } elseif (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/var/task/user') { if (getenv('ONEMANAGER_CONFIG_SAVE')=='env') include 'platform/Vercel_env.php'; else include 'platform/Vercel.php'; @@ -44,7 +45,8 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { header($headerName . ': ' . $headerVal, true); } http_response_code($re['statusCode']); - echo $re['body']; + if ($re['isBase64Encoded']) echo base64_decode($re['body']); + else echo $re['body']; } else { include 'platform/Normal.php'; $path = getpath(); @@ -58,7 +60,8 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { header($headerName . ': ' . $headerVal, true); } http_response_code($re['statusCode']); - echo $re['body']; + if ($re['isBase64Encoded']) echo base64_decode($re['body']); + else echo $re['body']; } // Tencent SCF From d2909b85bcbfecef6a3f48e01772844a1ef4d6f5 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 8 Sep 2021 18:06:53 +0800 Subject: [PATCH 3/5] fileConduit --- conststr.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conststr.php b/conststr.php index b3a6db3..8975150 100644 --- a/conststr.php +++ b/conststr.php @@ -105,7 +105,8 @@ $constStr = [ 'background' => 'Set an url as background photo.', 'backgroundm' => 'Set an url as background in mobile phone.', 'forceHttps' => 'if 1, force to redirect to https when visit via http.', - 'littleFileCacheTime' => 'Unit is hour, if set this, little file<1M will through program and cache in explorer, otherwise, default 302 to Microsoft', + 'fileConduitCacheTime' => 'Input number, unit is hour, if set this, little file<1M(or fileConduitSize) will through program and cache in explorer, otherwise, default 302 to Microsoft', + 'fileConduitSize' => 'Input number, unit is M(suggest less than 4M), if set this, little file 'Select theme for guest.', 'timezone' => 'Set default timezone.', 'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.', @@ -134,7 +135,8 @@ $constStr = [ 'background' => '设置一个url作为背景。', 'backgroundm' => '设置一个url作为手机端用的背景。', 'forceHttps' => '0或1。如果设置为1,会强制跳https', - 'littleFileCacheTime' => '单位是小时,如果设置,小于1M的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软', + 'fileConduitCacheTime' => '填数字,单位是小时,如果设置,小于1M(或fileConduitSize)的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软', + 'fileConduitSize' => '填数字,单位是M(建议4M以下),如果设置,小于这个值的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软', 'theme' => '为游客选择一个主题。', 'timezone' => '设置默认时区。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', From 369e5c339465f30dd76c687db7b87dcd8d190947 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 8 Sep 2021 18:07:03 +0800 Subject: [PATCH 4/5] fileConduit --- common.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/common.php b/common.php index d3c5449..121e18d 100644 --- a/common.php +++ b/common.php @@ -38,7 +38,6 @@ $EnvConfigs = [ 'useBasicAuth' => 0b010, 'referrer' => 0b011, 'forceHttps' => 0b010, - 'littleFileCacheTime' => 0b010, 'Driver' => 0b100, 'client_id' => 0b100, @@ -60,6 +59,8 @@ $EnvConfigs = [ 'guestup_path' => 0b111, 'domainforproxy' => 0b111, 'public_path' => 0b111, + 'fileConduitSize' => 0b110, + 'fileConduitCacheTime' => 0b110, ]; $timezones = array( @@ -393,14 +394,17 @@ function main($path) $url = $files['url']; if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']); else { - $littleFileCacheTime = getConfig('littleFileCacheTime'); - if ($files['size']<1024*1024 && !!$littleFileCacheTime) { - if ($littleFileCacheTime>1) $littleFileCacheTime *= 3600; - else $littleFileCacheTime = 3600; - return output( + $fileConduitSize = getConfig('fileConduitSize', $_SERVER['disktag']); + $fileConduitCacheTime = getConfig('fileConduitCacheTime', $_SERVER['disktag']); + if (!!$fileConduitSize || !!$fileConduitCacheTime) { + if ($fileConduitSize>1) $fileConduitSize *= 1024*1024; + else $fileConduitSize = 1024*1024; + if ($fileConduitCacheTime>1) $fileConduitCacheTime *= 3600; + else $fileConduitCacheTime = 3600; + if ($files['size']<$fileConduitSize) return output( base64_encode(file_get_contents($files['url'])), 200, - ['Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $littleFileCacheTime], + ['Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $fileConduitCacheTime], true ); } From 76524fbced6f9396d5d14242178faf161657ce34 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:21:31 +0800 Subject: [PATCH 5/5] video add ts #388 --- conststr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conststr.php b/conststr.php index 8975150..4b72019 100644 --- a/conststr.php +++ b/conststr.php @@ -7,7 +7,7 @@ $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff' $exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a']; $exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; $exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf']; -$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'rmvb']; +$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'ts', 'rmvb']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; $constStr = [