-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangePwd.php
160 lines (128 loc) · 3.77 KB
/
changePwd.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
<?php
/*
* UWS - Universal Wealth System
* changePwd.php
* GPL license
* author: Fabio Barone
* date: 30. Nov. 2009
*
* Change the user's password. Displays an entry field
* for the old password, and two for the new one.
*/
session_start();
include "config.php";
try
{
$content = "";
//echo $_COOKIE['Key_my_site'];
//This code runs if the form has been submitted
if (isset($_POST['submit']))
{
//This makes sure they did not leave any fields blank
if (!$_POST['oldpwd'] | !$_POST['newpass'] | !$_POST['newpass2'] )
{
throw new Exception('You did not complete all of the required fields.');
}
//oldpwd does not match registered password!
$member_id = $_SESSION['member_id'];
$sql = "SELECT password FROM members WHERE member_id='$member_id'";
$query = mysql_query($sql);
$result = mysql_fetch_row($query);
$pass = $result[0];
if (md5($_POST['oldpwd']) != $pass)
{
throw new Exception('Your current passwort does not match. Cannot change to new one.');
}
// this makes sure both passwords entered match
if ($_POST['newpass'] != $_POST['newpass2'])
{
throw new Exception('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$_POST['newpass'] = md5($_POST['newpass']);
if (!get_magic_quotes_gpc())
{
$_POST['newpass'] = addslashes($_POST['newpass']);
}
// now we insert it into the database
$hour = time() + 3600;
$newpass = $_POST['newpass'];
$sql = "UPDATE members SET password='$newpass' WHERE member_id='$member_id'";
do_query($sql);
setcookie("Key_my_site", $_POST['newpass'] , $hour);
$content = "<h1>". translate("uws:newpwdok"). "</h1><br><br>";
} // if
}//try
catch (Exception $e)
{
$redirect = $errorpage.$e->getMessage();
header("Location:".$redirect);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
terrafirma1.0 by nodethirtythree design
http://www.nodethirtythree.com
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Universal Wealth System UWS - <?php echo translate("uws:changepwd") ?></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>
<div id="outer">
<div id="upbg"></div>
<div id="inner">
<?php include "header.php" ?>
<h3><?php echo translate("uws:changepwd") ?></h3>
<div class="date">
<?php echo date('d F Y') ?></div> <!-- div date -->
</div><!-- div header -->
<div class="content">
<?php
echo $content;
if (! isset($_POST['submit']))
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table class="nicetable" cellspacing="0">
<tr><td><?php echo translate("uws:oldpwd") ?>:</td><td>
<input type="password" name="oldpwd" maxlength="60">
</td></tr>
<tr><td><?php echo translate("uws:pwd") ?>:</td><td>
<input type="password" name="newpass" maxlength="10">
</td></tr>
<tr><td><?php echo translate("uws:pwd-confirm") ?>:</td><td>
<input type="password" name="newpass2" maxlength="10">
</td></tr>
<tr><td colspan=2><input type="submit" name="submit" value="<?php echo translate("uws:changepwd") ?>"></td></tr> </table>
</form><br><br>
<?php
} //else
?>
</div>
<div class="footer">
<ul>
<li class="printerfriendly"><a href="#">Printer Friendly</a></li>
<li class="readmore"><a href="#">Read more</a></li>
</ul>
</div>
</div>
</div>
<div id="secondarycontent">
<!-- Displaying lists links -->
<?php //include "lists.php" ?>
<!-- Displaying action links -->
<?php //include "actions.php" ?>
<!-- secondary content end -->
</div>
<div id="footer">
© UWS. </a>.
</div>
</div>
</div>
</body>
</html>