-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagedisplay.php
973 lines (822 loc) · 48.2 KB
/
imagedisplay.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
<?php
ob_start();
include 'top.php';
include 'leftnav.php';
$b=ob_get_contents();
ob_end_clean();
$title = "Dedicated meme page";
$buffer = preg_replace('/(<title>)(.*?)(<\/title>)/i', '$1' . $title . '$3', $b);
echo $buffer;
//<a href="allmemes.php">Back to all memes</a>
include 'dbh.php';
include_once 'functions.php';
$imageId=mysqli_real_escape_string($conn,$_GET['id']);
//now checking the scope of the meme that is, its visibility
if(isset($_GET['world'])){
//if one is set then the others are also definitely set
$world=$_GET['world'];
$sharedWithUserId=$_GET['uid'];
$sharedWithGroupId=$_GET['gid'];
if($world!=0){
$originLabel="from The World";
}
else if($sharedWithUserId!=0){
$sql1001="SELECT uploaderId FROM memestable WHERE id='$imageId'";
$result1001=mysqli_query($conn,$sql1001);
$row1001=mysqli_fetch_assoc($result1001);
if($_SESSION['id']==$row1001['uploaderId'])
{
$fid=mysqli_real_escape_string($conn,$sharedWithUserId);
$sql1002="SELECT username FROM memberstable WHERE id='$fid'";
$result1002=mysqli_query($conn,$sql1002);
$row1002=mysqli_fetch_assoc($result1002);
$originLabel="from My Friends: <a target='_blank' href='userimagesharing.php?id=".$sharedWithUserId."'>".$row1002['username']."</a>";
}
else{
$fid=mysqli_real_escape_string($conn,$row1001['uploaderId']);
$sql1002="SELECT username FROM memberstable WHERE id='$fid'";
$result1002=mysqli_query($conn,$sql1002);
$row1002=mysqli_fetch_assoc($result1002);
$originLabel="from My Friends: <a target='_blank' href='userimagesharing.php?id=".$row1001['uploaderId']."'>".$row1002['username']."</a>";
}
}
else{
$sql1001="SELECT groupname FROM groups_table WHERE id='$sharedWithGroupId'";
$result1001=mysqli_query($conn,$sql1001);
$row1001=mysqli_fetch_assoc($result1001);
$originLabel="from My Groups: <a target='_blank' href='groupspage.php?id=".$sharedWithGroupId."'>".$row1001['groupname']."</a>";
}
}
/*echo $world;
echo $sharedWithUserId;
echo $sharedWithGroupId;*/
/*
//Facebook and twitter share buttons
if(isset($_GET['world'])){
?>
<div class="fb-share-button" data-href="http://localhost/memewebsite_test1/imagedisplay.php?id=<?php echo $imageId; ?>&world=<?php echo $world; ?>&uid=<?php echo $sharedWithUserId; ?>&gid=<?php echo $sharedWithGroupId; ?>" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Flocalhost%2Fmemewebsite_test1%2Fimagedisplay.php%3Fid%3D<?php echo $imageId; ?>%26world%3D<?php echo $world; ?>%26uid%3D<?php echo $sharedWithUserId; ?>%26gid%3D<?php echo $sharedWithGroupId; ?>&src=sdkpreparse">Share</a></div>
<a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-text="Check out this hilarious meme that I found here:" data-show-count="false">Tweet</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<?php
}*/
$sql= "SELECT * FROM memestable WHERE id='$imageId'";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_assoc($result);
$imagelocation=$row['memeDestination'];
$memetitle=$row['memetitle'];
$uploader=$row['uploader'];
//obtaining user id and number of subscribers
$uploaderId=$row['uploaderId'];
$sql1= "SELECT * FROM memberstable WHERE id='$uploaderId'";
$result1=mysqli_query($conn,$sql1);
$row1=mysqli_fetch_assoc($result1);
$datetime=$row['datetime'];
if($row['memeDescription']!=''){
$memeDescription=$row['memeDescription'];
}else{
$memeDescription="No special description for this meme!";
}
$numberOfFlags=$row['flags'];
$profilePictureLocation=$row1['profilePictureLocation'];
$imageId=$row['id'];
$likesLabel="likes".$imageId;
$numberOfLikes=$row['likes'];//obtains the likes for this particular meme
//subscribe to user
$subscribeLabel="subscribers".$uploaderId;//subscriber to the meme uploader
$numberofSubscribers=$row1['numberofSubscribers'];//subscribers for the uploader obtained
$subscribeToUserInnerHtml="Subscribe";
if(isset($_SESSION['id'])){
//echo '<script language="javascript">alert("im in 1")</script>';
$sql2= "SELECT subscribedById FROM subscriberstable WHERE uploaderId='$uploaderId'";
$result2=mysqli_query($conn,$sql2);
while($row2=mysqli_fetch_assoc($result2)){//checks if the user has already liked the meme..if yes, then it will show the option to undo the like
if($row2['subscribedById']==$_SESSION['id']){
//echo '<script language="javascript">alert("im in 2")</script>';
$subscribeToUserInnerHtml="Unsubscribe";
}
}
}
//comments
if(isset($world) && $world==0){
$sql100="SELECT numberOfComments FROM meme_sharing_visibility_table WHERE imageId='$imageId' AND userId='$sharedWithUserId' AND groupId='$sharedWithGroupId'";
$result100=mysqli_query($conn,$sql100);
$row100=mysqli_fetch_assoc($result100);
$numberOfComments=$row100['numberOfComments'];
}else{
$numberOfComments=$row['numberOfComments'];
}
$numberOfCommentsLabel="comments".$imageId;
$likesinnerhtml="Like";
if(isset($_SESSION['id'])){
//echo '<script language="javascript">alert("im in 1")</script>';
$sql2= "SELECT likedByuserId FROM likestable WHERE imageId='$imageId'";
$result2=mysqli_query($conn,$sql2);
while($row2=mysqli_fetch_assoc($result2)){//checks if the user has already liked the meme..if yes, then it will show the option to undo the like
if($row2['likedByuserId']==$_SESSION['id']){
//echo '<script language="javascript">alert("im in 2")</script>';
$likesinnerhtml="Undo Like";
}
}
}
$likeErrorLabel="Error".$imageId;
$likeButtonId="like".$imageId;
//subscribers for the meme category
$memecategory=$row['memeCategory'];//gets the meme category
$numberOfViews=$row['views'];
//IMPORTANT:::while the user base of our website is small, the views is calculated per session only(this is to encourage our website's users)...but as the number of users increase..for example wwhen we reach about 1 lakh users, there will be a views table just like the likestable where the data for the questionId and the viewer's id shall be stored so that for 1 user only 1 view shall be registered..but then youll have to think of what to do for users who have not logged in
//echo "session value=".($_SESSION['viewed'.$questionId]);
if(!isset($_SESSION['viewed'.$imageId])){
//if the user in the current session has not viewed this question
//then increment the number of views for him
$numberOfViews+=1;
$sql11="UPDATE memestable SET views='$numberOfViews' WHERE id='$imageId'";
$row11=mysqli_query($conn,$sql11);
$_SESSION['viewed'.$imageId]="viewed";
}
$sql4="SELECT totalSubscribers FROM memecategoriestable WHERE memeCategory='$memecategory'";
$result4=mysqli_query($conn,$sql4);
while($row4=mysqli_fetch_assoc($result4)){
$memeCategorySubscribers=$row4['totalSubscribers'];//stores the total number of subscribers for this meme category
}
$memeCategorySubscribersLabel="categorySubscribe".$memecategory;
//echo $memeCategorySubscribersLabel;
$subscribeToMemeCategoryInnerHtml="Subscribe";
if($memecategory=="Savage"){
$tableName="savagememessubscriberstable";
$categoryImageSource="defaults/savage_memes.png";
}else if($memecategory=="Sports"){
$tableName="sportsmemessubscriberstable";
$categoryImageSource="defaults/sports_memes.png";
}else if($memecategory=="Gaming"){
$tableName="gamingmemessubscriberstable";
$categoryImageSource="defaults/gaming_memes.png";
}else if($memecategory=="Comics"){
$tableName="comicmemessubscriberstable";
$categoryImageSource="defaults/comic_memes.png";
}else if($memecategory=="Celeb"){
$tableName="celebmemessubscriberstable";
$categoryImageSource="defaults/celeb_memes.png";
}else if($memecategory=="College / School"){
$tableName="collegememessubscriberstable";
$categoryImageSource="defaults/college_memes.png";
}else if($memecategory=="Politics"){
$tableName="politicsmemessubscriberstable";
$categoryImageSource="defaults/politics_memes.png";
}else if($memecategory=="Just My Thoughts"){
$tableName="justmythoughtsmemessubscriberstable";
$categoryImageSource="defaults/just_my_thoughts.png";
}else if($memecategory=="Other"){
$tableName="othermemessubscriberstable";
$categoryImageSource="defaults/other_memes.png";
}
if(isset($_SESSION['id'])){
$userId=mysqli_real_escape_string($conn,$_SESSION['id']);
//echo '<script language="javascript">alert("im in 1")</script>';
$sql6= "SELECT subscribedByUserId FROM $tableName WHERE subscribedByUserId='$userId'";
$result6=mysqli_query($conn,$sql6);
if($row6=mysqli_fetch_assoc($result6)){//checks if the user has already liked the meme..if yes, then it will show the option to undo the like
//echo '<script language="javascript">alert("im in 2")</script>';
$subscribeToMemeCategoryInnerHtml="Unsubscribe";
}
}
//flag button
$displayFlagButton=false;
$flaggedByCurrentUser=false;
//echo "ITHE";
if(isset($_SESSION['id'])){
if($_SESSION['id']!=$uploaderId){//the user who uploads the image himself can't flag it - -' XD
$userId=$_SESSION['id'];
$sql7="SELECT flaggerUserId FROM image_flags_table WHERE imageId='$imageId' AND flaggerUserId='$userId'";
$result7=mysqli_query($conn,$sql7);
if($row7=mysqli_fetch_assoc($result7)){
//echo "FLAG KELAY";
$flaggedByCurrentUser=true;
}
else{
//if this user has not flagged this image already
//echo "FLAG NAHI KELAY!!";
$displayFlagButton=true;
$flagButtonId="flagbutton".$imageId;
}
}
}
if($numberOfFlags<5 && $flaggedByCurrentUser==false){
/*echo '<h1>'.$memetitle.'</h1>
<img src="'.$imagelocation.'" style="width:500px;height:500px;">
<h2>Uploaded by:<a href="userprofile.php?id='.htmlentities($uploaderId).'">'.$uploader.'</a></h2>
<p>Views:'.$numberOfViews.'</p>
<button type="submit" class="likeimagebutton" onclick="imagelikeFunction(\''.htmlentities($imageId).'\',\''.htmlentities($likesLabel).'\',\''.htmlentities($likeErrorLabel).'\',\''.htmlentities($likeButtonId).'\');" id="like'.htmlentities($imageId).'" name="like'.htmlentities($imageId).'">'.$likesinnerhtml.'</button>
<p name="'.htmlentities($likesLabel).'">Likes:'.$numberOfLikes.'</p>
<button type="submit" onclick="subscribeFunction(\''.htmlentities($imageId).'\',\''.htmlentities($uploaderId).'\',\''.htmlentities($subscribeLabel).'\',\''.htmlentities($uploader).'\');" name="subscribe'.htmlentities($uploaderId).'">'.htmlentities($subscribeToUserInnerHtml).' to '.$uploader.'</button>
<p id="'.htmlentities($subscribeLabel).'" name="'.$subscribeLabel.'">Number of Subscribers:'.$numberofSubscribers.'</p>
<p>Meme Category: '.$memecategory.'</p>
<p id="'.htmlentities($memeCategorySubscribersLabel).'" name="'.htmlentities($memeCategorySubscribersLabel).'">Number of Subscribers for '.$memecategory.' memes category:'.$memeCategorySubscribers.'</p>
<button type="submit" onclick="memeCategorySubscribeFunction(\''.htmlentities($imageId).'\',\''.$memecategory.'\',\''.htmlentities($memeCategorySubscribersLabel).'\');" name="subscribecategory'.$memecategory.'">'.$subscribeToMemeCategoryInnerHtml.' to '.$memecategory.'</button>
<p id="'.htmlentities($numberOfCommentsLabel).'">Number of Comments:'.$numberOfComments.'</p>
<p class="datetime">Posted: '.getTime($datetime).'</p>
<p class="memeDescription">Meme description: '.$memeDescription.'</p>
<p name="Error'.htmlentities($imageId).'"></p>
';
if($displayFlagButton==true){
echo '<p id="flagimage'.htmlentities($imageId).'"></p>';
echo '<button type="submit" class="flagimagebutton" name="'.htmlentities($imageId).'" id="imageFlagButton'.htmlentities($imageId).'">Flag Image!</button>';
}else{
if($flaggedByCurrentUser==true){
echo 'You have flagged this image!';
}
}
//////////////////////////delete image button
if(isset($_SESSION['id'])){
if($_SESSION['id']==$uploaderId){
echo '<button type="submit" class="deleteimagebutton" name="'.htmlentities($imageId).'">Delete meme</button>
<hr>
<br>';
}
}
*/
echo '<div class="meme dedicated-meme meme-box'.$imageId.'" id="meme-box'.$imageId.'">
<h1 class="title">'.$memetitle.'</h1>';
/*if(isset($world))
{
echo '<h1 class="origin" style="color:#9A12B3">'.$originLabel.'</h1>';
}*/
echo '<img class="image" src="'.$imagelocation.'">
<h1 class="points" name="'.$likesLabel.'">'.$numberOfLikes.' likes</h1>';
//<h1 class="comments" id="'.$numberOfCommentsLabel.'">'.$numberOfComments.' Comments</h1>
echo '<div class="category_1">
<h1 align="right" style="font-size:17px;" class="category">Category: <a href="#" style="color:#9A12B3">'.$memecategory.'</a>
</h1></div>
';
if($displayFlagButton==true){
//echo "in";
//echo '<input type="image" class="flagimagebutton flag" name="'.$imageId.'" id="imageFlagButton'.$imageId.'" style="display:inline" src="icons/flag_icon.jpg"> Flag</input>';
echo '<input type="image" class="flagimagebutton flag" name="'.$imageId.'" id="imageFlagButton'.$imageId.'" style="display:inline" alt="Downvote"></input>';
echo '<p id="flagimage'.$imageId.'"></p>';
}else{
if($flaggedByCurrentUser==true){
echo '<p>You have flagged this image!</p>';
}
else{
echo '<p></p>';//this is for CSS debugging..if this is not done tthen everything collapses in the meme box
}
}
/*echo '
<a href="#"><img src="https://image.freepik.com/iconos-gratis/comentario-de-chat-discurso-burbuja-oval-con-lineas-de-texto_318-70514.jpg" class="comment"></a>';*/
echo '<a href="#"><img src="https://image.freepik.com/iconos-gratis/comentario-de-chat-discurso-burbuja-oval-con-lineas-de-texto_318-70514.jpg" class="comment"></a>';
//echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'">'.$numberofSubscribers.'</p>';
//echo '<button type="submit" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
//this is for proper styling of the subscribe button
if($subscribeToUserInnerHtml=="Subscribe")
{
if($numberofSubscribers>=100)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:72px">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:2px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
else if($numberofSubscribers<100&&$numberofSubscribers>10)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:52px">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:2px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
else if($numberofSubscribers<=10)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:32px">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:2px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
}else if($subscribeToUserInnerHtml=="Unsubscribe"){
if($numberofSubscribers>=100)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:72px">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:-0.7px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
else if($numberofSubscribers<100&&$numberofSubscribers>10)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:52px">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:-0.7px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
else if($numberofSubscribers<=10)
{
echo '<p class="subscribers" id="'.$subscribeLabel.'" name="'.$subscribeLabel.'" style="width:32px;">'.$numberofSubscribers.'</p>';
echo '<button type="submit" style="letter-spacing:-0.7px" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" name="subscribe'.$uploaderId.'" class="btn subscribe-button">'.$subscribeToUserInnerHtml.'</button> ';
}
}
//echo' <button type="submit" class="likeimagebutton upvote" onclick="imagelikeFunction(\''.$imageId.'\',\''.$likesLabel.'\',\''.$likeErrorLabel.'\',\''.$likeButtonId.'\');" id="like'.$imageId.'" name="like'.$imageId.'" style="background:url(https://image.freepik.com/free-icon/like-hand-symb6l-for-social-media-interface_318-30403.jpg)">'.$likesinnerhtml.'</button>';
if($likesinnerhtml=="Like"){
echo' <input type="image" class="likeimagebutton upvote like-button'.$imageId.'" onclick="imagelikeFunction(\''.$imageId.'\',\''.$likesLabel.'\',\''.$likeErrorLabel.'\',\''.$likeButtonId.'\');" id="like'.$imageId.'" name="like'.$imageId.'" src="icons/undo_like_icon.jpg"></input>';
//https://image.freepik.com/free-icon/like-hand-symb6l-for-social-media-interface_318-30403.jpg--like button url
}else{
echo' <input type="image" class="likeimagebutton upvote like-button'.$imageId.'" onclick="imagelikeFunction(\''.$imageId.'\',\''.$likesLabel.'\',\''.$likeErrorLabel.'\',\''.$likeButtonId.'\');" id="like'.$imageId.'" name="like'.$imageId.'" src="icons/like_icon.jpg"></input>';
//http://www.vox.com.my/vox/resources/user_1/512.png---like icon url
}
echo '<div class="posted-by"><h1 align="right" style="font-size:17px">posted by:<a href="userprofile.php?id='.$uploaderId.'" style="color:#9A12B3;">'.$uploader.'</a></h1></div>
';
/*echo '<p id="'.$memeCategorySubscribersLabel.'" name="'.$memeCategorySubscribersLabel.'">Number of Subscribers for '.$memecategory.' memes category:'.$memeCategorySubscribers.'</p>
<button type="submit" onclick="memeCategorySubscribeFunction(\''.$imageId.'\',\''.$memecategory.'\',\''.$memeCategorySubscribersLabel.'\');" name="subscribecategory'.$memecategory.'">'.$subscribeToMemeCategoryInnerHtml.' to '.$memecategory.'</button>';*/
/*echo '
<p class="datetime">'.getTime($datetime).'</p>
<p name="Error'.$imageId.'"></p>
';*/
//echo "display=".$displayFlagButton;
echo '</div>';//dedicated-meme box div
?>
<div class="flag-message flag-message<?php echo $imageId; ?>" id="flag-message<?php echo $imageId; ?>" style="display:none">
<p id="flag-p">Downvoting helps Meagl remove low quality, racist or pornographic content. You could tell us more about why you downvoted this meme:</p>
<form class="flag-form" name="<?php echo $imageId; ?>" method="POST" action="">
<input type="hidden" name="imageId" value="<?php echo $imageId; ?>">
<input type="radio" name="downvote" value="low-quality" checked> Low Quality Content<br>
<input type="radio" name="downvote" value="pornographic"> Pornographic<br>
<input type="radio" name="downvote" value="racist"> Racist/abusive<br>
<input type="radio" name="downvote" value="plagiarism"> Plagiarism<br>
<input type="radio" name="downvote" value="other"> Other <br>
<button type="submit" class="btn flag-submit" name="<?php echo $imageId; ?>">Submit</button>
</form>
</div>
<div class="flag-message final-flag-message final-flag-message<?php echo $imageId; ?>" id="final-flag-message<?php echo $imageId; ?>" style="display:none;height:60px;font-size:20px;">
<p id="flag-p" style="left:40px;letter-spacing:0.5px;">Thank you for reporting low quality content to Meagl.</p>
</div>
<?php
echo '<p id="Error'.htmlentities($imageId).'" name="Error'.htmlentities($imageId).'" class="error-message"></p> ';
?>
<div class="meme-description-box">
<p class="meme-desc-content"><?php echo $memeDescription; ?></p>
</div>
<?php
//~~~~~~~~~~~~~~~~~right part~~~~~~~~~~~~~~~~~~~~~
?>
<div class="right-container" style="max-height:250px">
<div class="posters-plate">
<h1 class="username" style="top:0px;left:130px;"><a href="userprofile.php?id=<?php echo $uploaderId; ?>"><?php echo $uploader; ?></a></h1>
<!--<h1 class="info-followers" style="top:50px;left:180px;">Subscribers: 21</h1>-->
<h1 class="info-subscribers" style="top:40px;left:180px;">Subscribers:</h1>
<h1 class="info-subscribers" id="<?php echo $subscribeLabel; ?>" name="<?php echo $subscribeLabel; ?>" style="top:40px;left:305px;"><?php echo $numberofSubscribers; ?></h1>
<!--<button class="btn" id="userprofile-subscribe-button" style="top:118px;left:180px;">Subscribe</button>-->
<!--<button type="submit" id="userprofile-subscribe-button" onclick="subscribeFunction(<?php //echo $imageId; ?>,<?php// echo $uploaderId; ?>,<?php //echo $subscribeLabel; ?>,<?php //echo $uploader; ?>);" name="subscribe<?php //echo $uploaderId; ?>" class="btn" style="top:118px;left:180px;"><?php //echo $subscribeToUserInnerHtml?></button>-->
<?php
echo '<button type="submit" onclick="subscribeFunction(\''.$imageId.'\',\''.$uploaderId.'\',\''.$subscribeLabel.'\',\''.$uploader.'\');" id="userprofile-subscribe-button" name="subscribe'.$uploaderId.'" class="btn" style="top:100px;left:180px;" >'.$subscribeToUserInnerHtml.'</button> ';
?>
<img id="infobox-dp" src="<?php echo $profilePictureLocation; ?>" style="left:10px;top:20px;">
<p class="posters-time"><i><span class="glyphicon glyphicon-alarm"></span><?php echo getTime($datetime); ?></i></p>
</div>
<div class="category-plate">
<img src="<?php echo $categoryImageSource; ?>" class="category-dp">
<h1 class="info-subscribers" style="top:0px;left:180px;"><?php echo $memecategory; ?></h1>
<h1 class="info-subscribers" id="<?php echo $memeCategorySubscribersLabel; ?>" name="<?php echo $memeCategorySubscribersLabel; ?>" style="top:40px;left:180px;">Subscribers: <?php echo $memeCategorySubscribers; ?></h1>
<!--<button class="btn" id="userprofile-subscribe-button" style="top:130px;left:180px;">Subscribe</button>-->
<?php
echo '<button type="submit" onclick="memeCategorySubscribeFunction(\''.$imageId.'\',\''.$memecategory.'\',\''.$memeCategorySubscribersLabel.'\');" name="subscribecategory'.$memecategory.'" class="btn" id="userprofile-subscribe-button" style="top:100px;left:180px;">'.$subscribeToMemeCategoryInnerHtml.'</button>';
?>
</div>
<br>
<?php
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Facebook and twitter share buttons
if(isset($_GET['world'])){
/*
?>
<div class="fb-share-button" data-href="http://localhost/memewebsite_test1/imagedisplay.php?id=<?php echo $imageId; ?>&world=<?php echo $world; ?>&uid=<?php echo $sharedWithUserId; ?>&gid=<?php echo $sharedWithGroupId; ?>" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Flocalhost%2Fmemewebsite_test1%2Fimagedisplay.php%3Fid%3D<?php echo $imageId; ?>%26world%3D<?php echo $world; ?>%26uid%3D<?php echo $sharedWithUserId; ?>%26gid%3D<?php echo $sharedWithGroupId; ?>&src=sdkpreparse">Share</a></div>
*/
?>
<div class="fb-share-button" style="margin-top:10px;margin-left:0px" data-href="http://www.meagl.com/imagedisplay.php?id=<?php echo $imageId; ?>&world=<?php echo $world; ?>&uid=<?php echo $sharedWithUserId; ?>&gid=<?php echo $sharedWithGroupId; ?>" data-layout="button_count" data-size="large" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.meagl.com%2Fimagedisplay.php%3Fid%3D<?php echo $imageId; ?>%26world%3D<?php echo $world; ?>%26uid%3D<?php echo $sharedWithUserId; ?>%26gid%3D<?php echo $sharedWithGroupId; ?>&src=sdkpreparse">Share</a></div>
<a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-text="Check out this hilarious meme that I found here:" data-show-count="false">Tweet</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<?php
}
?>
</div>
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TIP
/*
?>
<a href="tip-memer.php?imageId=<?php echo $imageId; ?>">TIP</a>
<?php
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
<?php
//comments system is made below
date_default_timezone_set('Asia/Kolkata');//setting the timezone
if(isset($world) && isset($sharedWithUserId) && isset($sharedWithGroupId)){
?>
<div class="heading">
<h1 class="heading-part2 comments" id="<?php echo $numberOfCommentsLabel; ?>"><?php echo htmlentities($numberOfComments); ?> Comments</h1>
</div>
<div class="submission" id="submission-dedicated">
<form method="post" class="commentform" id="commentform<?php echo htmlentities($imageId); ?>" action="" onsubmit="">
<input type="hidden" id="imageId" value="<?php echo htmlentities($imageId); ?>">
<input type="hidden" id="datetime" value="<?php echo date('Y-m-d H:i:s'); ?>">
<input type="hidden" id="world" value="<?php echo htmlentities($world); ?>">
<input type="hidden" id="sharedWithGroupId" value="<?php echo htmlentities($sharedWithGroupId); ?>">
<input type="hidden" id="sharedWithUserId" value="<?php echo htmlentities($sharedWithUserId); ?>">
<textarea class="comment-input form-control" rows="1" name="comment" id="comment" placeholder="Write comment" style="font-size:21px"></textarea>
<?php
if(isset($_SESSION['id'])){
//show the postcomment button only if the user has signed in
?>
<button type="submit" class="postcomment btn submit-comment">Post</button>
<?php
}
?>
</form>
</div>
<div class="comment-section" id="dedicated-comment-section">
<div class="allcomments" id="allcomments">
<?php
if(isset($userId))
{ $sql= "SELECT * FROM commentstable WHERE (sharedWithWorld='$world' AND sharedWithGroupId='$sharedWithGroupId' AND (sharedWithUserId='$sharedWithUserId' OR sharedWithUserId='$userId')) ORDER BY id DESC";}
else
{ $sql= "SELECT * FROM commentstable WHERE (sharedWithWorld='$world' AND sharedWithGroupId='$sharedWithGroupId' AND (sharedWithUserId='$sharedWithUserId')) ORDER BY id DESC";}
$result=mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($result))
{
$commentForMemeId=$row['commentForMemeId'];
if($commentForMemeId==$imageId){
$comment=$row['comment'];
$datetime=$row['datetime'];
$likes=$row['likes'];
$numberOfReplies=$row['numberOfReplies'];
$commentId=$row['id'];
$commentByUserId=$row['commentByUserId'];
$username=$row['commentByUserName'];
$uId=mysqli_real_escape_string($conn,$row['commentByUserId']);
$sql11="SELECT profilePictureLocation FROM memberstable WHERE id='$uId'";
$result11=mysqli_query($conn,$sql11);
$row11=mysqli_fetch_assoc($result11);
$ppl=$row11['profilePictureLocation'];
//echo nl2br(htmlentities($comment));
//$comment=str_replace(["\r\n", "\r", "\n"], "<br/>",$comment);
?>
<div class="comment_div comments-dedicated comments" id="commentdiv<?php echo htmlentities($commentId); ?>">
<a href="userprofile.php?id=<?php echo $uId; ?>">
<div class="comment-top">
<img src="<?php echo $ppl; ?>" class="notif-dp" id="comment-dp">
</div>
</a>
<p class="real-comment">
<span class="username"><a href="userprofile.php?id=<?php echo $uId; ?>"><span id="dedicated-username"><?php echo htmlentities($username); ?></span></a></span>
<span class="comment" id="comment<?php echo htmlentities($commentId); ?>" contenteditable="false"><?php echo htmlentities($comment); ?></span>
<br>
<?php
//shows/hides reply button on clicking
echo '<a class="showreplyformbutton action-link reply-link" name="'.htmlentities($commentId).'">Reply</a>';
//comment like button
$commentlikesLabel="commentlikes".$commentId;
$commentlikesinnerhtml="Like";
if(isset($_SESSION['id'])){
//echo '<script language="javascript">alert("im in 1")</script>';
$sql3= "SELECT likedByUserId FROM commentlikestable WHERE commentId='$commentId'";
$result3=mysqli_query($conn,$sql3);
while($row3=mysqli_fetch_assoc($result3)){//checks if the user has already liked the meme..if yes, then it will show the option to undo the like
if($row3['likedByUserId']==$_SESSION['id']){
//echo '<script language="javascript">alert("im in commentlikes")</script>';
$commentlikesinnerhtml="Undo Like";
//echo '<script language="javascript">alert("'.$commentlikesinnerhtml.'")</script>';
break;
}
}
}
echo '<a class="likecommentbutton action-link like-link" onclick="commentlikeFunction(\''.htmlentities($commentId).'\',\''.htmlentities($commentlikesLabel).'\');" id="commentlike'.htmlentities($commentId).'" name="'.htmlentities($commentId).'">'.$commentlikesinnerhtml.'</a>';
//like button finished
?>
<span class="likes comment-info" id="commentlikes<?php echo htmlentities($commentId); ?>">Likes: <?php echo htmlentities($likes); ?></span>
<span class="numberOfReplies comment-info comment-replies" id="numberOfReplies<?php echo htmlentities($commentId); ?>">Replies: <?php echo htmlentities($numberOfReplies); ?></span>
<?php
echo '<span class="datetime comment-info comment-time">'.getTime($datetime).'</span><br>';//echo is done specifically for this because otherwise, for some reason, date doesnot get displayed -_-' XD
//changes 1.0 in the if block
if(isset($_SESSION['id'])){
if($commentByUserId==$_SESSION['id']){
//if the comment has been by the user then it will show the delete option
echo '<div><a class="display-edit"><span class="glyphicon glyphicon-chevron-down"></span></a></div>';
echo '<div class="edit-panel"><button type="submit" class="deletecommentbutton" name="'.htmlentities($commentId).'">Delete</button><br>';
echo '<button type="submit" class="editcommentbutton" name="'.htmlentities($commentId).'">Edit</button>';//makes the comment editable
echo '<button type="submit" class="updatecommentbutton" name="'.htmlentities($commentId).'" style="display:none">Update</button>';//updates the database with the changes to the comment
echo '</div>';
}
}
echo '<p id="commentLikeError'.htmlentities($commentId).'"></p>';
echo '<form method="post" class="replyform" id="replyform'.htmlentities($commentId).'" action="" onsubmit="return postreply();" style="display:none">
<input type="hidden" id="commentId'.htmlentities($commentId).'" value="'.htmlentities($commentId).'">
<input type="hidden" id="datetime'.htmlentities($commentId).'" value="'.date('Y-m-d H:i:s').'">
<textarea class="reply-action form-control text-reply" rows="1" id="replytext'.htmlentities($commentId).'" placeholder="Write reply"></textarea><br>
<button type="submit" name="'.htmlentities($commentId).'" class="postreplybutton btn reply-action post-reply">Post</button>
</form>';
if($numberOfReplies>=1){
echo '<a class="repliestogglebutton replies" name="'.htmlentities($commentId).'">Replies <span class="glyphicon glyphicon-chevron-down"></span></a>';
}else{
echo '<a class="repliestogglebutton replies" name="'.htmlentities($commentId).'" style="display:none">Replies <span class="glyphicon glyphicon-chevron-down"></span></a>';
}
?>
</p>
<?php
echo '<div id="allreplies'.htmlentities($commentId).'" class="allreplies" style="display:none">';//we add the comment id of the comment to the end of "allreplies" ..this makes a unique name for every div containing all the replies to a particular meme...the above thing is done so that when we press the "show all replies" button, only the replies for that particular comment shall be shown
if($numberOfReplies>=1){
$sql1= "SELECT * FROM repliestable ORDER BY id";
$result1=mysqli_query($conn,$sql1);
while($row1=mysqli_fetch_assoc($result1))
{
$replyToCommentId=$row1['replyToCommentId'];
if($replyToCommentId==$commentId){
$replyUsername=$row1['replyByUsername'];
$reply=$row1['reply'];
$replyDatetime=$row1['datetime'];
$replyLikes=$row1['likes'];
$replyId=$row1['id'];
$replyByUserId=mysqli_real_escape_string($conn,$row1['replyByUserId']);
$replydivname="reply_div".$replyId;
$replylikesLabel="replylikes".$replyId;
$replylikesinnerhtml="Like";
if(isset($_SESSION['id'])){
//echo '<script language="javascript">alert("im in 1")</script>';
$sql4= "SELECT likedByUserId FROM replylikestable WHERE replyId='$replyId'";
$result4=mysqli_query($conn,$sql4);
while($row4=mysqli_fetch_assoc($result4)){//checks if the user has already liked the meme..if yes, then it will show the option to undo the like
if($row4['likedByUserId']==$_SESSION['id']){
//echo '<script language="javascript">alert("im in commentlikes")</script>';
$replylikesinnerhtml="Undo Like";
//echo '<script language="javascript">alert("'.$commentlikesinnerhtml.'")</script>';
break;
}
}
}
$sql5="SELECT profilePictureLocation FROM memberstable WHERE id='$replyByUserId'";
$result5=mysqli_query($conn,$sql5);
$row5=mysqli_fetch_assoc($result5);
$replyPPL=$row5['profilePictureLocation'];
//echo '<button type="submit" class="likereplybutton" onclick="replylikeFunction(\''.$commentId.'\',\''.$commentlikesLabel.'\');" id="commentlike'.$commentId.'" name="'.$commentId.'">'.$commentlikesinnerhtml.'</button>';
echo '
<div class="reply_div reply-comment" id="'.htmlentities($replydivname).'">
<a href="userprofile.php?id='.$replyByUserId.'">
<div class="reply-comment-top">
<img src="'.$replyPPL.'" class="notif-dp" id="comment-dp">
</div>
</a>
<p class="reply-real-comment">
<span class="replyUsername"><a href="userprofile.php?id='.$replyByUserId.'"><span id="dedicated-username">'.htmlentities($replyUsername).'</span></a></span>
<span class="reply" id="reply'.htmlentities($replyId).'" contenteditable="false">'.htmlentities($reply).'</span>
<br>
<a type="submit" class="likereplybutton reply-like-link" onclick="replylikeFunction(\''.htmlentities($replyId).'\',\''.htmlentities($replylikesLabel).'\');" id="replylike'.htmlentities($replyId).'" name="'.htmlentities($replyId).'">'.$replylikesinnerhtml.'</a>
<span id="replyLikeError'.htmlentities($replyId).'"></span>
<span class="replyLikes comment-reply-info" id="replylikes'.htmlentities($replyId).'">Likes:'.htmlentities($replyLikes).'</span>
<span class="replyDatetime">'.getTime($replyDatetime).'</span>
</p>
';
if(isset($_SESSION['id'])){
if($replyByUserId==$_SESSION['id']){//if the reply has been posted by the same user who is viewing it, he'll get theoption to delete the reply
echo '<div><a class="display-edit"><span class="glyphicon glyphicon-chevron-down"></span></a></div>';
echo '<div class="edit-panel"><button type="submit" class="deletereplybutton" id="'.htmlentities($commentId).'" name="'.htmlentities($replyId).'">Delete</button><br>';
echo '<button type="submit" class="editreplybutton" name="'.htmlentities($replyId).'">Edit</button>';//makes the reply editable
echo '<button type="submit" class="updatereplybutton" name="'.htmlentities($replyId).'" style="display:none">Update</button>';//updates the database with the changes to the reply
echo '</div>';
}
}
echo '</div>';
}
}
}
echo '</div>';
?>
</div>
<?php
}
}
//}
?>
</div>
</div>
<?php
}else{
//if $world,$sharedWithUserId and $sharedWithGroupId are not set means the user has just uploaded the meme and this is the page being displayed on that meme's upload
if(!isset($world) && $_SESSION['id']==$uploaderId)
{
echo "<p class='meme-sharing-header'>Meme Shared With:</p>
<div class='shared-div'>
";
$sql="SELECT visibilityStatus FROM memestable WHERE /*(visibilityStatus=1 OR visibilityStatus=3) AND*/ id='$imageId'";//means, the meme has been shared with the world
$result=mysqli_query($conn,$sql);
if($row=mysqli_fetch_assoc($result)){
//echo "visibilityStatus=".$row['visibilityStatus'];
if($row['visibilityStatus']==1){
//echo "yo";
//only shared with the world
echo '<a href="imagedisplay.php?id='.htmlentities($imageId).'&world=1&uid=0&gid=0" class="shared"><span style="position:relative;bottom:3.5px">The World: <span style="font-size:15px">Everyone on this website</span></span></a>';
}else{
//shared with the world and also with some user or group
if($row['visibilityStatus']==3){
echo '<a href="imagedisplay.php?id='.htmlentities($imageId).'&world=1&uid=0&gid=0" class="shared"><span style="position:relative;bottom:3.5px">The World: <span style="font-size:15px">Everyone on this website</span></span></a>';
}
if(isset($_SESSION['id']) && $_SESSION['id']==$uploaderId){
//if the uploader himself is viewing it then show the groups and friends it's been shared with otherwise, dont show anything
//searching for users and groups
$sql1="SELECT userId,groupId FROM meme_sharing_visibility_table WHERE imageId='$imageId'";//means, the meme has been shared with the world
$result1=mysqli_query($conn,$sql1);
while($row1=mysqli_fetch_assoc($result1)){
if($row1['groupId']!=0){
//means this is a group share
$groupId=$row1['groupId'];
//getting the groupname
$sql2="SELECT groupname FROM groups_table WHERE id='$groupId'";
$result2=mysqli_query($conn,$sql2);
$row2=mysqli_fetch_assoc($result2);
$groupname=$row2['groupname'];
echo '<p style="margin-bottom:5px;"><a href="imagedisplay.php?id='.htmlentities($imageId).'&world=0&uid=0&gid='.htmlentities($groupId).'" class="shared">'.$groupname.'</a>: My Group</p>';
}else{
//means this is a user share
//echo 'user';
$userId=$row1['userId'];
//getting the userpname
$sql2="SELECT username FROM memberstable WHERE id='$userId'";
$result2=mysqli_query($conn,$sql2);
$row2=mysqli_fetch_assoc($result2);
$username=$row2['username'];
echo '<p style="margin-bottom:5px;"><a href="imagedisplay.php?id='.htmlentities($imageId).'&world=0&uid='.htmlentities($userId).'&gid=0" class="shared">'.$username.'</a>: My Friend</p>';
}
}
}
}
}
}
else
{
echo "<p class='meme-sharing-header'>Meme Shared With:</p>
<div class='shared-div'>
";
$sql="SELECT visibilityStatus FROM memestable WHERE /*(visibilityStatus=1 OR visibilityStatus=3) AND*/ id='$imageId'";//means, the meme has been shared with the world
$result=mysqli_query($conn,$sql);
if($row=mysqli_fetch_assoc($result)){
//echo "visibilityStatus=".$row['visibilityStatus'];
if($row['visibilityStatus']==1){
//echo "yo";
//only shared with the world
echo '<a href="imagedisplay.php?id='.htmlentities($imageId).'&world=1&uid=0&gid=0" class="shared"><span style="position:relative;bottom:3.5px">The World: <span style="font-size:15px">Everyone on this website</span></span></a>';
}else{
//shared with the world and also with some user or group
//echo $row['visibilityStatus'];
if($row['visibilityStatus']==3){
echo '<a href="imagedisplay.php?id='.htmlentities($imageId).'&world=1&uid=0&gid=0" class="shared"><span style="position:relative;bottom:3.5px">The World: <span style="font-size:15px">Everyone on this website</span></span></a>';
}
//if(isset($_SESSION['id']) && $_SESSION['id']==$uploaderId){
//if the uploader himself is viewing it then show the groups and friends it's been shared with otherwise, dont show anything
//searching for users and groups
$sql1="SELECT userId,groupId FROM meme_sharing_visibility_table WHERE imageId='$imageId'";//means, the meme has been shared with the world
$result1=mysqli_query($conn,$sql1);
while($row1=mysqli_fetch_assoc($result1)){
if($row1['groupId']!=0){
//means this is a group share
$groupId=mysqli_real_escape_string($conn,$row1['groupId']);
$uid=mysqli_real_escape_string($conn,$_SESSION['id']);
$sql101="SELECT participantId FROM group_participants_table WHERE participantId='$uid' AND groupId='$groupId' AND invitationStatus=1";
$result101=mysqli_query($conn,$sql101);
if(mysqli_num_rows($result101)!=0)
{
//getting the groupname
$sql2="SELECT groupname FROM groups_table WHERE id='$groupId'";
$result2=mysqli_query($conn,$sql2);
$row2=mysqli_fetch_assoc($result2);
$groupname=$row2['groupname'];
echo '<p style="margin-bottom:5px;"><a href="imagedisplay.php?id='.htmlentities($imageId).'&world=0&uid=0&gid='.htmlentities($groupId).'" class="shared">'.$groupname.'</a>: Your Group</p>';
}
}else{
//means this is a user share
//echo 'user';
$userId=mysqli_real_escape_string($conn,$row1['userId']);
if($userId==$_SESSION['id'])
{
$username=$uploader;
echo '<p style="margin-bottom:5px;"><a href="imagedisplay.php?id='.htmlentities($imageId).'&world=0&uid='.htmlentities($userId).'&gid=0" class="shared">You</a>: Personal Sharing</p>';
}
}
}
}
}
}
}
}
else{
echo '<p>This image has been flagged more than five times and is awaiting admin approval.</p></div>';
}
?>
<div class="small-notifications-column">
<?php
if(isset($_SESSION['id']))
{
$userId=mysqli_real_escape_string($conn,$_SESSION['id']);
$sql="SELECT * FROM notifications_table WHERE receiverId='$userId' ORDER BY id DESC";
$result=mysqli_query($conn,$sql);
$areThereNotifications=false;
$notifications_counter=0;
echo '<div class="small-notifications-body">';
while($row=mysqli_fetch_assoc($result)){
$areThereNotifications=true;
$notification=$row['notification'];
$notificationId=mysqli_real_escape_string($conn,$row['id']);
$datetime=$row['datetime'];
$nL=$row['notificationLink'];
$senderId=$row['senderId'];
$sql1="SELECT profilePictureLocation FROM memberstable WHERE id='$senderId'";
$result1=mysqli_query($conn,$sql1);
$row1=mysqli_fetch_assoc($result1);
$ppL=$row1['profilePictureLocation'];
if($ppL=='')
{
//this means its a group ka notification
if(preg_match_all('/\d+/', $nL, $numbers))
{
$groupId = end($numbers[0]);
}
$sql10="SELECT groupPicLocation FROM groups_table WHERE id='$groupId'";
$result10=mysqli_query($conn,$sql10);
$row10=mysqli_fetch_assoc($result10);
$ppL=$row10['groupPicLocation'];
}
$viewingStatus=$row['viewingStatus'];
if($viewingStatus==0)
{
$notifications_counter+=1;
?>
<a href="<?php echo htmlentities($nL); ?>" class="notif-link" id="notification<?php echo htmlentities($notificationId); ?>">
<div class="notif">
<img src="<?php echo htmlentities($ppL) ?>" class="small-notif-dp">
<p class="small-notif-text"><?php echo $notification; ?></p>
</div>
</a>
<?php
}
else
{
?>
<a href="<?php echo htmlentities($nL); ?>" class="notif-link" id="notification<?php echo htmlentities($notificationId); ?>">
<div class="notif" style="background-color:#EAEAEA">
<img src="<?php echo htmlentities($ppL) ?>" class="small-notif-dp">
<p class="small-notif-text"><?php echo $notification; ?></p>
</div>
</a>
<?php
}
}
if($areThereNotifications==false){
echo '<p>No notifications yet!</p>';
}else{
?>
<script>thereAreNotifications(<?php echo $notifications_counter; ?>);</script>
<?php
}
echo "</div>";
}
?>
</div>
<?php
$sql="SELECT verified FROM memberstable WHERE id='$uploaderId' AND verified=1";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0)
{
//if((isset($_SESSION['id']) && $uploaderId!=$_SESSION['id']) || !isset($_SESSION['id']))
//{
?>
<a href="tip-memer.php?imageId=<?php echo $imageId; ?>" type="submit" class="tip-btn">DROP A TIP</a><br><br>
<?php
//}
?>
<div class="encourage-memer" style="overflow:scroll;overflow-x:hidden;overflow-y:scroll;">
<h1 style="font-size:22px;text-align:left;margin-left:20px;font-family:'Open Sans'">Tips:</h1>
<hr style="border-color:#cccccc">
<?php
$sql="SELECT tipperId,tipAmount,currency FROM tips_table WHERE tipReceiverId='$uploaderId' AND tipForImageId='$imageId' ORDER BY id DESC";
$result=mysqli_query($conn,$sql);
//echo "rows=".mysqli_num_rows($result);
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_assoc($result))
{
$tipperId=$row['tipperId'];
$tipAmount=$row['tipAmount'];
$currency=$row['currency'];
$sql1="SELECT username,profilePictureLocation FROM memberstable WHERE id='$tipperId'";
$result1=mysqli_query($conn,$sql1);
$row1=mysqli_fetch_assoc($result1);
$tipperName=$row1['username'];
$tipperPPL=$row1['profilePictureLocation'];
?>
<a class="opensans" href="userprofile.php?id=<?php echo $tipperId; ?>" style="text-align:center;margin-left:110px;font-size:20px;margin-top:300px;font-family:'Open Sans'"><img style="position:absolute;left:60px;height:35px;width:35px;border-radius:50%" src="<?php echo $tipperPPL; ?>"><?php echo $tipperName; ?><p class="opensans" style="margin-left:30px;display:inline;color:#b225a8"><?php echo $currency; ?> <?php echo $tipAmount; ?></p></a><br><br><br>
<?php
}
}
else
{
?>
<p class="opensans" style="margin-left:30px;display:inline;color:#b225a8;font-size:20px;font-family:'Open Sans'">No tips for this meme yet.</p>
<?php
}
?>
</div>
<?php
}
else
{
?>
<div style="border:1px solid #cccccc;position:absolute;top:100px;right:200px;padding:10px;width:230px;">
<p class="opensans" style="color:#b225a8;text-align:center;font-size:20px;font-family:'Open Sans'">Tipping has not been enabled by this user yet!</p>
</div>
<?php
}
?>
</body>
</head>
</html>