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 1773 2012-09-27 23:42:13Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/email.php $
|
15
|
* @lastmodified $Date: 2012-09-28 01:42:13 +0200 (Fri, 28 Sep 2012) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
/* -------------------------------------------------------- */
|
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
|
|
28
|
// 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
|
// Validate values
|
36
|
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
|
// Update the database
|
44
|
$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
|
}
|