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