-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_gallery.php
100 lines (78 loc) · 2.7 KB
/
generate_gallery.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
include_once("caption_functions.php");
include_once("generate_filelist.php");
function generate_gallery($gallery, $dirkey) {
include("set_paths.php");
include("$imagedata/$gallery");
$basedir=$dirs[$dirkey];
#print "DEBUG: $gallery, $dirkey, $basedir <br/>";
//Get list of files for this gallery
$filelist=generate_filelist($gallery, $dirkey);
// and export it
$_SESSION['filelist']=$filelist;
// Process filename list
foreach ( array_keys($filelist) as $filekey) {
$file=$filelist[$filekey];
if ( preg_match( "/\.(jpg|jpeg|png)$/i" , $file )) {
JPEG_Thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir) ;
}
elseif ( preg_match( "/\.(mov|mpeg|mpg|avi|mp4)$/i" , $file )) {
Movie_thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir) ;
}
}
}
/////////
function Movie_thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir){
$filename=$filelist[$filekey] ;
$file="$basedir/$filename";
$mimetype=mime_content_type($file);
$filesize = filesize($file);
$nicefilesize = format_bytes($filesize);
$caption=get_caption($file);
if ( ! isset($caption) || $caption == "" ) $caption = $filename;
$imagetag = " MOVIE: $filename <br/>";
$filesize_display= " File Size: $nicefilesize <br/>";
#<a href='?action=send_file&gallery=$gallery&dirkey=$dirkey&filekey=$filekey'>
print <<<HTMLEND
<div class=thumbnail >
<div class=movie >
$imagetag
$filesize_display
<a href='send_file.php?mode=attach&gallery=$gallery&dirkey=$dirkey&filekey=$filekey'>
Download
</a>
|
<a href='gallery.php?action=display_image&gallery=$gallery&dirkey=$dirkey&filekey=$filekey' type='$mimetype' >
View in browser
</a>
</div>
</div>
HTMLEND
;
}
function JPEG_Thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir ){
#include_once("generate_filelist.php");
#$filelist = generate_filelist($gallery, $dirkey);
$filename=$filelist[$filekey] ;
$file="$basedir/$filename";
$caption=get_caption($file);
if ( ! isset($caption) || $caption == "" ) $caption = $filename;
#$imagecache=dirname(__FILE__)."/imagecache";
$random = rand(1000, 999999) ;
$imagetag = "<img class=thumbnail src='image_resample.php?gallery=$gallery&dirkey=$dirkey&filekey=$filekey&size=150&xx=$random' title='$caption'>";
print <<<HTMLEND
<div class=thumbnail>
<a class=thumbnail href='gallery.php?gallery=$gallery&dirkey=$dirkey&filekey=$filekey&size=700&action=display_image'>
$imagetag
</a>
</div>
HTMLEND
;
// END OF FUNCTION Thumbnail
}
function format_bytes($size) {
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
return round($size, 2).$units[$i];
}
?>