Project

General

Profile

« Previous | Next » 

Revision 1777

Added by Dietmar about 12 years ago

+ add methode StripCodeFromText in class.wb to clean injection
! rebranding the admin/settings and security fixes
! a few new styling in backend wb_theme
! beginning aa lot of account changes like correction of $_SESSION indexe, security fixes
+ add head.load.min.js and head.min.js to /include/jquery/ to style HTML5 templates

View differences:

email.php
18 18

  
19 19
/* -------------------------------------------------------- */
20 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>');
21
if(!defined('WB_PATH')) {
22
	require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
23
	throw new IllegalFileException();
25 24
}
26 25
/* -------------------------------------------------------- */
27 26

  
28 27
// Get entered values
29
	$password = $wb->get_post('current_password');
30
	$email = $wb->get_post('email');
28
	$password = $wb->StripCodeFromText($wb->get_post('current_password'));
29
	$email = strip_tags($wb->StripCodeFromText($wb->get_post('email')));
31 30
// validate password
32 31
	$sql  = "SELECT `user_id` FROM `".TABLE_PREFIX."users` ";
33
	$sql .= "WHERE `user_id` = ".$wb->get_user_id()." AND `password` = '".md5($password)."'";
32
	$sql .= "WHERE `user_id` = ".(int)$wb->get_user_id()." AND `password` = '".md5($password)."'";
34 33
	$rowset = $database->query($sql);
35 34
// Validate values
36 35
	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
		}
36
		$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
        			$email = mysql_escape_string($email);
50
                    // 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

  
53 66
	}

Also available in: Unified diff