| 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 |  |  | // Get the values entered
 | 
      
        | 23 |  |  | $current_password = $wb->get_post('current_password');
 | 
      
        | 24 |  |  | $email = $wb->get_post('email');
 | 
      
        | 25 |  |  | 
 | 
      
        | 26 | 1425 | Luisehahne | // Create a javascript back link
 | 
      
        | 27 |  |  | $js_back = WB_URL.'/account/preferences.php';
 | 
      
        | 28 | 1473 | Luisehahne | /*
 | 
      
        | 29 | 1400 | FrankH | if (!$wb->checkFTAN())
 | 
      
        | 30 |  |  | {
 | 
      
        | 31 | 1425 | Luisehahne | 	$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back, false);
 | 
      
        | 32 | 1400 | FrankH | 	exit();
 | 
      
        | 33 |  |  | }
 | 
      
        | 34 | 1473 | Luisehahne | */
 | 
      
        | 35 | 1386 | Luisehahne | // Get existing password
 | 
      
        | 36 |  |  | // $database = new database();
 | 
      
        | 37 |  |  | $query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
 | 
      
        | 38 |  |  | $results = $database->query($query);
 | 
      
        | 39 |  |  | 
 | 
      
        | 40 |  |  | // Validate values
 | 
      
        | 41 |  |  | if($results->numRows() == 0) {
 | 
      
        | 42 |  |  | 	$wb->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back, false);
 | 
      
        | 43 |  |  | }
 | 
      
        | 44 |  |  | // Validate values
 | 
      
        | 45 |  |  | if(!$wb->validate_email($email)) {
 | 
      
        | 46 |  |  | 	$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
 | 
      
        | 47 |  |  | }
 | 
      
        | 48 |  |  | 
 | 
      
        | 49 |  |  | $email = $wb->add_slashes($email);
 | 
      
        | 50 |  |  | 
 | 
      
        | 51 |  |  | // Update the database
 | 
      
        | 52 |  |  | // $database = new database();
 | 
      
        | 53 |  |  | $query = "UPDATE ".TABLE_PREFIX."users SET email = '$email' WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
 | 
      
        | 54 |  |  | $database->query($query);
 | 
      
        | 55 |  |  | if($database->is_error()) {
 | 
      
        | 56 | 1425 | Luisehahne | 	$wb->print_error($database->get_error,$js_back, false);
 | 
      
        | 57 | 1386 | Luisehahne | } else {
 | 
      
        | 58 | 1425 | Luisehahne | 	$wb->print_success($MESSAGE['PREFERENCES']['EMAIL_UPDATED']);
 | 
      
        | 59 | 1386 | Luisehahne | 	$_SESSION['EMAIL'] = $email;
 | 
      
        | 60 |  |  | }
 |