Project

General

Profile

1
<?php
2

    
3
// $Id: email.php,v 1.2 2005/03/28 11:58:03 rdjurovich Exp $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
if(!defined('WB_URL')) {
27
	header('Location: ../index.php');
28
}
29

    
30
// Get the values entered
31
$current_password = $admin->get_post('current_password');
32
$email = $admin->get_post('email');
33

    
34
// Create a javascript back link
35
$js_back = "javascript: history.go(-1);";
36

    
37
// Get existing password
38
$database = new database();
39
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."' AND password = '".md5($current_password)."'";
40
$results = $database->query($query);
41

    
42
// Validate values
43
if($results->numRows() == 0) {
44
	$admin->print_error($MESSAGE['PREFERENCES']['OLD_PASSWORD_INCORRECT'], $js_back);
45
}
46
// Validate values
47
if(!$admin->validate_email($email)) {
48
	$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
49
}
50

    
51
// Update the database
52
$database = new database();
53
$query = "UPDATE ".TABLE_PREFIX."users SET email = '$email' WHERE user_id = '".$admin->get_user_id()."' AND password = '".md5($current_password)."'";
54
$database->query($query);
55
if($database->is_error()) {
56
	$admin->print_error($database->get_error);
57
} else {
58
	$admin->print_success($MESSAGE['PREFERENCES']['EMAIL_UPDATED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
59
	$_SESSION['EMAIL'] = $email;
60
}
61

    
62
?>
(2-2/15)