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.php93
1 files changed, 41 insertions, 52 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c838876ddd..a61518401c 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -289,7 +289,6 @@ function phpbb_gmgetdate($time = false)
* @param array $allowed_units only allow these units (data array indexes)
*
* @return mixed data array if $string_only is false
-* @author bantu
*/
function get_formatted_filesize($value, $string_only = true, $allowed_units = false)
{
@@ -463,7 +462,6 @@ function phpbb_version_compare($version1, $version2, $operator = null)
* @param int $perms Permissions to set
*
* @return bool true on success, otherwise false
-* @author faw, phpBB Limited
*/
function phpbb_chmod($filename, $perms = CHMOD_READ)
{
@@ -1146,12 +1144,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
// Mark all topic notifications read for this user
$phpbb_notifications->mark_notifications_read(array(
- 'topic',
- 'quote',
- 'bookmark',
- 'post',
- 'approve_topic',
- 'approve_post',
+ 'notification.type.topic',
+ 'notification.type.quote',
+ 'notification.type.bookmark',
+ 'notification.type.post',
+ 'notification.type.approve_topic',
+ 'notification.type.approve_post',
), false, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered'])
@@ -1211,8 +1209,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$phpbb_notifications = $phpbb_container->get('notification_manager');
$phpbb_notifications->mark_notifications_read_by_parent(array(
- 'topic',
- 'approve_topic',
+ 'notification.type.topic',
+ 'notification.type.approve_topic',
), $forum_id, $user->data['user_id'], $post_time);
// Mark all post/quote notifications read for this user in this forum
@@ -1228,10 +1226,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$db->sql_freeresult($result);
$phpbb_notifications->mark_notifications_read_by_parent(array(
- 'quote',
- 'bookmark',
- 'post',
- 'approve_post',
+ 'notification.type.quote',
+ 'notification.type.bookmark',
+ 'notification.type.post',
+ 'notification.type.approve_post',
), $topic_ids, $user->data['user_id'], $post_time);
// Add 0 to forums array to mark global announcements correctly
@@ -1334,15 +1332,15 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
// Mark post notifications read for this user in this topic
$phpbb_notifications->mark_notifications_read(array(
- 'topic',
- 'approve_topic',
+ 'notification.type.topic',
+ 'notification.type.approve_topic',
), $topic_id, $user->data['user_id'], $post_time);
$phpbb_notifications->mark_notifications_read_by_parent(array(
- 'quote',
- 'bookmark',
- 'post',
- 'approve_post',
+ 'notification.type.quote',
+ 'notification.type.bookmark',
+ 'notification.type.post',
+ 'notification.type.approve_post',
), $topic_id, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered'])
@@ -1638,7 +1636,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
if (empty($sql_sort))
{
- $sql_sort = 'ORDER BY t.topic_last_post_time DESC';
+ $sql_sort = 'ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC';
}
if ($config['load_db_lastread'] && $user->data['is_registered'])
@@ -1991,6 +1989,9 @@ function tracking_unserialize($string, $max_depth = 3)
* @param mixed $params String or array of additional url parameters
* @param bool $is_amp Is url using & (true) or & (false)
* @param string $session_id Possibility to use a custom session id instead of the global one
+* @param bool $is_route Is url generated by a route.
+*
+* @return string The corrected url.
*
* Examples:
* <code>
@@ -2001,7 +2002,7 @@ function tracking_unserialize($string, $max_depth = 3)
* </code>
*
*/
-function append_sid($url, $params = false, $is_amp = true, $session_id = false)
+function append_sid($url, $params = false, $is_amp = true, $session_id = false, $is_route = false)
{
global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper;
global $phpbb_dispatcher;
@@ -2013,7 +2014,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
}
// Update the root path with the correct relative web path
- if ($phpbb_path_helper instanceof \phpbb\path_helper)
+ if (!$is_route && $phpbb_path_helper instanceof \phpbb\path_helper)
{
$url = $phpbb_path_helper->update_web_root_path($url);
}
@@ -2039,9 +2040,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
* the global one (false)
* @var bool|string append_sid_overwrite Overwrite function (string
* URL) or not (false)
+ * @var bool is_route Is url generated by a route.
* @since 3.1.0-a1
*/
- $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite');
+ $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite', 'is_route');
extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars)));
if ($append_sid_overwrite)
@@ -2578,15 +2580,17 @@ function add_form_key($form_name)
}
/**
-* Check the form key. Required for all altering actions not secured by confirm_box
-* @param string $form_name The name of the form; has to match the name used in add_form_key, otherwise no restrictions apply
-* @param int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting.
-* @param string $return_page The address for the return link
-* @param bool $trigger If true, the function will triger an error when encountering an invalid form
-*/
-function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false)
+ * Check the form key. Required for all altering actions not secured by confirm_box
+ *
+ * @param string $form_name The name of the form; has to match the name used
+ * in add_form_key, otherwise no restrictions apply
+ * @param int $timespan The maximum acceptable age for a submitted form
+ * in seconds. Defaults to the config setting.
+ * @return bool True, if the form key was valid, false otherwise
+ */
+function check_form_key($form_name, $timespan = false)
{
- global $config, $user;
+ global $config, $request, $user;
if ($timespan === false)
{
@@ -2594,10 +2598,10 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
$timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']);
}
- if (isset($_POST['creation_time']) && isset($_POST['form_token']))
+ if ($request->is_set_post('creation_time') && $request->is_set_post('form_token'))
{
- $creation_time = abs(request_var('creation_time', 0));
- $token = request_var('form_token', '');
+ $creation_time = abs($request->variable('creation_time', 0));
+ $token = $request->variable('form_token', '');
$diff = time() - $creation_time;
@@ -2614,11 +2618,6 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
}
}
- if ($trigger)
- {
- trigger_error($user->lang['FORM_INVALID'] . $return_page);
- }
-
return false;
}
@@ -2834,8 +2833,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
if ($result['status'] == LOGIN_SUCCESS)
{
$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
- $message = ($l_success) ? $l_success : $user->lang['LOGIN_REDIRECT'];
- $l_redirect = ($admin) ? $user->lang['PROCEED_TO_ACP'] : (($redirect === "{$phpbb_root_path}index.$phpEx" || $redirect === "index.$phpEx") ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']);
// append/replace SID (may change during the session for AOL users)
$redirect = reapply_sid($redirect);
@@ -3404,8 +3401,6 @@ function short_ipv6($ip, $length)
*
* @return mixed false if specified address is not valid,
* string otherwise
-*
-* @author bantu
*/
function phpbb_ip_normalise($address)
{
@@ -3434,8 +3429,6 @@ function phpbb_ip_normalise($address)
*
* @return mixed false on failure,
* string otherwise
-*
-* @author APTX
*/
function phpbb_inet_ntop($in_addr)
{
@@ -3505,8 +3498,6 @@ function phpbb_inet_ntop($in_addr)
*
* @return mixed false if address is invalid,
* in_addr representation of the given address otherwise (string)
-*
-* @author APTX
*/
function phpbb_inet_pton($address)
{
@@ -3586,8 +3577,6 @@ function phpbb_inet_pton($address)
*
* Since null can also be returned, you probably want to compare the result
* with === true or === false,
-*
-* @author bantu
*/
function phpbb_checkdnsrr($host, $type = 'MX')
{
@@ -4674,7 +4663,7 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config
/**
* Get avatar
*
-* @param array $row Row cleaned by \phpbb\avatar\driver\driver::clean_row
+* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
@@ -5073,7 +5062,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
// application/xhtml+xml not used because of IE
'Content-type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'private, no-cache="set-cookie"',
- 'Expires' => '0',
+ 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
'Pragma' => 'no-cache',
);
if (!empty($user->data['is_bot']))