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 |
1773
|
Luisehahne
|
/* -------------------------------------------------------- */
|
20 |
|
|
// Must include code to stop this file being accessed directly
|
21 |
1777
|
Luisehahne
|
if(!defined('WB_PATH')) {
|
22 |
|
|
require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
|
23 |
|
|
throw new IllegalFileException();
|
24 |
1773
|
Luisehahne
|
}
|
25 |
|
|
/* -------------------------------------------------------- */
|
26 |
1386
|
Luisehahne
|
|
27 |
1509
|
Luisehahne
|
// Get entered values
|
28 |
1777
|
Luisehahne
|
$display_name = strip_tags($wb->StripCodeFromText($wb->get_post('display_name')));
|
29 |
1872
|
Luisehahne
|
// language must be 2 upercase letters only
|
30 |
1792
|
Luisehahne
|
$sUserLanguage = strip_tags($wb->StripCodeFromText($wb->get_post('language')));
|
31 |
1872
|
Luisehahne
|
$sUserLanguage = (preg_match('/^[A-Z]{2}$/', $sUserLanguage) ? $sUserLanguage : DEFAULT_LANGUAGE);
|
32 |
|
|
// timezone must be between -12 and +13 or -20 as system_default
|
33 |
|
|
$timezone = ($wb->StripCodeFromText($wb->get_post('timezone')));
|
34 |
|
|
$timezone = ( (is_numeric($timezone) && ($timezone!=0)) ? $timezone : -20);
|
35 |
|
|
$timezone = ( ($timezone >= -12 && $timezone <= 13) ? $timezone : -20 ) * 3600;
|
36 |
|
|
// date_format must be a key from /interface/date_formats
|
37 |
1777
|
Luisehahne
|
$date_format = strip_tags($wb->StripCodeFromText($wb->get_post('date_format')));
|
38 |
1872
|
Luisehahne
|
$date_format = (($date_format==DEFAULT_DATE_FORMAT) ? '' : $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 |
|
|
// time_format must be a key from /interface/time_formats
|
46 |
1777
|
Luisehahne
|
$time_format = strip_tags($wb->StripCodeFromText($wb->get_post('time_format')));
|
47 |
1872
|
Luisehahne
|
$time_format = (($time_format==DEFAULT_TIME_FORMAT) ? '' : $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 |
1386
|
Luisehahne
|
|
55 |
1792
|
Luisehahne
|
// Update the database
|
56 |
1509
|
Luisehahne
|
$sql = "UPDATE `".TABLE_PREFIX."users` SET ";
|
57 |
1792
|
Luisehahne
|
$sql .= "`display_name` = '".$display_name."', `language` = '".$sUserLanguage."', ";
|
58 |
1509
|
Luisehahne
|
$sql .= "`timezone` = '".$timezone."', `date_format` = '".$date_format."', ";
|
59 |
|
|
$sql .= "`time_format` = '".$time_format."' ";
|
60 |
|
|
$sql .= "WHERE `user_id` = '".$wb->get_user_id()."'";
|
61 |
|
|
$database->query($sql);
|
62 |
|
|
if($database->is_error()) {
|
63 |
|
|
$error[] = $database->get_error();
|
64 |
1386
|
Luisehahne
|
} else {
|
65 |
1509
|
Luisehahne
|
$success[] = $MOD_PREFERENCE['DETAILS_SAVED'];
|
66 |
|
|
$_SESSION['DISPLAY_NAME'] = $display_name;
|
67 |
1792
|
Luisehahne
|
$_SESSION['LANGUAGE'] = $sUserLanguage;
|
68 |
1386
|
Luisehahne
|
$_SESSION['TIMEZONE'] = $timezone;
|
69 |
1872
|
Luisehahne
|
if(isset($_SESSION['USE_DEFAULT_TIMEZONE'])) { unset($_SESSION['USE_DEFAULT_TIMEZONE']); }
|
70 |
1509
|
Luisehahne
|
// Update date format
|
71 |
|
|
if($date_format != '') {
|
72 |
|
|
$_SESSION['DATE_FORMAT'] = $date_format;
|
73 |
|
|
if(isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); }
|
74 |
|
|
} else {
|
75 |
|
|
$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
|
76 |
|
|
if(isset($_SESSION['DATE_FORMAT'])) { unset($_SESSION['DATE_FORMAT']); }
|
77 |
|
|
}
|
78 |
|
|
// Update time format
|
79 |
|
|
if($time_format != '') {
|
80 |
|
|
$_SESSION['TIME_FORMAT'] = $time_format;
|
81 |
|
|
if(isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { unset($_SESSION['USE_DEFAULT_TIME_FORMAT']); }
|
82 |
|
|
} else {
|
83 |
|
|
$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
|
84 |
|
|
if(isset($_SESSION['TIME_FORMAT'])) { unset($_SESSION['TIME_FORMAT']); }
|
85 |
|
|
}
|
86 |
1386
|
Luisehahne
|
}
|