Split header in file, Minor visual changes
Made code a little prettier
This commit is contained in:
parent
c171629563
commit
e0e1097b49
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$header = <<<HEADER
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Magatzem de Dusk</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<meta name="description" content="Els fitxers de Dusk">
|
||||||
|
<link rel="icon" type="image/png" href="static/favicon.png" sizes="32x32">
|
||||||
|
</head>
|
||||||
|
HEADER;
|
55
index.php
55
index.php
|
@ -1,26 +1,24 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ca">
|
<html>
|
||||||
<head>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
||||||
<title>Dusk Kino</title>
|
|
||||||
<link rel="icon" type="image/png" href="./favicon.apng" sizes="32x32">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include 'include/header.php';
|
||||||
|
|
||||||
function link_from_file(string $filename, string $name = null, string $css_class = null ) : string {
|
function link_from_file(string $filename, string $name = null, string $css_class = null ) : string {
|
||||||
// Check if css_class is null
|
// Check if css_class is null
|
||||||
$css_class = $css_class ? "class=\"$css_class\"" : '';
|
$css_class = $css_class ? " class=\"$css_class\"" : '';
|
||||||
// Check if name is null
|
// Check if name is null
|
||||||
$name = $name ?: basename($filename);
|
$name = $name ?: basename($filename);
|
||||||
return sprintf('<a href=%s %s>%s</a>', $filename, $css_class, $name);
|
return sprintf('<a href=%s%s>%s</a>', $filename, $css_class, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_files_dir($files_array, string $path) : array {
|
function filter_files_dir($files_array, string $path) : array {
|
||||||
$ret_array = ['dir' => [], 'file' => []];
|
$ret_array = ['dir' => [], 'file' => []];
|
||||||
foreach($files_array as $file) {
|
foreach($files_array as $file) {
|
||||||
|
// Hidden Files are not shown
|
||||||
|
if(substr($file, 0, 1) == '.') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(is_dir($path . $file)) {
|
if(is_dir($path . $file)) {
|
||||||
// Append dir to array
|
// Append dir to array
|
||||||
$ret_array['dir'][] = $file;
|
$ret_array['dir'][] = $file;
|
||||||
|
@ -33,6 +31,14 @@ function filter_files_dir($files_array, string $path) : array {
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo($header);
|
||||||
|
echo("\n");
|
||||||
|
|
||||||
|
?>
|
||||||
|
<body>
|
||||||
|
<h1>Magatzem de Dusk</h1>
|
||||||
|
<?php
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
//var_dump($_SERVER);
|
//var_dump($_SERVER);
|
||||||
// Debug
|
// Debug
|
||||||
|
@ -58,29 +64,34 @@ $resource_array = filter_files_dir($files_in_folder, $path);
|
||||||
|
|
||||||
// Show folder links
|
// Show folder links
|
||||||
{
|
{
|
||||||
foreach($resource_array['dir'] as $dir) {
|
if(!empty($resource_array['dir'])) {
|
||||||
if(substr($dir, 0, 1) == '.') {
|
echo('<h2>Directoris</h2>');
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
echo(link_from_file($request_uri . $dir));
|
echo('<ul>');
|
||||||
|
foreach($resource_array['dir'] as $dir) {
|
||||||
|
echo('<li>' . link_from_file($request_uri . $dir, null, "dir_link") . '</li>');
|
||||||
echo('<br/>');
|
echo('<br/>');
|
||||||
}
|
}
|
||||||
echo('<hr/>');
|
echo('</ul>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo("\n");
|
||||||
|
|
||||||
//Show file links
|
//Show file links
|
||||||
{
|
{
|
||||||
foreach($resource_array['file'] as $file) {
|
if(!empty($resource_array['file'])) {
|
||||||
if(substr($file, 0, 1) == '.') {
|
echo('<h2>Fitxers</h2>');
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
echo(link_from_file($request_uri . $file));
|
echo('<ul>');
|
||||||
|
foreach($resource_array['file'] as $file) {
|
||||||
|
echo('<li>' . link_from_file($request_uri . $file, null, 'file_link') . '</li>');
|
||||||
echo('<br/>');
|
echo('<br/>');
|
||||||
}
|
}
|
||||||
echo('<hr/>');
|
echo('</ul>');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
echo("\n");
|
||||||
|
|
||||||
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue