From a81c94bad3cb97d128afd957360ea9ced252c2aa Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 4 May 2022 17:19:34 +0800 Subject: [PATCH] add diskDisplay a disk display to guest or hide, or disable for guest, only admin can visit --- common.php | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/common.php b/common.php index 9c887a4..41661c5 100644 --- a/common.php +++ b/common.php @@ -57,6 +57,7 @@ $EnvConfigs = [ 'activeLimit' => 0b100, 'driveId' => 0b100, + 'diskDisplay' => 0b110, 'diskname' => 0b111, 'diskDescription' => 0b111, 'domain_path' => 0b111, @@ -273,7 +274,7 @@ function main($path) $files['type'] = 'folder'; $files['childcount'] = count($disktags); $files['showname'] = 'root'; - foreach ($disktags as $disktag) { + foreach ($disktags as $disktag) if ($_SERVER['admin']||getConfig('diskDisplay', $disktag)=='') { $files['list'][$disktag]['type'] = 'folder'; $files['list'][$disktag]['name'] = $disktag; $files['list'][$disktag]['showname'] = getConfig('diskname', $disktag); @@ -287,7 +288,7 @@ function main($path) $_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0]; //$pos = strpos($path, '/'); //if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); - if (!in_array($_SERVER['disktag'], $disktags)) { + if ((!$_SERVER['admin']&&getConfig('diskDisplay', $_SERVER['disktag'])=='disable')||!in_array($_SERVER['disktag'], $disktags)) { $tmp = path_format($_SERVER['base_path'] . '/' . $disktags[0] . '/' . $path); if (!!$_GET) { $tmp .= '?'; @@ -400,6 +401,7 @@ function main($path) } else { $files = $drive->list_files($path1); } + //echo "
" . json_encode($files, 448) . "
"; //if ($path!=='') if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { $tmp = path_format($_SERVER['base_disk_path'] . $path . '/'); @@ -496,6 +498,7 @@ function main($path) ], true ); + //if ($files['size']<$fileConduitSize) return $drive->ConduitDown($files['url'], $files['time'], $fileConduitCacheTime); } if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; $header['Location'] = $url; @@ -513,12 +516,13 @@ function main($path) return render_list($path, $files); } else { if (!isset($files['error'])) { - if (is_array($files)) $files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT); - else $files['error']['message'] = $files; - $files['error']['code'] = 'unknownError'; - $files['error']['stat'] = 500; + if (is_array($files)) { + $files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT); + $files['error']['code'] = 'unknownError'; + $files['error']['stat'] = 500; + } } - return message('
' . $files['error']['message'] . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); + return message('
' . $files.json_encode($files, JSON_PRETTY_PRINT) . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); } } @@ -1096,7 +1100,7 @@ function needUpdate() function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false) { if (isset($_SERVER['Set-Cookie'])) $headers['Set-Cookie'] = $_SERVER['Set-Cookie']; - if (baseclassofdrive()=='Aliyundrive') $headers['Referrer-Policy'] = 'no-referrer'; + if (baseclassofdrive()=='Aliyundrive' || baseclassofdrive()=='BaiduDisk') $headers['Referrer-Policy'] = 'no-referrer'; //$headers['Referrer-Policy'] = 'same-origin'; //$headers['X-Frame-Options'] = 'sameorigin'; return [ @@ -1695,11 +1699,26 @@ output: '; foreach ($EnvConfigs as $key => $val) if (isInnerEnv($key) && isShowedEnv($key)) { - $frame .= ' + if ($key=='diskDisplay') { + $frame .= ' + + + + + ' . getconstStr('EnvironmentsDescription')[$key] . ' + + '; + } else { + $frame .= ' '; + } } $frame .= ' @@ -2959,7 +2978,7 @@ function render_list($path = '', $files = []) $MultiDiskArea = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MultiDisks = $tmp[0]; - foreach ($disktags as $disk) { + foreach ($disktags as $disk) if ($_SERVER['admin']||getConfig('diskDisplay', $disk)=='') { $diskname = getConfig('diskname', $disk); if ($diskname=='') $diskname = $disk; $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks);