1 |
1262
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category frontend
|
5 |
|
|
* @package account
|
6 |
1268
|
Luisehahne
|
* @author WebsiteBaker Project
|
7 |
1262
|
Luisehahne
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
1349
|
Luisehahne
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
1262
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1373
|
Luisehahne
|
* * @requirements PHP 5.2.2 and higher
|
13 |
1268
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
1262
|
Luisehahne
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
if(!defined('WB_URL')) {
|
20 |
|
|
header('Location: ../index.php');
|
21 |
|
|
exit(0);
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
// Get the values entered
|
25 |
|
|
$current_password = $_POST['current_password'];
|
26 |
|
|
$new_password = $_POST['new_password'];
|
27 |
|
|
$new_password2 = $_POST['new_password2'];
|
28 |
|
|
|
29 |
|
|
// Create a javascript back link
|
30 |
|
|
$js_back = "javascript: history.go(-1);";
|
31 |
|
|
|
32 |
|
|
// Get existing password
|
33 |
|
|
$database = new database();
|
34 |
|
|
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
|
35 |
|
|
$results = $database->query($query);
|
36 |
|
|
|
37 |
|
|
// Validate values
|
38 |
|
|
if($results->numRows() == 0) {
|
39 |
|
|
$wb->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back, false);
|
40 |
|
|
}
|
41 |
|
|
if(strlen($new_password) < 3) {
|
42 |
|
|
$wb->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back, false);
|
43 |
|
|
}
|
44 |
|
|
if($new_password != $new_password2) {
|
45 |
|
|
$wb->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back, false);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
// MD5 the password
|
49 |
|
|
$md5_password = md5($new_password);
|
50 |
|
|
|
51 |
|
|
// Update the database
|
52 |
|
|
$database = new database();
|
53 |
|
|
$query = "UPDATE ".TABLE_PREFIX."users SET password = '$md5_password' WHERE user_id = '".$wb->get_user_id()."'";
|
54 |
|
|
$database->query($query);
|
55 |
|
|
if($database->is_error()) {
|
56 |
|
|
$wb->print_error($database->get_error, 'index.php', false);
|
57 |
|
|
} else {
|
58 |
|
|
$wb->print_success($MESSAGE['PREFERENCES']['PASSWORD_CHANGED'], WB_URL.'/account/preferences.php');
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
|
62 |
4
|
ryan
|
?>
|