%s', $filename, $css_class, $name);
}
function filter_files_dir($files_array, string $path) : array {
$ret_array = ['dir' => [], 'file' => []];
foreach($files_array as $file) {
// Hidden Files are not shown
if(substr($file, 0, 1) == '.') {
continue;
}
if(is_dir($path . $file)) {
// Append dir to array
$ret_array['dir'][] = $file;
}
else {
// Append file to array
$ret_array['file'][] = $file;
}
}
return $ret_array;
}
echo($header);
echo("\n");
?>
Magatzem de Dusk
File not found, error 404';
$basedir = 'content';
$request_uri = $_SERVER['REQUEST_URI'];
$path = $basedir . $request_uri;
if(!is_dir($path)) {
echo($not_found_error);
die();
}
$files_in_folder = scandir($path);
$resource_array = filter_files_dir($files_in_folder, $path);
// Show folder links
{
if(!empty($resource_array['dir'])) {
echo('Directoris
');
}
echo('');
foreach($resource_array['dir'] as $dir) {
echo('- ' . link_from_file($request_uri . $dir, null, "dir_link") . '
');
echo('
');
}
echo('
');
}
echo("\n");
//Show file links
{
if(!empty($resource_array['file'])) {
echo('Fitxers
');
}
echo('');
foreach($resource_array['file'] as $file) {
echo('- ' . link_from_file($request_uri . $file, null, 'file_link') . '
');
echo('
');
}
echo('
');
}
echo("\n");
?>