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";
|
$motd = "get fucked";
|
||||||
$script_name = "listdir.php";
|
$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){
|
function do_error($code, $title, $text, $motd, $script_name){
|
||||||
|
|
||||||
http_response_code($code);
|
http_response_code($code);
|
||||||
|
@ -179,7 +186,7 @@ if(isset($_GET["query"])){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "pcre":
|
case "pcre":
|
||||||
$match = preg_match($query, $filename);
|
$match = @preg_match($query, $filename);
|
||||||
|
|
||||||
if($match === false){
|
if($match === false){
|
||||||
|
|
||||||
|
@ -224,7 +231,7 @@ if(isset($_GET["query"])){
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
||||||
'<td>' .
|
'<td>' .
|
||||||
'<a href="' . $script_name . '?path=' . urlencode($fullpath) . '">' .
|
'<a href="' . $script_name . '?path=' . encode_path($fullpath) . '">' .
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
$filename
|
$filename
|
||||||
) .
|
) .
|
||||||
|
@ -321,7 +328,7 @@ if(is_dir($realpath)){
|
||||||
|
|
||||||
$up = explode("/", $relative_path);
|
$up = explode("/", $relative_path);
|
||||||
unset($up[count($up) - 1]);
|
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);
|
do_header("index of " . $relative_path, "", "and", false, "", $up);
|
||||||
|
@ -342,7 +349,7 @@ if(is_dir($realpath)){
|
||||||
'<tr><td></td>' .
|
'<tr><td></td>' .
|
||||||
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
'<td>' . ($is_dir ? "<DIR>" : "<FILE>") . '</td>' .
|
||||||
'<td>' .
|
'<td>' .
|
||||||
'<a href="' . $script_name . '?path=' . urlencode(rtrim($relative_path, "/") . "/" . $filename) . '">' .
|
'<a href="' . $script_name . '?path=' . encode_path(rtrim($relative_path, "/") . "/" . $filename) . '">' .
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
$filename
|
$filename
|
||||||
) .
|
) .
|
||||||
|
@ -367,7 +374,7 @@ if(is_dir($realpath)){
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<td>' .
|
'<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>';
|
'</td>';
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
@ -382,7 +389,7 @@ if(is_dir($realpath)){
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<td>' .
|
'<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>';
|
'</td>';
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue