| 
      1
     | 
    
      <?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: email.php 1868 2013-02-19 21:07:19Z Luisehahne $
 
     | 
  
  
    | 
      14
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/email.php $
 
     | 
  
  
    | 
      15
     | 
    
       * @lastmodified    $Date: 2013-02-19 22:07:19 +0100 (Tue, 19 Feb 2013) $
 
     | 
  
  
    | 
      16
     | 
    
       *
 
     | 
  
  
    | 
      17
     | 
    
       */
 
     | 
  
  
    | 
      18
     | 
    
      
 
     | 
  
  
    | 
      19
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      20
     | 
    
      // Must include code to stop this file being accessed directly
 
     | 
  
  
    | 
      21
     | 
    
      if(!defined('WB_PATH')) {
     | 
  
  
    | 
      22
     | 
    
      	require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
 
     | 
  
  
    | 
      23
     | 
    
      	throw new IllegalFileException();
 
     | 
  
  
    | 
      24
     | 
    
      }
 
     | 
  
  
    | 
      25
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      26
     | 
    
      
 
     | 
  
  
    | 
      27
     | 
    
      // Get entered values
 
     | 
  
  
    | 
      28
     | 
    
      	$password = $wb->StripCodeFromText($wb->get_post('current_password'));
     | 
  
  
    | 
      29
     | 
    
      	$email = strip_tags($wb->StripCodeFromText($wb->get_post('email')));
     | 
  
  
    | 
      30
     | 
    
      // validate password
 
     | 
  
  
    | 
      31
     | 
    
      	$sql  = "SELECT `user_id` FROM `".TABLE_PREFIX."users` ";
 
     | 
  
  
    | 
      32
     | 
    
      	$sql .= "WHERE `user_id` = ".(int)$wb->get_user_id()." AND `password` = '".md5($password)."'";
 
     | 
  
  
    | 
      33
     | 
    
      	$rowset = $database->query($sql);
 
     | 
  
  
    | 
      34
     | 
    
      // Validate values
 
     | 
  
  
    | 
      35
     | 
    
      	if($rowset->numRows() == 0) {
     | 
  
  
    | 
      36
     | 
    
      		$error[] = $MESSAGE['PREFERENCES_CURRENT_PASSWORD_INCORRECT'];
 
     | 
  
  
    | 
      37
     | 
    
      	} else {
     | 
  
  
    | 
      38
     | 
    
              $sSessionEmail = $wb->get_session('EMAIL');
     | 
  
  
    | 
      39
     | 
    
          	if($sSessionEmail != "") {
     | 
  
  
    | 
      40
     | 
    
          		// Check if the email already exists
 
     | 
  
  
    | 
      41
     | 
    
          		$sql  = 'SELECT `user_id` FROM `'.TABLE_PREFIX.'users` WHERE `email` = \''.$email.'\' ';
 
     | 
  
  
    | 
      42
     | 
    
                  $sql .= 'AND `email` != \''.$sSessionEmail. '\' ';
 
     | 
  
  
    | 
      43
     | 
    
          		if($database->get_one($sql)){
     | 
  
  
    | 
      44
     | 
    
          			$error[] = ($MESSAGE['USERS_EMAIL_TAKEN']);
 
     | 
  
  
    | 
      45
     | 
    
          		} else {
     | 
  
  
    | 
      46
     | 
    
          			if(!$wb->validate_email($email)){
     | 
  
  
    | 
      47
     | 
    
          				$error[] = ($MESSAGE['USERS_INVALID_EMAIL']);
 
     | 
  
  
    | 
      48
     | 
    
          			} else {
     | 
  
  
    | 
      49
     | 
    
              			$email = $database->escapeString($email);
 
     | 
  
  
    | 
      50
     | 
    
                          // Update the database
 
     | 
  
  
    | 
      51
     | 
    
              			$sql = "UPDATE `".TABLE_PREFIX."users` SET `email` = '".$email."' WHERE `user_id` = ".$wb->get_user_id();
 
     | 
  
  
    | 
      52
     | 
    
              			$database->query($sql);
 
     | 
  
  
    | 
      53
     | 
    
              			if($database->is_error()) {
     | 
  
  
    | 
      54
     | 
    
              				$error[] = $database->get_error();
 
     | 
  
  
    | 
      55
     | 
    
              			} else {
     | 
  
  
    | 
      56
     | 
    
              				$success[] = $MESSAGE['PREFERENCES_EMAIL_UPDATED'];
 
     | 
  
  
    | 
      57
     | 
    
              				$_SESSION['EMAIL'] = $email;
 
     | 
  
  
    | 
      58
     | 
    
              			}
 
     | 
  
  
    | 
      59
     | 
    
              		}
 
     | 
  
  
    | 
      60
     | 
    
      
 
     | 
  
  
    | 
      61
     | 
    
          		}
 
     | 
  
  
    | 
      62
     | 
    
          	} else {
     | 
  
  
    | 
      63
     | 
    
          		$error[] = ($MESSAGE['SIGNUP_NO_EMAIL']);
 
     | 
  
  
    | 
      64
     | 
    
          	}
 
     | 
  
  
    | 
      65
     | 
    
      
 
     | 
  
  
    | 
      66
     | 
    
      	}
 
     |