| 1 | 1386 | Luisehahne | <?php
 | 
      
        | 2 |  |  | /**
 | 
      
        | 3 |  |  |  *
 | 
      
        | 4 |  |  |  * @category        frontend
 | 
      
        | 5 |  |  |  * @package         account
 | 
      
        | 6 |  |  |  * @author          WebsiteBaker Project
 | 
      
        | 7 |  |  |  * @copyright       2004-2009, Ryan Djurovich
 | 
      
        | 8 |  |  |  * @copyright       2009-2011, Website Baker Org. e.V.
 | 
      
        | 9 |  |  |  * @link			http://www.websitebaker2.org/
 | 
      
        | 10 |  |  |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
      
        | 11 |  |  |  * @platform        WebsiteBaker 2.8.x
 | 
      
        | 12 |  |  |  * @requirements    PHP 5.2.2 and higher
 | 
      
        | 13 |  |  |  * @version         $Id$
 | 
      
        | 14 |  |  |  * @filesource		$HeadURL$
 | 
      
        | 15 |  |  |  * @lastmodified    $Date$
 | 
      
        | 16 |  |  |  *
 | 
      
        | 17 |  |  |  */
 | 
      
        | 18 |  |  | 
 | 
      
        | 19 | 1420 | Luisehahne | // Must include code to stop this file being access directly
 | 
      
        | 20 |  |  | if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
 | 
      
        | 21 | 1386 | Luisehahne | 
 | 
      
        | 22 | 1508 | Luisehahne | // 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');
 | 
      
        | 26 | 1386 | Luisehahne | // Get existing password
 | 
      
        | 27 | 1508 | Luisehahne | 	$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);
 | 
      
        | 29 | 1386 | Luisehahne | // Validate values
 | 
      
        | 30 | 1508 | Luisehahne | 	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 {
 | 
      
        | 39 | 1386 | Luisehahne | // MD5 the password
 | 
      
        | 40 | 1508 | Luisehahne | 				$md5_password = md5($new_password);
 | 
      
        | 41 | 1386 | Luisehahne | // Update the database
 | 
      
        | 42 | 1508 | Luisehahne | 				$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 |  |  | 	}
 |