Redirect when folder not end with / (fix disktag with no /)

pull/493/head
qkqpttgf 2021-11-23 19:59:41 +08:00 committed by GitHub
parent 51d7e13ca5
commit e0d7bba0fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -249,7 +249,8 @@ function main($path)
return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 302, [ 'Location' => $tmp ]);
//return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', '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('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
@ -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;
}