diff --git a/index.php b/index.php
index f2caa44..0bd1582 100644
--- a/index.php
+++ b/index.php
@@ -22,6 +22,8 @@
die();
}
+
+
//Check if home and back buttons are needed
if($currentdir != $basedir) {
echo("
");
@@ -39,32 +41,48 @@
echo("
");
- $is_there_files = false;
-
- //Show folder links
+ $directories = [];
+ $files = [];
+
$dirs = scandir($currentdir);
- echo("
Carpetes
");
+
foreach($dirs as $file) {
- if ($file[0] != '.' && is_dir("$currentdir/$file")) {
- echo("
/$file/\n");
+ if ($file[0] != '.') {
+ if (is_dir("$currentdir/$file")) {
+ array_push($directories, $file);
+ }
+ else {
+ array_push($files, $file);
+ }
}
- if(!is_dir("$currentdir/$file")) $is_there_files = true;
}
- if($is_there_files){
- echo("
");
+ //Show folder links
+ if(count($directories) > 0) {
+ echo("
Carpetes
");
+ foreach($directories as $file) {
+ printf('
/%s/' . "\n" ,
+ $_GET["q"] ? $_GET["q"] . "/" : "", $file, $file);
+ }
+ }
+
+ //Show Files
+ if(count($files) > 0) {
+ if (count($directories) > 0) echo("
");
//Show file links
echo("
Fitxers
");
echo("
");
- foreach($dirs as $file) {
- if ($file[0] != '.' && !is_dir("$currentdir/$file")) {
- echo("
$file\n");
- }
+
+ foreach($files as $file) {
+ printf('
%s' ,
+ $currentdir, $file, $file);
+ printf("\n");
}
echo("
");
}
+
printf('
/%s
', $_GET["q"]);
?>