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];