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: ../pages/index.php');
21
	exit(0);
22
}
23
24 1407 FrankH
// Get and sanitize entered values
25 1386 Luisehahne
$display_name = $wb->add_slashes(strip_tags($wb->get_post('display_name')));
26 1407 FrankH
$language = strtoupper($wb->get_post('language'));
27
$language = (preg_match('/^[A-Z]{2}$/', $language) ? $language : DEFAULT_LANGUAGE);
28
$timezone = (int) $wb->get_post_escaped('timezone')*60*60;
29 1386 Luisehahne
30 1407 FrankH
// date_format must be a key from /interface/date_formats
31
$date_format = $wb->get_post('date_format');
32
$date_format_key  = str_replace(' ', '|', $date_format);
33
$user_time = true;
34
include( ADMIN_PATH.'/interface/date_formats.php' );
35
$date_format = (array_key_exists($date_format_key, $DATE_FORMATS) ? $date_format : 'system_default');
36
$date_format = ($date_format == 'system_default' ? '' : $date_format);
37
unset($DATE_FORMATS);
38
39
// time_format must be a key from /interface/time_formats
40
$time_format = $wb->get_post('time_format');
41
$time_format_key  = str_replace(' ', '|', $time_format);
42
$user_time = true;
43
include( ADMIN_PATH.'/interface/time_formats.php' );
44
$time_format = (array_key_exists($time_format_key, $TIME_FORMATS) ? $time_format : 'system_default');
45
$time_format = ($time_format == 'system_default' ? '' : $time_format);
46
unset($TIME_FORMATS);
47
48 1400 FrankH
if (!$wb->checkFTAN())
49
{
50
	$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
51
	exit();
52
}
53
54 1386 Luisehahne
// Create a javascript back link
55
$js_back = "javascript: history.go(-1);";
56
57
// Update the database
58
// $database = new database();
59
$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()."'";
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']['DETAILS_SAVED'], WB_URL.'/account/preferences.php');
65
	$_SESSION['DISPLAY_NAME'] = $display_name;
66
	$_SESSION['LANGUAGE'] = $language;
67
	// Update date format
68
	if($date_format != '') {
69
		$_SESSION['DATE_FORMAT'] = $date_format;
70
		if(isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); }
71
	} else {
72
		$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
73
		if(isset($_SESSION['DATE_FORMAT'])) { unset($_SESSION['DATE_FORMAT']); }
74
	}
75
	// Update time format
76
	if($time_format != '') {
77
		$_SESSION['TIME_FORMAT'] = $time_format;
78
		if(isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { unset($_SESSION['USE_DEFAULT_TIME_FORMAT']); }
79
	} else {
80
		$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
81
		if(isset($_SESSION['TIME_FORMAT'])) { unset($_SESSION['TIME_FORMAT']); }
82
	}
83
	// Update timezone
84
	if($timezone != '-72000') {
85
		$_SESSION['TIMEZONE'] = $timezone;
86
		if(isset($_SESSION['USE_DEFAULT_TIMEZONE'])) { unset($_SESSION['USE_DEFAULT_TIMEZONE']); }
87
	} else {
88
		$_SESSION['USE_DEFAULT_TIMEZONE'] = true;
89
		if(isset($_SESSION['TIMEZONE'])) { unset($_SESSION['TIMEZONE']); }
90
	}
91
}
92
93 239 stefan
?>