Tabel om fotogallerie
ik heb al beetje geprobeerd maar ik ben nog niet egt bepaald goed in PHP duz vandaar dat ik hier ff om hulp vraag. Weet iemand hoe ik dat kan doet met het volgende script
Code (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<?php
//Configuration
//Title for your gallery that will be used with the default header.
$title="Titel";
// Logo for the site. Use HTML it can be a graphic.
//$logo='<a href="'.$_SERVER['PHP_SELF'].'" target="_top"><img alt="Your Logo Here" src="http://www.lgr.ca/images/lgrlogo.gif" height="60" width="300" align="right" border="0" /></a>';
$logo='';
//Thumbnail maker. Some servers don't like this. Defualt is to leave it on. If you have trouble turn it off.
//0=off 1=on
$makethumbs=1;
//Thumbnail extension. You can change the thumbnail filename extesntion that is added onto the end of the original filename.
//Thumbnail file name will be "OriginalFilename.jpg_thmb.jpg" Warning if you leave this blank you will overwrite your original files!
//If you change the extension it will create new thumbnail files, but not delete the old ones.
// default=_thmb.jpg
$thumbext='_thmb.jpg';
//Thumbnail size. The minimum width and height in pixels, that you would like the thumbnails to be. Photos are scaled.
$twidth=150;
$theight=150;
//Photo size. The minimum width and height in pixels, that you would like you photos scaled to when displayed.
$pwidth = 640;
$pheight = 640;
//The thumbnail gallery is displayed in a table. Please choose the number of rows and columns you would like.
$rows=3;
$cols=5;
//If you would like the filename of the photo to be displayed under the thumbnail change this setting.
//0=off 1=on
$showfilename=0;
$showpathname=0;
//If you would like photo to up a new window when clicked change this setting.
//The defualt is to open the image up in the same browser window.
//0=off 1=on
$window=0;
//Use Javascript for new window
//0=off 1=on
$javascript=0;
//If you would like the thumb to link directly to the photo and not the script set this.
//This works best if you use the Javascript window. It pops open in a nice size.
//Default is to the script.
//0=off 1=on
$linktophoto=0;
//If you would like to use a custom header or footer please add the file names here and they will be included in the script.
//Otherwise the plain jane default will be used. The files should be in the same folder as the script, but if you provide an
//alternate path it will work as well. Example: header.html, header.php.
$header="NULL";
$footer="NULL";
$stylesheet="styles.css";
$divider=" | ";
//No need to mess with anything below here.
//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function thumb_maker($filename, $minwidth, $minheight) {
global $thumbext,$makethumbs;
if ($makethumbs==1) {
if (file_exists($filename.$thumbext)) {
$photosize = getimagesize($filename.$thumbext);
if (max($minwidth,$minheight)!=max($photosize[0],$photosize[1])) {
unlink($filename.$thumbext);
}
}
if (!file_exists($filename.$thumbext) && file_exists($filename)) {
echo "<br/>One moment please....creating a thumbnail.";
set_time_limit(60);
$photosize = getimagesize($filename);
// Get image size and scale ratio
$scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
if ($scale < 1) {
$width = floor($scale*$photosize[0]);
$height = floor($scale*$photosize[1]);
}
else {
$width = $minwidth;
$height = $minheight;
}
if ($photosize[mime]=="image/jpeg") {
$resizedimage = imagecreatetruecolor($width, $height);
$thumbimage = imagecreatefromjpeg($filename);
imagecopyresampled($resizedimage, $thumbimage, 0, 0, 0, 0, $width, $height, $photosize[0], $photosize[1]);
imagejpeg($resizedimage,$filename.$thumbext,50);
imageDestroy($resizedimage);
imageDestroy($thumbimage);
}
}
}
}
//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function gallery_sizer($photo,$minwidth,$minheight) {
if (file_exists($photo)) {
$photosize = getimagesize("$photo");
# Get image size and scale ratio
$scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
if ($scale <= 1) {
$width = floor($scale*$photosize[0]);
$height = floor($scale*$photosize[1]);
}
else {
$width = floor($photosize[0]);
$height = floor($photosize[1]);
}
return array($width,$height,$photosize[0],$photosize[1]);
}
}
function getdirs($dir) {
$dirs=array();
chdir($dir);
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".."){
if (is_dir($file)) {
$dirs[] = $file;
}
}
}
closedir($handle);
}
sort($dirs);
return $dirs;
}
function getphotos($photodir) {
global $thumbext;
$photos=array();
if ($handle = opendir($photodir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !eregi(".jpg".$thumbext."$",$file) && eregi(".jpg$",$file)){
$photos[] = $file;
}
}
closedir($handle);
}
sort($photos);
return $photos;
}
function thumb_gallery($photonum) {
global $photos, $photourl, $photodir, $twidth, $theight, $rows, $cols, $showfilename,$showpathname,$linktophoto,$thumbext, $album, $window, $javascript;
if ($photonum>count($photos)-1) {
$photonum=count($photos)-1;
}
if (($photonum)<=0) {
$photonum=0;
}
if(isset($album)) { $query="&album=".urlencode($album); }
for ($tr = 1; $tr <= $rows; $tr++) {
$photobody[]="<tr>";
for ($td = 1; $td <= $cols; $td++) {
$photobody[]="<td align=\"center\">";
if (file_exists($photodir."/".$photos[$photonum].$thumbext)) {
$size=gallery_sizer($photodir."/".$photos[$photonum].$thumbext,$twidth,$theight);
$jswindowsize=gallery_sizer($photodir."/".$photos[$photonum],1,1);
$link = $photourl."/".$photos[$photonum].$thumbext;
if ($linktophoto==1) { $linktarget="http://".$_SERVER[HTTP_HOST].$photourl."/".$photos[$photonum]; } else { $linktarget="http://".$_SERVER[HTTP_HOST].$_SERVER[PHP_SELF]."?p=".urlencode($photos[$photonum]).$query; }
if ($window==1) { if ($javascript==1) { $linktarget='javascript:Popup(\''.$linktarget.'\',\''.($jswindowsize[2]+15).'\',\''.($jswindowsize[3]+15).'\')'; } else { $target="_blank"; } } else { $target="_self"; }
if ($photonum<=count($photos)-1) {
if ($javascript==0) {
$photobody[]="<a href=\"$linktarget\" target=\"$target\">";
}
else { $photobody[]="<a href=\"$linktarget\">"; }
}
$photobody[]="<img src=\"$link\" width=\"$size[2]\" height=\"$size[3]\" alt=\"$photos[$photonum]\" border=\"1\" /></a><br />";
}
if ($photos[$photonum]) {
if ($showfilename==1) { $photobody[]=$photos[$photonum]; }
if ($showpathname==1) { $photobody[]="<br />http://".$_SERVER[HTTP_HOST].$photourl."/".$photos[$photonum]; }
}
$photobody[]="</td>";
$photonum++;
}
$photobody[]="</tr>";
}
unset($tr, $td);
#this is down here for a reason don't move it and use array_unshift instead. Trust me.
if (($photonum-($rows*$cols))>0) { $prev="<a href=\"$_SERVER[PHP_SELF]?pn=".($photonum-(($rows*$cols)*2)).$query."\"><< Vorige Pagina</a>"; }
if (($photonum)<(count($photos))) { $next="<a href=\"$_SERVER[PHP_SELF]?pn=".$photonum.$query."\">Volgende Pagina >></a>"; }
$photopage=array();
$photopage[]="Pagina: ";
for ($pagelink=0, $pagenum=1; $pagelink<=count($photos); $pagelink+=($rows*$cols), $pagenum++) {
$photopage[]="<a href=\"$_SERVER[PHP_SELF]?pn=".($pagelink).$query."\">$pagenum</a> | ";
}
unset($pagelink, $pagenum);
$photopage=implode("", $photopage);
if ($photonum >= count($photos)) { $endnum=count($photos); } else { $endnum=$photonum; }
$photobody[]="<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\">".$prev."</div></td><td width=\"33%\"><div align=\"center\" class=\"caption\">Foto's <strong>".($photonum-(($rows*$cols)-1))."</strong> van <strong>".$endnum."</strong> Totaal: <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\">".$next."</div></td></tr></table></td></tr>";
array_unshift($photobody, "<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\">".$prev."</div></td><td width=\"33%\"><div align=\"center\">Foto's <strong>".($photonum-(($rows*$cols)-1))."</strong> van <strong>".$endnum."</strong> Totaal: <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\">".$next."</div></td></tr></table></td></tr>");
#put the table tag at the top of the array.
array_unshift($photobody, '<table width="100%" border="0" cellspacing="0" cellpadding="3">');
$photobody[]='</table>';
if ($window==1 && $javascript=1) {
array_unshift($photobody, '<SCRIPT language="JavaScript">function Popup(url,width,height) { PopupWindow = window.open (\'\', \'PopupWindow\',\'scrollbars=0,resizable=1,height=\'+height+\',width=\'+width+\',left=100,top=20\'); PopupWindow.focus(); PopupWindow.location.href = url; }</SCRIPT>');
}
return $photobody;
}
function photo_gallery($photo) {
global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $album, $thumbext, $header;
$photobody=array();
if (isset($photo)) {
if(isset($album)) { $query="&album=".urlencode($album); }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\">Volgende Foto ></a>";
$nextphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
if($photos[$key-1]) {
$prevphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\">< Vorige Foto</a>";
$prevphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
}
}
if ($window==1) { $target="<a href=\"javascript:window.close()\">Close Window</a>"; } else { $target="<a href=\"".$_SERVER[HTTP_REFERER]."\"><< Vorige Pagina Page</a>"; }
$size=gallery_sizer("$photodir/$photo",$pwidth,$pheight);
$photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\"></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\"></div></td><td align=\"right\" width=\"33%\"></td></tr>";
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\">".$prevphotothumb.$prevphoto."</td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
if ($header=="NULL") {
if (isset($album)) { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($album)."&p=".$photo."&slide=1\">Start Slideshow</a>\n"; }
else { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photo."&slide=1\">Start Slideshow</a>\n"; }
}
$photobody[]="</div></td><td align=\"right\" width=\"33%\">".$nextphotothumb.$nextphoto."</td></tr>";
$photobody[]='<tr><td colspan="3" align="center">';
$photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';
$photobody[]='</td></tr>';
$photobody[]='</table>';
}
return $photobody;
}
function photo_slides($photo) {
global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $album, $header;
$photobody=array();
if (isset($photo)) {
if(isset($album)) { $query="&album=".urlencode($album); }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"> Volgende </a>";
$nextphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
if($photos[$key-1]) {
$prevphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><< Vorige Foto</a>";
$prevphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
}
}
$size=gallery_sizer("$photodir/$photo",$pwidth,$pheight);
$photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\">".$prevphotothumb.$prevphoto."</td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
if ($header=="NULL") {
if (isset($album)) { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($album)."&p=".$photo."\">Stop Slideshow</a>\n"; }
else { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photo."\">Stop Slideshow</a>\n"; }
}
$photobody[]="</div></td><td align=\"right\" width=\"33%\">".$nextphotothumb.$nextphoto."</td></tr>";
if ($window==1) { $target="<a href=\"javascript:window.close()\">Close Window</a>"; } else { $target="<a href=\"".$_SERVER[HTTP_REFERER]."\">Back</a>"; }
$photobody[]='<tr><td colspan="3" align="center">';
$photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';
$photobody[]='</td></tr>';
$photobody[]='</table>';
}
return $photobody;
}
function display($photobody) {
global $photodir;
getheader();
echo "";
albums(dirname($_SERVER['SCRIPT_FILENAME']));
echo "<div class=\"photobody\">";
foreach ($photobody as $value) {
echo $value."\n";
}
echo "</div>";
getfooter();
exit;
}
function albums($dir) {
//for now only one level of albums works.
global $album, $title, $photos, $divider, $logo, $photo;
$dirs=getdirs($dir);
if (isset($logo)) { echo $logo; }
if (isset($album)) { echo "<h1>".$album."</h1>"; } else { echo "<center><h1>".$title."</h1></center><p>Foto Albums Beschikbaar</p>"; }
echo "<div class=\"album\"><p>";
if (isset($album) || isset($photo)) { echo "<a href=\"".$_SERVER[PHP_SELF]."\">$title Home</a>$divider\n"; }
else { }
if (count($dirs)>0) {
foreach ($dirs as $value) {
echo "<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($value)."\">".$value."</a>$divider\n";
}
}
// echo "<img src=\"" width=\"1\" height=\"1\" alt=\"\" /></p></div>";
echo "</p></div>";
}
//returns the header for the page. Checks for a user defined header.
function getheader() {
global $header, $title, $slide, $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window,$photo, $photos, $album, $stylesheet;
if(isset($album)) { $query="&album=".urlencode($album); }
if ($slide==1) { $query=$query."&slide=1"; }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextslide=$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query;
}
elseif (!$photos[$key+1]) {
$slide=0;
}
}
}
if (isset($header) && $header!="NULL" && is_file ($header)) {
require("$header");
}
else {
echo "\n";
echo '<head>';
echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
echo "\n";
echo "<title>$title</title>\n";
echo '<meta name="Author" content="Blaat" />';
if ($slide==1 && $header=="NULL") { echo "<META HTTP-EQUIV=refresh CONTENT=\"4; URL=".$nextslide." \">"; }
echo '<style type="text/css" media="all">@import "'.$stylesheet.'";</style>';
echo "\n";
echo '</head>';
echo "\n";
echo '<body>';
echo "\n";
echo '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="100%">';
echo '<tr>';
echo '<td width="100%"> </td>';
}
}
//returns the footer for the page. Checks for a user defined footer.
function getfooter() {
global $footer;
if (isset($footer) && $footer!="NULL" && is_file ($footer)) {
require("$footer");
}
else {
echo '</tr>';
echo '</table>';
echo '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">';
echo '<tr>';
echo '<td width="100%" bgcolor="#000000">';
echo '<p align="center"><font color="#FFFFFF"><h2>© testje ©</2></font></td>';
echo '</tr>';
echo '</table>';
echo "</body>\n</html>";
}
}
$photodir=dirname($_SERVER['SCRIPT_FILENAME']);
$photourl=dirname($_SERVER['PHP_SELF']);
$thumbsurl=dirname($_SERVER['PHP_SELF']);
$photobody=array();
if (isset($_GET[album])) {
if (in_array($_GET[album],getdirs(dirname($_SERVER['SCRIPT_FILENAME'])))==FALSE) {
$album = NULL;
}
else {
$album = urldecode($_GET[album]);
}
$photodir=$photodir."/".$album;
$photourl=$photourl."/".$album;
$thumbsurl=$thumbsurl."/".$album;
}
//To make sure this works both on Linux and Win
$photodir = str_replace("\\", "/", $photodir);
//Get the jpegs from the folder.
$photos=getphotos($photodir);
//check to see if thumbnails are made if not it will make. Adds time to the processing of the script.
for ($i=0; $i<=count($photos)-1; $i++) {
thumb_maker($photodir."/".$photos[$i], $twidth, $theight);
}
if (count($photos)<=0) {
$photobody[]="";
display($photobody);
exit;
}
if (isset($_GET[pn])) {
$photonum = $_GET[pn];
$photobody=thumb_gallery($photonum);
}
elseif (isset($_GET[slide])) {
$slide=$_GET[slide];
$photo=urldecode($_GET[p]);
$photobody=photo_slides($photo,$pwidth,$pheight);
}
elseif (isset($_GET[p])) {
$photo=urldecode($_GET[p]);
$photobody=photo_gallery($photo,$pwidth,$pheight);
}
else {
$photobody=thumb_gallery(0);
}
//output it all to the browser.
display($photobody);
exit;
echo '</tr>';
echo '</table>';
?>
//Configuration
//Title for your gallery that will be used with the default header.
$title="Titel";
// Logo for the site. Use HTML it can be a graphic.
//$logo='<a href="'.$_SERVER['PHP_SELF'].'" target="_top"><img alt="Your Logo Here" src="http://www.lgr.ca/images/lgrlogo.gif" height="60" width="300" align="right" border="0" /></a>';
$logo='';
//Thumbnail maker. Some servers don't like this. Defualt is to leave it on. If you have trouble turn it off.
//0=off 1=on
$makethumbs=1;
//Thumbnail extension. You can change the thumbnail filename extesntion that is added onto the end of the original filename.
//Thumbnail file name will be "OriginalFilename.jpg_thmb.jpg" Warning if you leave this blank you will overwrite your original files!
//If you change the extension it will create new thumbnail files, but not delete the old ones.
// default=_thmb.jpg
$thumbext='_thmb.jpg';
//Thumbnail size. The minimum width and height in pixels, that you would like the thumbnails to be. Photos are scaled.
$twidth=150;
$theight=150;
//Photo size. The minimum width and height in pixels, that you would like you photos scaled to when displayed.
$pwidth = 640;
$pheight = 640;
//The thumbnail gallery is displayed in a table. Please choose the number of rows and columns you would like.
$rows=3;
$cols=5;
//If you would like the filename of the photo to be displayed under the thumbnail change this setting.
//0=off 1=on
$showfilename=0;
$showpathname=0;
//If you would like photo to up a new window when clicked change this setting.
//The defualt is to open the image up in the same browser window.
//0=off 1=on
$window=0;
//Use Javascript for new window
//0=off 1=on
$javascript=0;
//If you would like the thumb to link directly to the photo and not the script set this.
//This works best if you use the Javascript window. It pops open in a nice size.
//Default is to the script.
//0=off 1=on
$linktophoto=0;
//If you would like to use a custom header or footer please add the file names here and they will be included in the script.
//Otherwise the plain jane default will be used. The files should be in the same folder as the script, but if you provide an
//alternate path it will work as well. Example: header.html, header.php.
$header="NULL";
$footer="NULL";
$stylesheet="styles.css";
$divider=" | ";
//No need to mess with anything below here.
//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function thumb_maker($filename, $minwidth, $minheight) {
global $thumbext,$makethumbs;
if ($makethumbs==1) {
if (file_exists($filename.$thumbext)) {
$photosize = getimagesize($filename.$thumbext);
if (max($minwidth,$minheight)!=max($photosize[0],$photosize[1])) {
unlink($filename.$thumbext);
}
}
if (!file_exists($filename.$thumbext) && file_exists($filename)) {
echo "<br/>One moment please....creating a thumbnail.";
set_time_limit(60);
$photosize = getimagesize($filename);
// Get image size and scale ratio
$scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
if ($scale < 1) {
$width = floor($scale*$photosize[0]);
$height = floor($scale*$photosize[1]);
}
else {
$width = $minwidth;
$height = $minheight;
}
if ($photosize[mime]=="image/jpeg") {
$resizedimage = imagecreatetruecolor($width, $height);
$thumbimage = imagecreatefromjpeg($filename);
imagecopyresampled($resizedimage, $thumbimage, 0, 0, 0, 0, $width, $height, $photosize[0], $photosize[1]);
imagejpeg($resizedimage,$filename.$thumbext,50);
imageDestroy($resizedimage);
imageDestroy($thumbimage);
}
}
}
}
//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function gallery_sizer($photo,$minwidth,$minheight) {
if (file_exists($photo)) {
$photosize = getimagesize("$photo");
# Get image size and scale ratio
$scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
if ($scale <= 1) {
$width = floor($scale*$photosize[0]);
$height = floor($scale*$photosize[1]);
}
else {
$width = floor($photosize[0]);
$height = floor($photosize[1]);
}
return array($width,$height,$photosize[0],$photosize[1]);
}
}
function getdirs($dir) {
$dirs=array();
chdir($dir);
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".."){
if (is_dir($file)) {
$dirs[] = $file;
}
}
}
closedir($handle);
}
sort($dirs);
return $dirs;
}
function getphotos($photodir) {
global $thumbext;
$photos=array();
if ($handle = opendir($photodir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !eregi(".jpg".$thumbext."$",$file) && eregi(".jpg$",$file)){
$photos[] = $file;
}
}
closedir($handle);
}
sort($photos);
return $photos;
}
function thumb_gallery($photonum) {
global $photos, $photourl, $photodir, $twidth, $theight, $rows, $cols, $showfilename,$showpathname,$linktophoto,$thumbext, $album, $window, $javascript;
if ($photonum>count($photos)-1) {
$photonum=count($photos)-1;
}
if (($photonum)<=0) {
$photonum=0;
}
if(isset($album)) { $query="&album=".urlencode($album); }
for ($tr = 1; $tr <= $rows; $tr++) {
$photobody[]="<tr>";
for ($td = 1; $td <= $cols; $td++) {
$photobody[]="<td align=\"center\">";
if (file_exists($photodir."/".$photos[$photonum].$thumbext)) {
$size=gallery_sizer($photodir."/".$photos[$photonum].$thumbext,$twidth,$theight);
$jswindowsize=gallery_sizer($photodir."/".$photos[$photonum],1,1);
$link = $photourl."/".$photos[$photonum].$thumbext;
if ($linktophoto==1) { $linktarget="http://".$_SERVER[HTTP_HOST].$photourl."/".$photos[$photonum]; } else { $linktarget="http://".$_SERVER[HTTP_HOST].$_SERVER[PHP_SELF]."?p=".urlencode($photos[$photonum]).$query; }
if ($window==1) { if ($javascript==1) { $linktarget='javascript:Popup(\''.$linktarget.'\',\''.($jswindowsize[2]+15).'\',\''.($jswindowsize[3]+15).'\')'; } else { $target="_blank"; } } else { $target="_self"; }
if ($photonum<=count($photos)-1) {
if ($javascript==0) {
$photobody[]="<a href=\"$linktarget\" target=\"$target\">";
}
else { $photobody[]="<a href=\"$linktarget\">"; }
}
$photobody[]="<img src=\"$link\" width=\"$size[2]\" height=\"$size[3]\" alt=\"$photos[$photonum]\" border=\"1\" /></a><br />";
}
if ($photos[$photonum]) {
if ($showfilename==1) { $photobody[]=$photos[$photonum]; }
if ($showpathname==1) { $photobody[]="<br />http://".$_SERVER[HTTP_HOST].$photourl."/".$photos[$photonum]; }
}
$photobody[]="</td>";
$photonum++;
}
$photobody[]="</tr>";
}
unset($tr, $td);
#this is down here for a reason don't move it and use array_unshift instead. Trust me.
if (($photonum-($rows*$cols))>0) { $prev="<a href=\"$_SERVER[PHP_SELF]?pn=".($photonum-(($rows*$cols)*2)).$query."\"><< Vorige Pagina</a>"; }
if (($photonum)<(count($photos))) { $next="<a href=\"$_SERVER[PHP_SELF]?pn=".$photonum.$query."\">Volgende Pagina >></a>"; }
$photopage=array();
$photopage[]="Pagina: ";
for ($pagelink=0, $pagenum=1; $pagelink<=count($photos); $pagelink+=($rows*$cols), $pagenum++) {
$photopage[]="<a href=\"$_SERVER[PHP_SELF]?pn=".($pagelink).$query."\">$pagenum</a> | ";
}
unset($pagelink, $pagenum);
$photopage=implode("", $photopage);
if ($photonum >= count($photos)) { $endnum=count($photos); } else { $endnum=$photonum; }
$photobody[]="<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\">".$prev."</div></td><td width=\"33%\"><div align=\"center\" class=\"caption\">Foto's <strong>".($photonum-(($rows*$cols)-1))."</strong> van <strong>".$endnum."</strong> Totaal: <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\">".$next."</div></td></tr></table></td></tr>";
array_unshift($photobody, "<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\">".$prev."</div></td><td width=\"33%\"><div align=\"center\">Foto's <strong>".($photonum-(($rows*$cols)-1))."</strong> van <strong>".$endnum."</strong> Totaal: <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\">".$next."</div></td></tr></table></td></tr>");
#put the table tag at the top of the array.
array_unshift($photobody, '<table width="100%" border="0" cellspacing="0" cellpadding="3">');
$photobody[]='</table>';
if ($window==1 && $javascript=1) {
array_unshift($photobody, '<SCRIPT language="JavaScript">function Popup(url,width,height) { PopupWindow = window.open (\'\', \'PopupWindow\',\'scrollbars=0,resizable=1,height=\'+height+\',width=\'+width+\',left=100,top=20\'); PopupWindow.focus(); PopupWindow.location.href = url; }</SCRIPT>');
}
return $photobody;
}
function photo_gallery($photo) {
global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $album, $thumbext, $header;
$photobody=array();
if (isset($photo)) {
if(isset($album)) { $query="&album=".urlencode($album); }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\">Volgende Foto ></a>";
$nextphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
if($photos[$key-1]) {
$prevphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\">< Vorige Foto</a>";
$prevphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
}
}
if ($window==1) { $target="<a href=\"javascript:window.close()\">Close Window</a>"; } else { $target="<a href=\"".$_SERVER[HTTP_REFERER]."\"><< Vorige Pagina Page</a>"; }
$size=gallery_sizer("$photodir/$photo",$pwidth,$pheight);
$photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\"></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\"></div></td><td align=\"right\" width=\"33%\"></td></tr>";
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\">".$prevphotothumb.$prevphoto."</td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
if ($header=="NULL") {
if (isset($album)) { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($album)."&p=".$photo."&slide=1\">Start Slideshow</a>\n"; }
else { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photo."&slide=1\">Start Slideshow</a>\n"; }
}
$photobody[]="</div></td><td align=\"right\" width=\"33%\">".$nextphotothumb.$nextphoto."</td></tr>";
$photobody[]='<tr><td colspan="3" align="center">';
$photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';
$photobody[]='</td></tr>';
$photobody[]='</table>';
}
return $photobody;
}
function photo_slides($photo) {
global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $album, $header;
$photobody=array();
if (isset($photo)) {
if(isset($album)) { $query="&album=".urlencode($album); }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"> Volgende </a>";
$nextphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
if($photos[$key-1]) {
$prevphoto="<br /><a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><< Vorige Foto</a>";
$prevphotothumb="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
}
}
}
$size=gallery_sizer("$photodir/$photo",$pwidth,$pheight);
$photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';
$photobody[]="<tr class=\"imageborder\"><td width=\"33%\">".$prevphotothumb.$prevphoto."</td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
if ($header=="NULL") {
if (isset($album)) { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($album)."&p=".$photo."\">Stop Slideshow</a>\n"; }
else { $photobody[]="<a href=\"".$_SERVER[PHP_SELF]."?p=".$photo."\">Stop Slideshow</a>\n"; }
}
$photobody[]="</div></td><td align=\"right\" width=\"33%\">".$nextphotothumb.$nextphoto."</td></tr>";
if ($window==1) { $target="<a href=\"javascript:window.close()\">Close Window</a>"; } else { $target="<a href=\"".$_SERVER[HTTP_REFERER]."\">Back</a>"; }
$photobody[]='<tr><td colspan="3" align="center">';
$photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';
$photobody[]='</td></tr>';
$photobody[]='</table>';
}
return $photobody;
}
function display($photobody) {
global $photodir;
getheader();
echo "";
albums(dirname($_SERVER['SCRIPT_FILENAME']));
echo "<div class=\"photobody\">";
foreach ($photobody as $value) {
echo $value."\n";
}
echo "</div>";
getfooter();
exit;
}
function albums($dir) {
//for now only one level of albums works.
global $album, $title, $photos, $divider, $logo, $photo;
$dirs=getdirs($dir);
if (isset($logo)) { echo $logo; }
if (isset($album)) { echo "<h1>".$album."</h1>"; } else { echo "<center><h1>".$title."</h1></center><p>Foto Albums Beschikbaar</p>"; }
echo "<div class=\"album\"><p>";
if (isset($album) || isset($photo)) { echo "<a href=\"".$_SERVER[PHP_SELF]."\">$title Home</a>$divider\n"; }
else { }
if (count($dirs)>0) {
foreach ($dirs as $value) {
echo "<a href=\"".$_SERVER[PHP_SELF]."?album=".urlencode($value)."\">".$value."</a>$divider\n";
}
}
// echo "<img src=\"" width=\"1\" height=\"1\" alt=\"\" /></p></div>";
echo "</p></div>";
}
//returns the header for the page. Checks for a user defined header.
function getheader() {
global $header, $title, $slide, $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window,$photo, $photos, $album, $stylesheet;
if(isset($album)) { $query="&album=".urlencode($album); }
if ($slide==1) { $query=$query."&slide=1"; }
foreach ($photos as $key => $value) {
if($photo==$value) {
if($photos[$key+1]) {
$nextslide=$_SERVER[PHP_SELF]."?p=".$photos[$key+1].$query;
}
elseif (!$photos[$key+1]) {
$slide=0;
}
}
}
if (isset($header) && $header!="NULL" && is_file ($header)) {
require("$header");
}
else {
echo "\n";
echo '<head>';
echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
echo "\n";
echo "<title>$title</title>\n";
echo '<meta name="Author" content="Blaat" />';
if ($slide==1 && $header=="NULL") { echo "<META HTTP-EQUIV=refresh CONTENT=\"4; URL=".$nextslide." \">"; }
echo '<style type="text/css" media="all">@import "'.$stylesheet.'";</style>';
echo "\n";
echo '</head>';
echo "\n";
echo '<body>';
echo "\n";
echo '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="100%">';
echo '<tr>';
echo '<td width="100%"> </td>';
}
}
//returns the footer for the page. Checks for a user defined footer.
function getfooter() {
global $footer;
if (isset($footer) && $footer!="NULL" && is_file ($footer)) {
require("$footer");
}
else {
echo '</tr>';
echo '</table>';
echo '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">';
echo '<tr>';
echo '<td width="100%" bgcolor="#000000">';
echo '<p align="center"><font color="#FFFFFF"><h2>© testje ©</2></font></td>';
echo '</tr>';
echo '</table>';
echo "</body>\n</html>";
}
}
$photodir=dirname($_SERVER['SCRIPT_FILENAME']);
$photourl=dirname($_SERVER['PHP_SELF']);
$thumbsurl=dirname($_SERVER['PHP_SELF']);
$photobody=array();
if (isset($_GET[album])) {
if (in_array($_GET[album],getdirs(dirname($_SERVER['SCRIPT_FILENAME'])))==FALSE) {
$album = NULL;
}
else {
$album = urldecode($_GET[album]);
}
$photodir=$photodir."/".$album;
$photourl=$photourl."/".$album;
$thumbsurl=$thumbsurl."/".$album;
}
//To make sure this works both on Linux and Win
$photodir = str_replace("\\", "/", $photodir);
//Get the jpegs from the folder.
$photos=getphotos($photodir);
//check to see if thumbnails are made if not it will make. Adds time to the processing of the script.
for ($i=0; $i<=count($photos)-1; $i++) {
thumb_maker($photodir."/".$photos[$i], $twidth, $theight);
}
if (count($photos)<=0) {
$photobody[]="";
display($photobody);
exit;
}
if (isset($_GET[pn])) {
$photonum = $_GET[pn];
$photobody=thumb_gallery($photonum);
}
elseif (isset($_GET[slide])) {
$slide=$_GET[slide];
$photo=urldecode($_GET[p]);
$photobody=photo_slides($photo,$pwidth,$pheight);
}
elseif (isset($_GET[p])) {
$photo=urldecode($_GET[p]);
$photobody=photo_gallery($photo,$pwidth,$pheight);
}
else {
$photobody=thumb_gallery(0);
}
//output it all to the browser.
display($photobody);
exit;
echo '</tr>';
echo '</table>';
?>
Gewijzigd op 23/03/2005 16:35:00 door Thijs X
Have fun
D@rk:
Have fun
?? kan je helpen of niet?
Na 2,5 halve dag lezen kwam ik tot de conclusie dat ik nog geen idee heb....
haha ja is wel lang script ik weet het
maar kheb al geprobeerd om hem in het begin neer te zette maar dan moet ik </table> ook ergens neerzette zodat hij t doet anders krijg ik eerst een lege tabel en dan de fotos :S
echo "<table><tr><td>";
display($photobody);
echo "</td></tr>";
heb het niet geprobeerd... maar is het proberen waard denk ik
hij komt er nog steeds boven de fotos te staan :S
//edit:
een huidig gd script (stats) gebruikt imagerectangle voor een randje om het plaatje... moet je maar ff kijken of je der iets meej kan... :)
Gewijzigd op 23/03/2005 17:38:00 door Johan
maar ik bdoel dat hij een tabel gaat maken om alle thumbnails! gwoon een tabel waar alle thumbnails in worden gegenereerd
Ok laat maar zitte het is al glukt
Werkt perfect!
Niels hb je daar een link van?