aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php78
1 files changed, 57 insertions, 21 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index a61518401c..a502314ded 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -31,7 +31,7 @@ function phpbb_load_extensions_autoloaders($phpbb_root_path)
new \phpbb\recursive_dot_prefix_filter_iterator(
new \RecursiveDirectoryIterator(
$phpbb_root_path . 'ext/',
- \FilesystemIterator::SKIP_DOTS
+ \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS
)
),
\RecursiveIteratorIterator::SELF_FIRST
@@ -937,14 +937,20 @@ function style_select($default = '', $all = false)
* Format the timezone offset with hours and minutes
*
* @param int $tz_offset Timezone offset in seconds
+* @param bool $show_null Whether null offsets should be shown
* @return string Normalized offset string: -7200 => -02:00
* 16200 => +04:30
*/
-function phpbb_format_timezone_offset($tz_offset)
+function phpbb_format_timezone_offset($tz_offset, $show_null = false)
{
$sign = ($tz_offset < 0) ? '-' : '+';
$time_offset = abs($tz_offset);
+ if ($time_offset == 0 && $show_null == false)
+ {
+ return '';
+ }
+
$offset_seconds = $time_offset % 3600;
$offset_minutes = $offset_seconds / 60;
$offset_hours = ($time_offset - $offset_seconds) / 3600;
@@ -1040,13 +1046,14 @@ function phpbb_get_timezone_identifiers($selected_timezone)
/**
* Options to pick a timezone and date/time
*
+* @param \phpbb\template\template $template phpBB template object
* @param \phpbb\user $user Object of the current user
* @param string $default A timezone to select
* @param boolean $truncate Shall we truncate the options text
*
-* @return array Returns an array, also containing the options for the time selector.
+* @return array Returns an array containing the options for the time selector.
*/
-function phpbb_timezone_select($user, $default = '', $truncate = false)
+function phpbb_timezone_select($template, $user, $default = '', $truncate = false)
{
static $timezones;
@@ -1062,15 +1069,15 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
$dt = $user->create_datetime('now', $tz);
$offset = $dt->getOffset();
$current_time = $dt->format($user->lang['DATETIME_FORMAT'], true);
- $offset_string = phpbb_format_timezone_offset($offset);
- $timezones['GMT' . $offset_string . ' - ' . $timezone] = array(
+ $offset_string = phpbb_format_timezone_offset($offset, true);
+ $timezones['UTC' . $offset_string . ' - ' . $timezone] = array(
'tz' => $timezone,
- 'offset' => 'GMT' . $offset_string,
+ 'offset' => $offset_string,
'current' => $current_time,
);
if ($timezone === $default)
{
- $default_offset = 'GMT' . $offset_string;
+ $default_offset = 'UTC' . $offset_string;
}
}
unset($unsorted_timezones);
@@ -1078,18 +1085,27 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
uksort($timezones, 'phpbb_tz_select_compare');
}
- $tz_select = $tz_dates = $opt_group = '';
+ $tz_select = $opt_group = '';
- foreach ($timezones as $timezone)
+ foreach ($timezones as $key => $timezone)
{
if ($opt_group != $timezone['offset'])
{
+ // Generate tz_select for backwards compatibility
$tz_select .= ($opt_group) ? '</optgroup>' : '';
- $tz_select .= '<optgroup label="' . $timezone['offset'] . ' - ' . $timezone['current'] . '">';
+ $tz_select .= '<optgroup label="' . $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']) . '">';
$opt_group = $timezone['offset'];
+ $template->assign_block_vars('timezone_select', array(
+ 'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
+ 'VALUE' => $key . ' - ' . $timezone['current'],
+ ));
- $selected = ($default_offset == $timezone['offset']) ? ' selected="selected"' : '';
- $tz_dates .= '<option value="' . $timezone['offset'] . ' - ' . $timezone['current'] . '"' . $selected . '>' . $timezone['offset'] . ' - ' . $timezone['current'] . '</option>';
+ $selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : '';
+ $template->assign_block_vars('timezone_date', array(
+ 'VALUE' => $key . ' - ' . $timezone['current'],
+ 'SELECTED' => !empty($selected),
+ 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
+ ));
}
$label = $timezone['tz'];
@@ -1097,22 +1113,26 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
{
$label = $user->lang['timezones'][$label];
}
- $title = $timezone['offset'] . ' - ' . $label;
+ $title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label);
if ($truncate)
{
$label = truncate_string($label, 50, 255, false, '...');
}
+ // Also generate timezone_select for backwards compatibility
$selected = ($timezone['tz'] === $default) ? ' selected="selected"' : '';
$tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>';
+ $template->assign_block_vars('timezone_select.timezone_options', array(
+ 'TITLE' => $title,
+ 'VALUE' => $timezone['tz'],
+ 'SELECTED' => !empty($selected),
+ 'LABEL' => $label,
+ ));
}
$tz_select .= '</optgroup>';
- return array(
- 'tz_select' => $tz_select,
- 'tz_dates' => $tz_dates,
- );
+ return $tz_select;
}
// Functions handling topic/post tracking/marking
@@ -2748,7 +2768,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
{
global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config;
- global $request, $phpbb_container;
+ global $request, $phpbb_container, $phpbb_dispatcher;
$err = '';
@@ -2834,6 +2854,18 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{
$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
+ /**
+ * This event allows an extension to modify the redirection when a user successfully logs in
+ *
+ * @event core.login_box_redirect
+ * @var string redirect Redirect string
+ * @var boolean admin Is admin?
+ * @var bool return If true, do not redirect but return the sanitized URL.
+ * @since 3.1.0-RC5
+ */
+ $vars = array('redirect', 'admin', 'return');
+ extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars)));
+
// append/replace SID (may change during the session for AOL users)
$redirect = reapply_sid($redirect);
@@ -3317,6 +3349,11 @@ function get_preg_expression($mode)
case 'table_prefix':
return '#^[a-zA-Z][a-zA-Z0-9_]*$#';
break;
+
+ // Matches the predecing dot
+ case 'path_remove_dot_trailing_slash':
+ return '#^(?:(\.)?)+(?:(.+)?)+(?:([\\/\\\])$)#';
+ break;
}
return '';
@@ -4898,7 +4935,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
}
$dt = $user->create_datetime();
- $timezone_offset = 'GMT' . phpbb_format_timezone_offset($dt->getOffset());
+ $timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset()));
$timezone_name = $user->timezone->getName();
if (isset($user->lang['timezones'][$timezone_name]))
{
@@ -5063,7 +5100,6 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'Content-type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'private, no-cache="set-cookie"',
'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
- 'Pragma' => 'no-cache',
);
if (!empty($user->data['is_bot']))
{