-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
243 lines (152 loc) · 6.16 KB
/
profile.php
File metadata and controls
243 lines (152 loc) · 6.16 KB
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
<?php
require 'connection.php';
include("user.php");
include("posts.php");
if(isset($_SESSION['username']))
{
$user_logged = $_SESSION['username'];
$user_details = mysqli_query($connect, "SELECT * FROM users WHERE username = '$user_logged'");
$users = mysqli_fetch_array($user_details);
}
else{
header("Location: register.php");
}
if(isset($_GET['profile_username']))
{
$username = $_GET['profile_username'];
$user_details_query = mysqli_query($connect , "SELECT * FROM users WHERE username = '$username'");
$user_details = mysqli_fetch_array($user_details_query);
$user_friend_query = mysqli_query($connect , "SELECT * FROM friends WHERE user_from='$username' OR user_to = '$username'");
$user_friend = mysqli_num_rows($user_friend_query);
//$num_friends = (substr_count($user_details['friend_array'], ",")) -1;
$user = new User($connect , $user_logged);
$mutual = 0;// for now, has to be eddited
if($user_details['user_closed'] =="yes")
{
header("Location: user_deactivated.php");
}
//if($user->isClosed())
//{
// header("Location: user_deactivated.php");
// }
}
if(isset($_POST['remove_friend']))
{
$user = new User($connect , $user_logged);
$user->remove_friend($username);
}
if(isset($_POST['add_friend']))
{
$user = new User($connect , $user_logged);
$user->send_request($username);
}
if(isset($_POST['respond_request']))
{
header("Location: friend_request.php");
}
if(isset($_POST['friends']))
{
header("Location: friends.php?u=$username");
}
?>
<html>
<head>
<title> Amigo</title>
<!--<script src = "js/bootstrap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>-->
<link rel = "stylesheet" type = "text/css " href = "css/bootstrap.css">
<link rel = "stylesheet" type = "text/css" href = "css/style.css">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<link rel = "stylesheet" type = "text/css " href = "css/bootstrap.css">
<link rel = "stylesheet" type = "text/css" href = "css/style.css">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Muli|Raleway|Ubuntu" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Muli|Raleway|Ubuntu" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Heebo:500|Montserrat|PT+Sans|Sarala|Satisfy" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Dancing+Script|Noto+Sans|Open+Sans:300|Pacifico|Questrial|Quicksand|Slabo+27px|Source+Sans+Pro:200,400" rel="stylesheet">
</head>
<body style="background-color :#e6e9e7" >
<div class = "nav_bar">
<div class = "logosmall">
<a style ="color: white;margin-left: 30px;" href = "index.php">Amigo</a>
</div>
<div class = "search" style=" margin-top: -2.5%;margin-left: 15%;">
<form action ="search_results.php" method = "GET" name = "search_form" style="width: 30%">
<input type = "text" name ="q" placeholder ="Search for a User.." autocomplete = "off" id ="search_text">
<div class = "button_holder">
<img id = "magnify" src = "images/search2.png" >
</div>
</form>
</div>
<div class ="nav">
<a href= "<?php echo $user_logged; ?>" ><img src = "<?php echo $users['profile_pic']; ?>" style="border-radius:100px; border: 1px solid #e6e9e7;width: 38px;
margin-top: 0px;"></a>
<a href= "index.php" ><img id="navb"src = "images/nav/home.png"> </a>
<a href= "friend_request.php" ><img id ="navb" src = "images/nav/add_friend.png"> </a>
<a href= "Messages.php" ><img id = "navb" src = "images/nav/messages.png"> </a>
<a href= "settings.php" > <img id="navb" src = "images/nav/settings.png"></a>
<a href= "forms/logout.php" ><img id="navb" src = "images/nav/log_out.png"></a>
</div>
</div>
<div class = "wrapper">
<div class = "userColumn profile_column">
<img src = "<?php echo $user_details['profile_pic']; ?>" style="border-radius:100px; border: 3px solid #e6e9e7; margin-left: 8%">
<div class = "user_info">
<span id = "profile_details"> <?php echo "Posts: " . " ". $user_details['num_posts'] ;?></span><br>
<apan id = "profile_details"> <?php echo "Friends: " . $user_friend;?> </span>
<!--<p><?php echo "Mutual Friends " . $mutual;?> </p> -->
</div>
<form action ="<?php echo $username; ?>" method = "POST" id = "friend_b">
<input type = "submit" name ="friends" value ="Friends">
</form>
<form action = "<?php echo $username; ?>" id = "friend_c" method = "POST">
<?php
$user_obj = new User($connect , $username);
if($user_obj->isClosed())
{
header("Location: user_deactivated.php");
}
?>
<?php
$user_logged_in = new User($connect , $user_logged);
if($user_logged != $username)
{
if($user_logged_in->isFriend($username))
{
//remove friend
echo '<input type="submit" name="remove_friend" style="background-color:#E15E3A" value ="Remove Friend"<br>';
}
else if($user_logged_in->receive_request($username) ) //respond
{
echo '<input type="submit" name="respond_request" value ="Respond to Request"<br>';
// add friend
}
else if($user_logged_in->sent_request($username) ) //
{
echo '<input type="submit" name="" class="default" value ="Request Sent"<br>';
// add friend
}
else {
echo '<input type="submit" name="add_friend" class="success" value="Add Friend"><br>';
}
}
?>
<br><br>
</form>
</div>
<div class = "feed column">
<div class = "mypage"> <?php echo $user_details['first_name'] . " " . $user_details['last_name']?></div>
</div>
<div class = "feed column">
<?php
if(isset($_GET['profile_username'])){
$username = $_GET['profile_username'];
}
$ppost = new Posts($connect , $username);
$ppost->displayProfilePosts();
?>
<br><br>
<span class ="no"> No more posts to show :) </span>
</div>
</div>