1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
|
<style type="text/css">
.downloads a {
padding-left: 20px;
background-image: url(dein-lustiges-bild.jpg);
background-repeat: no-repeat;
background-position: center left;
}
</style>
<?php
// einstellungen
$dir = 'downloads/'; // trailing slash nicht vergessen!!!
// verzeichnis auslesen
foreach( glob( $dir.'*' ) as $path ) {
$file = basename( $path ); // dateiname
// ordner auslassen
if( !is_file( $path ) ) {
continue;
}
$files[] = array(
'name' => $file,
'path' => $path,
'date' => date( 'd.m.Y', filemtime( $path ) ),
'size' => fsize( $path )
);
}
// ergebnis ausgeben
if( count( $files ) == 0 ) {
print( 'Keine Dateien gefunden!' );
} else {
?>
<table class="downloads">
<tr>
<th>Dateiname</th>
<th>Datum</th>
<th>Größe</th>
</tr>
<?php
foreach( $files as $f ) {
?>
<tr>
<td><a href="<?php print( $f['path'] ) ?>"><?php print( $f['name'] ) ?></a></td>
<td><?php print( $f['date'] ) ?></td>
<td><?php print( $f['size'] ) ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
// hilfsfunktion fuer dateigroesse
function fsize( $path ) {
$benennung = array( 'B', 'kB', 'MB', 'GB', 'TB' );
$size = filesize( $path );
$i = 0;
while( strlen( "$size" ) > 3 ) {
$size = round( $size/1024 );
$i++;
}
return "$size ".$benennung[$i];
}
?> |