-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.php
242 lines (189 loc) · 12.4 KB
/
header.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
<?php
require 'config/config.php';
include("./includes/classes/User.php");
include("./includes/classes/Post.php");
include("./includes/classes/Message.php");
include("./includes/classes/Notification.php");
if(isset($_SESSION['username'])){
$userLoggedIn = $_SESSION['username'];
$user_details_query = mysqli_query($con, "SELECT * FROM users WHERE username='$userLoggedIn'");
$user = mysqli_fetch_array($user_details_query);
}
else {
header("Location: register.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kouamedia</title>
<!------------------ Connecting to ----- javascript ------------------------>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous">
</script>
<script src="./Assets/js/kouam.js"></script>
<script src="./Assets/js/bootbox.min.js"></script>
<script src="./Assets/js/jcrop_bits.js"></script>
<script src="./Assets/js/jquery.Jcrop.js"></script>
<!------------------ Connecting to bootstrap----- css ------------------------>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<!---- link style.css----->
<link rel="stylesheet" href="./Assets/CSS/style.css">
<link rel="stylesheet" href="./Assets/CSS/jquery.Jcrop.css">
</head>
<body>
<div class="top_bar">
<div class="logo">
<a href="index.php">Kouamedia!</a>
</div>
<div onclick="toggle()" id="menu" class="menu_icon btn btn-secondary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list"
viewBox="0 0 16 16">
<path fill-rule="evenodd"
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z" />
</svg>
</div>
<div id="nav_content" class="nav_content">
<div class="search">
<form action="search.php" method="GET" name="search_form">
<input type="text" name="q" onkeyup="getLiveSearchUsers(this.value, '<?php echo $userLoggedIn;?>')"
id="search_text_input" placeholder="Search..." autocomplete="off">
<div class="button_holder">
<img src="./Assets/images/icons/search.png" alt="">
</div>
</form>
<!-- live search results section -->
<!-- <div class="search_results">
</div>
<div class="search_results_footer_empty">
</div> -->
</div>
<nav class="nav_icons">
<?php
// unread messages
$messages = new Message($con, $userLoggedIn);
$num_messages = $messages->getUnreadNumber();
// unread notifications
$notifications = new Notification($con, $userLoggedIn);
$num_notifications = $notifications->getUnreadNumber();
// num of friend requests
$user_obj = new User($con, $userLoggedIn);
$num_requests = $user_obj->getNumberOfFriendRequests();
?>
<a href="<?php echo $userLoggedIn;?>">
<?php echo $user["first_name"]?>
</a>
<a href="index.php">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-house-door" viewBox="0 0 16 16">
<path
d="M8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4.5a.5.5 0 0 0 .5-.5v-4h2v4a.5.5 0 0 0 .5.5H14a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146zM2.5 14V7.707l5.5-5.5 5.5 5.5V14H10v-4a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v4H2.5z" />
</svg>
</a>
<a href="javascript:void(0);" onclick="getDropdownData('<?php echo $userLoggedIn; ?>', 'message')">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-chat-left-dots" viewBox="0 0 16 16">
<path
d="M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z" />
<path
d="M5 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" />
</svg>
<?php
if($num_messages > 0){
echo '
<span class="notification_badge" id="unread_message">' . $num_messages . '</span>';
}
?>
</a>
<a href="javascript:void(0);" onclick="getDropdownData('<?php echo $userLoggedIn; ?>', 'notification')">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-bell" viewBox="0 0 16 16">
<path
d="M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z" />
</svg>
<?php
if($num_notifications > 0){
echo '
<span class="notification_badge" id="unread_notification">' . $num_notifications . '</span>';
}
?>
</a>
<a href="requests.php">
<!-- friend requests -->
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-people" viewBox="0 0 16 16">
<path
d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816zM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275zM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4z" />
</svg>
<?php
if($num_requests > 0){
echo '
<span class="notification_badge" id="unread_requests">' . $num_requests . '</span>';
}
?>
</a>
<a href="settings.php">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-gear" viewBox="0 0 16 16">
<path
d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492zM5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0z" />
<path
d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52l-.094-.319zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115l.094-.319z" />
</svg>
</a>
<a href="./includes/handlers/logout.php">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor"
class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd"
d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd"
d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg>
</a>
</nav>
</div>
<div class="dropdown_data_window" style="height: 0px; border:none;"></div>
<input type="hidden" id="dropdown_data_type" value="">
</div>
<div class="wrapper">
<script>
var userLoggedIn = '<?php echo $userLoggedIn?>';
$(document).ready(function() {
$('.dropdown_data_window').scroll(function() {
var inner_height = $('.dropdown_data_window').innerHeight(); // div containig data
var scroll_top = $('.dropdown_data_window').scrollTop();
var page = $('.dropdown_data_window').find('.nextPageDropdownData').val();
var noMoreData = $('.dropdown_data_window').find('.noMoreDropdownData').val();
if ((scroll_top + inner_height >= $('.dropdown_data_window')[0].scrollHeight) &&
noMoreData == 'false') {
var pageName; // holds name of page to send ajax request to
var type = $('#dropdown_data_type').val();
if (type == 'notification') {
pageName = "ajax_load_notifications.php"
} else if (type == 'message') {
pageName = "ajax_load_messages.php"
}
var ajaxReq = $.ajax({
url: "./includes/handlers/" + pageName,
type: "POST",
data: "page=" + page + "&userLoggedIn=" + userLoggedIn,
cache: false,
success: function(response) {
$('.dropdown_data_window').find('.nextPageDropdownData')
.remove(); // remove current .nextpage
$('.dropdown_data_window').find('.noMoreDropdownData')
.remove(); // remove current .nextpage
$('.dropdown_data_window').append(response);
}
});
} //end if
return false;
}); // end $(document).ready(function())
})
</script>