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 1425 Luisehahne
// 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 1407 FrankH
// Get and sanitize entered values
32 1386 Luisehahne
$display_name = $wb->add_slashes(strip_tags($wb->get_post('display_name')));
33 1407 FrankH
$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;
36 1386 Luisehahne
37 1407 FrankH
// 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 1386 Luisehahne
// Update the database
56
// $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 1425 Luisehahne
	$wb->print_error($database->get_error,$js_back,false);
61 1386 Luisehahne
} else {
62 1425 Luisehahne
	$wb->print_success($MESSAGE['PREFERENCES']['DETAILS_SAVED'] );
63 1386 Luisehahne
	$_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']); }
69
	} 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') {
83
		$_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']); }
88
	}
89
}
90
91 239 stefan
?>