diff --git a/common.php b/common.php index fd601a6..121e18d 100644 --- a/common.php +++ b/common.php @@ -59,6 +59,8 @@ $EnvConfigs = [ 'guestup_path' => 0b111, 'domainforproxy' => 0b111, 'public_path' => 0b111, + 'fileConduitSize' => 0b110, + 'fileConduitCacheTime' => 0b110, ]; $timezones = array( @@ -392,6 +394,20 @@ function main($path) $url = $files['url']; if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']); else { + $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=' . $fileConduitCacheTime], + true + ); + } if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; $header['Location'] = $url; $domainforproxy = ''; 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 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