-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
62 lines (61 loc) · 2.14 KB
/
profile.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
<?php require "header.php";?>
<?php
if (!empty($_GET["uid"])) $uid = $_GET["uid"];
if (empty($uid) || !is_numeric($uid)) {
if ($isLog) $uid = $_SESSION["uid"];
else $uid = 0;
}
?>
<div class="callout">
<?php
if ($uid != 0) {
$db = new Database();
$stmt = $db->prepare("SELECT * FROM users
WHERE users.userID = :uid");
$stmt->bindValue(":uid", $uid, SQLITE3_INTEGER);
$result = $stmt->execute();
$userData = $result->fetchArray();
if ($userData) {
echo '<ul class="accordion" data-accordion data-multi-expand="true" data-allow-all-closed="true">
<li class="accordion-item is-active" data-accordion-item>
<a href="#" class="accordion-title">'.$userData["realname"].'</a>
<div class="accordion-content" data-tab-content>
<a id="qrURL"><div id="qr-code"></div></a>
<script>
$("#qrURL").attr("href", "http://cs139.dcs.warwick.ac.uk/~u1600262/cs139/cw/profile.php?uid='.$uid.'");
new QRCode(document.getElementById("qr-code"),"http://cs139.dcs.warwick.ac.uk/~u1600262/cs139/cw/profile.php?uid='.$uid.'");
</script>
Name: <a href="profile.php?uid='.$uid.'">'.$userData["realname"].'</a><br />
Username: '.$userData["username"].'<br />
</div>
</li>
<li class="accordion-item is-active" data-accordion-item>
<a href="#" class="accordion-title">Groups</a>
<div class="accordion-content" data-tab-content>';
$stmt = $db->prepare("SELECT * FROM groups
INNER JOIN groupUserRel ON groupUserRel.groupID = groups.groupID
WHERE groupUserRel.userID = :uid");
$stmt->bindValue(":uid", $uid, SQLITE3_INTEGER);
$result = $stmt->execute();
$count = 0;
while ($group = $result->fetchArray()) {
echo '<a href="viewGroup.php?gid='.$group["groupID"].'">'
.$group["name"].'</a><br />';
$count++;
}
if ($count == 0) echo '<div class="callout warning">'.$userData["realname"]
.' is not part of any group :(</div>';
echo' </div>
</li>
</ul>';
} else {
echo '<div class="callout warning">User not found.</div>';
die();
}
} else {
echo '<div class="classout warning">No user provided.</div>';
die();
}
?>
</div>
<?php require "footer.php";?>