-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
555 lines (529 loc) · 34.5 KB
/
profile.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<?php
session_start();
//Include database connection
require_once('includes/db.inc.php');
//Include remember me login
require_once('includes/remember_cookie.inc.php');
//Include CSRFToken generator
require_once('includes/csrf_token.inc.php');
//Print function to avoid XSS
require_once('includes/xss.inc.php');
//If user isn't logged in he cant see a shopping cart
require_once('includes/redirect_home.inc.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The Official Page of Engage Games">
<meta name="author" content="Szymon Bialkowski & Shane Doyle">
<link rel="icon" href="assets/img/favicon.ico">
<title>Engage Profile</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="assets/css/profile.css" rel="stylesheet">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,700" rel="stylesheet">
<!-- HTML5 shiv and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="loading"></div>
<?php
//Navbar
require_once('includes/navbar.inc.php');
?>
<div class="main-body">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="catalogue">
<div class="container">
<div class="row">
<div class="col-sm-12">
<img type="button"
data-toggle="modal" data-target="#changePhoto" class="profile-picture" src="assets\img\users\<?php xss($_SESSION['user_image_path']); ?>" alt="The profile picture of <?php xss($_SESSION['username']); ?>">
<h3 class="name text-white"><?php xss($_SESSION['username']); ?></h3>
<h5 class="text-white"><?php xss($_SESSION['email']); ?></h5>
<?php
if (!empty($_GET['request']))
{
switch ($_GET['request'])
{
case 'password':
if (!empty($_GET['q']))
{
switch ($_GET['q'])
{
case 'empty':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Password</h4>
Please fill out all the fields.
</div>
<?php
break;
case 'lenght':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Password</h4>
Your password is too long. Max 72
</div>
<?php
break;
case 'nonmatching':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Password</h4>
Your passwords did not match.
</div>
<?php
break;
case 'incorrect':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Password</h4>
Incorrect current password.
</div>
<?php
break;
case 'success':
?>
<div class="alert alert-success" role="alert">
<h4>Change Password</h4>
You've successfully changed your password.
</div>
<?php
break;
default:
break;
}
}
break;
case 'name':
if (!empty($_GET['q']))
{
switch ($_GET['q'])
{
case 'empty':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Name</h4>
Please fill out all the fields.
</div>
<?php
break;
case 'invalid':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Name</h4>
Please only enter numbers and letters.
</div>
<?php
break;
case 'lenght':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Name</h4>
Input is too long.
</div>
<?php
break;
case 'nouser':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Name</h4>
This user doesn't exist.
</div>
<?php
break;
case 'incorrect':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Name</h4>
Incorrect password.
</div>
<?php
break;
case 'success':
?>
<div class="alert alert-success" role="alert">
<h4>Change Name</h4>
You've successfully changed your name.
</div>
<?php
break;
default:
break;
}
}
break;
case 'email':
if (!empty($_GET['q']))
{
switch ($_GET['q'])
{
case 'empty':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
Please fill out all the fields.
</div>
<?php
break;
case 'invalid':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
Invalid characters in email.
</div>
<?php
break;
case 'lenght':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
Input is too long.
</div>
<?php
break;
case 'nouser':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
This user doesn't exist.
</div>
<?php
break;
case 'incorrect':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
Incorrect password.
</div>
<?php
break;
case 'exists':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Email</h4>
User with this email already exists.
</div>
<?php
break;
case 'success':
?>
<div class="alert alert-success" role="alert">
<h4>Change Email</h4>
You've successfully changed your email.
</div>
<?php
break;
default:
break;
}
}
break;
case 'picture':
if (!empty($_GET['q']))
{
switch ($_GET['q'])
{
case 'empty':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Photo</h4>
Empty photo sent.
</div>
<?php
break;
case 'ext':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Photo</h4>
Invalid extension.
</div>
<?php
break;
case 'size':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Photo</h4>
Photo is too large.
</div>
<?php
break;
case 'invalidimage':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Photo</h4>
Invalid image.
</div>
<?php
break;
case 'servererror':
?>
<div class="alert alert-danger" role="alert">
<h4>Change Photo</h4>
Server has encountered an error.
</div>
<?php
break;
default:
break;
}
}
break;
case 'delete':
if (!empty($_GET['q']))
{
switch ($_GET['q'])
{
case 'empty':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Please fill in all fields.
</div>
<?php
break;
case 'bot':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Please fill out all fields.
</div>
<?php
break;
case 'invalid':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Illegal email.
</div>
<?php
break;
case 'length':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Email or Password are too long.
</div>
<?php
break;
case 'email':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Your email does not match.
</div>
<?php
break;
case 'password':
?>
<div class="alert alert-danger" role="alert">
<h4>Delete Account</h4>
Incorrect password.
</div>
<?php
break;
default:
break;
}
}
break;
default:
break;
}
}
?>
<a href="shopping_cart.php">
<button type="button" class="btn btn-light middle middle-first">Shopping cart</button>
</a>
<button type="button" class="btn btn-light middle middle" data-toggle="modal" data-target="#changePass">
Change Password
</button>
<button type="button" class="btn btn-light middle" data-toggle="modal" data-target="#changeName">
Change Name
</button>
<button type="button" class="btn btn-light middle" data-toggle="modal" data-target="#changeEmail">
Change Email
</button>
<button type="button" class="btn btn-light middle" data-toggle="modal" data-target="#deleteAcc">
Delete Account
</button>
<a href="includes/logout.inc.php">
<button type="button" class="btn btn-light middle">Logout</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="changePhoto" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Change Profile Picture</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="includes/change_photo.inc.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="custom-file">
<input type="file" name="profile_picture" id="file_input" class="custom-file-input">
<span class="custom-file-control" id="photo_name"></span>
<input type="hidden" name="CSRFToken" value="<?php xss($_SESSION['CSRFToken']); ?>">
</label>
</div>
<button type="submit" class="btn btn-dark modal-submit">Change Photo</button>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="changePass" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Change Password</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="includes/change_password.inc.php" method="post">
<div class="form-group">
<label for="exampleInputPassword1">Current Password*</label>
<input type="password" class="form-control" name="current_password" placeholder="Password" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">New Password*</label>
<input type="password" class="form-control" name="new_password" placeholder=" New Password" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Confirm New Password*</label>
<input type="password" class="form-control" name="new_password_check" placeholder="Confirm Password" required>
<input type="hidden" name="CSRFToken" value="<?php xss($_SESSION['CSRFToken']); ?>">
</div>
<button type="submit" class="btn btn-dark modal-submit">Change Password</button>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="changeName" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Change Name</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="delete_account" action="includes/change_name.inc.php" method="post">
<div class="form-group">
<label for="exampleInputPassword1">New Name</label>
<input type="text" class="form-control" placeholder="Name" name="new_name" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" placeholder="Password" name="password" required>
<input type="hidden" name="CSRFToken" value="<?php xss($_SESSION['CSRFToken']); ?>">
</div>
<button type="submit" class="btn btn-dark modal-submit">Change Name</button>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="changeEmail" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Change Email</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="includes/change_email.inc.php" method="post">
<div class="form-group">
<label for="exampleInputPassword1">New Email</label>
<input type="email" class="form-control" name="new_email" placeholder="New Email" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="password" placeholder="Password" required>
<input type="hidden" name="CSRFToken" value="<?php xss($_SESSION['CSRFToken']); ?>">
</div>
<button type="submit" class="btn btn-dark modal-submit">Change Email</button>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="deleteAcc" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body delete-account-first">
<p>Are you sure you want to permanently delete your account?</p>
</div>
<div class="modal-body">
<form action="includes/delete_account.inc.php" method="post">
<div class="alert alert-danger hidden-tick" role="alert">
Please tick the reCaptcha box.
</div>
<div class="form-group first-form-group">
<label for="exampleInputPassword1">Current Email</label>
<input type="email" class="form-control" name="email" placeholder="Email" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Current Password</label>
<input type="password" class="form-control" name="password" placeholder="Confirm Password" required>
<input type="hidden" name="CSRFToken" value="<?php xss($_SESSION['CSRFToken']); ?>">
</div>
<div class="g-recaptcha" data-sitekey="6LdafTMUAAAAAEjOROjGfi4qCGu6UOeABrjGIWRw">
</div>
<button type="submit" class="btn btn-danger modal-submit">DELETE ACCOUNT</button>
</form>
</div>
</div>
</div>
</div>
<?php
//Print footer
require_once('includes/footer.inc.php');
?>
<script src="assets/js/file_input.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<!-- JQuery JavaScript -->
<script src="assets/js/jquery.min.js"></script>
<!-- Popper JavaScript -->
<script src="assets/js/popper.min.js"></script>
<!-- Bootstrap JavaScript -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/custom.js"></script>
<!-- Profile JS -->
<script src="assets/js/profile.js"></script>
</body>