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
if(!defined('WB_URL')) {
20
	header('Location: ../index.php');
21
	exit(0);
22
}
23
24
// Get the values entered
25
$current_password = $_POST['current_password'];
26
$new_password = $_POST['new_password'];
27
$new_password2 = $_POST['new_password2'];
28
29 1400 FrankH
if (!$wb->checkFTAN())
30
{
31
	$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
32
	exit();
33
}
34
35 1386 Luisehahne
// Create a javascript back link
36
$js_back = "javascript: history.go(-1);";
37
38
// Get existing password
39
// $database = new database();
40
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
41
$results = $database->query($query);
42
43
// Validate values
44
if($results->numRows() == 0) {
45
	$wb->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back, false);
46
}
47
if(strlen($new_password) < 3) {
48
	$wb->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back, false);
49
}
50
if($new_password != $new_password2) {
51
	$wb->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back, false);
52
}
53
54
// MD5 the password
55
$md5_password = md5($new_password);
56
57
// Update the database
58
// $database = new database();
59
$query = "UPDATE ".TABLE_PREFIX."users SET password = '$md5_password' WHERE user_id = '".$wb->get_user_id()."'";
60
$database->query($query);
61
if($database->is_error()) {
62
	$wb->print_error($database->get_error, 'index.php', false);
63
} else {
64
	$wb->print_success($MESSAGE['PREFERENCES']['PASSWORD_CHANGED'], WB_URL.'/account/preferences.php');
65
}
66
67 4 ryan
?>