Project

General

Profile

1
<?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: details.php 1420 2011-01-26 17:43:56Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/details.php $
15
 * @lastmodified    $Date: 2011-01-26 18:43:56 +0100 (Wed, 26 Jan 2011) $
16
 *
17
 */
18

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

    
22
// Get and sanitize entered values
23
$display_name = $wb->add_slashes(strip_tags($wb->get_post('display_name')));
24
$language = strtoupper($wb->get_post('language'));
25
$language = (preg_match('/^[A-Z]{2}$/', $language) ? $language : DEFAULT_LANGUAGE);
26
$timezone = (int) $wb->get_post_escaped('timezone')*60*60;
27

    
28
// date_format must be a key from /interface/date_formats
29
$date_format = $wb->get_post('date_format');
30
$date_format_key  = str_replace(' ', '|', $date_format);
31
$user_time = true;
32
include( ADMIN_PATH.'/interface/date_formats.php' );
33
$date_format = (array_key_exists($date_format_key, $DATE_FORMATS) ? $date_format : 'system_default');
34
$date_format = ($date_format == 'system_default' ? '' : $date_format);
35
unset($DATE_FORMATS);
36

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

    
46
if (!$wb->checkFTAN())
47
{
48
	$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
49
	exit();
50
}
51

    
52
// Create a javascript back link
53
$js_back = "javascript: history.go(-1);";
54

    
55
// 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
	$wb->print_error($database->get_error,'index.php',false);
61
} else {
62
	$wb->print_success($MESSAGE['PREFERENCES']['DETAILS_SAVED'], WB_URL.'/account/preferences.php');
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']); }
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
?>
(1-1/14)