-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
90 lines (81 loc) · 3.15 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
<?php
session_start();
if (isset($_POST['difficulty'])) {
$_SESSION['difficulty'] = $_POST['difficulty'];
} else if(empty($_SESSION['difficulty'])) {
$_SESSION['difficulty'] = 'low';
}
require 'database.php';
$get_user = null;
if (isset($_GET['user'])) {
$get_user = $_GET['user'];
}
if($_SESSION['difficulty'] == 'low' || $_SESSION['difficulty'] == 'medium'){
$sql='SELECT id,email,username,message FROM users WHERE username="'.$get_user.'" LIMIT 1';
$get_user_result = mysqli_query($connection, $sql);
$user = mysqli_fetch_array($get_user_result,MYSQLI_ASSOC);
if(!$user && empty($get_user) && $_SESSION['user_id']){
$sql='SELECT id,email,username,message FROM users WHERE id="'.$_SESSION['user_id'].'"';
$get_user_result = mysqli_query($connection, $sql);
$user = mysqli_fetch_array($get_user_result,MYSQLI_ASSOC);
}elseif(!$user){
header("Location: ../index");
}
}else{
$get_user_result = $conn->prepare('SELECT id,email,username,message FROM users WHERE username = :username LIMIT 1');
$get_user_result->bindParam(':username', $get_user);
$get_user_result->execute();
$user = $get_user_result->fetch(PDO::FETCH_ASSOC);
if(!$user && empty($get_user) && $_SESSION['user_id']){
$get_user_result = $conn->prepare('SELECT id,email,username,message FROM users WHERE id = :id');
$get_user_result->bindParam(':id', $_SESSION['user_id']);
$get_user_result->execute();
$user = $get_user_result->fetch(PDO::FETCH_ASSOC);
}elseif(!$user){
header("Location: ../index");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Profile: <?php echo $user['username'] ?></title>
<link rel="stylesheet" type="text/css" href="../assets/css/style.css">
<link href='http://fonts.googleapis.com/css?family=Comfortaa' rel='stylesheet' type='text/css'>
</head>
<body>
<form action="#" method="POST">
Security Level: 
<?php if($_SESSION['difficulty'] == 'low'){ ?>
<input name="difficulty" type="submit" value="low" style="width: 100px; background-color: red">
<?php } else{ ?>
<input name="difficulty" type="submit" value="low" style="width: 100px; background-color: gray">
<?php }?>
<?php if($_SESSION['difficulty'] == 'medium'){ ?>
<input name="difficulty" type="submit" value="medium" style="width: 100px; background-color: orange">
<?php } else{ ?>
<input name="difficulty" type="submit" value="medium" style="width: 100px; background-color: gray">
<?php }?>
<?php if($_SESSION['difficulty'] == 'high'){ ?>
<input name="difficulty" type="submit" value="high" style="width: 100px; background-color: green">
<?php } else{ ?>
<input name="difficulty" type="submit" value="high" style="width: 100px; background-color: gray">
<?php }?>
</form>
<div class="header">
<b>YOU HAVE GAINED ACCESS TO THE SUPER SECRET INFORMATION!</b>
</div>
<br>Welcome on the profile of <?= $user['username']; ?>
<br><br>Personal message<br>
<?php if(!empty($user['message'])){
if($_SESSION['difficulty'] == 'low' || $_SESSION['difficulty'] == 'medium'){
echo $user['message'];
}else{
echo htmlentities($user['message']);
}
}else{
echo ''.$user['username'].' does not have a personal message currently.';
}
?>
</body>
</html>