Revision 1508
Added by Luisehahne about 14 years ago
| password.php | ||
|---|---|---|
| 19 | 19 |
// Must include code to stop this file being access directly |
| 20 | 20 |
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
| 21 | 21 |
|
| 22 |
// Get the values entered |
|
| 23 |
$current_password = $_POST['current_password']; |
|
| 24 |
$new_password = $_POST['new_password']; |
|
| 25 |
$new_password2 = $_POST['new_password2']; |
|
| 26 |
|
|
| 27 |
// Create a javascript back link |
|
| 28 |
$js_back = WB_URL.'/account/preferences.php'; |
|
| 29 |
/* |
|
| 30 |
if (!$wb->checkFTAN()) |
|
| 31 |
{
|
|
| 32 |
$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back, false); |
|
| 33 |
exit(); |
|
| 34 |
} |
|
| 35 |
*/ |
|
| 22 |
// Get entered values |
|
| 23 |
$current_password = $wb->get_post('current_password');
|
|
| 24 |
$new_password = $wb->get_post('new_password');
|
|
| 25 |
$new_password2 = $wb->get_post('new_password2');
|
|
| 36 | 26 |
// Get existing password |
| 37 |
// $database = new database(); |
|
| 38 |
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'"; |
|
| 39 |
$results = $database->query($query); |
|
| 40 |
|
|
| 27 |
$sql = "SELECT `user_id` FROM `".TABLE_PREFIX."users` WHERE `user_id` = ".$wb->get_user_id()." AND `password` = '".md5($current_password)."'"; |
|
| 28 |
$rowset = $database->query($sql); |
|
| 41 | 29 |
// Validate values |
| 42 |
if($results->numRows() == 0) {
|
|
| 43 |
$wb->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back, false); |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
if(strlen($new_password) < 3) {
|
|
| 47 |
$wb->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back, false); |
|
| 48 |
} |
|
| 49 |
if($new_password != $new_password2) {
|
|
| 50 |
$wb->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back, false); |
|
| 51 |
} |
|
| 52 |
|
|
| 30 |
if($rowset->numRows() == 0) {
|
|
| 31 |
$error[] = $MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT']; |
|
| 32 |
}else {
|
|
| 33 |
if(strlen($new_password) < 3) {
|
|
| 34 |
$error[] = $MESSAGE['USERS']['PASSWORD_TOO_SHORT']; |
|
| 35 |
}else {
|
|
| 36 |
if($new_password != $new_password2) {
|
|
| 37 |
$error[] = $MESSAGE['USERS']['PASSWORD_MISMATCH']; |
|
| 38 |
}else {
|
|
| 53 | 39 |
// MD5 the password |
| 54 |
$md5_password = md5($new_password); |
|
| 55 |
|
|
| 40 |
$md5_password = md5($new_password); |
|
| 56 | 41 |
// Update the database |
| 57 |
// $database = new database(); |
|
| 58 |
$query = "UPDATE ".TABLE_PREFIX."users SET password = '$md5_password' WHERE user_id = '".$wb->get_user_id()."'"; |
|
| 59 |
$database->query($query); |
|
| 60 |
if($database->is_error()) {
|
|
| 61 |
$wb->print_error($database->get_error, $js_back, false); |
|
| 62 |
} else {
|
|
| 63 |
$wb->print_success($MESSAGE['PREFERENCES']['PASSWORD_CHANGED']); |
|
| 64 |
} |
|
| 42 |
$sql = "UPDATE `".TABLE_PREFIX."users` SET `password` = '".$md5_password."' WHERE `user_id` = ".$wb->get_user_id(); |
|
| 43 |
$database->query($sql); |
|
| 44 |
if($database->is_error()) {
|
|
| 45 |
$error[] = $database->get_error(); |
|
| 46 |
} else {
|
|
| 47 |
$success[] = $MESSAGE['PREFERENCES']['PASSWORD_CHANGED']; |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
} |
|
| 51 |
} |
|
Also available in: Unified diff
fixed print_error exit in frontend account