-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
executable file
·265 lines (201 loc) · 8.21 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
<?php
session_start();
include('config.php');
if(isset($_SESSION['logged_in'])) {
if($_SESSION['logged_in'] != 1) {
header("Location: home.php");
}
} else if (!isset($_SESSION['logged_in'])) {
header("Location: home.php");
}
if(isset($_POST['oldpassword']) and isset($_POST['newpassword'])) {
$userid = $_SESSION['userid'];
$oldpassword = $_POST['oldpassword'];
$newpassword = $_POST['newpassword'];
$query = "select * from users where userid='${userid}' and password=md5('${oldpassword}')";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
$updatequery = "update users set password=md5('${newpassword}') where userid='${userid}' and password=md5('${oldpassword}')";
$updateresult = mysqli_query($conn, $updatequery);
if($updateresult) {
$success = "Password has been updated!";
} else {
$error = "Password Change failed!";
}
} else {
$error = "Wrong old password!";
}
}
$userid = $_SESSION['userid'];
$query = "select * from files where receiverid='${userid}' or senderid='${userid}'";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
$count = mysqli_num_rows($result);
}
?>
<html lang="en">
<head>
<title>Secure P2P File Sharing Service</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
<style>
.send-hover:hover {
color: #c850c0;
}
.receive-hover:hover {
color: #4158d0;
}
.form-button-color {
background: #9053c7;
}
.form-button-color:hover {
background: #5b57cd;
}
</style>
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100" style="display:block; padding: 30px 50px 35px 50px;">
<div style="text-align:center">
<a href="index.php">
<h2 style="color:#212529">Secure P2P File Sharing Service</h2>
</a>
</div>
<hr style="color:black;background-color:black;height:2px;">
<div style="padding: 0 0 10px 0;">
<div style="float:left; padding-right:10px;">
<a class="txt1" href="index.php">
<i class="fa fa-angle-double-left m-l-5" style="font-size:17px;"aria-hidden="true"></i>
</a>
</div>
<div style="float:left">
<a class="txt1" href="profile.php" style="color:black;">
<h6><?php echo "Welcome: <b>${_SESSION['username']}</b> [${_SESSION['userid']}]"; ?></h6>
</a>
</div>
<div style="float:right">
<a class="txt1" href="logout.php">
<h6>Logout
<i class="fa fa-sign-out m-l-5" aria-hidden="true"></i>
</h6>
</a>
</div>
</div>
<hr style="color:black;background-color:black;height:2px;">
<div>
<div style="margin-left:auto; margin-right:auto;">
<div style="float:left">
<div style="padding-left:20px; padding-top:20px; text-align:center; width:150%;">
<?php
if(isset($error)) {
echo "
<div class=\"text-center p-t-136\" style='padding:0 0 20px 0;'>
<span class=\"txt1\" style=\"color:red;\">
${error}
</span>
</div>
";
} else if(isset($success)) {
echo "
<div class=\"text-center p-t-136\" style='padding:0 0 20px 0;'>
<span class=\"txt1\" style=\"color:green;\">
${success}
</span>
</div>
";
}
?>
<div class="text-center p-t-136" style="padding:20px">
<span class="txt1" style="color:black;">
<h5>TRANSFER HISTORY</h5><br>
</span>
</div>
<div>
<ul class="list-group">
<?php
for($i = 0; $i < $count; $i++) {
$row = mysqli_fetch_assoc($result);
$filepath = $row['filepath'];
$filename = $row['filename'];
$senderid = $row['senderid'];
$receiverid = $row['receiverid'];
if($receiverid == $userid) {
$html = "<li class=\"list-group-item list-group-item-action\">";
$html .= "${filename} sent by ${senderid}</li>";
} else {
$html = "<li class=\"list-group-item list-group-item-action\">";
$html .= "${filename} sent to ${senderid}</li>";
}
echo $html;
}
?>
</ul>
</div>
</div>
</div>
<div style="float:right">
<div style="padding-top:20px; padding-right:25px; text-align:center;">
<i class="fa fa-user" style="font-size:12em; border: 3px dotted black; padding: 7px;" aria-hidden="true"></i><br><br>
<form action="profile.php" method="post" enctype="multipart/form-data">
<div class="wrap-input100 validate-input" data-validate = "Old Password is mandatory">
<input class="input100" type="password" name="oldpassword" placeholder="Old Password">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-user" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input" data-validate = "New Password is mandatory">
<input class="input100" type="password" name="newpassword" placeholder="New Password">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-user" aria-hidden="true"></i>
</span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn form-button-color">
Change Password
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/tilt/tilt.jquery.min.js"></script>
<script >
$('.js-tilt').tilt({
scale: 1.1
})
</script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>