make urls more readable
This commit is contained in:
parent
9c01f3f4ab
commit
3643b79b4b
19
listdir.php
19
listdir.php
|
@ -8,6 +8,13 @@ $max_results = 100; // will break; once we reach limit, -1 for no limit
|
|||
$motd = "get fucked";
|
||||
$script_name = "listdir.php";
|
||||
|
||||
function encode_path($path){
|
||||
|
||||
return implode("/", array_map(function($v){
|
||||
return urlencode($v);
|
||||
}, explode("/", $path)));
|
||||
}
|
||||
|
||||
function do_error($code, $title, $text, $motd, $script_name){
|
||||
|
||||
http_response_code($code);
|
||||
|
@ -179,7 +186,7 @@ if(isset($_GET["query"])){
|
|||
break;
|
||||
|
||||
case "pcre":
|
||||
$match = preg_match($query, $filename);
|
||||
$match = @preg_match($query, $filename);
|
||||
|
||||
if($match === false){
|
||||
|
||||
|
@ -224,7 +231,7 @@ if(isset($_GET["query"])){
|
|||
'<tr>' .
|
||||
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
||||
'<td>' .
|
||||
'<a href="' . $script_name . '?path=' . urlencode($fullpath) . '">' .
|
||||
'<a href="' . $script_name . '?path=' . encode_path($fullpath) . '">' .
|
||||
htmlspecialchars(
|
||||
$filename
|
||||
) .
|
||||
|
@ -321,7 +328,7 @@ if(is_dir($realpath)){
|
|||
|
||||
$up = explode("/", $relative_path);
|
||||
unset($up[count($up) - 1]);
|
||||
$up = $script_name . "?path=" . urlencode(implode("/", $up));
|
||||
$up = $script_name . "?path=" . encode_path(implode("/", $up));
|
||||
}
|
||||
|
||||
do_header("index of " . $relative_path, "", "and", false, "", $up);
|
||||
|
@ -342,7 +349,7 @@ if(is_dir($realpath)){
|
|||
'<tr><td></td>' .
|
||||
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
||||
'<td>' .
|
||||
'<a href="' . $script_name . '?path=' . urlencode(rtrim($relative_path, "/") . "/" . $filename) . '">' .
|
||||
'<a href="' . $script_name . '?path=' . encode_path(rtrim($relative_path, "/") . "/" . $filename) . '">' .
|
||||
htmlspecialchars(
|
||||
$filename
|
||||
) .
|
||||
|
@ -367,7 +374,7 @@ if(is_dir($realpath)){
|
|||
|
||||
echo
|
||||
'<td>' .
|
||||
'<a href="' . $script_name . '?path=' . urlencode($path) . '&page=' . ($page - 1) . '"><PREV></a>' .
|
||||
'<a href="' . $script_name . '?path=' . encode_path($path) . '&page=' . ($page - 1) . '"><PREV></a>' .
|
||||
'</td>';
|
||||
}else{
|
||||
|
||||
|
@ -382,7 +389,7 @@ if(is_dir($realpath)){
|
|||
|
||||
echo
|
||||
'<td>' .
|
||||
'<a href="' . $script_name . '?path=' . urlencode($path) . '&page=' . ($page + 1) . '"><NEXT></a>' .
|
||||
'<a href="' . $script_name . '?path=' . encode_path($path) . '&page=' . ($page + 1) . '"><NEXT></a>' .
|
||||
'</td>';
|
||||
}else{
|
||||
|
||||
|
|
Loading…
Reference in New Issue