From e0d7bba0fb7ad4dd8213fb5fde6e1d31e6ace6d6 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 23 Nov 2021 19:59:41 +0800 Subject: [PATCH] Redirect when folder not end with / (fix disktag with no /) --- common.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 672438d..30c3c1e 100644 --- a/common.php +++ b/common.php @@ -249,7 +249,8 @@ function main($path) return output('Please visit ' . $tmp . '.', 302, [ 'Location' => $tmp ]); //return message('Please visit from Home Page.', 'Error', 404); } - $path = substr($path, strlen('/' . $_SERVER['disktag'])); + //$path = substr($path, strlen('/' . $_SERVER['disktag'])); + $path = splitfirst($path, $_SERVER['disktag'])[1]; if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_SERVER['disktag'] . '/'); } } else $_SERVER['disktag'] = $disktags[0]; @@ -358,7 +359,8 @@ function main($path) } else { $files = $drive->list_files($path1); } - if ($path!=='') if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { + //if ($path!=='') + if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { $tmp = path_format($_SERVER['base_disk_path'] . $path . '/'); return output(' @@ -1207,6 +1209,7 @@ function splitfirst($str, $split) $tmp[0] = ''; $tmp[1] = substr($str, $len); } + if ($tmp[1]===false) $tmp[1] = ''; return $tmp; } @@ -1224,6 +1227,7 @@ function splitlast($str, $split) $tmp[0] = ''; $tmp[1] = substr($str, $len); } + if ($tmp[1]===false) $tmp[1] = ''; return $tmp; }