forked from moidmw/Social
/
user.php
executable file
·280 lines (252 loc) · 11.5 KB
/
user.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
<html>
<head>
<link rel="stylesheet" href="includes/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="includes/css/bootstrap.min.css">
<link rel="stylesheet" href="Stylesheets/stylesheet.css">
<link href='http://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="menu-trans/assets/css/hmbrgr.min.css"/>
<?php
include "connect.php";
session_start();
if (!$_COOKIE['userid'] && !$_SESSION['id']) {
header('Location:index.php?login=0');
}
include "scrapy.php";
include "meta_scraping.php";
$user_id = $_SESSION['id'];
if (!$_SESSION['id']) {
$user_id = $_COOKIE['userid'];
}
$_COOKIE['userid'];
$user_query = $conn->query("select * from user_info where id = $user_id");
$user_row = $user_query->fetch();
$dp_query = $conn->query("select * from display_pic where user_id = $user_id");
$dp_row = $dp_query->fetch();
?>
</head>
<body>
<!--<img src="img/Wallpaper%20(13).jpg" style="position:fixed;">-->
<!--<img id="para-image" src="img/Digit%20(16).jpg">-->
<div class="container-fluid" style="padding-top: 20px">
<!-- off canvas menu-->
<div class="friends sidebar">
<div class="sidebar_option"><a href="#"><img src="img/logo.png" class="logo" style="margin-left: 10px"></a>
</div>
<!-- home button-->
<div class="sidebar_option"><a href="home.php" class="side-option"><span><img src="img/home.png"></span>Home</a>
</div>
<div class="sidebar_option"><a href="aboutu.php" class="side-option"><?php
echo '<span><img src="' . $dp_row['dp'] . '" class="user_dp"></span>';
echo $user_row['firstname']; ?></a></div>
<!-- number of friends-->
<?php
$un = true;
$kn = true;
$ad = true;
$wl = true;
$friend = 0;
$request = 0;
//friend list
$query = $conn->query("select * from user_info");
while ($row = $query->fetch()) {
$get_id = $row['id'];
if ($get_id != $user_id) {
$count_query = $conn->query("select count(*) from friends where user_id = $user_id and friend_id = $get_id");
$row = $count_query->fetchColumn();
if ($row == 1) {
$f_query = $conn->query("select * from friends where user_id = $get_id and friend_id = $user_id");
$r_query = $conn->query("select * from friends where user_id = $user_id and friend_id = $get_id");
$f_row = $f_query->fetch();
$r_row = $r_query->fetch();
if ($f_row['accepted'] == 1 && $r_row['accepted'] == 1) {
if ($kn) {
$kn = false;
}
$friend++;
}
}
}
}
?>
<div class="sidebar_option"><a href="friend_list.php" class="side-option"><span><img src="img/friends-icon.png"></span>Friends<span
class="badge"><?php echo $friend; ?></span></a></div>
<!-- pending requests count-->
<?php
$query = $conn->query("select * from user_info");
while ($row = $query->fetch()) {
$get_id = $row['id'];
if ($get_id != $user_id) {
$count_query = $conn->query("select count(*) from friends where user_id = $user_id and friend_id = $get_id");
$row = $count_query->fetchColumn();
if ($row == 1) {
$f_query = $conn->query("select * from friends where user_id = $get_id and friend_id = $user_id");
$r_query = $conn->query("select * from friends where user_id = $user_id and friend_id = $get_id");
$f_row = $f_query->fetch();
$r_row = $r_query->fetch();
if ($r_row['accepted'] == 0 && $f_row['accepted'] == 1) {
if ($ad) {
$ad = false;
}
$request++;
}
}
}
}
if (!$ad) {
echo '<div class="sidebar_option"><a href="friend_list.php" class="side-option"><span><img src="img/received.png"></span>Pending<span class="badge"><?php echo $request; ?></span></a></div>';
}
?>
<div class="sidebar_option"><a href="settings.php" class="side-option"><span><img src="img/settings.png"></span>Settings</a>
</div>
<div class="sidebar_option">
<?php
if (isset($_SESSION['id']) && $_SESSION['start'] == true) {
echo '<a href="logout.php" class="side-option"><span><img src="img/logout.png"></span>Logout</a>';
}
?>
</div>
</div>
<!--user info -img, name and status update-->
<div class="main_content">
<div class="row about_status">
<div class="col-md-1" style="text-align: center">
<a href="#" class="menu_toggle hmbrgr"></a>
</div>
<?php
$get_id = $_GET['id'];
$user_query = $conn->query("select * from user_info where id = $get_id");
$user_row = $user_query->fetch();
$dp_query = $conn->query("select * from display_pic where user_id = $get_id");
$dp_row = $dp_query->fetch();
echo '<div class="col-md-2 dp_box">';
echo '<a href="dp_change.php?user=' . $user_id . '"><img src="' . $dp_row['dp'] . '" class="user_dp"></a>';
echo '</div>';
echo '<div class="col-md-6">';
echo '<p id="hi">' . $user_row['firstname'] . ' ' . $user_row['lastname'];
echo '<p>' . $user_row['birth'] . '</p>';
echo '<p>' . $user_row['email'] . '</p>';
echo '</div>';
echo '<div class="col-md-2 text-center">';
$count_query = $conn->query("select count(*) from friends where user_id = $user_id and friend_id = $get_id");
$row = $count_query->fetchColumn();
if ($row == 0) {
echo '<a href="add_friends.php?id=' . $get_id . '"><img src="img/add_friend.png" style="width:50px"></a>'; //if no row exists
}
$my_count = $conn->query("select * from friends where user_id = $user_id and friend_id = $get_id");
$my_row = $my_count->fetch();
$frnd_count = $conn->query("select * from friends where user_id = $get_id and friend_id = $user_id");
$frnd_row = $frnd_count->fetch();
if ($frnd_row['accepted'] == 1 && $my_row['accepted'] == 1) {
echo '<img src="img/friends-icon.png" style="width: 50px">';
}
if ($my_row['accepted'] == 1 && $frnd_row['accepted'] == 0) {
echo '<img src="img/request.png" style="width: 50px">';
}
if ($my_row['accepted'] == 0 && $frnd_row['accepted'] == 1) {
echo '<img src="img/request.png" style="width: 50px">';
echo '<div>';
echo '<a href="accept_req.php?id=' . $get_id . '"><img src="img/accept.png" style="width:50px;"></a>';
echo '<a href="decline_req.php?id=' . $get_id . '"><img src="img/cancel.png" style="width:50px;"></a>';
echo '</div>';
}
echo '</div>'
?>
</div>
</div>
<div class="prev_content col-md-offset-2">
<?php
//
$post_query = $conn->query("select * from status_update order by event_time desc");
while ($post_row = $post_query->fetch()) {
$get_id = $post_row['user_id'];
$my_count = $conn->query("select * from friends where user_id = $user_id and friend_id = $get_id");
$my_row = $my_count->fetch();
$frnd_count = $conn->query("select * from friends where user_id = $get_id and friend_id = $user_id");
$frnd_row = $frnd_count->fetch();
if ($frnd_row['accepted'] == 1 && $my_row['accepted'] == 1) {
$id = $post_row['id'];
$post_id = 0;
if ($get_id == $_GET['id']) {
$dp_query = $conn->query("select * from display_pic where user_id = $get_id");
$dp_row = $dp_query->fetch();
// $ind_query = $conn->query("select * from status_update where user_id = $get_id");
// $post_row = $ind_query->fetch();
echo '<div class="row post">';
echo '<div class="col-md-2 text-center">';
//user image
echo '<a><img src="' . $dp_row['dp'] . '" class="post_dp"></a>';
echo '</div>';
echo '<div class="col-md-6">';
//user post
echo '<a href="comp_post.php?id=' . $post_row['id'] . '" class="prev_posts"><p style="font-size:20px">' . $post_row['title'] . '</p><img src="' . $post_row['image'] . '" class="post_img">';
echo '<p class="post_txt">' . $post_row['status_post'] . '</p></a>';
echo '</div>';
echo '</div>';
}
}
}
?>
</div>
<a href="#" class="scrollToTop"><img src="" </a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="menu-trans/assets/js/jquery.hmbrgr.min.js"></script>
<script src="includes/js/bootstrap.min.js"></script>
<!--off canvas menu-->
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#pre').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$("#file1").change(function () {
readURL(this);
});
</script>
<script type="text/javascript">
$('.hmbrgr').hmbrgr({
width: 50, // optional - set hamburger width
height: 30, // optional - set hamburger height
speed: 200, // optional - set animation speed
barHeight: 4, // optional - set bars height
barRadius: 0, // optional - set bars border radius
barColor: '#000000' // optional - set bars color
});
$(document).ready(function () {
var menu = "close";
$('.menu_toggle').click(function () {
if (menu == "close") {
var pos = window.pageYOffset;
$('.sidebar').css('-webkit-transform', 'translate(0, 0)');
$('.main_content').css('-webkit-transform', 'translate(15%,0)');
$('.menu-img').attr('src', 'img/back.png');
menu = "open";
}
else {
$('.sidebar').css('-webkit-transform', 'translate(-100%,0)');
$('.main_content').css('-webkit-transform', 'translate(0,0)');
$('.menu-img').attr('src', 'img/menu-icon.png');
menu = "close";
}
});
//Check to see if the window is top if not then display button
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
//Click event to scroll to top
$('.scrollToTop').click(function () {
$('html, body').animate({scrollTop: 0}, 800);
return false;
});
});
</script>
</body>
</html>