| 1 | 
        
            2
         | 
        
            Manuela
         | 
        <?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 | 
        
         | 
        
         | 
        // Must include code to stop this file being access directly
  | 
      
      
        | 20 | 
        
         | 
        
         | 
        if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
 | 
      
      
        | 21 | 
        
         | 
        
         | 
        
  | 
      
      
        | 22 | 
        
         | 
        
         | 
        // Get entered values
  | 
      
      
        | 23 | 
        
         | 
        
         | 
            $password = $wb->get_post('current_password');
 | 
      
      
        | 24 | 
        
         | 
        
         | 
            $email = $wb->get_post('email');
 | 
      
      
        | 25 | 
        
         | 
        
         | 
        // validate password
  | 
      
      
        | 26 | 
        
         | 
        
         | 
            $sql  = 'SELECT `user_id` FROM `'.TABLE_PREFIX.'users` '
  | 
      
      
        | 27 | 
        
         | 
        
         | 
                  . 'WHERE `user_id` = '.$wb->get_user_id().' AND `password` = \''.md5($password).'\'';
  | 
      
      
        | 28 | 
        
         | 
        
         | 
            $rowset = $database->query($sql);
  | 
      
      
        | 29 | 
        
         | 
        
         | 
        // Validate values
  | 
      
      
        | 30 | 
        
         | 
        
         | 
            if($rowset->numRows() == 0) {
 | 
      
      
        | 31 | 
        
         | 
        
         | 
                $error[] = $MESSAGE['PREFERENCES_CURRENT_PASSWORD_INCORRECT'];
  | 
      
      
        | 32 | 
        
         | 
        
         | 
            }else {
 | 
      
      
        | 33 | 
        
         | 
        
         | 
                if(!$wb->validate_email($email)) {
 | 
      
      
        | 34 | 
        
         | 
        
         | 
                    $error[] = $MESSAGE['USERS_INVALID_EMAIL'];
  | 
      
      
        | 35 | 
        
         | 
        
         | 
                }else {
 | 
      
      
        | 36 | 
        
         | 
        
         | 
                    $email = $wb->add_slashes($email);
  | 
      
      
        | 37 | 
        
         | 
        
         | 
        // Update the database
  | 
      
      
        | 38 | 
        
         | 
        
         | 
                    $sql  = 'UPDATE `'.TABLE_PREFIX.'users` '
  | 
      
      
        | 39 | 
        
         | 
        
         | 
                          . 'SET `email` = \''.$database->escapeString($email).'\' '
  | 
      
      
        | 40 | 
        
         | 
        
         | 
                          . 'WHERE `user_id` = \''.$wb->get_user_id().'\'';
  | 
      
      
        | 41 | 
        
         | 
        
         | 
                     $database->query($sql);
  | 
      
      
        | 42 | 
        
         | 
        
         | 
                    if($database->is_error()) {
 | 
      
      
        | 43 | 
        
         | 
        
         | 
                        $error[] = $database->get_error();
  | 
      
      
        | 44 | 
        
         | 
        
         | 
                    } else {
 | 
      
      
        | 45 | 
        
         | 
        
         | 
                        $success[] = $MESSAGE['PREFERENCES_EMAIL_UPDATED'];
  | 
      
      
        | 46 | 
        
         | 
        
         | 
                        $_SESSION['EMAIL'] = $email;
  | 
      
      
        | 47 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 48 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 49 | 
        
         | 
        
         | 
            }
  |