From 8075c3d2d82b8dc40819e6df4a82389797d184fa Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 11 May 2020 13:11:07 +0800 Subject: [PATCH] if no disktag 302 to 1st disk --- common.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common.php b/common.php index 33fe6e4..2ae7073 100644 --- a/common.php +++ b/common.php @@ -153,6 +153,7 @@ function main($path) global $exts; global $constStr; + $path = path_format($path); if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) { $constStr['language'] = $_SERVER['firstacceptlanguage']; } else { @@ -216,10 +217,14 @@ function main($path) // echo 'count$disk:'.count($disktags); if (count($disktags)>1) { if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]); - $_SERVER['disktag'] = $path; - $pos = strpos($path, '/'); - if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); - if (!in_array($_SERVER['disktag'], $disktags)) return message('Please visit from Home Page.', 'Error', 404); + $_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)) { + $tmp = path_format($_SERVER['base_path'].'/'.$disktags[0].'/'.$path); + return output('Please visit '.$tmp.'.', 302, [ 'Location' => $tmp ]); + //return message('Please visit from Home Page.', 'Error', 404); + } $path = substr($path, strlen('/'.$_SERVER['disktag'])); if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/'); } else $_SERVER['disktag'] = $disktags[0];