-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile-friends.php
130 lines (101 loc) · 4.64 KB
/
profile-friends.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
<?php
//ob_start needed to allow redirecting after login
ob_start();
//session_start() needed to use global session variabls $_SESSION etc
session_start();
include('includes/config.php');
require_once('includes/dbconnect.php');
$filename = basename(__FILE__, '.php');
if (isset($_GET['id'])) {
$profileUserName = $_GET['id'];
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<script src="https://use.fontawesome.com/ed51c90fe4.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB2qniLS_JRqdMIDCuy0L3ac7usMi6fbi4&v=3.exp&sensor=false&libraries=places"></script>
<link rel="stylesheet" href="css/offset.css">
<link rel="stylesheet" href="css/style.css">
<title>Pano - Profile</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#ffffff">
<meta property="og:title" content="Pano" />
<meta property="og:image" content="https://apppanoblob.blob.core.windows.net/assets/ogimage.jpg" />
<meta property="og:description" content="The social network taking a wider perspective " />
</head>
<body ng-app="">
<?php
include('includes/header.php');
?>
<div class="profile-header">
<?php
if (isset($_GET['id'])) {
include('includes/profile-header.php');
}
?>
</div>
<main>
<div class="profile-header">
</div>
<div class="content friends-content container">
<h2><?= $profileUserName ?>'s Friends</h2>
<br />
<hr />
<?php
include('includes/friends-list.php');
//join query to associate a UserID with their UserName.
$query = ("SELECT
user.`UserName` AS UserName, user.`UserID` AS UserID, user.`ProfilePictureID` AS ProfilePictureID
FROM friends LEFT JOIN user
ON user.`UserID` = friends.`UserID`
AND user.`UserID` != '$profileUserID'
WHERE friends.`FriendID` = '$profileUserID'");
if ($result = mysqli_query($conn, $query)) {
$count = mysqli_num_rows($result);
if ($count == 0){
echo '<h2 class="center-center">'.$profileUserName.' does not have any friends yet!</h2>';
} else {
while ($row = mysqli_fetch_array($result)) {
$isFriendOfUser = false;
$friendName = $row['UserName'];
$friendUserID = $row['UserID'];
$friendProfilePictureID = $row['ProfilePictureID'];
//if the friend is yourself, skip the iteration
if ($friendName == $profileUserName || $friendName == $_SESSION['UserName']){
continue;
}
//otherwise check to see if the logged in user is friends with this user's friends
$query2 = "SELECT * FROM friends
WHERE UserID = '$friendUserID' AND FriendID = '{$_SESSION['UserID']}'";
if ($result2 = mysqli_query($conn, $query2)) {
$count = mysqli_num_rows($result2);
//if friends, display tick, otherwise an add friend icon will appear
if ($count != 0) {
$isFriendOfUser = true;
}
}
//create a frienditem and allow the returnHTML function to run with the parameters
$row = new frienditem($friendName, $friendName, $friendProfilePictureID, $isFriendOfUser);
echo $row->returnHTML();
}
}
}
?>
</div>
</main>
<?php
include('includes/footer.php');
?>
</body>
</html>