-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnotifications.php
More file actions
259 lines (203 loc) · 12.3 KB
/
notifications.php
File metadata and controls
259 lines (203 loc) · 12.3 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
session_start();
$now = time();
$then = $_SESSION['time'];
$diff = $now - $then;
if( $diff > 600000 ) {
session_destroy();
header('Location: http://localhost:8080/projekt/expired.html');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Player statistics</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="app.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src = ./app.js> </script>
</head>
<body style="background-color: #e6ffff">
<?php
$s = '';
$db = new mysqli('127.0.0.1', 'root', '', 'player_stats');
if( isset($_SESSION['priv']) ) {
if( isset($_SESSION['priv']) ) {
if( $_SESSION['priv'] == 1 ) $s = $_SESSION['user'] . '(admin)  ';
else {
$s = $_SESSION['user'];
}
}
}
$q = "SELECT * FROM followers_pending WHERE want_follow=" . $_SESSION['id'];
$res = $db->query($q);
$foll = $res->num_rows;
//$q = "SELECT notification FROM users_notifications WHERE seen=1 AND ID=" . $_SESSION['id'];
$q = "UPDATE users_notifications SET was_fav=1 WHERE reg_br_igr IN ( SELECT reg_br_igr FROM users_igrac WHERE ID=" . $_SESSION['id'] . " ) AND ID=" . $_SESSION['id'];
$db->query($q);
$q = "UPDATE users_notifications SET seen=0 WHERE was_fav=0 AND ID=" . $_SESSION['id'];
$db->query($q);
$q = "SELECT notification FROM users_notifications WHERE seen=1 AND ID=" . $_SESSION['id'];
$res = $db->query($q);
if ($res) {
$not = $res->num_rows;
}
else $not = 0;
$q = "SELECT weekNo, startDate FROM weeks ORDER BY weekNo DESC";
$res = ($db->query($q))->fetch_assoc();
echo "<div class='container-fluid top-menu'>
<table>
<tr> <td width='25%'>
<a href='#' class='btn btn-dark' id='menu-toggle'><div class='menu-icon'></div>
<div class='menu-icon'></div>
<div class='menu-icon'></div></a>";
$sum = $foll + $not;
if( $foll == 0 && $not == 0 ) {
echo " <button type='button' class='btn btn-dark home-btn'><a href='notifications.php' style='text-decoration: none;color: white'>Notifications <span class='badge badge-light'>0</span></a></button>";
}else {
echo " <button type='button' class='btn btn-dark home-btn'><a href='notifications.php' style='text-decoration: none;color: white'>Notifications <span class='badge badge-light' style='color: red'>" . $sum . "</span></a></button>";
}
echo " <button type='button' class='btn btn-dark home-btn'><a href='app.php' style='text-decoration: none;color: white'>Home</a></button>
</td>
<td style='text-align: center; padding: 20px; font-family: Papyrus, fantasy; font-size: 49px; font-style: normal; font-variant: small-caps; font-weight: 700; line-height: 40.6px;'><h2>Welcome to the site about football players</h2></td>
<td width='25%' style='text-align: right; padding: 20px'><button type='button' class='btn btn-dark btn-sm'><a href='logout.php' style='text-decoration: none;color: white'>LogOut " . $s . "</a></button>
<br><br><span class='badge badge-dark'style='padding-top: 10px; padding-bottom: 10px; padding-left: 6px; padding-right: 6px;
'> Week ".$res['weekNo']." started on ".$res['startDate']."</span>
</td>
</tr>
</table>
</div>";
?>
<div id="wrapper">
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li>
<?php
$db = new mysqli('127.0.0.1', 'root', '', 'player_stats');
$q = "SELECT back_photo FROM users WHERE ID=" . $_SESSION['id'];
$res = $db->query($q);
while( $r = $res->fetch_assoc() ) {
$pic = $r['back_photo'];
}
echo '<div id="wrapper" class="images" style="background-image: url(' . $pic . ');">
<div class="row">
<div class="col-md-3">';
$q = "SELECT user_photo FROM users WHERE ID=" . $_SESSION['id'];
$res = $db->query($q);
while( $r = $res->fetch_assoc() ) {
$pic = $r['user_photo'];
}
echo "<a href='users_info.php?id=" . $_SESSION['id'] . "' id='post'><img src=" . $pic . " alt='Avatar' class='avatar useravatar'></a>";
echo '</div>
<div class="col-md-8 sidebar-text">';
$q = "SELECT name, last_name, e_mail FROM users WHERE ID=" . $_SESSION['id'];
$res = $db->query($q);
while( $r = $res->fetch_assoc() ) {
echo "<span class='sidebar-name'>" . $r['name'] . " " . $r['last_name'] . "</span><br>";
echo "<small class='sidebar-name'>" . $r['e_mail'] . "</small>";
}
echo '</div>
</div>
</div>';
?>
</li>
<li><a href="forwards.php" id="fwd">Forwards</a></li>
<li><a href="midfielders.php" id="mid">Midfielders</a></li>
<li><a href="defenders.php" id="def">Defenders</a></li>
<li><a href="goalkeepers.php" id="gk">Goalkeepers</a></li>
<li><a href="favourites.php" id="fav">Favourites</a></li>
<li><a href="settings.php" id="pos">Settings</a></li>
<li><a href='users.php' id='pos'>Users</a></li>
<!--<?php
if( isset($_SESSION['priv']) ) {
if( $_SESSION['priv'] == 1 ) echo "<li><a href='users.php' id='pos'>Users</a></li>";
}
?>-->
</ul>
</div>
<div id="page-content-wrapper" style="background-color: white;">
<div class="row align-items-center">
<div class="col-md-8">
<h2 style="text-align: center;">Notifications</h2><br>
<div id = "pagination_data"> <!--class = "table-responsive"-->
</div>
<?php
$db = new mysqli('127.0.0.1', 'root', '', 'player_stats');
$q = "SELECT ID, name, last_name, e_mail, user_photo FROM users JOIN followers_pending using(ID) WHERE want_follow=" . $_SESSION['id'];
$res = $db->query($q);
$fu = 0;
if( $res->num_rows == 0 ) {
$fu = 1;
}else {
while( $r = $res->fetch_assoc() ) {
echo "<div class='row'>
<div class='col-md-3'>
<img src='" . $r['user_photo'] . "' height='55px' width='55px'><br>
<button type='button' class='btn btn-dark btn-sm'><a href='users_info.php?id=" . $r['ID'] . "' style='text-decoration: none;color: white'>User info</a></button>
</div>
<div class='col-md-3'>
Name: " . $r['name'] . "<br>
Last name: " . $r['last_name'] . "<br>
E-mail: " . $r['e_mail'] . "<br>
</div>
<div class='col-md-6'>
<button type='button' class='btn btn-dark btn-sm'><a href='accept_foll.php?id=" . $r['ID'] . "' style='text-decoration: none;color: white'>Accept</a></button>
<button type='button' class='btn btn-dark btn-sm'><a href='reject_foll.php?id=" . $r['ID'] . "' style='text-decoration: none;color: white'>Reject</a></button>
</div>
</div><br><hr>";
}
}
$q = "SELECT notification FROM users_notifications WHERE seen=1 AND ID=" . $_SESSION['id'] . " ORDER BY recieved DESC";
$res = $db->query($q);
if ($res) {
$not = $res->num_rows;
}
else {
$not = 0;
}
$fn = 0;
if($not) {
while( $r = $res->fetch_assoc() ) {
echo $r['notification'] . "
<button type='button' class='btn btn-dark btn-sm' style='float: right'><a href='remove_notification.php?id=" . $_SESSION['id'] . "¬=" . $r['notification'] . "' style='text-decoration: none;color: white'>x</a></button>
<br><hr>";
}
}else $fn = 1;
if( $fu == 1 && $fn == 1 ) echo "<h3 style='text-align: center;color: grey'>No results</h3>";
?>
<!--<script>
var pos = 'GK';
$(document).ready(function(){
load_data(1);
function load_data(page){
$.ajax({
url:"pagination.php",
method: "POST",
data:{page:page,
pos:pos},
success:function(data){
$('#pagination_data').html(data);
}
})
}
$(document).on('click', '.pagination_link',function(){
var page = $(this).attr("id");
load_data(page);
})
});
</script>-->
</div>
</div>
</div>
</div>
<script type="text/javascript">
document.getElementById('menu-toggle').addEventListener( 'click', e => {
e.preventDefault();
document.getElementById('wrapper').classList.toggle('menuDisplayed');
});
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>