diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/constants.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 54 | ||||
-rw-r--r-- | phpBB/includes/functions_acp.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_content.php | 66 | ||||
-rw-r--r-- | phpBB/includes/functions_messenger.php | 22 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 34 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 23 |
7 files changed, 167 insertions, 38 deletions
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index a1d85cf272..a6decaa0e8 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -28,7 +28,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.1.8-dev'); +define('PHPBB_VERSION', '3.1.9-dev'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 094b1fd364..72c0d458c6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2821,6 +2821,21 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $user->setup(); } + /** + * This event allows an extension to modify the login process + * + * @event core.login_box_before + * @var string redirect Redirect string + * @var string l_explain Explain language string + * @var string l_success Success language string + * @var bool admin Is admin? + * @var bool s_display Display full login form? + * @var string err Error string + * @since 3.1.9-RC1 + */ + $vars = array('redirect', 'l_explain', 'l_success', 'admin', 's_display', 'err'); + extract($phpbb_dispatcher->trigger_event('core.login_box_before', compact($vars))); + // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) { @@ -2833,7 +2848,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa trigger_error('NO_AUTH_ADMIN'); } - if ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external')) + if (empty($err) && ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external'))) { // Get credential if ($admin) @@ -2902,11 +2917,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa * * @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. + * @var bool admin Is admin? * @since 3.1.0-RC5 + * @changed 3.1.9-RC1 Removed undefined return variable */ - $vars = array('redirect', 'admin', 'return'); + $vars = array('redirect', 'admin'); extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars))); // append/replace SID (may change during the session for AOL users) @@ -4909,7 +4924,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) /** * Generate page header */ -function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum') +function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true) { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path; @@ -4969,6 +4984,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id = } } + $user->update_session_infos(); + // Generate logged in/logged out status if ($user->data['user_id'] != ANONYMOUS) { @@ -5247,17 +5264,22 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'SITE_LOGO_IMG' => $user->img('site_logo'), )); - // An array of http headers that phpbb will set. The following event may override these. - $http_headers = array( - // application/xhtml+xml not used because of IE - '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', - ); - if (!empty($user->data['is_bot'])) + $http_headers = array(); + + if ($send_headers) { - // Let reverse proxies know we detected a bot. - $http_headers['X-PHPBB-IS-BOT'] = 'yes'; + // An array of http headers that phpbb will set. The following event may override these. + $http_headers += array( + // application/xhtml+xml not used because of IE + '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', + ); + if (!empty($user->data['is_bot'])) + { + // Let reverse proxies know we detected a bot. + $http_headers['X-PHPBB-IS-BOT'] = 'yes'; + } } /** @@ -5395,8 +5417,6 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = return; } - $user->update_session_infos(); - phpbb_check_and_display_sql_report($request, $auth, $db); $template->assign_vars(array( diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 4193f69929..2bbf1c9e57 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -55,6 +55,8 @@ function adm_page_header($page_title) return; } + $user->update_session_infos(); + // gzip_compression if ($config['gzip_compress']) { @@ -164,8 +166,6 @@ function adm_page_footer($copyright_html = true) return; } - $user->update_session_infos(); - phpbb_check_and_display_sql_report($request, $auth, $db); $template->assign_vars(array( diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 6f861b8607..36d7dfc03c 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -47,7 +47,7 @@ if (!defined('IN_PHPBB')) */ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param, $def_st = false, $def_sk = false, $def_sd = false) { - global $user; + global $user, $phpbb_dispatcher; $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); @@ -106,6 +106,42 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, $u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : ''; } + /** + * Run code before generated sort selects are returned + * + * @event core.gen_sort_selects_after + * @var int limit_days Days limit + * @var array sort_by_text Sort by text options + * @var int sort_days Sort by days flag + * @var string sort_key Sort key + * @var string sort_dir Sort dir + * @var string s_limit_days String of days limit + * @var string s_sort_key String of sort key + * @var string s_sort_dir String of sort dir + * @var string u_sort_param Sort URL params + * @var bool def_st Default sort days + * @var bool def_sk Default sort key + * @var bool def_sd Default sort dir + * @var array sorts Sorts + * @since 3.1.9-RC1 + */ + $vars = array( + 'limit_days', + 'sort_by_text', + 'sort_days', + 'sort_key', + 'sort_dir', + 's_limit_days', + 's_sort_key', + 's_sort_dir', + 'u_sort_param', + 'def_st', + 'def_sk', + 'def_sd', + 'sorts', + ); + extract($phpbb_dispatcher->trigger_event('core.gen_sort_selects_after', compact($vars))); + return; } @@ -392,7 +428,7 @@ function phpbb_clean_search_string($search_string) */ function decode_message(&$message, $bbcode_uid = '') { - global $config; + global $config, $phpbb_dispatcher; if ($bbcode_uid) { @@ -405,12 +441,38 @@ function decode_message(&$message, $bbcode_uid = '') $replace = array("\n"); } + /** + * Use this event to modify the message before it is decoded + * + * @event core.decode_message_before + * @var string message_text The message content + * @var string bbcode_uid The message BBCode UID + * @since 3.1.9-RC1 + */ + $message_text = $message; + $vars = array('message_text', 'bbcode_uid'); + extract($phpbb_dispatcher->trigger_event('core.decode_message_before', compact($vars))); + $message = $message_text; + $message = str_replace($match, $replace, $message); $match = get_preg_expression('bbcode_htm'); $replace = array('\1', '\1', '\2', '\1', '', ''); $message = preg_replace($match, $replace, $message); + + /** + * Use this event to modify the message after it is decoded + * + * @event core.decode_message_after + * @var string message_text The message content + * @var string bbcode_uid The message BBCode UID + * @since 3.1.9-RC1 + */ + $message_text = $message; + $vars = array('message_text', 'bbcode_uid'); + extract($phpbb_dispatcher->trigger_event('core.decode_message_after', compact($vars))); + $message = $message_text; } /** diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ae393739b9..0525cfc29e 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -210,10 +210,12 @@ class messenger /** * Set email template to use */ - function template($template_file, $template_lang = '', $template_path = '') + function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '') { global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager; + $template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix; + $this->setup_template(); if (!trim($template_file)) @@ -232,7 +234,7 @@ class messenger if ($template_path) { $template_paths = array( - $template_path, + $template_path . $template_dir_prefix, ); } else @@ -241,7 +243,7 @@ class messenger $template_path .= $template_lang . '/email'; $template_paths = array( - $template_path, + $template_path . $template_dir_prefix, ); // we can only specify default language fallback when the path is not a custom one for which we @@ -251,14 +253,14 @@ class messenger $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; $fallback_template_path .= basename($config['default_lang']) . '/email'; - $template_paths[] = $fallback_template_path; + $template_paths[] = $fallback_template_path . $template_dir_prefix; } } $this->set_template_paths(array( array( 'name' => $template_lang . '_email', - 'ext_path' => 'language/' . $template_lang . '/email' + 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix, ), ), $template_paths); @@ -859,6 +861,11 @@ class queue fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); fclose($fp); + if (function_exists('opcache_invalidate')) + { + @opcache_invalidate($this->cache_file); + } + phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } } @@ -901,6 +908,11 @@ class queue fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); fclose($fp); + if (function_exists('opcache_invalidate')) + { + @opcache_invalidate($this->cache_file); + } + phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); $this->data = array(); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 75d77285a0..b2713fef07 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1129,6 +1129,32 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $db->sql_freeresult($result); } + /** + * Event to modify the posts list for topic reviews + * + * @event core.topic_review_modify_post_list + * @var array attachments Array with the post attachments data + * @var int cur_post_id Post offset ID + * @var int forum_id The topic's forum ID + * @var string mode The topic review mode + * @var array post_list Array with the post IDs + * @var array rowset Array with the posts data + * @var bool show_quote_button Flag indicating if the quote button should be displayed + * @var int topic_id The topic ID that is being reviewed + * @since 3.1.9-RC1 + */ + $vars = array( + 'attachments', + 'cur_post_id', + 'forum_id', + 'mode', + 'post_list', + 'rowset', + 'show_quote_button', + 'topic_id', + ); + extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars))); + for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) { // A non-existing rowset only happens if there was no user present for the entered poster_id @@ -1610,6 +1636,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u break; } } + else if (isset($data['post_visibility']) && $data['post_visibility'] !== false) + { + $post_visibility = $data['post_visibility']; + } // MODs/Extensions are able to force any visibility on posts if (isset($data['force_approved_state'])) @@ -2403,7 +2433,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $params = $add_anchor = ''; - if ($post_visibility == ITEM_APPROVED) + if ($post_visibility == ITEM_APPROVED || + ($auth->acl_get('m_softdelete', $data['forum_id']) && $post_visibility == ITEM_DELETED) || + ($auth->acl_get('m_approve', $data['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE)))) { $params .= '&t=' . $data['topic_id']; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3e2dbcb794..bfdd1badc3 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2831,7 +2831,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, * * @return false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER' */ -function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false) +function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $log_action = true) { global $db, $auth, $config, $phpbb_dispatcher, $phpbb_container; @@ -2966,16 +2966,19 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); extract($phpbb_dispatcher->trigger_event('core.group_delete_user_after', compact($vars))); - if (!$group_name) + if ($log_action) { - $group_name = get_group_name($group_id); - } + if (!$group_name) + { + $group_name = get_group_name($group_id); + } - $log = 'LOG_GROUP_REMOVE'; + $log = 'LOG_GROUP_REMOVE'; - if ($group_name) - { - add_log('admin', $log, $group_name, implode(', ', $username_ary)); + if ($group_name) + { + add_log('admin', $log, $group_name, implode(', ', $username_ary)); + } } group_update_listings($group_id); @@ -3619,8 +3622,8 @@ function remove_newly_registered($user_id, $user_data = false) } // We need to call group_user_del here, because this function makes sure everything is correctly changed. - // A downside for a call within the session handler is that the language is not set up yet - so no log entry - group_user_del($group_id, $user_id); + // Force function to not log the removal of users from newly registered users group + group_user_del($group_id, $user_id, false, false, false); // Set user_new to 0 to let this not be triggered again $sql = 'UPDATE ' . USERS_TABLE . ' |