Project

General

Profile

« Previous | Next » 

Revision 1509

Added by Dietmar about 13 years ago

continue fixing frontend account

View differences:

details.php
19 19
// Must include code to stop this file being access directly
20 20
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
21 21

  
22
// Create a javascript back link
23
$js_back = WB_URL.'/account/preferences.php';
24
/*
25
if (!$wb->checkFTAN())
26
{
27
	$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back);
28
	exit();
29
}
30
*/
31
// Get and sanitize entered values
32
$display_name = $wb->add_slashes(strip_tags($wb->get_post('display_name')));
33
$language = strtoupper($wb->get_post('language'));
34
$language = (preg_match('/^[A-Z]{2}$/', $language) ? $language : DEFAULT_LANGUAGE);
35
$timezone = (int) $wb->get_post_escaped('timezone')*60*60;
22
// Get entered values
23
	$display_name = $wb->add_slashes(strip_tags($admin->get_post('display_name')));
24
	$language = $wb->get_post('language');
25
	$timezone = $wb->get_post('timezone')*60*60;
26
	$date_format = $wb->get_post('date_format');
27
	$time_format = $wb->get_post('time_format');
36 28

  
37
// date_format must be a key from /interface/date_formats
38
$date_format = $wb->get_post('date_format');
39
$date_format_key  = str_replace(' ', '|', $date_format);
40
$user_time = true;
41
include( ADMIN_PATH.'/interface/date_formats.php' );
42
$date_format = (array_key_exists($date_format_key, $DATE_FORMATS) ? $date_format : 'system_default');
43
$date_format = ($date_format == 'system_default' ? '' : $date_format);
44
unset($DATE_FORMATS);
45

  
46
// time_format must be a key from /interface/time_formats	
47
$time_format = $wb->get_post('time_format');
48
$time_format_key  = str_replace(' ', '|', $time_format);
49
$user_time = true;
50
include( ADMIN_PATH.'/interface/time_formats.php' );
51
$time_format = (array_key_exists($time_format_key, $TIME_FORMATS) ? $time_format : 'system_default');
52
$time_format = ($time_format == 'system_default' ? '' : $time_format);
53
unset($TIME_FORMATS);
54

  
55 29
// Update the database
56 30
// $database = new database();
57
$query = "UPDATE ".TABLE_PREFIX."users SET display_name = '$display_name', language = '$language', timezone = '$timezone', date_format = '$date_format', time_format = '$time_format' WHERE user_id = '".$wb->get_user_id()."'";
58
$database->query($query);
59
if($database->is_error()) {
60
	$wb->print_error($database->get_error,$js_back,false);
61
} else {
62
	$wb->print_success($MESSAGE['PREFERENCES']['DETAILS_SAVED'] );
63
	$_SESSION['DISPLAY_NAME'] = $display_name;
64
	$_SESSION['LANGUAGE'] = $language;
65
	// Update date format
66
	if($date_format != '') {
67
		$_SESSION['DATE_FORMAT'] = $date_format;
68
		if(isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); }
31
	$sql  = "UPDATE `".TABLE_PREFIX."users` SET ";
32
	$sql .= "`display_name` = '".$display_name."', `language` = '".$language."', ";
33
	$sql .= "`timezone` = '".$timezone."', `date_format` = '".$date_format."', ";
34
	$sql .= "`time_format` = '".$time_format."' ";
35
	$sql .=	"WHERE `user_id` = '".$wb->get_user_id()."'";
36
	$database->query($sql);
37
	if($database->is_error()) {
38
		$error[] = $database->get_error();
69 39
	} else {
70
		$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
71
		if(isset($_SESSION['DATE_FORMAT'])) { unset($_SESSION['DATE_FORMAT']); }
72
	}
73
	// Update time format
74
	if($time_format != '') {
75
		$_SESSION['TIME_FORMAT'] = $time_format;
76
		if(isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { unset($_SESSION['USE_DEFAULT_TIME_FORMAT']); }
77
	} else {
78
		$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
79
		if(isset($_SESSION['TIME_FORMAT'])) { unset($_SESSION['TIME_FORMAT']); }
80
	}
81
	// Update timezone
82
	if($timezone != '-72000') {
40
		$success[] = $MOD_PREFERENCE['DETAILS_SAVED'];
41
		$_SESSION['DISPLAY_NAME'] = $display_name;
42
		$_SESSION['LANGUAGE'] = $language;
83 43
		$_SESSION['TIMEZONE'] = $timezone;
84
		if(isset($_SESSION['USE_DEFAULT_TIMEZONE'])) { unset($_SESSION['USE_DEFAULT_TIMEZONE']); }
85
	} else {
86
		$_SESSION['USE_DEFAULT_TIMEZONE'] = true;
87
		if(isset($_SESSION['TIMEZONE'])) { unset($_SESSION['TIMEZONE']); }
44
// Update date format
45
		if($date_format != '') {
46
			$_SESSION['DATE_FORMAT'] = $date_format;
47
			if(isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); }
48
		} else {
49
			$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
50
			if(isset($_SESSION['DATE_FORMAT'])) { unset($_SESSION['DATE_FORMAT']); }
51
		}
52
// Update time format
53
		if($time_format != '') {
54
			$_SESSION['TIME_FORMAT'] = $time_format;
55
			if(isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { unset($_SESSION['USE_DEFAULT_TIME_FORMAT']); }
56
		} else {
57
			$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
58
			if(isset($_SESSION['TIME_FORMAT'])) { unset($_SESSION['TIME_FORMAT']); }
59
		}
88 60
	}
89
}

Also available in: Unified diff