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 |
1777
|
Luisehahne
|
if(!defined('WB_PATH')) {
|
22 |
|
|
require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
|
23 |
|
|
throw new IllegalFileException();
|
24 |
1773
|
Luisehahne
|
}
|
25 |
|
|
/* -------------------------------------------------------- */
|
26 |
1386
|
Luisehahne
|
|
27 |
1509
|
Luisehahne
|
// Get entered values
|
28 |
1777
|
Luisehahne
|
$password = $wb->StripCodeFromText($wb->get_post('current_password'));
|
29 |
|
|
$email = strip_tags($wb->StripCodeFromText($wb->get_post('email')));
|
30 |
1509
|
Luisehahne
|
// validate password
|
31 |
|
|
$sql = "SELECT `user_id` FROM `".TABLE_PREFIX."users` ";
|
32 |
1777
|
Luisehahne
|
$sql .= "WHERE `user_id` = ".(int)$wb->get_user_id()." AND `password` = '".md5($password)."'";
|
33 |
1509
|
Luisehahne
|
$rowset = $database->query($sql);
|
34 |
1386
|
Luisehahne
|
// Validate values
|
35 |
1509
|
Luisehahne
|
if($rowset->numRows() == 0) {
|
36 |
1777
|
Luisehahne
|
$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 |
1868
|
Luisehahne
|
$email = $database->escapeString($email);
|
50 |
1777
|
Luisehahne
|
// 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 |
1509
|
Luisehahne
|
}
|