-
Notifications
You must be signed in to change notification settings - Fork 0
/
Searching_for_friends.php
319 lines (266 loc) · 14 KB
/
Searching_for_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
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
<?php
include("dbconfig.php");
include("friending_functions.php");
#require_once('common_navbar.html');
session_start();
if (isset($_SESSION['login_user'])){
$user_email = $_SESSION['login_user'];
} else {
$user_email = "error";
}
$user_accountID = mysqli_fetch_assoc(search_by_email($user_email,$conn))['accountID'];
$friend_list = load_friend_list($user_accountID, $conn);
if (isset($_POST["name"])&&(!empty($_POST["name"]))){
$friend_name = mysqli_real_escape_string($conn, $_POST["name"]);
$search_friend_list = search_by_name($friend_name, $conn);
} else if (isset($_POST["age"])&&(!empty($_POST["age"]))){
$friend_age = mysqli_real_escape_string($conn, $_POST["age"]);
$search_friend_list = search_by_age($friend_age, $conn);
} else if (isset($_POST["city"])&&(!empty($_POST["city"]))){
$friend_city = mysqli_real_escape_string($conn, $_POST["city"]);
$search_friend_list = search_by_city($friend_city, $conn);
} else if (isset($_POST["country"])&&(!empty($_POST["country"]))){
$friend_country = mysqli_real_escape_string($conn, $_POST["country"]);
$search_friend_list = search_by_country($friend_country, $conn);
} else if (isset($_POST["email"])&&(!empty($_POST["email"]))){
$friend_email = mysqli_real_escape_string($conn, $_POST["email"]);
$search_friend_list = search_by_email($friend_email, $conn);
} else if (isset($_POST["friend_of_f"])&&(!empty($_POST["friend_of_f"]))){
$friend_friend = mysqli_real_escape_string($conn, $_POST["friend_of_f"]);
$search_friend_list = search_by_friend($friend_friend, $conn);
} else {
echo "<script>location.href='FriendList.php'</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Social Media</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
/* Add a gray background color and some padding to the footer */
footer {
background-color: #f2f2f2;
padding: 25px;
}
.carousel-inner img {
width: 100%; /* Set width to 100% */
min-height: 200px;
}
/* Hide the carousel text when the screen is less than 600 pixels wide */
@media (max-width: 600px) {
.carousel-caption {
display: none;
}
}
</style>
</head>
<body>
<!--the common nav bar-->
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"><span class="glyphicon glyphicon-apple"></span></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li id="profile_header"><a href="welcome.php">Profile</a></li>
<li id="friendList_header"><a href="FriendList.php">Friend list</a></li>
<li id="friendInvitation_header"><a href="friend_invitation.php">Friend invitation</a></li>
<li id="selectedFriends_header"><a href="select_friends.php">Create friend circle</a></li>
<li id="chatRoom_header"><a href="chat_room.php">Chat room</a></li>
<li id="chatRoom_header"><a href="blog.php">Blog</a></li>
<li id="chatRoom_header"><a href="allCollections.php">Photo Collections</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="logout.php"><span class="glyphicon glyphicon-log-in"></span> Log out</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h3> Friends found:</h3>
<br>
<div class="row">
<div class="col-sm-3">
<?php
if ($search_friend_list->num_rows == 0) {
echo "Sorry, no result found.<br><br>"; ?>
<img src="image1.jpeg" class="img-responsive" style="width:100%" alt="Image"> <br> <?php
} else {
while ($row = mysqli_fetch_assoc($search_friend_list)){
if (!($row['accountID']==$user_accountID)){
$friend_accountID = $row['accountID'];
$privacy_setting = check_privacy_status($friend_accountID,$conn);
$isFriend = false;
while ($f_row = mysqli_fetch_assoc($friend_list)){
if ($row['accountID']==$f_row['accountID']){
$isFriend = true;
}
} ?>
<img src="image5.png" class="img-responsive" style="width:80%" alt="Image">
<p>
<?php if (!$isFriend){
$isInvited = false;
$sent_friend_invitation = load_sent_friend_invitation($user_accountID, $conn);
while ($i_row = mysqli_fetch_assoc($sent_friend_invitation)){
if ($friend_accountID==$i_row['accountID']){
$isInvited = true;}
}
$hasBeenInvited = false;
$sent_friend_invitation = load_sent_friend_invitation($friend_accountID, $conn);
while ($j_row = mysqli_fetch_assoc($sent_friend_invitation)){
if ($user_accountID==$j_row['accountID']){
$hasBeenInvited = true;}
}
if ($privacy_setting == "public") {
echo "<br>Name: ".$row['name']."<br>Email address: ".$row['email_address']."<br>Age: ".$row['age']."<br>Self_introduction: ".$row['self_introduction']."<br>City: ".$row['city']."<br>Country: ".$row['country'];
?></p>
<ul class="nav navbar-nav">
<li><a href="allCollections.php?accountID=<?php echo $row['accountID']?>">Photos</a></li>
<li class="active"><a href="blog.php?accountID=<?php echo $row['accountID']?>">Blog</a></li>
</ul>
<?php if ($isInvited||$hasBeenInvited){
echo '<b>Invitation has been sent. </b><a href="friend_invitation.php">Go and check.</a>';
} else { ?>
<form action="friending_backend.php" method="post">
<input type="submit" class = "btn btn-warning" name="select" value="Send invitation" />
<input name="a" type="hidden" id="a" value="<?php
echo $row['accountID'];?>" />
</form>
<br>
<?php
}} else {
echo "<br>Name: ".$row['name']."<br>City: ".$row['city'];
?>
<ul class="nav navbar-nav">
<li><a href="allCollections.php?accountID=<?php echo $row['accountID']?>">Photos</a></li>
</ul>
<?php if ($isInvited||$hasBeenInvited){
echo '<b>Invitation has been sent. </b><a href="friend_invitation.php">Go and check.</a>';
} else { ?>
<form action="friending_backend.php" method="post">
<input type="submit" class = "btn btn-warning" name="select" value="Send invitation" />
<input name="a" type="hidden" id="a" value="<?php
echo $row['accountID'];?>" />
</form>
<?php }}
} else {
if ($privacy_setting != "private") {
echo "<br>Name: ".$row['name']."<br>Email address: ".$row['email_address']."<br>Age: ".$row['age']."<br>Self_introduction: ".$row['self_introduction']."<br>City: ".$row['city']."<br>Country: ".$row['country']."<br><b>Has been your friend</b>";
?>
<ul class="nav navbar-nav">
<li><a href="allCollections.php?accountID=<?php echo $row['accountID']?>">Photos</a></li>
<li class="active"><a href="blog.php?accountID=<?php echo $row['accountID']?>">Blog</a></li>
</ul>
<?php } else {
echo "<br>Name: ".$row['name']."<br>City: ".$row['city'];
?>
<ul class="nav navbar-nav">
<li><a href="#">Photos</a></li>
</ul>
<?php } ?>
<form action="friending_backend.php" method="post">
<input type="submit" class = "btn btn-warning" name="select" value="Remove" />
<input name="b" type="hidden" id="b" value="<?php
echo $row['accountID'];?>" />
</form>
<br>
<?php
} }}} ?>
</div>
<div class="col-sm-5">
</div>
<div class="col-sm-4">
<h4>Searching for a friend:</h4>
<br>
<div class="row">
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-4">
<p>Name:
<input type="text" name = "name" class="form-control" placeholder="Jacky" aria-describedby="basic-addon1" > </p>
</div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div></form>
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-4">
<p>age:
<input type="number" name = "age" class="form-control" placeholder="25" aria-describedby="basic-addon1"> </p>
</div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div></div></form>
<div class="row">
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-4">
<p>City:
<input type="text" name = "city" class="form-control" placeholder="london" aria-describedby="basic-addon1" > </p>
</div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div></form>
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-4">
<p>Country:
<input type="text" name = "country" class="form-control" placeholder="U.K." aria-describedby="basic-addon1"> </p>
</div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div>
</form>
</div>
<div class="row">
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-10">
<p>Email address:
<input type="text" name = "email" class="form-control" placeholder="xxx@fake.com" aria-describedby="basic-addon1"> </p>
</div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div>
</form>
</div>
<div class="row">
<form action="Searching_for_friends.php" method = "post">
<div class="col-sm-10">
<p>Friends of a known friend: <br>
<?php
$r_friend_list = load_friend_list($user_accountID, $conn);
$select = '<select name="friend_of_f">';
while ($row = mysqli_fetch_assoc($r_friend_list)) {
$friend_accountID = $row['accountID'];
$privacy_setting = check_privacy_status($friend_accountID, $conn);
if ($privacy_setting != "private") {
$select.='<option value="'.$row['accountID'].'">'.$row['name'].'</option>';
} }
$select.='</select>';
echo $select;?>
</p></div>
<div class="col-sm-2">
<br>
<input type="submit" class = "btn btn-info" name="select" value="Go" />
</div>
</form>
</div>
</div>
<hr>
</div>
<br>
<?php require_once('common_footer.html');?>
</body>
</html>