-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriends.php
More file actions
147 lines (135 loc) · 7.23 KB
/
friends.php
File metadata and controls
147 lines (135 loc) · 7.23 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
<?php include 'config.php'; ?>
<!DOCTYPE html>
<html>
<head>
<title>Friends <?php include 'includes/title.php'; ?></title>
<link href="assets/css/bootstrap.css" rel='stylesheet' type='text/css' />
<!-- Custom Theme files -->
<link href="assets/css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- Custom Theme files -->
<?php include 'includes/stylesheets.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container">
<div class="total-info">
<?php include 'includes/left_panel.php'; ?>
<div class="col-md-4 grid_2">
<!--Friends-->
<?php //friends
$sql_newest_mem1=mysqli_query($dbconfig,"SELECT *,CONCAT(firstName,' ',lastName) AS name FROM my_friends LEFT JOIN users ON my_friends.userID=users.userID
WHERE my_friends.friendWith='".$userid."' UNION SELECT *,CONCAT(firstName,' ',lastName) AS name FROM my_friends LEFT JOIN users ON my_friends.friendWith=users.userID
WHERE my_friends.userID='".$userid."'");
$count_frnds=mysqli_num_rows($sql_newest_mem1);
$count_frnds = isset($count_frnds) ? $count_frnds : '';
?>
<div class="white-area"><h5>Friends (<?php echo $count_frnds; ?>)</h5></div>
<div class="profile_container <?php if($count_frnds>10) {echo 'scroll';} ?> ">
<ul class="listing">
<?php
if($count_frnds=='')
{echo '<small class="grey" style="padding:5px;">No Friends Yet</small>';}else{
while($row_friends=mysqli_fetch_assoc($sql_newest_mem1)){
?>
<a href="<?php if($row_friends['webName']==''){echo 'user/'.$row_friends["userID"].'';}else{ echo 'user/'.$row_friends["webName"].'';} ?>">
<li class="subitem_grey" style="padding:5px; ">
<img src="<?php if($row_friends['userImg']==''){echo 'images/default.jpg';}else {
echo 'uploads/'.$row_friends['userImg']; } ?>" alt="User Avatar" class="recent_chat">
<small class="" style="margin-left: 5px;">
<?php echo $row_friends['name']; ?>
</small>
</li>
</a>
<?php }} ?>
</ul>
</div>
</div><!--end col-md-4-->
<div class="col-md-3 grid_2">
<!--Friend Request-->
<?php
//fetching info whome req recieved
$sql_req=mysqli_query($dbconfig,"SELECT * FROM friend_request LEFT JOIN users ON friend_request.friendWith=users.userID
WHERE friend_request.friendWith='".$_SESSION['userid']."'") or die(mysqli_error($dbconfig));
//check of request available
$check_req=mysqli_num_rows($sql_req);
$check_req = isset($check_req) ? $check_req : '';
if($check_req!=''){
?>
<div class="white-area"><h5>Friend Request (<?php echo $check_req; ?>)</h5></div>
<div class="profile_container">
<ul class="cute">
<?php
while($row_frnd=mysqli_fetch_assoc($sql_req)){
//fetching info whose req recieved
$sql_req_accept=mysqli_query($dbconfig,"SELECT *,$name FROM friend_request LEFT JOIN users ON friend_request.userID=users.userID
WHERE friendreqID='".$row_frnd['friendreqID']."'") or die(mysqli_error($dbconfig));
($row_frnd_accept=mysqli_fetch_assoc($sql_req_accept));
?>
<li><img src="<?php if($row_frnd_accept['userImg']==''){echo 'images/default.jpg';}else {
echo 'uploads/'.$row_frnd_accept['userImg']; } ?>" alt="User Avatar" class="recent_chat">
<a href="<?php if($row_frnd_accept['webName']==''){echo 'user/'.$row_frnd_accept["userID"].'';}else{ echo 'user/'.$row_frnd_accept["webName"].'';} ?>">
<small class="" style="margin-left: 5px;">
<?php echo $row_frnd_accept['name']; ?>
</small>
</a>
<small id="right_btn">
<!--Accept Frnd Request-->
<a href="javascript:void(0);" class="click_accept_friend invite2" rel="<?php echo $row_frnd_accept['friendreqID'];?>">
<span id="req_accept<?php echo $row_frnd_accept['friendreqID'];?>"></span> <span id="accept_frnd<?php echo $row_frnd_accept['friendreqID'];?>">Accept Request</span></a>
<!--Delete Request-->
<a href="javascript:void(0);" class="click_delete_friend invite2" rel="<?php echo $row_frnd_accept['friendreqID'];?>">
<span id="req_delete<?php echo $row_frnd_accept['friendreqID'];?>"></span><span id="delete_frnd<?php echo $row_frnd_accept['friendreqID'];?>">Cancel</span></a>
</small>
<hr>
</li>
<?php } ?>
</ul>
</div><div class="div-title"></div>
<?php } ?>
<!--Friend Request Sent-->
<?php
//fetching info whome req recieved
$sql_req=mysqli_query($dbconfig,"SELECT * FROM friend_request LEFT JOIN users ON friend_request.friendWith=users.userID
WHERE friend_request.userID='".$userid."'") or die(mysqli_error($dbconfig));
//check of request available
$check_req=mysqli_num_rows($sql_req);
$check_req = isset($check_req) ? $check_req : '';
if($check_req!=''){
?>
<div class="white-area"><h5>Sent Friend Request (<?php echo $check_req; ?>)</h5></div>
<div class="profile_container">
<ul class="cute">
<?php
while($row_frnd=mysqli_fetch_assoc($sql_req)){
//fetching info whose req recieved
$sql_req_accept=mysqli_query($dbconfig,"SELECT *,$name FROM friend_request LEFT JOIN users ON friend_request.friendWith=users.userID
WHERE friendreqID='".$row_frnd['friendreqID']."'") or die(mysqli_error($dbconfig));
($row_frnd_accept=mysqli_fetch_assoc($sql_req_accept));
?>
<li><img src="<?php if($row_frnd_accept['userImg']==''){echo 'images/default.jpg';}else {
echo 'uploads/'.$row_frnd_accept['userImg']; } ?>" alt="User Avatar" class="recent_chat">
<a href="<?php if($row_frnd_accept['webName']==''){echo 'user/'.$row_frnd_accept["userID"].'';}else{ echo 'user/'.$row_frnd_accept["webName"].'';} ?>">
<small class="" style="margin-left: 5px;">
<?php echo $row_frnd_accept['name']; ?>
</small>
</a>
<small id="right_btn">
<!--Delete Request-->
<a href="javascript:void(0);" class="click_cancel_friend invite2" rel="<?php echo $row_frnd_accept['friendreqID'];?>">
<span id="req_sent_cancel<?php echo $row_frnd_accept['friendreqID'];?>"></span><span id="cancel_frnd<?php echo $row_frnd_accept['friendreqID'];?>">Cancel</span></a>
</small>
<hr>
</li>
<?php } ?>
</ul>
</div><div class="div-title"></div> <?php } ?>
</div><!--end col-md-3-->
<?php include 'includes/right_panel.php'; ?>
<!--Container Ends Here-->
<div class="clearfix"></div>
</div>
<script src="assets/js/myscript.js"></script>
<script src="assets/my-js/friend_request.js"></script>
</div>
</body>
</html>