-
Notifications
You must be signed in to change notification settings - Fork 0
/
listFileFolder.php
55 lines (43 loc) · 1.11 KB
/
listFileFolder.php
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
<?php
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$i=1;
function listFolder($dir){
global $i;
$ffs = scandir($dir);
foreach($ffs as $ff){
if($ff != '.' && $ff != '..'){
if(is_dir($dir.'/'.$ff)) {
echo ' <tr>';
echo ' <td>' .$i++ .'</td>';
echo ' <td><a href="showPics.php?path=' .$dir.'/'.$ff .'" >' .$ff .'</a></td>';
echo ' </tr>';
listFolder($dir.'/'.$ff);
}
}
}
}
function showFiles($dir_handle, $dirPath) {
global $allowed_types;
global $file_parts;
$ext='';
$title='';
$i=0;
while ($file = readdir($dir_handle)) {
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
$nomargin='';
if(in_array($ext, $allowed_types)) {
if(($i+1)%4==0) $nomargin='nomargin';
echo '
<div class="pic '.$nomargin.'" style="background:url('.$dirPath.'/'.$file.') no-repeat 50% 50%;">
<a href="'.$dirPath.'/'.$file.'" title="'.$title.'" target="_blank">'.$title. '</a>
</div>';
$i++;
}
}
}
?>