-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdetails.php
More file actions
75 lines (68 loc) · 2.01 KB
/
details.php
File metadata and controls
75 lines (68 loc) · 2.01 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
<?php
$pagetitle = 'Edit Details';
require 'common.php';
if (!$logged)
{
$tpl->message = 'You must be logged in to view this page.';
$tpl->Execute(null);
exit;
}
if (!empty($_POST['fullname']) && !empty($_POST['location']) && !empty($_POST['email']))
{
if ($userdata['fullname'] == $_POST['fullname'] && $userdata['location'] == $_POST['location'] && $userdata['email'] == $_POST['email'])
{
}
else
{
//webcp_db_execute("UPDATE accounts SET fullname = ?, location = ?, email = ? WHERE username = ?", $_POST['fullname'], $_POST['location'], $_POST['email'], $sess->username);
if ($db->AffectedRows() != 1)
{
$tpl->message = "Failed to update account info.";
}
else
{
//$userdata = webcp_db_execute("SELECT * FROM accounts WHERE username = ?", $sess->username);
$tpl->userdata = $sess->userdata = $userdata[0];
//$tpl->message = "Account details updated.";
$tpl->message = "Failed to update account info.";
}
}
}
if (!empty($_POST['currentpassword']) && !empty($_POST['newpassword']) && !empty($_POST['repeatpassword']))
{
if (!isset($tpl->message))
{
$tpl->message = '';
}
else
{
$tpl->message = $tpl->message . '<br>';
}
if ($_POST['newpassword'] != $_POST['repeatpassword'])
{
$tpl->message = $tpl->message . "Passwords did not match.";
}
else
{
$currentpassword = hash('sha256',$salt.($sess->username).substr($_POST['currentpassword'],0,12));
if ($currentpassword != $userdata['password'])
{
$tpl->message = $tpl->message . "Current password did not match the one in the database.";
}
else
{
$newpassword = hash('sha256',$salt.($sess->username).substr($_POST['newpassword'],0,12));
webcp_db_execute("UPDATE accounts SET password = ? WHERE username = ?", $newpassword, $sess->username);
if ($db->AffectedRows() != 1)
{
$tpl->message = $tpl->message . "Failed to update password.";
}
else
{
//$tpl->message = $tpl->message . "Failed to update password.";
$tpl->message = $tpl->message . "Password updated.";
}
}
}
}
$tpl->Execute('details');