phpBB

Code Changes

File: phpbb/user.php

  Unmodified   Added   Modified   Removed
Line 227Line 227

$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 262Line 254
		}

$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 274Line 266
			$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);
}


 
		// Fallback to board's default style

		if (!$this->style)
{

		if (!$this->style)
{

			trigger_error('NO_STYLE_DATA', E_USER_ERROR);


































			// Verify default style exists in the database
$sql = 'SELECT style_id
FROM ' . STYLES_TABLE . '
WHERE style_id = ' . (int) $config['default_style'];
$result = $db->sql_query($sql);
$style_id = (int) $db->sql_fetchfield('style_id');
$db->sql_freeresult($result);

if ($style_id > 0)
{
$db->sql_transaction('begin');

// Update $user row
$sql = 'SELECT *
FROM ' . STYLES_TABLE . '
WHERE style_id = ' . (int) $config['default_style'];
$result = $db->sql_query($sql);
$this->style = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

// Update user style preference
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_style = ' . (int) $style_id . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);

$db->sql_transaction('commit');
}
}

// This should never happen
if (!$this->style)
{
trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR);

		}

// Now parse the cfg file and cache it

		}

// Now parse the cfg file and cache it

Line 343Line 369
		}

// Is board disabled and user not an admin or moderator?

		}

// Is board disabled and user not an admin or moderator?

		if ($config['board_disable'] && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))

		if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))

		{
if ($this->data['is_bot'])
{

		{
if ($this->data['is_bot'])
{

Line 601Line 627
		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 609Line 635
		{
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 621Line 677
	*/
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 635Line 691
	*/
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;
}