-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
192 lines (191 loc) · 9.33 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
<?php
session_start();
include_once($_SERVER['DOCUMENT_ROOT'] . '/camagru/includes/session_expiry.php');
if (!isset($_SESSION) || !isset($_SESSION['userLoggedIn']))
header('Location: /camagru/index.php');
include_once($_SERVER['DOCUMENT_ROOT'] . "/camagru/includes/config.php");
if (isset($_GET) && isset($_GET['username']))
$un = $_GET['username'];
else
$un = $_SESSION['userLoggedIn'];
$query = "SELECT * FROM users WHERE username = :userLoggedIn";
try {
$stmt = $pdo->prepare($query);
$stmt->bindValue(":userLoggedIn", $un);
$stmt->execute();
} catch (PDOException $e) {
die("Error communicating with the database:" . $e );
}
$array = $stmt->fetch();
$em = $array["email"];
$pcPath = $array["profilePic"];
$date = $array['signUpDate'];
$notif = $array['notif'] === '1' ? 'checked' : '';
if ($array === false && !isset($_GET['error'])) {
header('Location: /camagru/profile?error=nouser');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/camagru/includes/links.php") ?>
<link rel="stylesheet" href="/camagru/assets/css/profile.css">
<link rel="stylesheet" href="/camagru/assets/css/gallery.css">
<link rel="stylesheet" href="/camagru/assets/css/animations.css">
<script src="/camagru/assets/js/updatePicOnHover.js"></script>
<script src="/camagru/assets/js/editProfilePic.js"></script>
<script src="/camagru/assets/js/postManagement.js"></script>
<script src="/camagru/assets/js/emailNotifs.js"></script>
<script src="/camagru/assets/js/deleteUser.js"></script>
<script src="/camagru/assets/js/themeSwitcher.js"></script>
<title>Camagru - My Profile</title>
<script src="/camagru/assets/js/themeSwitcher.js"></script>
</head>
<body id="body">
<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/camagru/includes/navbar.php"); ?>
<div class="everything">
<div id="messages"></div>
<div class="container">
<div class="jumbotron mx-auto profile" id="form">
<?php
if (isset($_GET) && isset($_GET['error']) && $_GET['error'] === 'nouser') {
?>
<img src="/camagru/assets/images/icons-dark/bad.png" class ="bad" alt="good" width="200" height="200">
<h1 class="display-4">User not found !</h1>
<hr>
<p class="lead">We cannot find any account with this username</p>
<?php } else { ?>
<div id="spinner" class="spinner-border"></div>
<a href="javascript:history.back()" class="goback">
<img src="/camagru/assets/images/icons-dark/goback.png" alt="go back" width="30" height="30">
</a>
<div class="divini">
<div class="absolute-div" id="absoluteDiv" style="background-image: url('<?php echo $pcPath; ?>');">
<?php if ( !isset($_GET) || !isset($_GET['username']) || $_GET['username'] === $_SESSION['userLoggedIn']) { ?>
<form method="POST" action="profile.php">
<input type="file" name="newPicture" id="newPicture" enctype="multipart/form-data">
<label for="newPicture" id="pdpContainer">
<img class="update click" id="updatePic" src="/camagru/assets/images/update.png">
</label>
</form>
<?php } ?>
</div>
</div>
<span class="label">Username:</span>
<div class="info-container">
<span class="info"><?php echo $un; ?></span>
<?php
if (!isset($_GET) || !isset($_GET['username']) || $_GET['username'] === $_SESSION['userLoggedIn'])
echo '<a href="/camagru/editUsername.php" class="edit">
<img class="click" src="/camagru/assets/images/icons-dark/edit.png" width="20" height="20" alt="edit">
</a>';
?>
</div>
<span class="label">Email Address:</span>
<div class="info-container">
<span class="info"><?php echo $em; ?></span>
<?php
if (!isset($_GET) || !isset($_GET['username']) || $_GET['username'] === $_SESSION['userLoggedIn'])
echo '<a href="/camagru/editEmail.php" class="edit">
<img class="click" src="/camagru/assets/images/icons-dark/edit.png" width="20" height="20" alt="edit">
</a>';
?>
</div>
<?php
if (!isset($_GET) || !isset($_GET['username']) || $_GET['username'] === $_SESSION['userLoggedIn'])
echo '<span class="label">Password:</span>
<div class="info-container">
<span class="info">****************</span>
<a href="/camagru/editPassword.php" class="edit">
<img class="click" src="/camagru/assets/images/icons-dark/edit.png" width="20" height="20" alt="edit">
</a>
</div>
<div class="switch-container">
<span class="switch-label">Enable email\'s notifications:</span>
<label class="switch">
<input type="checkbox" '. $notif .' id="switcha">
<span class="slider round"></span>
</label>
</div>';
?>
<span class="label">Member since:</span>
<div class="info-container">
<span class="info"><?php echo $date; ?></span>
</div>
<?php }
if ((!isset($_GET) || !isset($_GET['username']) || $_GET['username'] === $_SESSION['userLoggedIn']) && !isset($_GET['error']))
echo '<button id="deleteUserButton" class="btn btn-danger" style="margin-top: 50px"><img src="/camagru/assets/images/bad.png" width="20" height="20" style="margin-right: 10px">Delete my account</button>';
?>
</div>
<?php if (!isset($_GET) || !isset($_GET['error']) || $_GET['error'] !== 'nouser') { ?>
<div id="userPostsContainer">
</div>
<?php } ?>
</div>
<canvas id=canvas></canvas>
<div class="alert-container" id="alert-container">
<div class="container" id="alert-body">
<div class="alert-card jumbotron text-center m-auto">
<h1 class="text-break">Are you sure ?</h1>
<hr>
<p class="lead text-break">Do you really want to delete this post?<br>This action is irreversible!</p>
<button class="btn btn-lg botona my-2 mx-4 click" id="delete">
<img src="/camagru/assets/images/icons-dark/good.png" alt="yes" width="30" height="30">
Delete
</button>
<button class="btn btn-lg botona m-0 mx-4 click" id="cancel">
<img src="/camagru/assets/images/icons-dark/bad.png" alt="no" width="30" height="30">
Cancel
</button>
</div>
</div>
</div>
<div class="alert-container" id="alertDelete-container">
<div class="container" id="alertDelete-body">
<div class="alert-card jumbotron text-center m-auto">
<h1 class="text-break">Are you sure ?</h1>
<hr>
<p class="lead text-break">Do you really want to delete your account?<br>This action is irreversible!</p>
<button class="btn btn-lg botona my-2 mx-4 click" id="deleteUser">
<img src="/camagru/assets/images/icons-dark/good.png" alt="yes" width="30" height="30">
Delete
</button>
<button class="btn btn-lg botona m-0 mx-4 click" id="cancelDeleteUser">
<img src="/camagru/assets/images/icons-dark/bad.png" alt="no" width="30" height="30">
Cancel
</button>
</div>
</div>
</div>
</div>
<div class="loading-container" id="loading" style="display: block;">
<div class="container">
<div class="jumbotron mx-auto profile loading2">
<div class="absolute-div loading" style="height:150px; width:150px; display:block; margin:auto; border-radius:200px"></div>
<div class="loading" style="height:20px; width:20%; display:block; margin-top:20px"></div>
<div class="info loading" style="height:50px; width:100%; display:block; border-radius: 10px; margin-top:10px"></div>
<div class="loading" style="height:20px; width:20%; display:block; margin-top:20px"></div>
<div class="info loading" style="height:50px; width:100%; display:block; border-radius: 10px; margin-top:10px"></div>
<div class="loading" style="height:20px; width:20%; display:block; margin-top:20px"></div>
<div class="info loading" style="height:50px; width:100%; display:block; border-radius: 10px; margin-top:10px"></div>
</div>
<div class="jumbotron py-3 px-3 mx-auto post loading2">
<a class="text-decoration-none text-reset click">
<img class="profilepic" src="/camagru/assets/images/icons-dark/blank-pdp.png" width="30" height="30" class="d-inline-block align-top" >
<span class="text loading" style="width:20%; height:20px; display:inline-block; vertical-align:middle"> </span>
<span class="badge badge-secondary new-badge loading" style="width:50px; height:20px; display:inline-block; vertical-align:middle; border-radius:10px; transition-duration: none"></span>
</a>
<hr class="separator loading">
<p class="text-break loading" style="width:50%; height:20px; display:inline-block; vertical-align:middle"></p>
<div class="heartContainer"></div>
<img class="loading postImg" src="/camagru/assets/images/icons-dark/blank-post.png">
<hr class="loading separator">
<img class="loading" src="/camagru/assets/images/icons-dark/blank-icon.png" width="33" height="30" style="border-radius:200px"><span class="loading" style="width:50px; height:20px; display:inline-block; margin-left:10px; vertical-align:middle"></span>
<img class="loading" src="/camagru/assets/images/icons-dark/blank-icon.png" width="33" height="30" style="border-radius:200px"><span class="loading" style="width:50px; height:20px; display:inline-block; margin-left:10px; vertical-align:middle"></span>
<img class="loading" src="/camagru/assets/images/icons-dark/blank-icon.png" width="33" height="30" style="border-radius:200px">
</img>
</div>
</div>
</div>
</body>
</html>