1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category frontend
|
5
|
* @package account
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright Ryan Djurovich
|
8
|
* @copyright WebsiteBaker Org. e.V.
|
9
|
* @link http://websitebaker.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.3
|
12
|
* @requirements PHP 5.3.6 and higher
|
13
|
* @version $Id: details.php 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/account/details.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
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
|
// sanitize entered values
|
22
|
$display_name = strip_tags( $wb->StripCodeFromText($wb->get_post('display_name')));
|
23
|
$display_name = ( $display_name == '' ? $wb->get_display_name() : $display_name );
|
24
|
$language = preg_match('/^[a-z]{2}$/si', $wb->get_post('language'))
|
25
|
? $wb->get_post('language') : 'EN';
|
26
|
$user_time = true;
|
27
|
// timezone must be between -12 and +13 or -20 as system_default
|
28
|
$timezone = $wb->get_post('timezone');
|
29
|
$timezone = (is_numeric($timezone) ? $timezone : DEFAULT_TIMEZONE/3600);
|
30
|
$timezone = (($timezone >= -12 && $timezone <= 13) ? $timezone : DEFAULT_TIMEZONE/3600) * 3600;
|
31
|
|
32
|
/*
|
33
|
$timezone = $wb->get_post('timezone');
|
34
|
$timezone = is_numeric($wb->get_post('timezone')) ? $wb->get_post('timezone')*3600 : 0;
|
35
|
$timezone = (is_numeric($timezone) ? $timezone : DEFAULT_TIMEZONE/3600);
|
36
|
$timezone = (($timezone >= -12 && $timezone <= 13) ? $timezone : DEFAULT_TIMEZONE/3600) * 3600;
|
37
|
*/
|
38
|
$date_format = $wb->get_post('date_format');
|
39
|
$time_format = $wb->get_post('time_format');
|
40
|
// check that display_name is unique in whoole system (prevents from User-faking)
|
41
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'users` ';
|
42
|
$sql .= 'WHERE `user_id` <> '.(int)$wb->get_user_id().' AND `display_name` LIKE \''.$display_name.'\'';
|
43
|
if ($database->get_one($sql)) {
|
44
|
$error[] = ( @$oTrans->MESSAGE_USERS_DISPLAYNAME_TAKEN ?:$oTrans->MESSAGE_MEDIA_BLANK_NAME.' ('.$oTrans->TEXT_DISPLAY_NAME.')');
|
45
|
} else {
|
46
|
// Update the database
|
47
|
$sql = 'UPDATE `'.TABLE_PREFIX.'users` SET '
|
48
|
. '`display_name` = \''.$database->escapeString($display_name).'\', '
|
49
|
. '`language` = \''.$database->escapeString($language).'\', '
|
50
|
. '`timezone` = \''.$database->escapeString($timezone).'\', '
|
51
|
. '`date_format` = \''.$database->escapeString($date_format).'\', '
|
52
|
. '`time_format` = \''.$database->escapeString($time_format).'\' '
|
53
|
. 'WHERE `user_id` = \''.$wb->get_user_id().'\'';
|
54
|
$database->query($sql);
|
55
|
if($database->is_error()) {
|
56
|
$error[] = $database->get_error();
|
57
|
} else {
|
58
|
$success[] = $oTrans->MOD_PREFERENCE_DETAILS_SAVED;
|
59
|
$_SESSION['DISPLAY_NAME'] = $display_name;
|
60
|
$_SESSION['LANGUAGE'] = $language;
|
61
|
$_SESSION['TIMEZONE'] = $timezone;
|
62
|
// Update date format
|
63
|
if($date_format != '') {
|
64
|
$_SESSION['DATE_FORMAT'] = $date_format;
|
65
|
if(isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); }
|
66
|
} else {
|
67
|
$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
|
68
|
if(isset($_SESSION['DATE_FORMAT'])) { unset($_SESSION['DATE_FORMAT']); }
|
69
|
}
|
70
|
|
71
|
// Update time format
|
72
|
if($time_format != '') {
|
73
|
$_SESSION['TIME_FORMAT'] = $time_format;
|
74
|
if(isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { unset($_SESSION['USE_DEFAULT_TIME_FORMAT']); }
|
75
|
} else {
|
76
|
$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
|
77
|
if(isset($_SESSION['TIME_FORMAT'])) { unset($_SESSION['TIME_FORMAT']); }
|
78
|
}
|
79
|
}
|
80
|
}
|