Project

General

Profile

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 1773 Luisehahne
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(defined('WB_PATH') == false)
22
{
23
	// Stop this file being access directly
24
		die('<h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2>');
25
}
26
/* -------------------------------------------------------- */
27 1386 Luisehahne
28 1509 Luisehahne
// Get entered values
29
	$password = $wb->get_post('current_password');
30
	$email = $wb->get_post('email');
31
// validate password
32
	$sql  = "SELECT `user_id` FROM `".TABLE_PREFIX."users` ";
33
	$sql .= "WHERE `user_id` = ".$wb->get_user_id()." AND `password` = '".md5($password)."'";
34
	$rowset = $database->query($sql);
35 1386 Luisehahne
// Validate values
36 1509 Luisehahne
	if($rowset->numRows() == 0) {
37
		$error[] = $MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'];
38
	}else {
39
		if(!$wb->validate_email($email)) {
40
			$error[] = $MESSAGE['USERS']['INVALID_EMAIL'];
41
		}else {
42
			$email = $wb->add_slashes($email);
43 1386 Luisehahne
// Update the database
44 1509 Luisehahne
			$sql = "UPDATE `".TABLE_PREFIX."users` SET `email` = '".$email."' WHERE `user_id` = ".$wb->get_user_id();
45
			$database->query($sql);
46
			if($database->is_error()) {
47
				$error[] = $database->get_error();
48
			} else {
49
				$success[] = $MESSAGE['PREFERENCES']['EMAIL_UPDATED'];
50
				$_SESSION['EMAIL'] = $email;
51
			}
52
		}
53
	}