MINIGAL MG2: afbeelding wordt niet altijd getoond
Vooreerst enorm bedankt voor jullie eerdere hulp bij probl. in scripts.
Ik heb MG2 ( Minigal) geïnstalleerd en het is de bedoeling dat één of meerdere foto's worden geuploaded, thumb gegenereerd en getoond wordt.
Dat lukt maar niét altijd ?!
Dezelfde foto wordt nu eens wél en dan eens niét getoond.let wél : de afbeelding wordt ALTIJD geuploaded in de correcte dir maar er wordt niet altijd een thumbnail van gemaakt.
Indien er dan wél een thumbnail van wordt gemaakt kan het zijn dat deze dan niet wordt getoond...
Ik zie dit reeds ogenblikkelijk want hij toont de vooruitgang: 'foto werd geïmporteerd','foto niet gevonden' ( = werd dan wél geuploaded!),...
bestandsgrootte is OK...
Wat kan het probleem zijn volgens jullie ?
Alvast bedankt op voorhand !
Fred
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
<?php
//////////////////////////////////////////////////////////////////////////////////
// //
// MG2 //
// A PHP/HTML based image gallery script. //
// //
// Copyright 2005 by Thomas Rybak //
// http://www.minigal.dk //
// [email protected] //
// //
// The script utilises Exif reader v 1.2 (free to use) //
// Exif reader v 1.2 //
// By Richard James Kendall ([email protected]) //
// //
// ----------------- //
// //
// MG2 is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// MG2 is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// TO COMPLY WITH THIS LICENSE, DO NOT REMOVE THE LINK TO THE MINIGAL //
// WEBSITE FROM YOUR GALLERY FRONT PAGE. THIS IS THE LEAST YOU CAN DO TO //
// SUPPORT THE DEVELOPMENT OF MG2! //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, you can find it here: //
// http://www.gnu.org/copyleft/gpl.html //
// //
// ----------------- //
// //
// If you find this script useful, please make a donation via the main //
// website: //
// http://www.minigal.dk //
// //
//////////////////////////////////////////////////////////////////////////////////
class mg2db{
//
// SORT SEARCH RESULTS
//
function sort($datatable,$field,$mode) {
$i_cnt = count($datatable);
for($i=0;$i<$i_cnt;$i++) {
foreach($datatable[$i] as $key => $value) {
$array[$key][$i] = $value;
}
}
$mode == 0 ? asort($array[$field]) : arsort($array[$field]);
$_keys = array_keys($array[$field]);
for($i=0;$i<$i_cnt;$i++) {
foreach($array as $key => $value) {
$_hash[$i][$key] = $array[$key][$_keys[$i]];
}
}
return $_hash;
}
//
// UPDATE DATABASE FROM TEMP FILES
//
function updateDB(){
$iDB = "mg2db_idatabase.php";
$iDB_temp = "mg2db_idatabase_temp.php";
$fDB = "mg2db_fdatabase.php";
$fDB_temp = "mg2db_fdatabase_temp.php";
//OVERWRITE ORIGINAL WITH TEMP FILE IF CHANGED
if (IS_FILE($iDB) && IS_FILE($iDB_temp) && filemtime($iDB) < filemtime($iDB_temp)){
if (!copy($iDB_temp, $iDB)) {
$this->log("ERROR: Failed to copy temporary image database file");
echo "MG2 ERROR: Failed to copy temp file (function 'readDB')";
exit();
}
}
if (IS_FILE($fDB) && IS_FILE($fDB_temp) && filemtime($fDB) < filemtime($fDB_temp)){
if (!copy($fDB_temp, $fDB)) {
$this->log("ERROR: Failed to copy temporary folder database file");
echo "MG2 ERROR: Failed to copy temp file (function 'readDB')";
exit();
}
}
}
//
// READ ENTIRE DATABASE
//
function readdb(){
$iDB = "mg2db_idatabase.php";
$fDB = "mg2db_fdatabase.php";
$this->updateDB();
if (is_file($iDB)){
$fd = fopen($iDB,"r");
$this->autoid = trim(fgets($fd,4096));
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->all_images[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
}else {
$fd = fopen($iDB,"w");
fclose($fd);
}
if (is_file($fDB)){
$fd = fopen($fDB,"r");
$this->folderautoid = trim(fgets($fd,4096));
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->all_folders[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
}else {
$fd = fopen($fDB,"w");
fwrite($fd,"1\n");
fwrite($fd,"*1*root*root*1*0*****");
fclose($fd);
}
}
//
// SELECT ENTRIES FROM DATABASE
//
function select($key,$array,$row,$sortrow,$sortmode){
for ($idx=0; $idx < count($array); $idx++){
if ($array[$idx][$row] == $key) $selectarray[] = $array[$idx];
}
if ($key == "*")
$selectarray = $array;
if (is_array($selectarray))
$selectarray = $this->sort($selectarray,$sortrow,$sortmode);
return $selectarray;
}
function insert($filename="", $folder="1", $password="", $description="", $filesize="", $width="", $height="", $tn_width="", $tn_height="", $filetime=""){
$this->all_images[] = array(($this->autoid+1), $filename, $folder, $password, $description, $filesize, $width, $height, $tn_width, $tn_height, $filetime);
$this->autoid = $this->autoid + 1;
}
//
// WRITE IMAGE DATABASE
//
function write_iDB(){
if (count($this->all_images) > 0) {
unset($buffer);
for ($i=0; $i < count($this->all_images); $i++){
for ($j=0; $j < count($this->all_images[$i]); $j++){
$buffer .= "*" . $this->all_images[$i][$j];
}
$buffer .= "\n";
$fd = fopen("mg2db_idatabase_temp.php","w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $this->autoid . "\n");
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
} else {
$this->log("ERROR: Could not lock image database for writing");
echo "MG2 ERROR: Could not lock temp file (function 'write_iDB')";
}
}
$this->log("Writing image database");
} else $this->log("ERROR: Writing image database - Image array empty!");
}
//
// WRITE FOLDER DATABASE
//
function write_fDB(){
if (count($this->all_folders) > 0) {
unset($buffer);
for ($i=0; $i < count($this->all_folders); $i++){
for ($j=0; $j < count($this->all_folders[$i]); $j++){
$buffer .= "*" . $this->all_folders[$i][$j];
}
$buffer .= "\n";
$fd = fopen("mg2db_fdatabase_temp.php","w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $this->folderautoid . "\n");
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
} else {
$this->log("ERROR: Could not lock folder database file for writing");
echo "MG2 ERROR: Could not lock temp file (function 'write_fDB')";
}
}
$this->log("Writing folder database");
} else $this->log("ERROR: Writing image database - Image array empty!");
}
//
// SEARCH DATABASE FOR FILENAME
//
function inDB($filename){
$search = $this->select($filename,$this->all_images,1,1,0);
if (count($search) == 0){
return false;
} else return true;
}
//
// NEW DATABASE ENTRY
//
function addnew($filename, $folder="1"){
if (is_file("pictures/" . $filename) && $this->inDB == false){
list($width, $height, $type, $attr) = getimagesize("pictures/" . $filename);
$filesize = filesize("pictures/" . $filename);
if (is_file("pictures/" . $this->thumb($filename))){
list($tn_width, $tn_height, $type, $attr) = getimagesize("pictures/" . $this->thumb($filename));
}
$filetime = filectime("pictures/" . $filename);
$this->insert($filename, $folder, $password, $description, $filesize, $width, $height, $tn_width, $tn_height, $filetime);
return true;
} else return false;
}
//
// IMPORT NEW IMAGES
//
function importnewimages(){
$allowed_extensions = explode(",", $this->extensions);
if (!$_REQUEST['list']) $_REQUEST['list'] = "1";
if ($handle = opendir("pictures/")) {
while (false !== ($file = readdir($handle))) {
$fileInfo = pathinfo("pictures/" . $file);
$extension = strtolower($fileInfo["extension"]);
if(is_file("pictures/" . $file) && !$this->inDB($file) && in_array(strtolower($extension), $allowed_extensions) && strpos($file, "_medium") === false && strpos($file, "_thumb") === false){
$this->log("Importing '$file' (" . filesize("pictures/" . $file). " bytes)");
$imported++;
@chmod("pictures/" . $file,0644);
$this->createthumb($file);
$this->log(" * finished creating thumbnails");
$this->addnew($file,$_REQUEST['list']);
$this->log(" * finished adding file to database");
$this->log(" = finished importing '$file'");
}
}
$this->write_iDB();
closedir($handle);
$this->updateDB();
return $imported;
}
}
//
// IMAGE NAVIGATION
//
function imagenavigation($result){
$result = $this->select($result,$this->all_images,2,$this->folder_sortby,$this->folder_sortway);
$folders = $this->select($result[0][2],$this->all_folders,1,0,0);
for($i=0; $i < count($result);$i++){
if ($_REQUEST['id'] == $result[$i][0]){
$this->page = ceil(($i + 1 + count($folders)) / ($this->imagerows * $this->imagecolumns));
$this->nav_current = $i + 1;
break;
}
}
$this->nav_total = count($result);
$navtxt_total = $this->lang['total'];
if ($result[$this->nav_current - 2][0] != "") $this->nav_prev = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_current - 2][0] . "\">" . $this->lang['prev']. "</a>";
else $this->nav_prev = $this->lang['prev'];
if ($result[0][0] != $_REQUEST['id']) $this->nav_first = "<a href=\"" . $this->indexfile . "?id=" . $result[0][0] . "\">" . $this->lang['first']. "</a>";
else $this->nav_first = $this->lang['first'];
if ($result[$this->nav_current][0] != "") $this->nav_next = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_current][0] . "\">" . $this->lang['next']. "</a>";
else $this->nav_next = $this->lang['next'];
if ($this->nav_total != $this->nav_current) $this->nav_last = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_total - 1][0] . "\">" . $this->lang['last']. "</a>";
else $this->nav_last = $this->lang['last'];
}
//
// GALLERY NAVIGATION
//
function gallerynavigation($delimiter){
echo " ";
if ($_REQUEST['list'] != "") $result = $_REQUEST['list'];
if ($_REQUEST['id'] != "") {
$getfolder = $this->select($_REQUEST['id'],$this->all_images,0,1,0);
$result = $getfolder[0][2];
$imgdisplay = 1;
}
while ($result != "1" && $result != ""){
$result = $this->select($result,$this->all_folders,0,1,0);
$folders[] = $result[0][1];
$result = $result[0][1];
}
if ($this->websitelink != "") echo "<a href=\"$this->websitelink\" target=\"_self\">" . $this->lang['website'] . "</a>";
for ($i=count($folders) - 1; $i >= 0; $i--){
if ($folders[$i] == "1"){
if ($this->websitelink != "") echo " $delimiter ";
echo "<a href=\"?list=" . $folders[$i] . "\">" . $this->lang['gallery'] . "</a>";
}else
echo " $delimiter <a href=\"?list=" . $folders[$i] . "\">" . $this->getfoldername($folders[$i]) . "</a>";
}
if ($imgdisplay == 1){
if ($getfolder[0][2] == "1"){
if ($this->websitelink != "") echo " $delimiter ";
echo "<a href=\"?list=" . $folders[$i] . "\">" . $this->lang['gallery'] . "</a>";
}else
echo " $delimiter <a href=\"?list=" . $getfolder[0][2] . "\">" . $this->getfoldername($getfolder[0][2]) . "</a>";
}
}
//
// PAGE NAVIGATION
//
function pagenavigation($pages, $list) {
if ($pages > 1) {
echo "<p align=\"center\">" . $this->lang['page'] . " ";
for ($i=1; $i <= $pages; $i++) {
if ($i == $_REQUEST['page']) {
echo "| $i ";
} else
echo "| <a href=\"" . $this->galleryindex . "?list=$list&page=$i\" target=\"_self\">" . $i . "</a> ";
}
if ($_REQUEST['page'] == "all") {
echo "| " . $this->lang['all'];
} else
echo "| <a href=\"" . $this->galleryindex . "?list=$list&page=all\" target=\"_self\">" . $this->lang['all']. "</a>";
echo "</p>";
}
}
//
// SEARCH IMAGE DATABASE
//
function search_iDB($string, $field){
for ($i=0; $i < count($this->all_images); $i++) {
if ($this->all_images[$i][$field] == $string) {
return $i;
}
}
}
//
// SEARCH FOLDER DATABASE
//
function search_fDB($string, $field){
for ($i=0; $i < count($this->all_folders); $i++) {
if ($this->all_folders[$i][$field] == $string) {
return $i;
}
}
}
//
// DETERMINE THUMBNAIL
//
function getthumb($folder){
unset($this->subfolder_class);
unset($this->icon_comp);
$subfiles = $this->select($folder,$this->all_images,2,1,0);
$subfolders = $this->select($folder,$this->all_folders,1,1,0);
$currentfolder = $this->select($folder,$this->all_folders,0,1,0);
// DOES STANDARD THUMB EXIST?
if ($currentfolder[0][7] != "") {
if ($this->foldericons == 1) {
$this->width = 150;
$this->height = 100;
$icon_comp = 2;
$this->subfolder_class = "subfolder";
return "skins/$this->activeskin/images/folder.gif";
}
$this->width = $currentfolder[0][8];
$this->height = $currentfolder[0][9];
$this->subfolder_class = "subfolder border";
return "pictures/" . $currentfolder[0][7];
}
// IS FOLDER LOCKED?
else if ($currentfolder[0][5] != "") {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/locked.gif";
}
// DOES FOLDER CONTAIN IMAGES?
if (count($subfiles) > 0){
if ($this->foldericons == 1) {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/folder.gif";
}
$random = array_rand($subfiles);
$this->width = $subfiles[$random][8];
$this->height = $subfiles[$random][9];
$this->subfolder_class = "subfolder border";
return "pictures/" . $this->thumb($subfiles[$random][1]);
// DOES FOLDER CONTAIN FOLDERS?
}else if (count($subfolders) > 0) {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/folder.gif";
}
// FOLDER IS EMPTY
else{
$this->width = "150";
$this->height = "100";
$this->subfolder_class = "subfolder";
$this->icon_comp = 2;
return "skins/$this->activeskin/images/emptyfolder.gif";
}
}
//
// READ FOLDER SORTING SETTINGS
//
function getfoldersettings($list){
$this->folder_pwd = 0;
$result = $this->select($list,$this->all_folders,0,0,0);
if($result[0][3] == "") $this->folder_sortby = 1;
else $this->folder_sortby = $result[0][3];
if($result[0][4] == "") $this->folder_sortway = 1;
else $this->folder_sortway = $result[0][4];
$this->introtext = $result[0][10];
if($result[0][5] != "") $this->folder_pwd = 1;
}
//
// DELETE DATABASE ENTRY
//
function array_delete ( $array, $index ) {
if ( is_array ( $array ) ) {
unset ( $array[$index] );
array_unshift ( $array, array_shift ( $array ) );
return $array;
}
else {
return false;
}
$this->log("Database entry deleted");
}
//
// DECIMAL TO FRACTION
//
function dec2frac( $decimal ) {
$decimal = (string)$decimal;
$num = '';
$den = 1;
$dec = false;
// find least reduced fractional form of number
for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ )
{
// build the denominator as we 'shift' the decimal to the right
if( $dec ) $den *= 10;
// find the decimal place/ build the numberator
if( $decimal{$i} == '.' ) $dec = true;
else $num .= $decimal{$i};
}
$num = (int)$num;
// whole number, just return it
if( $den == 1 ) return $num;
$num2 = $num;
$den2 = $den;
$rem = 1;
// Euclid's Algorithm (to find the gcd)
while( $num2 % $den2 ) {
$rem = $num2 % $den2;
$num2 = $den2;
$den2 = $rem;
}
if( $den2 != $den ) $rem = $den2;
// now $rem holds the gcd of the numerator and denominator of our fraction
return ($num / $rem ) . "/" . ($den / $rem);
}
//
// GET GD LIB VERSION
//
function gd_version() {
$gdInfo = gd_info();
$this->gd_version_number = trim(ereg_replace("[A-Za-z()]", "", $gdInfo["GD Version"]));
return $this->gd_version_number;
}
//
// GET FOLDER NAME
//
function getfoldername($id) {
$result = $this->select($id,$this->all_folders,0,1,0);
if ($result[0][2] == "1") $result[0][2] = "root";
return $result[0][2];
}
//
// SUBGALLERY SECURITY
//
function gallerysecurity($folderpassword) {
if (md5(strrev(md5($_REQUEST["password"]))) == $folderpassword) {
$_SESSION["folderpassword"] = md5(strrev(md5($_REQUEST["password"])));
}else if ($_SESSION["folderpassword"] == $folderpassword) {
}else if ($folderpassword != "" && md5(strrev(md5($_REQUEST["password"]))) != $folderpassword) {
include("skins/$this->activeskin/templates/thumbnails_password.php");
exit();
}
}
function charfix($string) {
$string = str_replace("*","#",$string);
$string = str_replace(chr(92).chr(34),""",$string);
$string = str_replace("\'","'",$string);
$string = str_replace(chr(34),""",$string);
return $string;
}
function readcomments($filename) {
if (is_file($filename)){
$fd = fopen($filename,"r");
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->comments[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
$this->comments = $this->sort($this->comments,0,1);
$this->log("Read file comments from '$filename'");
}
}
function writecomments($filename) {
$filename = "pictures/" . $filename;
unset($buffer);
if (count($this->comments) != 0) {
for ($i=0; $i < count($this->comments); $i++){
for ($j=0; $j < count($this->comments[$i]); $j++){
$buffer .= "*" . $this->comments[$i][$j];
}
$buffer .= "\n";
$fd = fopen($filename,"w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
$this->log("Wrote comment to '$filename'");
} else {
$this->log("ERROR: Could not lock commentfile '$filename' for writing");
echo "MG2 ERROR: Could not lock $filename (function 'writecomments')";
}
}
} else unlink($filename);
}
function addcomment() {
$_REQUEST['filename'] = $this->charfix($_REQUEST['filename']);
$_REQUEST['input'] = $this->charfix($_REQUEST['input']);
$_REQUEST['email'] = $this->charfix($_REQUEST['email']);
$_REQUEST['name'] = $this->charfix($_REQUEST['name']);
$_REQUEST['input'] = strip_tags($_REQUEST['input'], "<b></b><i></i><u></u><strong></strong><em></em>");
$_REQUEST['input'] = str_replace("\n","<br />",$_REQUEST['input']);
$_REQUEST['input'] = str_replace("\r","",$_REQUEST['input']);
if ($_REQUEST['input'] != "" && $_REQUEST['name'] != "" && $_REQUEST['email'] != "") {
$this->readcomments("pictures/" . $_REQUEST['filename'] . ".comment");
$comment_exists = $this->select($_REQUEST['input'],$this->comments,3,1,0);
$comment_exists = $this->select($_REQUEST['name'],$comment_exists,1,1,0);
$comment_exists = $this->select($_REQUEST['email'],$comment_exists,2,1,0);
if (count($comment_exists) == 0) {
$this->comments[] = array(time(), $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['input']);
$this->writecomments($_REQUEST['filename'] . ".comment");
// SEND COMMENT EMAIL
if ($this->sendmail == 1) {
mail($this->adminemail, $this->gallerytitle . ": " . $this->lang['commentadded'], strtoupper($this->lang['from']) . ":\n" . $_REQUEST['name'] . "(" . $_REQUEST['email'] . ")\n\n" . strtoupper($this->lang['comment']) . ":\n" . str_replace("<br />", "\n",$_REQUEST['input']) . "\n\n" . "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "?id=" . $_REQUEST['id'], "From: " . $_REQUEST["email"] . "\nReply-to: " . $_REQUEST["email"]);
$this->log("Sent comment email");
}
echo "<div align=\"center\"><strong><b>" . $this->lang['commentadded'] . "</b></strong></div>";
} else echo "<div align=\"center\"><strong><b>" . $this->lang['commentexists'] . "</b></strong></div>";
} else echo "<div align=\"center\"><strong><b>" . $this->lang['commentmissing'] . "</b></strong></div>";
unset($this->comments);
}
function getlanguages() {
$workdir = opendir("lang");
while (false !== ($pointer = readdir($workdir))) {
if ($pointer !== "." && $pointer !== "..") {
$this->languages[] = ucfirst(substr($pointer,0,(strlen($pointer)-4)));
}
}
sort($this->languages);
}
function output($var) {
if (isset($this->$var)) {
echo $this->$var;
} else echo "No data (" . $var . ")";
}
function log($entry) {
$logfile = "mg2_log.txt";
// DELETE LARGE LOG FILE
if (is_file($logfile) && filesize($logfile) > 300000) unlink($logfile);
// CREATE NEW LOGFILE
if (!is_file($logfile)) {
$fd = fopen($logfile,"a+");
fwrite($fd,"MG2 LFS (Log File System)\n\n");
fwrite($fd,"Version: " . $this->version . "\n");
fwrite($fd,"Install date: " . date("Y-m-d",$this->installdate) . "\n\n---LOG BEGIN------------------\n\n");
fwrite($fd,date("Ymd, H.i.s : ") . $entry . "\n");
} else {
$fd = fopen($logfile,"a+");
fwrite($fd,date("Ymd, H.i.s : ") . $entry . "\n");
}
}
function medium($name) {
$ext = strrchr($name, '.');
if($ext !== false) {
$name = substr($name, 0, -strlen($ext)) . "_medium." . end(explode('.',$name));
}
return $name;
}
function thumb($name) {
$ext = strrchr($name, '.');
if($ext !== false) {
$name = substr($name, 0, -strlen($ext)) . "_thumb." . end(explode('.',$name));
}
return $name;
}
function name_remove($name) {
$name = str_replace("_medium", "", $name);
$name = str_replace("_thumb", "", $name);
return $name;
}
}
?>
//////////////////////////////////////////////////////////////////////////////////
// //
// MG2 //
// A PHP/HTML based image gallery script. //
// //
// Copyright 2005 by Thomas Rybak //
// http://www.minigal.dk //
// [email protected] //
// //
// The script utilises Exif reader v 1.2 (free to use) //
// Exif reader v 1.2 //
// By Richard James Kendall ([email protected]) //
// //
// ----------------- //
// //
// MG2 is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// MG2 is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// TO COMPLY WITH THIS LICENSE, DO NOT REMOVE THE LINK TO THE MINIGAL //
// WEBSITE FROM YOUR GALLERY FRONT PAGE. THIS IS THE LEAST YOU CAN DO TO //
// SUPPORT THE DEVELOPMENT OF MG2! //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, you can find it here: //
// http://www.gnu.org/copyleft/gpl.html //
// //
// ----------------- //
// //
// If you find this script useful, please make a donation via the main //
// website: //
// http://www.minigal.dk //
// //
//////////////////////////////////////////////////////////////////////////////////
class mg2db{
//
// SORT SEARCH RESULTS
//
function sort($datatable,$field,$mode) {
$i_cnt = count($datatable);
for($i=0;$i<$i_cnt;$i++) {
foreach($datatable[$i] as $key => $value) {
$array[$key][$i] = $value;
}
}
$mode == 0 ? asort($array[$field]) : arsort($array[$field]);
$_keys = array_keys($array[$field]);
for($i=0;$i<$i_cnt;$i++) {
foreach($array as $key => $value) {
$_hash[$i][$key] = $array[$key][$_keys[$i]];
}
}
return $_hash;
}
//
// UPDATE DATABASE FROM TEMP FILES
//
function updateDB(){
$iDB = "mg2db_idatabase.php";
$iDB_temp = "mg2db_idatabase_temp.php";
$fDB = "mg2db_fdatabase.php";
$fDB_temp = "mg2db_fdatabase_temp.php";
//OVERWRITE ORIGINAL WITH TEMP FILE IF CHANGED
if (IS_FILE($iDB) && IS_FILE($iDB_temp) && filemtime($iDB) < filemtime($iDB_temp)){
if (!copy($iDB_temp, $iDB)) {
$this->log("ERROR: Failed to copy temporary image database file");
echo "MG2 ERROR: Failed to copy temp file (function 'readDB')";
exit();
}
}
if (IS_FILE($fDB) && IS_FILE($fDB_temp) && filemtime($fDB) < filemtime($fDB_temp)){
if (!copy($fDB_temp, $fDB)) {
$this->log("ERROR: Failed to copy temporary folder database file");
echo "MG2 ERROR: Failed to copy temp file (function 'readDB')";
exit();
}
}
}
//
// READ ENTIRE DATABASE
//
function readdb(){
$iDB = "mg2db_idatabase.php";
$fDB = "mg2db_fdatabase.php";
$this->updateDB();
if (is_file($iDB)){
$fd = fopen($iDB,"r");
$this->autoid = trim(fgets($fd,4096));
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->all_images[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
}else {
$fd = fopen($iDB,"w");
fclose($fd);
}
if (is_file($fDB)){
$fd = fopen($fDB,"r");
$this->folderautoid = trim(fgets($fd,4096));
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->all_folders[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
}else {
$fd = fopen($fDB,"w");
fwrite($fd,"1\n");
fwrite($fd,"*1*root*root*1*0*****");
fclose($fd);
}
}
//
// SELECT ENTRIES FROM DATABASE
//
function select($key,$array,$row,$sortrow,$sortmode){
for ($idx=0; $idx < count($array); $idx++){
if ($array[$idx][$row] == $key) $selectarray[] = $array[$idx];
}
if ($key == "*")
$selectarray = $array;
if (is_array($selectarray))
$selectarray = $this->sort($selectarray,$sortrow,$sortmode);
return $selectarray;
}
function insert($filename="", $folder="1", $password="", $description="", $filesize="", $width="", $height="", $tn_width="", $tn_height="", $filetime=""){
$this->all_images[] = array(($this->autoid+1), $filename, $folder, $password, $description, $filesize, $width, $height, $tn_width, $tn_height, $filetime);
$this->autoid = $this->autoid + 1;
}
//
// WRITE IMAGE DATABASE
//
function write_iDB(){
if (count($this->all_images) > 0) {
unset($buffer);
for ($i=0; $i < count($this->all_images); $i++){
for ($j=0; $j < count($this->all_images[$i]); $j++){
$buffer .= "*" . $this->all_images[$i][$j];
}
$buffer .= "\n";
$fd = fopen("mg2db_idatabase_temp.php","w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $this->autoid . "\n");
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
} else {
$this->log("ERROR: Could not lock image database for writing");
echo "MG2 ERROR: Could not lock temp file (function 'write_iDB')";
}
}
$this->log("Writing image database");
} else $this->log("ERROR: Writing image database - Image array empty!");
}
//
// WRITE FOLDER DATABASE
//
function write_fDB(){
if (count($this->all_folders) > 0) {
unset($buffer);
for ($i=0; $i < count($this->all_folders); $i++){
for ($j=0; $j < count($this->all_folders[$i]); $j++){
$buffer .= "*" . $this->all_folders[$i][$j];
}
$buffer .= "\n";
$fd = fopen("mg2db_fdatabase_temp.php","w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $this->folderautoid . "\n");
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
} else {
$this->log("ERROR: Could not lock folder database file for writing");
echo "MG2 ERROR: Could not lock temp file (function 'write_fDB')";
}
}
$this->log("Writing folder database");
} else $this->log("ERROR: Writing image database - Image array empty!");
}
//
// SEARCH DATABASE FOR FILENAME
//
function inDB($filename){
$search = $this->select($filename,$this->all_images,1,1,0);
if (count($search) == 0){
return false;
} else return true;
}
//
// NEW DATABASE ENTRY
//
function addnew($filename, $folder="1"){
if (is_file("pictures/" . $filename) && $this->inDB == false){
list($width, $height, $type, $attr) = getimagesize("pictures/" . $filename);
$filesize = filesize("pictures/" . $filename);
if (is_file("pictures/" . $this->thumb($filename))){
list($tn_width, $tn_height, $type, $attr) = getimagesize("pictures/" . $this->thumb($filename));
}
$filetime = filectime("pictures/" . $filename);
$this->insert($filename, $folder, $password, $description, $filesize, $width, $height, $tn_width, $tn_height, $filetime);
return true;
} else return false;
}
//
// IMPORT NEW IMAGES
//
function importnewimages(){
$allowed_extensions = explode(",", $this->extensions);
if (!$_REQUEST['list']) $_REQUEST['list'] = "1";
if ($handle = opendir("pictures/")) {
while (false !== ($file = readdir($handle))) {
$fileInfo = pathinfo("pictures/" . $file);
$extension = strtolower($fileInfo["extension"]);
if(is_file("pictures/" . $file) && !$this->inDB($file) && in_array(strtolower($extension), $allowed_extensions) && strpos($file, "_medium") === false && strpos($file, "_thumb") === false){
$this->log("Importing '$file' (" . filesize("pictures/" . $file). " bytes)");
$imported++;
@chmod("pictures/" . $file,0644);
$this->createthumb($file);
$this->log(" * finished creating thumbnails");
$this->addnew($file,$_REQUEST['list']);
$this->log(" * finished adding file to database");
$this->log(" = finished importing '$file'");
}
}
$this->write_iDB();
closedir($handle);
$this->updateDB();
return $imported;
}
}
//
// IMAGE NAVIGATION
//
function imagenavigation($result){
$result = $this->select($result,$this->all_images,2,$this->folder_sortby,$this->folder_sortway);
$folders = $this->select($result[0][2],$this->all_folders,1,0,0);
for($i=0; $i < count($result);$i++){
if ($_REQUEST['id'] == $result[$i][0]){
$this->page = ceil(($i + 1 + count($folders)) / ($this->imagerows * $this->imagecolumns));
$this->nav_current = $i + 1;
break;
}
}
$this->nav_total = count($result);
$navtxt_total = $this->lang['total'];
if ($result[$this->nav_current - 2][0] != "") $this->nav_prev = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_current - 2][0] . "\">" . $this->lang['prev']. "</a>";
else $this->nav_prev = $this->lang['prev'];
if ($result[0][0] != $_REQUEST['id']) $this->nav_first = "<a href=\"" . $this->indexfile . "?id=" . $result[0][0] . "\">" . $this->lang['first']. "</a>";
else $this->nav_first = $this->lang['first'];
if ($result[$this->nav_current][0] != "") $this->nav_next = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_current][0] . "\">" . $this->lang['next']. "</a>";
else $this->nav_next = $this->lang['next'];
if ($this->nav_total != $this->nav_current) $this->nav_last = "<a href=\"" . $this->indexfile . "?id=" . $result[$this->nav_total - 1][0] . "\">" . $this->lang['last']. "</a>";
else $this->nav_last = $this->lang['last'];
}
//
// GALLERY NAVIGATION
//
function gallerynavigation($delimiter){
echo " ";
if ($_REQUEST['list'] != "") $result = $_REQUEST['list'];
if ($_REQUEST['id'] != "") {
$getfolder = $this->select($_REQUEST['id'],$this->all_images,0,1,0);
$result = $getfolder[0][2];
$imgdisplay = 1;
}
while ($result != "1" && $result != ""){
$result = $this->select($result,$this->all_folders,0,1,0);
$folders[] = $result[0][1];
$result = $result[0][1];
}
if ($this->websitelink != "") echo "<a href=\"$this->websitelink\" target=\"_self\">" . $this->lang['website'] . "</a>";
for ($i=count($folders) - 1; $i >= 0; $i--){
if ($folders[$i] == "1"){
if ($this->websitelink != "") echo " $delimiter ";
echo "<a href=\"?list=" . $folders[$i] . "\">" . $this->lang['gallery'] . "</a>";
}else
echo " $delimiter <a href=\"?list=" . $folders[$i] . "\">" . $this->getfoldername($folders[$i]) . "</a>";
}
if ($imgdisplay == 1){
if ($getfolder[0][2] == "1"){
if ($this->websitelink != "") echo " $delimiter ";
echo "<a href=\"?list=" . $folders[$i] . "\">" . $this->lang['gallery'] . "</a>";
}else
echo " $delimiter <a href=\"?list=" . $getfolder[0][2] . "\">" . $this->getfoldername($getfolder[0][2]) . "</a>";
}
}
//
// PAGE NAVIGATION
//
function pagenavigation($pages, $list) {
if ($pages > 1) {
echo "<p align=\"center\">" . $this->lang['page'] . " ";
for ($i=1; $i <= $pages; $i++) {
if ($i == $_REQUEST['page']) {
echo "| $i ";
} else
echo "| <a href=\"" . $this->galleryindex . "?list=$list&page=$i\" target=\"_self\">" . $i . "</a> ";
}
if ($_REQUEST['page'] == "all") {
echo "| " . $this->lang['all'];
} else
echo "| <a href=\"" . $this->galleryindex . "?list=$list&page=all\" target=\"_self\">" . $this->lang['all']. "</a>";
echo "</p>";
}
}
//
// SEARCH IMAGE DATABASE
//
function search_iDB($string, $field){
for ($i=0; $i < count($this->all_images); $i++) {
if ($this->all_images[$i][$field] == $string) {
return $i;
}
}
}
//
// SEARCH FOLDER DATABASE
//
function search_fDB($string, $field){
for ($i=0; $i < count($this->all_folders); $i++) {
if ($this->all_folders[$i][$field] == $string) {
return $i;
}
}
}
//
// DETERMINE THUMBNAIL
//
function getthumb($folder){
unset($this->subfolder_class);
unset($this->icon_comp);
$subfiles = $this->select($folder,$this->all_images,2,1,0);
$subfolders = $this->select($folder,$this->all_folders,1,1,0);
$currentfolder = $this->select($folder,$this->all_folders,0,1,0);
// DOES STANDARD THUMB EXIST?
if ($currentfolder[0][7] != "") {
if ($this->foldericons == 1) {
$this->width = 150;
$this->height = 100;
$icon_comp = 2;
$this->subfolder_class = "subfolder";
return "skins/$this->activeskin/images/folder.gif";
}
$this->width = $currentfolder[0][8];
$this->height = $currentfolder[0][9];
$this->subfolder_class = "subfolder border";
return "pictures/" . $currentfolder[0][7];
}
// IS FOLDER LOCKED?
else if ($currentfolder[0][5] != "") {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/locked.gif";
}
// DOES FOLDER CONTAIN IMAGES?
if (count($subfiles) > 0){
if ($this->foldericons == 1) {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/folder.gif";
}
$random = array_rand($subfiles);
$this->width = $subfiles[$random][8];
$this->height = $subfiles[$random][9];
$this->subfolder_class = "subfolder border";
return "pictures/" . $this->thumb($subfiles[$random][1]);
// DOES FOLDER CONTAIN FOLDERS?
}else if (count($subfolders) > 0) {
$this->width = 150;
$this->height = 100;
$this->subfolder_class = "subfolder";
$icon_comp = 2;
return "skins/$this->activeskin/images/folder.gif";
}
// FOLDER IS EMPTY
else{
$this->width = "150";
$this->height = "100";
$this->subfolder_class = "subfolder";
$this->icon_comp = 2;
return "skins/$this->activeskin/images/emptyfolder.gif";
}
}
//
// READ FOLDER SORTING SETTINGS
//
function getfoldersettings($list){
$this->folder_pwd = 0;
$result = $this->select($list,$this->all_folders,0,0,0);
if($result[0][3] == "") $this->folder_sortby = 1;
else $this->folder_sortby = $result[0][3];
if($result[0][4] == "") $this->folder_sortway = 1;
else $this->folder_sortway = $result[0][4];
$this->introtext = $result[0][10];
if($result[0][5] != "") $this->folder_pwd = 1;
}
//
// DELETE DATABASE ENTRY
//
function array_delete ( $array, $index ) {
if ( is_array ( $array ) ) {
unset ( $array[$index] );
array_unshift ( $array, array_shift ( $array ) );
return $array;
}
else {
return false;
}
$this->log("Database entry deleted");
}
//
// DECIMAL TO FRACTION
//
function dec2frac( $decimal ) {
$decimal = (string)$decimal;
$num = '';
$den = 1;
$dec = false;
// find least reduced fractional form of number
for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ )
{
// build the denominator as we 'shift' the decimal to the right
if( $dec ) $den *= 10;
// find the decimal place/ build the numberator
if( $decimal{$i} == '.' ) $dec = true;
else $num .= $decimal{$i};
}
$num = (int)$num;
// whole number, just return it
if( $den == 1 ) return $num;
$num2 = $num;
$den2 = $den;
$rem = 1;
// Euclid's Algorithm (to find the gcd)
while( $num2 % $den2 ) {
$rem = $num2 % $den2;
$num2 = $den2;
$den2 = $rem;
}
if( $den2 != $den ) $rem = $den2;
// now $rem holds the gcd of the numerator and denominator of our fraction
return ($num / $rem ) . "/" . ($den / $rem);
}
//
// GET GD LIB VERSION
//
function gd_version() {
$gdInfo = gd_info();
$this->gd_version_number = trim(ereg_replace("[A-Za-z()]", "", $gdInfo["GD Version"]));
return $this->gd_version_number;
}
//
// GET FOLDER NAME
//
function getfoldername($id) {
$result = $this->select($id,$this->all_folders,0,1,0);
if ($result[0][2] == "1") $result[0][2] = "root";
return $result[0][2];
}
//
// SUBGALLERY SECURITY
//
function gallerysecurity($folderpassword) {
if (md5(strrev(md5($_REQUEST["password"]))) == $folderpassword) {
$_SESSION["folderpassword"] = md5(strrev(md5($_REQUEST["password"])));
}else if ($_SESSION["folderpassword"] == $folderpassword) {
}else if ($folderpassword != "" && md5(strrev(md5($_REQUEST["password"]))) != $folderpassword) {
include("skins/$this->activeskin/templates/thumbnails_password.php");
exit();
}
}
function charfix($string) {
$string = str_replace("*","#",$string);
$string = str_replace(chr(92).chr(34),""",$string);
$string = str_replace("\'","'",$string);
$string = str_replace(chr(34),""",$string);
return $string;
}
function readcomments($filename) {
if (is_file($filename)){
$fd = fopen($filename,"r");
while (!feof ($fd)) {
if(fgets($fd,2) == "*")
$this->comments[] = fgetcsv($fd,4096,"*");
}
fclose($fd);
$this->comments = $this->sort($this->comments,0,1);
$this->log("Read file comments from '$filename'");
}
}
function writecomments($filename) {
$filename = "pictures/" . $filename;
unset($buffer);
if (count($this->comments) != 0) {
for ($i=0; $i < count($this->comments); $i++){
for ($j=0; $j < count($this->comments[$i]); $j++){
$buffer .= "*" . $this->comments[$i][$j];
}
$buffer .= "\n";
$fd = fopen($filename,"w+");
if (flock($fd, LOCK_EX)) { // do an exclusive lock
ftruncate($fd, 0);
fwrite($fd, $buffer);
flock($fd, LOCK_UN); // release the lock
fclose($fd);
$this->log("Wrote comment to '$filename'");
} else {
$this->log("ERROR: Could not lock commentfile '$filename' for writing");
echo "MG2 ERROR: Could not lock $filename (function 'writecomments')";
}
}
} else unlink($filename);
}
function addcomment() {
$_REQUEST['filename'] = $this->charfix($_REQUEST['filename']);
$_REQUEST['input'] = $this->charfix($_REQUEST['input']);
$_REQUEST['email'] = $this->charfix($_REQUEST['email']);
$_REQUEST['name'] = $this->charfix($_REQUEST['name']);
$_REQUEST['input'] = strip_tags($_REQUEST['input'], "<b></b><i></i><u></u><strong></strong><em></em>");
$_REQUEST['input'] = str_replace("\n","<br />",$_REQUEST['input']);
$_REQUEST['input'] = str_replace("\r","",$_REQUEST['input']);
if ($_REQUEST['input'] != "" && $_REQUEST['name'] != "" && $_REQUEST['email'] != "") {
$this->readcomments("pictures/" . $_REQUEST['filename'] . ".comment");
$comment_exists = $this->select($_REQUEST['input'],$this->comments,3,1,0);
$comment_exists = $this->select($_REQUEST['name'],$comment_exists,1,1,0);
$comment_exists = $this->select($_REQUEST['email'],$comment_exists,2,1,0);
if (count($comment_exists) == 0) {
$this->comments[] = array(time(), $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['input']);
$this->writecomments($_REQUEST['filename'] . ".comment");
// SEND COMMENT EMAIL
if ($this->sendmail == 1) {
mail($this->adminemail, $this->gallerytitle . ": " . $this->lang['commentadded'], strtoupper($this->lang['from']) . ":\n" . $_REQUEST['name'] . "(" . $_REQUEST['email'] . ")\n\n" . strtoupper($this->lang['comment']) . ":\n" . str_replace("<br />", "\n",$_REQUEST['input']) . "\n\n" . "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "?id=" . $_REQUEST['id'], "From: " . $_REQUEST["email"] . "\nReply-to: " . $_REQUEST["email"]);
$this->log("Sent comment email");
}
echo "<div align=\"center\"><strong><b>" . $this->lang['commentadded'] . "</b></strong></div>";
} else echo "<div align=\"center\"><strong><b>" . $this->lang['commentexists'] . "</b></strong></div>";
} else echo "<div align=\"center\"><strong><b>" . $this->lang['commentmissing'] . "</b></strong></div>";
unset($this->comments);
}
function getlanguages() {
$workdir = opendir("lang");
while (false !== ($pointer = readdir($workdir))) {
if ($pointer !== "." && $pointer !== "..") {
$this->languages[] = ucfirst(substr($pointer,0,(strlen($pointer)-4)));
}
}
sort($this->languages);
}
function output($var) {
if (isset($this->$var)) {
echo $this->$var;
} else echo "No data (" . $var . ")";
}
function log($entry) {
$logfile = "mg2_log.txt";
// DELETE LARGE LOG FILE
if (is_file($logfile) && filesize($logfile) > 300000) unlink($logfile);
// CREATE NEW LOGFILE
if (!is_file($logfile)) {
$fd = fopen($logfile,"a+");
fwrite($fd,"MG2 LFS (Log File System)\n\n");
fwrite($fd,"Version: " . $this->version . "\n");
fwrite($fd,"Install date: " . date("Y-m-d",$this->installdate) . "\n\n---LOG BEGIN------------------\n\n");
fwrite($fd,date("Ymd, H.i.s : ") . $entry . "\n");
} else {
$fd = fopen($logfile,"a+");
fwrite($fd,date("Ymd, H.i.s : ") . $entry . "\n");
}
}
function medium($name) {
$ext = strrchr($name, '.');
if($ext !== false) {
$name = substr($name, 0, -strlen($ext)) . "_medium." . end(explode('.',$name));
}
return $name;
}
function thumb($name) {
$ext = strrchr($name, '.');
if($ext !== false) {
$name = substr($name, 0, -strlen($ext)) . "_thumb." . end(explode('.',$name));
}
return $name;
}
function name_remove($name) {
$name = str_replace("_medium", "", $name);
$name = str_replace("_thumb", "", $name);
return $name;
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Fred
Is dit phpafhaalrestaurant ofzo?
Relevante code svp.
In elk geval bedankt om te helpen !!
Fred