Line 57 | Line 57 |
---|
* @param \phpbb\language\language $lang phpBB's Language loader * @param string $datetime_class Class name of datetime class */
|
* @param \phpbb\language\language $lang phpBB's Language loader * @param string $datetime_class Class name of datetime class */
|
function __construct(\phpbb\language\language $lang, $datetime_class)
| public function __construct(\phpbb\language\language $lang, $datetime_class)
|
{ global $phpbb_root_path;
| { global $phpbb_root_path;
|
Line 76 | Line 76 |
---|
public function is_setup() { return $this->is_setup_flag;
|
public function is_setup() { return $this->is_setup_flag;
|
| }
/** * Get expiration time for user tokens, e.g. activation or reset password tokens * * @return int Expiration for user tokens */ public static function get_token_expiration(): int { return strtotime('+1 day') ?: 0;
|
}
/**
| }
/**
|
Line 227 | Line 237 |
---|
$this->language->set_user_language($user_lang_name);
|
$this->language->set_user_language($user_lang_name);
|
try { $this->timezone = new \DateTimeZone($user_timezone); } catch (\Exception $e) { // If the timezone the user has selected is invalid, we fall back to UTC. $this->timezone = new \DateTimeZone('UTC'); }
| $this->create_timezone($user_timezone);
|
$this->add_lang($lang_set); unset($lang_set);
| $this->add_lang($lang_set); unset($lang_set);
|
Line 262 | Line 264 |
---|
}
$sql = 'SELECT *
|
}
$sql = 'SELECT *
|
FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id";
| FROM ' . STYLES_TABLE . ' WHERE style_id = ' . (int) $style_id;
|
$result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
| $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
|
Line 274 | Line 276 |
---|
$style_id = $this->data['user_style'];
$sql = 'SELECT *
|
$style_id = $this->data['user_style'];
$sql = 'SELECT *
|
FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id";
| FROM ' . STYLES_TABLE . ' WHERE style_id = ' . (int) $style_id;
|
$result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
| $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
|
Line 334 | Line 336 |
---|
if (is_string($default_value)) {
|
if (is_string($default_value)) {
|
$this->style[$key] = htmlspecialchars($this->style[$key]);
| $this->style[$key] = htmlspecialchars($this->style[$key], ENT_COMPAT);
|
} }
| } }
|
Line 635 | Line 637 |
---|
if (!$format_date_override) { $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc);
|
if (!$format_date_override) { $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc);
|
$time->setTimezone($this->timezone);
| $time->setTimezone($this->create_timezone());
|
return $time->format($format, $forcedate); }
| return $time->format($format, $forcedate); }
|
Line 643 | Line 645 |
---|
{ return $format_date_override; }
|
{ return $format_date_override; }
|
| }
/** * Create a DateTimeZone object in the context of the current user * * @param string $user_timezone Time zone of the current user. * @return \DateTimeZone DateTimeZone object linked to the current users locale */ public function create_timezone($user_timezone = null) { if (!$this->timezone) { if (!$user_timezone) { global $config; $user_timezone = ($this->data['user_id'] != ANONYMOUS) ? $this->data['user_timezone'] : $config['board_timezone']; }
try { $this->timezone = new \DateTimeZone($user_timezone); } catch (\Exception $e) { // If the timezone the user has selected is invalid, we fall back to UTC. $this->timezone = new \DateTimeZone('UTC'); } }
return $this->timezone;
|
}
/**
| }
/**
|
Line 655 | Line 687 |
---|
*/ public function create_datetime($time = 'now', \DateTimeZone $timezone = null) {
|
*/ public function create_datetime($time = 'now', \DateTimeZone $timezone = null) {
|
$timezone = $timezone ?: $this->timezone;
| $timezone = $timezone ?: $this->create_timezone();
|
return new $this->datetime($this, $time, $timezone); }
| return new $this->datetime($this, $time, $timezone); }
|
Line 669 | Line 701 |
---|
*/ public function get_timestamp_from_format($format, $time, \DateTimeZone $timezone = null) {
|
*/ public function get_timestamp_from_format($format, $time, \DateTimeZone $timezone = null) {
|
$timezone = $timezone ?: $this->timezone;
| $timezone = $timezone ?: $this->create_timezone();
|
$date = \DateTime::createFromFormat($format, $time, $timezone); return ($date !== false) ? $date->format('U') : false; }
| $date = \DateTime::createFromFormat($format, $time, $timezone); return ($date !== false) ? $date->format('U') : false; }
|