-
Notifications
You must be signed in to change notification settings - Fork 2
/
notify.php
32 lines (29 loc) · 1.16 KB
/
notify.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
<?php
include ('./classes/DB.php');
include ('./classes/Login.php');
if (Login::isLoggedIn()) {
$userid = Login::isLoggedIn();
} else {
die ('Not logged in <br>');
}
echo "<h1>Notifications</h1>";
if(DB::query('SELECT * FROM notifications WHERE receiver=:userid',array(':userid'=>$userid))){
$notifications = DB::query('SELECT * FROM notifications WHERE receiver=:userid ORDER BY id DESC',array(':userid'=>$userid));
foreach ($notifications as $n){
if($n['type']==1){
$sender=DB::query('SELECT username FROM users WHERE id=:senderid',array(':senderid'=>$n['sender']))[0]['username'];
if($n['extra']==""){
echo "Unknown Notification<hr>";
}else{
$extra = json_decode($n['extra']);
echo $sender." Mentioned you in a post - ".$extra->postbody."<hr>";
}
}else if($n['type']==2){
$sender=DB::query('SELECT username FROM users WHERE id=:senderid',array(':senderid'=>$n['sender']))[0]['username'];
echo $sender." Liked your post <hr>";
}
}
}else{
echo 'No Notifications Check Back Later.. Thanks for using Sushi Network';
}
?>