-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboardRequests.php
92 lines (76 loc) · 2.58 KB
/
leaderboardRequests.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
<!DOCTYPE html>
<html>
<head>
<h1>Your Leaderboard Requests</h1>
<link rel="stylesheet" type="text/css" href="onClickAddFriend.css" />
</head>
<body>
<a href="leaderboards.php"><button class="leaderboardsBtn" name="leaderboards">Leaderboards</button></a>
<a href="searchMembers.php"><button class="searchBtn" name="search">Search Members</button></a>
<a href="profile.php"><button class="profileBtn" name="profile">My Profile</button></a>
<a href="logout.php"><button class="logoutBtn" name="logout">Log Out</button></a>
<div class="outgoingLeaderboardRequests">
<h2>Outgoing Leaderboard Requests</h2>
<?php
include 'db.php';
session_start();
if (isset($_SESSION['uid']) && isset($_SESSION['logged_in'])) {
$uid = $_SESSION['uid'];
$sql = "SELECT U.first, U.last, L.uid AS lUid, L.friendUid, L.leaderboardRequest FROM users U JOIN leaderboards L ON U.uid = L.friendUid AND L.leaderboardRequest = 1";
$query = $pdo->prepare($sql);
$query->execute();
// if there are results, then show results with accept and reject buttons on side
// otherwise, print no results
$count = 0;
if ($query->rowCount() > 0) {
$results = $query->fetchAll();
foreach($results as $row) {
//outgoing friend requests
if ($uid == $row['lUid']) {
$friendUid = $row['friendUid'];
$friendFirst = $row['first'];
$friendLast = $row['last'];
echo $friendFirst.' '.$friendLast.' '.$friendUid.'<br>';
$count++;
}
}
if ($count == 0) {
echo "No pending requests";
}
}
else {
echo "No pending requests";
}
}
else {
header("location: index.php");
}
?>
</div>
<div class="incomingLeaderboardRequests">
<h2>Incoming Leaderboard Requests</h2>
<div id="disp_data"></div>
</div>
<script type="text/javascript">
disp_data();
function disp_data() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "updateLeaderboardRequests.php?status=disp",false);
xmlhttp.send(null);
document.getElementById("disp_data").innerHTML=xmlhttp.responseText;
}
function acceptRow(id) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "updateLeaderboardRequests.php?id="+id+"&status=accept", false);
xmlhttp.send(null);
disp_data();
}
function declineRow(id) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "updateLeaderboardRequests.php?id="+id+"&status=decline", false);
xmlhttp.send(null);
disp_data();
}
</script>
</body>
</html>