-
Notifications
You must be signed in to change notification settings - Fork 0
/
gallery.inc.php
2051 lines (1774 loc) · 74.3 KB
/
gallery.inc.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
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Gallery Funktionen
*
* Beinhaltet alle Funktionen der Gallery.
* @TODO Move LAYOUT FUNCTIONS to Template Engine
* @TODO Wasserzeichen(?)
*
* @version 3.5
* @since 1.0 `[z]biko` File added
* @since 2.0 Added code documentations, polished & optimized various functions
* @since 3.0 `09.08.2018` `IneX` Refactored picPath() & createPic(), added APOD specific specials
* @since 3.5 `24.12.2023` `IneX` Code optimizations and refactorings
*
* @package zorg\Gallery
*/
/**
* Configs
*
* set_time_limit Maximale Zeit in Sekunden, welche das Script laufen darf
*/
set_time_limit(600);
/**
* File includes
* @include config.inc.php
* @include forum.inc.php
* @include util.inc.php DISABLED is part of config.inc.php
* @include usersystem.inc.php
*/
require_once __DIR__.'/config.inc.php';
include_once INCLUDES_DIR.'forum.inc.php';
require_once INCLUDES_DIR.'usersystem.inc.php';
/**
* Globals
* @const ZENSUR SQL-Query addition if the User is a Member (it can see censored Pics), otherwise filter them out.
* @const THUMBPAGE The number of Thumbnail pictures per column and page (rows) when rendering the layout
*/
define('ZENSUR', ($user->typ >= USER_MEMBER ? '' : 'AND p.zensur="0"'));
define('THUMBPAGE', ['cols'=>4, 'rows'=>3, 'padding'=>10]);
// ********************************** LAYOUT FUNCTIONS ***************************************************************************
/**
* Gallery Hauptseite anzeigen
*
* Zeigt die Gallery-Übersicht mit allen Alben
*
* @version 1.5
* @since 1.0 `[z]biko` function added
* @since 1.5 `24.12.2023` `IneX` Optimizations and refactorings
*
* @uses USER_MEMBER, ZENSUR
* @param string $state Aktueller Status des Albums, z.B. wenn es gerade bearbeitet wird
* @param string $error (Fehler-)Meldung, welche auf der Gallery-Seite angezeigt werden soll
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $user Globales Class-Object mit den User-Methoden & Variablen
* @global object $smarty Globales Class-Object mit allen Smarty-Methoden
* @return string HTML-Code der Gallery-Seite
*/
function galleryOverview ($state="", $error="")
{
global $db, $user, $smarty;
/** Error Output (function backwards compatibility) */
if ((isset($state) || isset($error)) && $user->typ >= USER_MEMBER)
{
$smarty->assign('error', ['type' => 'warn', 'dismissable' => 'false', 'title' => (isset($state) ? $state : $error), 'message' => (isset($error) ? $error : '')]);
}
$sidebarHtml = null;
/* Galleries Query */
$sql = 'SELECT
a.id
, a.name
, COUNT(p.id) anz
, UNIX_TIMESTAMP(created) AS created_at
FROM gallery_albums a, gallery_pics p
WHERE p.album = a.id '.ZENSUR.'
GROUP BY p.album
ORDER BY name ASC, created_at DESC';
$query = $db->query($sql, __FILE__, __LINE__, __FUNCTION__);
$numresult = $db->num($query);
if ($numresult > 0)
{
while ($d = $db->fetch($query))
{
$alphabeticalGroup = strtolower(mb_substr($d['name'], 0, 1));
$alphabeticalList[$alphabeticalGroup][] = [
'id' => $d['id']
,'name' => $d['name']
,'created' => ($d['created_at'] === '0000-00-00 00:00:00' ? '' : $d['created_at'])
,'numpics' => $d['anz']
];
$seen[] = $d['id']; // Add Gallery-ID to 'seen'-List
}
/* List of Galleries */
$smarty->assign('galleriesIdList', $seen);
$smarty->assign('galleriesOverviewGrouped', $alphabeticalList);
/* List empty Galleries */
if ($user->typ >= USER_MEMBER)
{
$emptylistSqlWhere = null;
foreach ($seen as $key => $galleryid) {
if ($key === array_key_first($seen)) $emptylistSqlWhere .= 'WHERE id NOT IN (';
$emptylistSqlWhere .= $galleryid.($key != array_key_last($seen) ? ',' : ')');
}
//$where = substr($where, 0, -5);
$emptylistSql = 'SELECT id, name, UNIX_TIMESTAMP(created) AS created_at FROM gallery_albums'.(!empty($emptylistSqlWhere) ? ' '.$emptylistSqlWhere : '');
$result = $db->query($emptylistSql, __FILE__, __LINE__, __FUNCTION__);
$numempty = $db->num($result);
if ($numempty > 0)
{
while ($rs = $db->fetch($result))
{
$emptyGalleriesList[] = [
'id' => $rs['id']
,'name' => $rs['name']
,'created' => ($rs['created_at'] === '0000-00-00 00:00:00' ? '' : $rs['created_at'])
];
}
$smarty->assign('galleriesEmptyIdList', $emptyGalleriesList);
}
}
}
$sidebarHtml = $smarty->fetch('file:layout/partials/gallery/block_sidebarlist.tpl');
if (!empty($sidebarHtml)) $smarty->assign('sidebarHtml', $sidebarHtml);
return true;
}
/**
* Album Thumbnails anzeigen
*
* @version 2.1
* @since 1.0 function added
* @since 1.5 moved pagination to new Sidebar, output it via $smarty
* @since 2.0 `16.12.2022` `IneX` lazy-loaded responsive Gallery Album Thumbs Overview
* @since 2.1 `24.12.2023` `IneX` Optimizations and refactorings
*
* @param integer $id ID des Albums von welchem die Thumbnails angezeigt werden sollen
* @param integer $page Aktuelle Seite des Albums, deren Thumbnails angezeigt werden sollen
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $user Globales Class-Object mit den User-Methoden & Variablen
* @global object $smarty Globales Class-Object mit allen Smarty-Methoden
* @uses THUMBPAGE, ZENSUR
* @uses user_error(), self::imgsrcThum(), Thread::getNumPosts(), Thread::getNumUnread()
*/
function albumThumbs ($id, $page=0)
{
global $db, $user, $smarty;
if (!is_numeric($id) || $id <= 0) user_error('Missing Parameter <i>id</i>', E_USER_ERROR);
if (!is_numeric($page) || $page < 0) user_error('Missing Parameter <i>page</i>', E_USER_ERROR);
$pagepics = THUMBPAGE['cols'] * THUMBPAGE['rows'];
$e = $db->query('SELECT count(id) anz FROM gallery_pics p WHERE album='.$id.' '.ZENSUR.' GROUP BY album', __FILE__, __LINE__, __FUNCTION__);
$d = $db->fetch($e);
$anz = $d['anz'];
$htmlOutput = null;
$sidebarHtml = null;
if (!empty($d) && $d['anz'] > 0)
{
$e = $db->query('SELECT g.id, g.name, IF(e.enddate != "0000-00-00 00:00:00" AND g.created IS NULL, e.enddate, g.created) created, e.id eventid, e.name eventname, GROUP_CONCAT(eu.user_id SEPARATOR ",") beenthere_users
FROM gallery_albums g LEFT JOIN events e ON e.gallery_id=g.id LEFT JOIN events_to_user eu ON eu.event_id=e.id
WHERE g.id=? GROUP BY g.id, e.enddate, e.id, e.name', __FILE__, __LINE__, __FUNCTION__, [$id]);
$d = $db->fetch($e);
$htmlOutput .= '<h1 class="bottom_border center">'.($d['eventname'] ? $d['eventname'] : $d['name']).(!empty($d['eventid']) ? ' <a href="/?tpl=158&event_id='.$d['eventid'].'">📅</a>' : '').'</h1>';
if ($user->typ == USER_MEMBER) $htmlOutput .= '<p class="small center">[<a href="/gallery.php?albID='.$id.'&show=editAlbum">edit name</a>] [<a href="?show=editAlbumV2&albID='.$id.'">add pics</a>]</p>';
$e = $db->query('SELECT * FROM gallery_pics p WHERE album='.$id.' '.ZENSUR.' ORDER BY p.id LIMIT '.($page*$pagepics).', '.$pagepics, __FILE__, __LINE__, __FUNCTION__);
// $hgt = MAX_THUMBNAIL_SIZE['height'] + 2 * THUMBPAGE['padding'];
// $wdt = MAX_THUMBNAIL_SIZE['width'] + 2 * THUMBPAGE['padding'];
$rows = 1;
$htmlOutput .= '<div class="gallerythumbs">';
while ($pic = $db->fetch($e))
{
$comments = Thread::getNumPosts('i', $pic['id']);
$unread = Thread::getNumUnread('i', $pic['id']);
$preload = ($rows <= 4 ? ' rel="preload" as="image"' : '');
$htmlOutput .= '<div class="thumbcontainer"><a href="?show=pic&picID='.$pic['id'].'">';
$htmlOutput .= (isset($pic['name']) && !empty($pic['name']) ? '<div class="pictitle">'.$pic['name'].'</div>' : '');
$htmlOutput .= '<img class="demspic" src="'.imgsrcThum($pic['id']).'" loading="lazy"'.$preload.'>';
if ($comments) {
$htmlOutput .= '<small>'.$comments.' Comment'.($comments > 1 ? 's' : '').'</small>';
if (!empty($unread)) $htmlOutput .= ' <small>('.$unread.' unread)</small>';
}
$htmlOutput .= '</a></div>';
$rows++;
}
$htmlOutput .= '</div>';
/** Pagination */
$sidebarHtml .= '<h3>Seiten</h3><font size="4">';
for ($i=0; $i<$anz/$pagepics; $i++)
{
$sidebarHtml .= ($page==$i ? '<b>['.($i+1).']</b>' : '<a href="?show=albumThumbs&albID='.$id.'&page='.$i.'">'.($i+1).'</a>').' ';
}
$sidebarHtml .= '</font>';
/**
* Album Sidebar
*/
/** Users who have attended */
if (!empty($d['beenthere_users']))
{
// TODO Should be combined with manually added "MyPic"-markings
$usersidlist = explode(',', $d['beenthere_users']);
$sidebarHtml .= '<h3>In diesem Album</h3>';
foreach ($usersidlist as $i => $attended_userid) {
$sidebarHtml .= $user->userprofile_link($attended_userid, ['username'=>true, 'clantag'=>true, 'pic'=>false, 'link'=>true]);
if ($i != array_key_last($usersidlist)) $sidebarHtml .= ' ';
}
}
}
/** Invalid / not found Album-ID */
else {
$smarty->assign('error', ['type' => 'warn', 'dismissable' => 'false', 'title' => t('error-invalid-album', 'gallery')]);
}
if (!empty($sidebarHtml)) $smarty->assign('sidebarHtml', $sidebarHtml);
$smarty->display('file:layout/head.tpl');
echo $htmlOutput;
}
/**
* Bild anzeigen
*
* @version 2.5
* @since 1.0 `21.10.2013` `[z]biko` function added
* @since 2.0 `01.10.2019` `IneX` APOD Special: statt Pic ein Video embedden
* @since 2.1 `01.10.2019` `IneX` responsive scaling `img` and <iframe> tags
* @since 2.2 `04.12.2020` `IneX` fixed fallback to show Album Name on Pic
* @since 2.3 `04.12.2020` `IneX` switched file_exists() to is_file() and fixed PHP notice for undefined exif data
* @since 2.4 `24.12.2022` `IneX` improved Pic detail view layout and functionality
* @since 2.5 `24.12.2023` `IneX` Optimizations and refactorings
*
* @uses USER_USER, USER_MEMBER, APOD_GALLERY_ID, THUMBPAGE, ZENSUR
* @uses text_width(), remove_html(), url_params(), datename()
* @param integer $id ID des Albums von welchem die Thumbnails angezeigt werden sollen
* @param integer $page Aktuelle Seite des Albums, deren Thumbnails angezeigt werden sollen
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $user Globales Class-Object mit den User-Methoden & Variablen
* @return bool
*/
function pic ($id)
{
global $user, $db;
if(!is_numeric($id) || $id <= 0) user_error('Missing Parameter <i>id</i>', E_USER_ERROR);
$sql = 'SELECT *, UNIX_TIMESTAMP(pic_added) as timestamp FROM gallery_pics WHERE id=?';
$e = $db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$id]);
$cur = $db->fetch($e);
if($cur === false || empty($cur)) user_error('Bild "'.$id.'" existiert nicht!', E_USER_ERROR);
$e = $db->query('SELECT id FROM gallery_pics p WHERE album='.$cur['album'].' AND id<'.$id.' '.ZENSUR.' ORDER BY id DESC LIMIT 1', __FILE__, __LINE__, __FUNCTION__);
$last = $db->fetch($e);
$e = $db->query('SELECT id FROM gallery_pics p WHERE album='.$cur['album'].' AND id>'.$id.' '.ZENSUR.' ORDER BY id ASC LIMIT 1', __FILE__, __LINE__, __FUNCTION__);
$next = $db->fetch($e);
$e = $db->query('SELECT album, a.id, count(p.id) anz, a.name, e.gallery_id, e.name eventname
FROM gallery_pics p, gallery_albums a
LEFT JOIN events e
ON e.gallery_id = a.id
WHERE p.id<='.$id.' AND p.album='.$cur['album'].' AND a.id='.$cur['album'].' '.ZENSUR.'
GROUP BY album, eventname', __FILE__, __LINE__, __FUNCTION__);
$d = mysqli_fetch_array($e);
$page = floor($d['anz'] / (THUMBPAGE['cols'] * THUMBPAGE['rows']));
echo '<a href="/gallery.php?show=albumThumbs&albID='.$cur['album'].'&page='.$page.'">';
echo '<h2 class="bottom_border center">'.($d['eventname'] ? $d['eventname'] : $d['name']).'</h2>';
echo '</a>';
if ($cur['zensur'] && $user->typ != USER_MEMBER) user_error('<b><font color="red">Access denied for this picture</font></b><br><br>', E_USER_ERROR);
/**
* Pic Title
*/
if (isset($_GET['editFotoTitle']) && $_GET['editFotoTitle'] && $user->typ >= USER_MEMBER) {
echo '<form method="post" action="?do=editFotoTitle&'.url_params().'">';
echo '<fieldset style="display: flex;white-space: nowrap;align-items: center; margin: 0;">';
echo '<input type="text" name="frm[name]" class="text" style="flex: 1.5;" value="'.$cur['name'].'" placeholder="Gib ems Fötli Name!"> ';
echo '<input type="submit" style="flex: 0.5;" value=" OK " class="button">';
echo ' <a class="small" href="?show=pic&picID='.$id.'">cancel</a>';
echo '</fieldset>';
echo "</form>";
} else {
if (!$cur['name'] && $user->typ >= USER_MEMBER) {
echo '<form method="post" action="?do=editFotoTitle&'.url_params().'">';
echo '<fieldset style="display: flex;white-space: nowrap;align-items: center; margin: 0;">';
echo '<input type="text" name="frm[name]" class="text" style="flex: 1.5;" placeholder="Gib ems Fötli Name!">';
echo '<input type="submit" style="flex: 0.5;" value=" OK " class="button">';
echo '</fieldset>';
echo "</form>";
} elseif ($cur['name']) {
echo '<h3 class="center">'.$cur['name'].($user->typ >= USER_MEMBER ? ' <span class="small">[<a href="?editFotoTitle=1&'.url_params().'">edit</a>]</span>' : '').'</h3><br>';
}
}
$pic_filepath = picPath($cur['album'], $id, '.jpg');
$pic_title = (!empty($cur['name']) ? text_width(remove_html($cur['name']), 250, '', false, true) : pathinfo($pic_filepath, PATHINFO_FILENAME));
/**
* PIC SCORE FORMULAR
*/
if ($user->typ >= USER_USER && !hasVoted($user->id, $cur['id'])) {
echo '<form name="f_benoten" method="post" action="/gallery.php?do=benoten&'.url_params().'" class="voteform">'
.'<input name="picID" type="hidden" value="'.$cur['id'].'">'
.'<span class="scoreinfo">Benoten:</span>'
.'<label class="scorevalue" title="Vote: 6 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="6"></label>'
.'<label class="scorevalue" title="Vote: 5 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="5"></label>'
.'<label class="scorevalue" title="Vote: 4 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="4"></label>'
.'<label class="scorevalue" title="Vote: 3 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="3"></label>'
.'<label class="scorevalue" title="Vote: 2 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="2"></label>'
.'<label class="scorevalue" title="Vote: 1 Sternli">
<input type="radio" name="score" onClick="document.f_benoten.submit();this.setAttribute(\'disabled\', \'disabled\');" value="1"></label>'
.'</form>';
} else {
$anz_votes = getNumVotes($cur['id']);
$votes = $anz_votes.' Vote'.(($anz_votes > 1) || ($anz_votes == 0) ? 's' : null );
echo '<p class="center">Bild Note: '.getScore($cur['id']).' <small>('.$votes.')</small></p>';
}
echo '<div align="center"><table border="0" cellspacing="0" cellpadding="0">';//.$cur['picsize'].'>';
echo '<tr style="font-size: 20px;"><td class="strong align-left" width="30%"">';
if ($last) echo '<a id="prevpiclink" href="?show=pic&picID='.$last['id'].'">⏴ previous</a>';
echo '</td><td class="center light small">';
/** Bild Zensur-Info */
if ($cur['zensur'] === '1') echo '<span class="small" title="Bild ist ZENSIERT">🫥</span>';
/** Bild Datum (Desktop Viewports) */
if ((!isset($user->from_mobile) || false === $user->from_mobile) && is_file($pic_filepath) !== false)
{
/** APOD Special: use pic_added from database, instead of filemtime */
if ($cur['album'] == APOD_GALLERY_ID && !empty($cur['timestamp'])) {
$pic_date = 'Bild von '.datename($cur['timestamp']);
}
/** Regular zorg Pics */
else {
/** Check for EXIF data */
$exif_data = exif_read_data($pic_filepath, 1, true);
if ($exif_data !== false && isset($exif_data['FILE.FileDateTime'])) {
$pic_date = 'Bild erstellt am '.date('d. F Y H:i', $exif_data['FILE.FileDateTime']);
}
/** Fallback: Datum aus dem filemtime() des Files */
else {
$pic_date = 'Bild Upload von '.datename(filemtime($pic_filepath));
}
}
echo $pic_date;
}
echo '</td><td class="strong align-right" width="30%">';
if ($next) echo '<a id="nextpiclink" href="?show=pic&picID='.$next['id'].'">next ⏵</a>';
echo '</td></tr>';
/* die DIVs machen mich verrückt... damn
echo '<tr><td colspan="3"><div style="position:static; width:800; height:600;"><div name="thepic" style="position:absolute;"><img border="0" src="'. imgsrcPic($id). '"></div>';
getUsersOnPic($cur['id']); // MyPic Markierungen laden
echo '</div></td></tr>';
*/
echo '<tr><td colspan="3">';
/** Normale Pic Anzeige (wenn nicht APOD UND Pic-Extension nicht mit '.' anfängt...) */
if ($cur['album'] != APOD_GALLERY_ID || mb_substr($cur['extension'],0,1,'UTF-8') === '.')
{
$pic_downloadname = htmlspecialchars($pic_title.$cur['extension'], ENT_QUOTES);
/** Wenn User eingeloggt & noch nicht auf Bild markiert ist, Formular anzeigen... */
if ($user->typ >= USER_USER && !checkUserToPic($user->id, $id))
{
// NOTE: %% = needed to prevent printf() stripping e.g. '100%' into '100'
printf('
<form action="%1$s" method="post" onsubmit="return markAsMypic()">
<input type="hidden" name="picID" value="%2$s" />
<input type="image" id="thatpic" name="mypic" src="%3$s" alt="Klicken um als MyPic zu markieren" title="Dich auf dem Bild markieren?" style="width: 100%%;max-width: 100%%;%4$s" />
</form>'
,'?do=mypic&'.url_params()
,$id
,imgsrcPic($id)
,($cur['zensur'] === '1' ? 'filter: blur(0.1rem);' : '')
);
/** ...sonst Bild normal ohne Markierungs-Formular ausgeben (auch für Nicht Eingeloggte) */
} else {
echo '<img id="thatpic" name="'.$pic_downloadname.'" src="'.imgsrcPic($id).'" download="'.$pic_downloadname.'" style="border: none;width: 100%;max-width: 100%;">';
}
/** APOD Special: statt Pic ein Video embedden */
} else {
switch ($cur['extension'])
{
case 'youtube':
echo '<iframe id="thatpic" src="'.$cur['picsize'].'" frameborder="0" scrolling="0" allow="autoplay; encrypted-media" allowfullscreen style="width: 800px;height: 450px;max-width: 100%;"></iframe>';
break;
case 'vimeo':
echo '<iframe id="thatpic" src="'.$cur['picsize'].'" frameborder="0" scrolling="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="width: 800px;height: 450px;max-width: 100%;"></iframe>';
break;
case 'website':
echo '<iframe id="thatpic" src="'.$cur['picsize'].'" frameborder="0" scrolling="0" importance="low" style="overflow:hidden;" style="width: 800px;height: 800px;max-width: 100%;"></iframe>';
break;
}
}
echo '</td></tr>';
/** Bild Datum (Mobile Viewports) */
if (isset($user->from_mobile) && $user->from_mobile != false && is_file($pic_filepath) !== false)
{
echo '<tr><td colspan="3" class="align-right padding-bottom-s small light">';
/** APOD Special: use pic_added from database, instead of filemtime */
if ($cur['album'] == APOD_GALLERY_ID && !empty($cur['timestamp'])) {
$pic_date = 'Bild von '.datename($cur['timestamp']);
}
/** Regular zorg Pics */
else {
/** Check for EXIF data */
$exif_data = exif_read_data($pic_filepath, 1, true);
if ($exif_data !== false && isset($exif_data['FILE.FileDateTime'])) {
$pic_date = 'Bild erstellt am '.date('d. F Y H:i', $exif_data['FILE.FileDateTime']);
}
/** Fallback: Datum aus dem filemtime() des Files */
else {
$pic_date = 'Bild Upload von '.datename(filemtime($pic_filepath));
}
}
echo $pic_date;
echo '</td></tr>';
}
/*echo '<tr><td clspan="3">';
getUsersOnPic($cur['id']); // MyPic Markierungen laden
while($i < count($theusers))
{
echo $theusers[$i].', ';
}
echo '</td></tr>';
*/
echo '<tr><td colspan="3">';
// Commenting (Das hier reicht schon :-) ) ------------------------------
Forum::printCommentingSystem('i', $id);
// End Commenting -------------------------------------------------------
echo '</td></tr></table></div>';
/**
* Bild Actions (rotate, Zensieren, usw.)
*
* @TODO Image Rotating...
* @FIXME deaktiviert weil doRotatePic()-Script das Bild nicht dreht.
*/
if ($user->typ >= USER_MEMBER) { // member
echo '<table align="center" class="border margin-top-l" cellspacing="0" cellpadding="10">';
echo '<tr>';
/** Delete Pic */
if ($user->typ >= USER_SPECIAL) { // admins
echo '<td><form action="/gallery.php?do=delPic&show=albumThumbs&albID='.$cur['album'].'" method="post">'
.'<input type="submit" class="button danger" value="Pic löschen"><input type="hidden" name="picID" value="'.$cur['id'].'">'
.'</form></td>';
}
/** Pic Zensieren/Zensur aufheben */
echo '<td><form action="/gallery.php?do=zensur&show=pic&picID='.$cur['id'].'" method="post">'
.'<input type="submit" class="button secondary" value="'.($cur['zensur'] === '1' ? 'Zensur AUFHEBEN' : 'Bild ZENSIEREN').'">'
.'</form></td>';
echo '</tr>';
echo '</table>';
}
/*if ($user->typ == USER_MEMBER) {
echo "<form method='post' action='$_SERVER['PHP_SELF']?do=doRotatePic&".url_params()."'><p>";
echo "<input type='radio' class='text' name='rotatedir' value='left' checked /> 90° links ";
echo "<input type='radio' class='text' name='rotatedir' value='right' /> 90° rechts ";
echo "<input type='submit' class='button' name='rotatebutton' value='Bild drehen' /></p>";
echo "</form>";
}*/
/**
* Mobile Touch Swipe - next/prev Pic
*/
if (isset($user->from_mobile) && $user->from_mobile != false)
{
echo '<script>// HammerJS
document.onreadystatechange = function(){
if (document.readyState === "complete") {
const prevPicLink = document.querySelector("a#prevpiclink");
const nextPicLink = document.querySelector("a#nextpiclink");
const swipeableEl = document.querySelector("#thatpic");
var swipe = new Hammer(swipeableEl);
if (typeof prevPicLink !== "undefined") { swipe.on("swiperight", function(){ window.location.href = prevPicLink.getAttribute("href") }) };
if (typeof nextPicLink !== "undefined") { swipe.on("swipeleft", function(){ window.location.href = nextPicLink.getAttribute("href") }) };
}
}
</script>';
}
}
// ====================================================
// | Pic Rating
// ====================================================
function getScore($pic_id) {
global $db;
$sql = 'SELECT AVG(score) as score FROM gallery_pics_votes WHERE pic_id='.$pic_id;
$result = $db->query($sql, __FILE__, __LINE__, __FUNCTION__);
$rs = $db->fetch($result, __FILE__, __LINE__, __FUNCTION__);
return round($rs['score'], 1);
}
function getNumVotes($pic_id) {
global $db;
$sql = 'SELECT pic_id FROM gallery_pics_votes WHERE pic_id='.$pic_id;
$result = $db->query($sql, __FILE__, __LINE__, __FUNCTION__);
return $db->num($result);
}
function hasVoted($user_id, $pic_id) {
global $db;
$sql = 'SELECT * FROM gallery_pics_votes WHERE pic_id='.$pic_id.' AND user_id='.$user_id;
$result = $db->query($sql, __FILE__, __LINE__, __FUNCTION__);
return $db->num($result);
}
/**
* Bild benoten
*
* Benotet ein Bild mit einer vom User gewählten Score (1-5)
*
* @author IneX
* @version 1.0
* @since 1.0 `IneX` function added
*
* @param integer $pic_id ID des betroffenen Bildes
* @param integer $score Bewertung (1-5) welche der User dem Bild gegeben hat
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $db Globales Class-Object mit den User-Methoden & Variablen
*/
function doBenoten($pic_id, $score) {
global $db, $user;
if (empty($pic_id) || $pic_id <= 0) user_error("Fehlender Parameter <i>pic_id</i>", E_USER_ERROR);
if (empty($score) || $score <= 0) user_error("Fehlender Parameter <i>score</i>", E_USER_ERROR);
if (!hasVoted($user->id, $pic_id))
{
$sql = 'REPLACE INTO gallery_pics_votes (pic_id, user_id, score) VALUES (?, ?, ?)';
$db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$pic_id, $user->id, $score]);
//header("Location: ".base64url_decode($_POST['url']));
//return array('state'=>"Pic $pic_id benotet");
// Activity Eintrag auslösen (ausser bei der Bärbel)
$sternli = '';
for ($s=0;$s<$score;$s++){$sternli .= '★';} // Sternli mache
if ($user->id != BARBARA_HARRIS) {
Activities::addActivity($user->id, 0, 'hat <a href="/gallery.php?show=pic&picID='.$pic_id.'">ein Bild</a> mit <b>'.$sternli.'</b> bewertet.<br/><br><a href="/gallery.php?show=pic&picID='.$pic_id.'"><img src="'.imgsrcThum($pic_id).'" /></a>', 'i');
}
return true;
}
return false;
}
// ====================================================
// | END Pic Rating
// ====================================================
function editAlbum ($id, $done="", $state="", $error="", $frm="")
{
global $db;
if (!isset($frm) || empty($frm)) $frm = array();
if (is_numeric($id) && $id > 0) {
$e = $db->query('SELECT * FROM gallery_albums WHERE id='.$id, __FILE__, __LINE__, __FUNCTION__);
$frm = mysqli_fetch_array($e);
echo '<h2>Album #'.$id.' bearbeiten</h2>';
} else {
echo '<h2>Neues Album erstellen</h2>';
$id = 0;
}
if ($done == "editAlbum" || $done == "delAlbum") {
$editError = $error;
$editState = $state;
}else {
$uploadError = $error;
$uploadState = $state;
}
if ($editState) echo "<font color='green'><b>$editState</b></font><br><br>"; // FIXME Undefined variable: editState
if ($editError) echo "<font color='red'><b>$editError</b></font><br><br>"; // FIXME Undefined variable: editError
if ($id > 0) echo '<a href="/gallery.php?albID='.$id.'&show=albumThumbs">↪ go to Album</a><br><br>';
?>
<table class="border" cellspacing="3"><tr><td>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?show=editAlbum&albID=<?php echo $id ?>&do=editAlbum" method="post">
<fieldset style="display: flex;flex-flow: wrap;white-space: nowrap;align-items: center; margin: 0;">
<label for="name" style="width: 100%;">Name:</label>
<input type="text" id="name" name="frm['name']" class="text" style="flex: 1.5;" placeholder="Album Name..." value="<?php echo (isset($frm['name']) || !empty($frm['name']) ? $frm['name'] : '') ?>">
<input type="submit" class="button" style="flex: 0.5;" value="<?php echo ($id > 0 ? ' OK ' : ' add ') ?>">
</fieldset>
</form>
</td></tr></table>
<br><br>
<?php
if ($id > 0)
{ ?>
<table class="border"><tr><td>
<form <?php echo 'action="/gallery.php?show=editAlbum&albID='.$id.'&do=delAlbum"'?> method="post">
<fieldset style="display: flex;flex-flow: wrap;white-space: nowrap;align-items: center; margin: 0;">
<label for="del" style="width: 100%;">Album löschen: <br>(Gib «<i>OK</i>» ins Feld ein, um zu bestätigen)</label>
<input type="text" id="del" name="del" class="text" style="flex: 2;" value="" placeholder="Hier bestätigen...">
<input type="submit" class="button" style="flex: 0.5;" value=" löschen ">
</fieldset>
</form>
</td></tr></table>
<br>
<?php
echo '<h3>Picture Upload</h3>';
if ($uploadState) echo "<font color='green'><b>$uploadState</b></font><br><br>";
if ($uploadError) echo "<font color='red'><b>$uploadError</b></font><br><br>";
}
echo '→ benutze den neuen <a href="/gallery.php?show=editAlbumV2'.(isset($id) && $id > 0 ? '&album_id='.$id : '').'">Gallery Maker v2</a>!';
}
// ************************************** ACTION FUNCTIONS *************************************************************************
function doEditAlbum ($id, $frm)
{
global $db;
// function errors
if (!is_numeric($id) || $id <= 0) user_error("Invalid Parameter <i>id</i>", E_USER_ERROR);
if (!is_array($frm) || (!isset($frm['name']) || empty($frm['name']))) user_error("Wrong Parameter-type for <i>frm</i>", E_USER_ERROR);
$frm['name'] = htmlspecialchars($frm['name'], ENT_NOQUOTES);
// save data
if (!$id) {
$id = $db->insert("gallery_albums", $frm, __FILE__, __LINE__, __FUNCTION__);
}else{
$db->update("gallery_albums", $id, $frm, __FILE__, __LINE__, __FUNCTION__);
}
return array('id'=>$id, 'state'=>"Database updated", 'frm'=>$frm);
}
/**
* Create Album Folder and Upload Pics.
* @deprecated Replaced with Gallery Maker + add-albumpic.php (AJAX)
* @uses GALLERY_DIR, GALLERY_UPLOAD_DIR, MAX_PIC_SIZE, MAX_THUMBNAIL_SIZE
*/
function doUpload($id, $frm)
{
global $db;
if (!is_numeric($id) || $id <= 0) user_error("Invalid Parameter <i>id</i>", E_USER_ERROR);
if (!is_array($frm) || (!isset($frm['name']) || empty($frm['name']))) user_error("Wrong Parameter-type for <i>frm</i>", E_USER_ERROR);
if (countFiles(GALLERY_UPLOAD_DIR.$frm['folder']) == 0) return array('error'=>'Gewählter Ordner "'.$frm['folder'].'" ist leer');
if (countFiles(GALLERY_UPLOAD_DIR.$frm['folder']) == -1) return array('error'=>'Keine Rechte auf den Ordner '.$frm['folder']);
if (!is_dir(GALLERY_DIR.$id)) mkdir(GALLERY_DIR.$id, 0775); //system('mkdir ".GALLERY_DIR.$id." -m 0775");
//system("chmod 0775 ".GALLERY_UPLOAD_DIR.$frm[folder]);
chmod(GALLERY_UPLOAD_DIR.$frm['folder'], 0775);
$directory = opendir(GALLERY_UPLOAD_DIR.$frm['folder']);
$notDone = "";
$done = "";
$error = "";
$picSize = "";
$tnSize = "";
while (false !== ($file = readdir ($directory))) {
// checks
if ($file==="." || $file==="..") continue;
if (!isPic(GALLERY_UPLOAD_DIR.$frm['folder'].$file)) {
$notDone .= "- $file (ist kein gültiges Bild)<br>";
}
elseif ($frm['delFiles']) {
// strpos() verifies that the resolved file path is within the intended directory
if (strpos($file, realpath(GALLERY_UPLOAD_DIR.$frm['folder'])) === 0 &&
!@unlink(GALLERY_UPLOAD_DIR.$frm['folder'].$file)) {
$error .= '- '.$file.' konnte nicht gelöscht werden<br>';
}
}
continue;
// writing DB
$picid = $db->insert("gallery_pics", array("album"=>$id, "extension"=>extension($file)), __FILE__, __LINE__, __FUNCTION__);
// create pic
$t = createPic(GALLERY_UPLOAD_DIR.$frm['folder'].$file, picPath($id, $picid, extension($file)), MAX_PIC_SIZE['width'], MAX_PIC_SIZE['height']);
if ($t['error']) {
$sql = 'DELETE FROM gallery_pics WHERE id=?';
$db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$picid]);
$notDone .= "- $file ";
if ($frm['delFiles']) {
if (!@unlink(GALLERY_UPLOAD_DIR.$frm['folder'].$file)) $error .= '- '.$file.' konnte nicht gelöscht werden<br>';
}
$notDone .= "(".$t['error'].")<br>";
continue;
}else{
$picSize = "width=".$t['width']." height=".$t['height'];
}
// create thumbnail
$t = createPic(GALLERY_UPLOAD_DIR.$frm['folder'].$file, tnPath($id, $picid, extension($file)), MAX_THUMBNAIL_SIZE['width'], MAX_THUMBNAIL_SIZE['height']);
if ($t == -1) {
$sql = 'DELETE FROM gallery_pics WHERE id=?';
$db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$picid]);
unlink(picPath($id, $picid, extension($file)));
$notDone .= "- $file (keine Rechte) <br>";
if ($frm['delFiles']) {
if (!@unlink(GALLERY_UPLOAD_DIR.$frm['folder'].$file)) $error .= "- $file konnte nicht gelöscht werden<br>";
}
continue;
}else{
$tnSize = "width=".$t['width']." height=".$t['height'];
}
// update sizes in DB
$sql_update = 'UPDATE gallery_pics SET tnsize=?, picsize=? WHERE id=?';
$db->query($sql_update, __FILE__, __LINE__, __FUNCTION__, [$tnSize, $picSize, $picid]);
// del uploaded pic, if requested
if ($frm['delPics']) {
if (!@unlink(GALLERY_UPLOAD_DIR.$frm['folder'].$file)) $error .= '- '.$file.' konnte nicht gelöscht werden<br>';
}
$done .= "- '.$file.' <br>";
}
closedir($directory);
// delete directory if empty
if (countFiles(GALLERY_UPLOAD_DIR.$frm['folder']) == 0) {
if (!@rmdir(GALLERY_UPLOAD_DIR.$frm['folder']))
$error .= '- Upload-Ordner "'.GALLERY_UPLOAD_DIR.$frm['folder'].'" konnte nicht gelöscht werden <br>';
}
if ($notDone) $notDone = 'Folgende Files konnten nicht indiziert werden:<br>'.$notDone;
if ($done) {
$done = 'Folgende Files wurden indiziert:<br>'.$done;
}else{
$notDone = 'Es konnten keine Files indiziert werden! <br><br>'.$notDone;
}
return array('error'=>$notDone.'<br>'.$error, 'state'=>$done);
}
function doDelAlbum ($id, $del)
{
global $db;
if (!$id) user_error("Missing Parameter <i>$id</i>", E_USER_ERROR);
if (strtolower($del) != "ok") {
return array('show'=>"editAlbum", 'error'=>'Löschen wurde nicht bestätigt <br/>Album wurde nicht gelöscht');
}
$db->query("DELETE FROM gallery_pics WHERE album='$id'", __FILE__, __LINE__, __FUNCTION__);
$db->query("DELETE FROM gallery_albums WHERE id='$id'", __FILE__, __LINE__, __FUNCTION__);
if (!delDir(GALLERY_DIR.$id)) return array('show'=>"", 'error'=>'Verzeichnis <i>'.GALLERY_DIR.$id.'</i> konnte nicht gelöscht werden.');
return array('show'=>'', 'state'=>'Album wurde gelöscht');
}
/**
* Ein Bild zensieren / unzensieren.
*
* @version 2.0
* @since 1.0 Function added
* @since 2.0 Bug #632 : Mark all Pic comments as READ for regular Users
*
* @param int $picID
* @return boolean
*/
function doZensur ($picID)
{
global $db;
if (!is_numeric($picID) || $picID <= 0) user_error('Invalid <i>picID</i>', E_USER_ERROR);
$sql_zensur = 'SELECT zensur FROM gallery_pics WHERE id=?';
$e = $db->query($sql_zensur, __FILE__, __LINE__, __FUNCTION__, [$picID]);
$d = $db->fetch($e);
/** Bild ist zensiert: unzensieren */
if ($d['zensur']) {
$sql_unzensieren = 'UPDATE gallery_pics SET zensur="0" WHERE id=?';
$db->query($sql_unzensieren, __FILE__, __LINE__, __FUNCTION__, [$picID]);
Thread::setRights('i', $picID, USER_ALLE);
return true;
}
/** Bild ist unzensiert: zensieren (nur für Member+Admins sichtbar) */
else {
$sql_zensieren = 'UPDATE gallery_pics SET zensur="1" WHERE id=?';
$db->query($sql_zensieren, __FILE__, __LINE__, __FUNCTION__, [$picID]);
Thread::setRights('i', $picID, USER_MEMBER);
/** Mark all Pic comments as READ for regular Users */
$sql_user_unreads = $db->query('SELECT cu.comment_id comment, cu.user_id user FROM comments_unread cu
INNER JOIN comments c ON cu.comment_id=c.id INNER JOIN user u ON cu.user_id=u.id
WHERE c.thread_id=? AND u.usertype<?',
__FILE__, __LINE__, __FUNCTION__, [$picID, USER_MEMBER]);
while ($user_unreads = $db->fetch($sql_user_unreads))
{
Comment::markasread(intval($user_unreads['comment']), intval($user_unreads['user']));
}
return true;
}
return false;
}
// ====================================================
// | MyPic markierung
// ====================================================
/**
* Bild als MyPic markieren
*
* Ein User kann ein Bild als MyPic markieren, womit er
* quasi sagt, dass er auf dem Bild abgebildet ist. Dazu
* werden auch die X- & Y-Koordinaten seines Klicks gespeichert
* (= detailliertere Anzeige, wo auf dem Bild der User
* zu sehen ist).
*
* @author IneX
* @date 13.08.2007
* @version 1.0
* @since 1.0 function added
*
* @param integer $pic_id ID des betroffenen Bildes
* @param integer $pic_x X-Koordinaten wo der User geklickt hat
* @param integer $pic_y Y-Koordinaten wo der User geklickt hat
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $user Globales Class-Object mit den User-Methoden & Variablen
*/
function doMyPic($pic_id, $pic_x, $pic_y) {
global $db, $user;
if (!is_numeric($pic_id) || $pic_id <= 0) user_error('Invalid <i>pic_id</i>', E_USER_ERROR);
// Sicherstellen dass nur eingeloggte markieren
if ($user->typ >= USER_USER) {
$sql = 'REPLACE INTO gallery_pics_users
(pic_id, user_id, pos_x, pos_y, datum)
VALUES
(?, ?, ?, ?, ?)';
$db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$pic_id, $user->id, $pic_x, $pic_y, timestamp(true)]);
// Activity Eintrag auslösen (ausser bei der Bärbel)
if ($user->id != 59) {
Activities::addActivity($user->id, 0, 'hat sich auf <a href="/gallery.php?show=pic&picID='.$pic_id.'">diesem Bild</a> markiert.<br/><br><a href="/gallery.php?show=pic&picID='.$pic_id.'"><img src="'.imgsrcThum($pic_id).'"></a>', 'i');
}
} else {
user_error("Das dörfsch DU nöd - isch nur für igloggti User!", E_USER_ERROR);
}
}
/* Bild markieren
*
* sets the connection between a user and a picture
* @author keep3r
* @date 02.04.2007
* @since 1.5
* @deprecated 2.0
* @see doMyPic
*/
/*function doMark ($picID) {
global $db, $user;
if (!$picID) user_error("Missing Parameter <i>picID</i>", E_USER_ERROR);
$sql = "SELECT * FROM gallery_user WHERE user_id = '$user->id' AND pic_id = '$picID'";
$query = $db->query($sql);
$result = $db->fetch($query);
//delete
if ($result) {
$sql = "DELETE FROM gallery_user WHERE user_id = '$user->id' AND pic_id = '$picID'";
$query = $db->query($sql);
$result = $db->fetch($query);
//insert
} else {
$data = array($user->id, $picID);
$sql = "INSERT INTO gallery_user (user_id, pic_id) VALUES ('$user->id', '$picID')";
$query = $db->query($sql);
$result = $db->fetch($query);
}
}*/
/**
* Check User<-->Bild Verknüpfung
* Prüft ob ein Benutzer bereits auf einem bestimmten Bild markiert wurde
*
* @author [z]keep3r
* @author IneX
* @date 19.08.2008
* @version 1.1
* @since 1.0 `19.08.2008` `keep3r` function added
* @since 1.1 `20.08.2018` `IneX` minor SQL-Query improvements
*
* @param integer $picID ID des betroffenen Bildes
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @return boolean Gibt true/false zurück, je nachdem ob User<->Bild Verknüpfung gefunden wurde
*/
function checkUserToPic($userID, $picID)
{
global $db;
if (!is_numeric($userID) || $userID <= 0) user_error('Invalid <i>userID</i>', E_USER_ERROR);
if (!is_numeric($picID) || $picID <= 0) user_error('Invalid <i>picID</i>', E_USER_ERROR);
$sql = 'SELECT * FROM gallery_pics_users WHERE user_id=? AND pic_id=?';
$result = $db->num($db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$userID, $picID]));
return ($result > 0 ? true : false);
}
/**
* Markierte User holen
*
* Holt die Benutzer, welche auf einem bestimmten Bild markiert wurden
*
* @author IneX
* @date 19.08.2008
* @version 1.0
* @since 1.0 function added
*
* @param integer $picID ID des betroffenen Bildes
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @return array Gibt ein Array mit allen Usern aus, welche auf dem Bild markiert sind
*/
function getUsersOnPic($pic_id) {
global $db, $user;
if (!is_numeric($pic_id) || $pic_id <= 0) user_error('Invalid <i>pic_id</i>', E_USER_ERROR);
$sql = 'SELECT * FROM gallery_pics_users WHERE pic_id=?';
$result = $db->query($sql, __FILE__, __LINE__, __FUNCTION__, [$pic_id]);
$usersonpic = array();
//$html = '';
while ($mp = $db->fetch($result)) {
array_push($usersonpic, $user->link_userpage($mp['user_id'], FALSE));
/* für DIV basierte positionierung/Ausgabe:
$html .= '
<div name="'.$user->id2user($mp[user_id], FALSE).'" style="position:absolute; left:'.$mp[pos_x].'; top:'.$mp[pos_y].'; z-index:'.$mp['id'].'">'.$user->id2user($mp[user_id], FALSE).'<div>
';*/
}
return $usersonpic;
//echo $html;
}
/**
* Alle Bilder eines Users
*
* Markierte Bilder eines bestimmten Benutzers ausgeben
*
* @author IneX
* @date 18.10.2013
* @version 1.1
* @since 1.0 `18.10.2013` `IneX` function added
* @since 1.1 `15.09.2019` `IneX` HTML-output & general code optimized
*
* @param integer $userid ID des Users dessen Bilder angezeigt werden sollen
* @param integer $limit Maximale Anzahl von Bildern
* @global object $db Globales Class-Object mit allen MySQL-Methoden
* @global object $user Globales Class-Object mit den User-Methoden & Variablen
* @return array Gibt ein Array mit allen Usern aus, welche auf dem Bild markiert sind
*/
function getUserPics($userid, $limit=1)
{
global $db, $user;