diff --git a/phpBB/app.php b/phpBB/app.php
index 4873fb10c3d..3781bfe0f0e 100644
--- a/phpBB/app.php
+++ b/phpBB/app.php
@@ -11,9 +11,6 @@
*
*/
-/**
-*/
-
/**
* @ignore
*/
diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml
index 0e3a74447bf..3f42684e567 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -15,6 +15,7 @@ imports:
- { resource: services_files.yml }
- { resource: services_filesystem.yml }
- { resource: services_finder.yml }
+ - { resource: services_forum.yml }
- { resource: services_help.yml }
- { resource: services_http.yml }
- { resource: services_language.yml }
diff --git a/phpBB/config/default/container/services_content.yml b/phpBB/config/default/container/services_content.yml
index 53592a4d0c7..f1ff60c9574 100644
--- a/phpBB/config/default/container/services_content.yml
+++ b/phpBB/config/default/container/services_content.yml
@@ -32,6 +32,7 @@ services:
- '@config'
- '@config_text'
- '@dbal.conn'
+ - '@controller.helper'
- '@user'
- '@event_dispatcher'
- '%core.root_path%'
@@ -43,6 +44,7 @@ services:
- '@auth'
- '@config'
- '@dbal.conn'
+ - '@controller.helper'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
@@ -53,6 +55,7 @@ services:
- '@auth'
- '@config'
- '@dbal.conn'
+ - '@controller.helper'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
diff --git a/phpBB/config/default/container/services_forum.yml b/phpBB/config/default/container/services_forum.yml
new file mode 100644
index 00000000000..befbca270b5
--- /dev/null
+++ b/phpBB/config/default/container/services_forum.yml
@@ -0,0 +1,27 @@
+services:
+
+ phpbb.birthday.helper:
+ class: phpbb\forum\birthday_helper
+ arguments:
+ - '@auth'
+ - '@config'
+ - '@dbal.conn'
+ - '@dispatcher'
+ - '@language'
+ - '@template'
+ - '@user'
+
+ forum.controller.index:
+ class: phpbb\forum\controller\index
+ arguments:
+ - '@auth'
+ - '@phpbb.birthday.helper'
+ - '@config'
+ - '@controller.helper'
+ - '@dispatcher'
+ - '@group_helper'
+ - '@language'
+ - '@user'
+ - '@template'
+ - '%core.root_path%'
+ - '%core.php_ext%'
diff --git a/phpBB/config/default/container/services_mention.yml b/phpBB/config/default/container/services_mention.yml
index e2861b984cd..39e6c8521a4 100644
--- a/phpBB/config/default/container/services_mention.yml
+++ b/phpBB/config/default/container/services_mention.yml
@@ -5,6 +5,7 @@ services:
arguments:
- '@mention.source_collection'
- '@request'
+ - '@controller.helper'
- '%core.root_path%'
- '%core.php_ext%'
diff --git a/phpBB/config/default/container/services_ucp.yml b/phpBB/config/default/container/services_ucp.yml
index bbe5d35f2b4..dcf8c8af9fa 100644
--- a/phpBB/config/default/container/services_ucp.yml
+++ b/phpBB/config/default/container/services_ucp.yml
@@ -4,6 +4,7 @@ services:
arguments:
- '@config'
- '@dispatcher'
+ - '@controller.helper'
- '@language'
- '@request'
- '@user'
diff --git a/phpBB/config/default/routing/routing.yml b/phpBB/config/default/routing/routing.yml
index 2e2638741c3..371cd23a251 100644
--- a/phpBB/config/default/routing/routing.yml
+++ b/phpBB/config/default/routing/routing.yml
@@ -8,6 +8,10 @@
# instantiate the 'foo_service' service and call the 'method' method.
#
+phpbb_index_controller:
+ path: /
+ defaults: { _controller: forum.controller.index:handle }
+
phpbb_cron_routing:
resource: cron.yml
prefix: /cron
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index f89644dce88..373e725e157 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3851,7 +3851,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"),
'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? $controller_helper->route('phpbb_members_online') : '',
'U_LOGIN_LOGOUT' => $u_login_logout,
- 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
+ 'U_INDEX' => $controller_helper->route('phpbb_index_controller'),
'U_SEARCH' => append_sid("{$phpbb_root_path}search.$phpEx"),
'U_SITE_HOME' => $config['site_home_url'],
'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php
index 5351e7c5182..9b478b120ad 100644
--- a/phpBB/includes/ucp/ucp_activate.php
+++ b/phpBB/includes/ucp/ucp_activate.php
@@ -32,6 +32,9 @@ function main($id, $mode)
global $config, $phpbb_root_path, $phpEx, $request;
global $db, $user, $auth, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$user_id = $request->variable('u', 0);
$key = $request->variable('k', '');
@@ -49,7 +52,7 @@ function main($id, $mode)
if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
{
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ meta_refresh(3, $controller_helper->route('phpbb_index_controller'));
trigger_error('ALREADY_ACTIVATED');
}
@@ -171,7 +174,7 @@ function main($id, $mode)
$vars = array('user_row', 'message');
extract($phpbb_dispatcher->trigger_event('core.ucp_activate_after', compact($vars)));
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ meta_refresh(3, $controller_helper->route('phpbb_index_controller'));
trigger_error($user->lang[$message]);
}
}
diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php
index b31457aa8cd..f5e90a0e309 100644
--- a/phpBB/includes/ucp/ucp_login_link.php
+++ b/phpBB/includes/ucp/ucp_login_link.php
@@ -257,8 +257,10 @@ protected function process_login_result($result)
*/
protected function perform_redirect()
{
- global $phpbb_root_path, $phpEx;
- $url = append_sid($phpbb_root_path . 'index.' . $phpEx);
+ global $phpbb_container;
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+ $url = $controller_helper->route('phpbb_index_controller');
redirect($url);
}
}
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index a8caee71214..7802ade5d0a 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -36,6 +36,9 @@ function main($id, $mode)
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher, $language;
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$user->add_lang('posting');
$submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
@@ -233,8 +236,9 @@ function main($id, $mode)
// Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
if (!empty($sql_ary['user_actkey']))
{
- meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
- $message = $user->lang[$message] . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
+ $index_route = $controller_helper->route('phpbb_index_controller');
+ meta_refresh(5, $index_route);
+ $message = $language->lang($message) . '
' . sprintf($language->lang('RETURN_INDEX'), '', '');
// Because the user gets deactivated we log him out too, killing his session
$user->session_kill();
@@ -242,7 +246,7 @@ function main($id, $mode)
else
{
meta_refresh(3, $this->u_action);
- $message = $user->lang[$message] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
+ $message = $language->lang($message) . '
' . sprintf($language->lang('RETURN_UCP'), '', '');
}
trigger_error($message);
@@ -389,7 +393,7 @@ function main($id, $mode)
$cp->update_profile_field_data($user->data['user_id'], $cp_data);
meta_refresh(3, $this->u_action);
- $message = $user->lang['PROFILE_UPDATED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
+ $message = $language->lang('PROFILE_UPDATED') . '
' . sprintf($language->lang('RETURN_UCP'), '', '');
trigger_error($message);
}
@@ -563,7 +567,7 @@ function main($id, $mode)
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
- $message = $user->lang['PROFILE_UPDATED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
+ $message = $language->lang('PROFILE_UPDATED') . '
' . sprintf($language->lang('RETURN_UCP'), '', '');
trigger_error($message);
}
}
@@ -589,9 +593,9 @@ function main($id, $mode)
'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''),
- 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
- 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
- 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
+ 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $language->lang('SMILIES_ARE_ON') : $language->lang('SMILIES_ARE_OFF'),
+ 'IMG_STATUS' => ($config['allow_sig_img']) ? $language->lang('IMAGES_ARE_ON') : $language->lang('IMAGES_ARE_OFF'),
+ 'URL_STATUS' => ($config['allow_sig_links']) ? $language->lang('URL_IS_ON') : $language->lang('URL_IS_OFF'),
'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'],
'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']),
@@ -722,7 +726,7 @@ function main($id, $mode)
$phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_');
meta_refresh(3, $this->u_action);
- $message = $user->lang['PROFILE_UPDATED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
+ $message = $language->lang('PROFILE_UPDATED') . '
' . sprintf($language->lang('RETURN_UCP'), '', '');
trigger_error($message);
}
}
@@ -812,7 +816,7 @@ function main($id, $mode)
$db->sql_query($sql);
meta_refresh(3, $this->u_action);
- $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
+ $message = $language->lang('AUTOLOGIN_SESSION_KEYS_DELETED') . '
' . sprintf($language->lang('RETURN_UCP'), '', '');
trigger_error($message);
}
}
@@ -872,7 +876,7 @@ function main($id, $mode)
$template->assign_vars(array(
'ERROR' => (count($error)) ? implode('
', $error) : '',
- 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
+ 'L_TITLE' => $language->lang('UCP_PROFILE_' . strtoupper($mode)),
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => $this->u_action)
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index e5319f1dbbc..1dbec8e3f67 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -32,6 +32,9 @@ function main($id, $mode)
global $config, $db, $user, $template, $phpbb_root_path, $phpEx;
global $request, $phpbb_container, $phpbb_dispatcher;
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
//
if ($config['require_activation'] == USER_ACTIVATION_DISABLE ||
(in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable']))
@@ -558,7 +561,7 @@ function main($id, $mode)
);
extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars)));
- $message = $message . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
+ $message = $message . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
trigger_error($message);
}
}
diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php
index c2debbbe27b..699e67b22af 100644
--- a/phpBB/includes/ucp/ucp_resend.php
+++ b/phpBB/includes/ucp/ucp_resend.php
@@ -32,6 +32,9 @@ function main($id, $mode)
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template, $request, $phpbb_container;
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$username = $request->variable('username', '', true);
$email = strtolower($request->variable('email', ''));
$submit = (isset($_POST['submit'])) ? true : false;
@@ -157,10 +160,10 @@ function main($id, $mode)
$this->update_activation_expiration();
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ meta_refresh(3, $controller_helper->route('phpbb_index_controller'));
$message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
- $message .= '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
+ $message .= '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
trigger_error($message);
}
diff --git a/phpBB/index.php b/phpBB/index.php
index e64a5614e05..3781bfe0f0e 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -18,136 +18,17 @@
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
-include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
-$user->setup('viewforum');
+$user->setup('app');
-display_forums('', $config['load_moderators']);
+/* @var $http_kernel \Symfony\Component\HttpKernel\HttpKernel */
+$http_kernel = $phpbb_container->get('http_kernel');
-/** @var \phpbb\group\helper $group_helper */
-$group_helper = $phpbb_container->get('group_helper');
-
-// This is shown only if display_online_list is true
-$group_helper->display_legend();
-
-// Generate birthday list if required ...
-$show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'));
-
-$birthdays = $birthday_list = array();
-if ($show_birthdays)
-{
- $time = $user->create_datetime();
- $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
-
- // Display birthdays of 29th february on 28th february in non-leap-years
- $leap_year_birthdays = '';
- if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
- {
- $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
- }
-
- $sql_ary = array(
- 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday',
- 'FROM' => array(
- USERS_TABLE => 'u',
- ),
- 'LEFT_JOIN' => array(
- array(
- 'FROM' => array(BANS_TABLE => 'b'),
- 'ON' => 'u.user_id = b.ban_userid',
- ),
- ),
- 'WHERE' => 'b.ban_id IS NULL
- AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ")
- AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)",
- );
-
- /**
- * Event to modify the SQL query to get birthdays data
- *
- * @event core.index_modify_birthdays_sql
- * @var array now The assoc array with the 'now' local timestamp data
- * @var array sql_ary The SQL array to get the birthdays data
- * @var object time The user related Datetime object
- * @since 3.1.7-RC1
- */
- $vars = array('now', 'sql_ary', 'time');
- extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_sql', compact($vars)));
-
- $sql = $db->sql_build_query('SELECT', $sql_ary);
- $result = $db->sql_query($sql);
- $rows = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
-
- foreach ($rows as $row)
- {
- $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
- $birthday_year = (int) substr($row['user_birthday'], -4);
- $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : '';
-
- $birthdays[] = array(
- 'USERNAME' => $birthday_username,
- 'AGE' => $birthday_age,
- );
-
- // For 3.0 compatibility
- $birthday_list[] = $birthday_username . (($birthday_age) ? " ({$birthday_age})" : '');
- }
-
- /**
- * Event to modify the birthdays list
- *
- * @event core.index_modify_birthdays_list
- * @var array birthdays Array with the users birthdays data
- * @var array rows Array with the birthdays SQL query result
- * @since 3.1.7-RC1
- */
- $vars = array('birthdays', 'rows');
- extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_list', compact($vars)));
-
- $template->assign_block_vars_array('birthdays', $birthdays);
-}
-
-$controller_helper = $phpbb_container->get('controller.helper');
-// Assign index specific vars
-$template->assign_vars(array(
- 'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']),
- 'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']),
- 'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']),
- 'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
-
- 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),
-
- 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
- 'U_SEND_PASSWORD' => ($config['email_enable'] && $config['allow_password_reset']) ? $controller_helper->route('phpbb_ucp_forgot_password_controller') : '',
- 'S_DISPLAY_BIRTHDAY_LIST' => $show_birthdays,
- 'S_INDEX' => true,
-
- 'U_CANONICAL' => generate_board_url() . '/',
- 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
- 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front') : '')
-);
-
-$page_title = ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['INDEX'];
-
-/**
-* You can use this event to modify the page title and load data for the index
-*
-* @event core.index_modify_page_title
-* @var string page_title Title of the index page
-* @since 3.1.0-a1
-*/
-$vars = array('page_title');
-extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars)));
-
-// Output page
-page_header($page_title, true);
-
-$template->set_filenames(array(
- 'body' => 'index_body.html')
-);
-
-page_footer();
+/* @var $symfony_request \phpbb\symfony_request */
+$symfony_request = $phpbb_container->get('symfony_request');
+$response = $http_kernel->handle($symfony_request);
+$response->send();
+$http_kernel->terminate($symfony_request, $response);
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index 582c8ed10bf..f42a79451ae 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -43,7 +43,9 @@
{
if ($user->data['is_bot'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+ redirect($controller_helper->route('phpbb_index_controller'));
}
login_box('', $user->lang['LOGIN_EXPLAIN_MCP']);
diff --git a/phpBB/phpbb/forum/birthday_helper.php b/phpBB/phpbb/forum/birthday_helper.php
new file mode 100644
index 00000000000..4c93f387bc1
--- /dev/null
+++ b/phpBB/phpbb/forum/birthday_helper.php
@@ -0,0 +1,156 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\forum;
+
+use phpbb\auth\auth;
+use phpbb\config\config;
+use phpbb\db\driver\driver_interface;
+use phpbb\event\dispatcher;
+use phpbb\language\language;
+use phpbb\template\template;
+use phpbb\user;
+
+class birthday_helper
+{
+ /** @var auth */
+ protected $auth;
+
+ /** @var config */
+ protected $config;
+
+ /** @var driver_interface */
+ protected $db;
+
+ /** @var dispatcher */
+ protected $dispatcher;
+
+ /** @var language */
+ protected $language;
+
+ /** @var template */
+ protected $template;
+
+ /** @var user */
+ protected $user;
+
+ /**
+ * Constructor
+ *
+ * @param auth $auth
+ * @param config $config
+ * @param driver_interface $db
+ * @param dispatcher $dispatcher
+ * @param language $language
+ * @param template $template
+ * @param user $user
+ */
+ public function __construct(auth $auth, config $config, driver_interface $db, dispatcher $dispatcher, language $language, template $template, user $user)
+ {
+ $this->auth = $auth;
+ $this->config = $config;
+ $this->db = $db;
+ $this->dispatcher = $dispatcher;
+ $this->language = $language;
+ $this->template = $template;
+ $this->user = $user;
+ }
+
+ /**
+ * Display birthdays in index page
+ *
+ * @return void
+ *
+ * @psalm-suppress InvalidArgument
+ */
+ public function display_birthdays(): void
+ {
+ $show_birthdays = ($this->config['load_birthdays'] && $this->config['allow_birthdays'] && $this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'));
+
+ $birthdays = array();
+ if ($show_birthdays)
+ {
+ $time = $this->user->create_datetime();
+ $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
+
+ // Display birthdays of 29th february on 28th february in non-leap-years
+ $leap_year_birthdays = '';
+ if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
+ {
+ $leap_year_birthdays = " OR u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
+ }
+
+ $sql_ary = array(
+ 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday',
+ 'FROM' => array(
+ USERS_TABLE => 'u',
+ ),
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(BANS_TABLE => 'b'),
+ 'ON' => 'u.user_id = b.ban_userid',
+ ),
+ ),
+ 'WHERE' => 'b.ban_id IS NULL
+ AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ")
+ AND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)",
+ );
+
+ /**
+ * Event to modify the SQL query to get birthdays data
+ *
+ * @event core.index_modify_birthdays_sql
+ * @var array now The assoc array with the 'now' local timestamp data
+ * @var array sql_ary The SQL array to get the birthdays data
+ * @var object time The user related Datetime object
+ * @since 3.1.7-RC1
+ */
+ $vars = array('now', 'sql_ary', 'time');
+ extract($this->dispatcher->trigger_event('core.index_modify_birthdays_sql', compact($vars)));
+
+ $sql = $this->db->sql_build_query('SELECT', $sql_ary);
+ $result = $this->db->sql_query($sql);
+ $rows = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ foreach ($rows as $row)
+ {
+ $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
+ $birthday_year = (int) substr($row['user_birthday'], -4);
+ $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : '';
+
+ $birthdays[] = array(
+ 'USERNAME' => $birthday_username,
+ 'AGE' => $birthday_age,
+ );
+ }
+
+ /**
+ * Event to modify the birthdays list
+ *
+ * @event core.index_modify_birthdays_list
+ * @var array birthdays Array with the users birthdays data
+ * @var array rows Array with the birthdays SQL query result
+ * @since 3.1.7-RC1
+ */
+ $vars = array('birthdays', 'rows');
+ extract($this->dispatcher->trigger_event('core.index_modify_birthdays_list', compact($vars)));
+
+ $this->template->assign_block_vars_array('birthdays', $birthdays);
+ }
+
+ $this->template->assign_vars([
+ 'S_DISPLAY_BIRTHDAY_LIST' => $show_birthdays,
+ ]);
+ }
+}
diff --git a/phpBB/phpbb/forum/controller/index.php b/phpBB/phpbb/forum/controller/index.php
new file mode 100644
index 00000000000..a074c609fb6
--- /dev/null
+++ b/phpBB/phpbb/forum/controller/index.php
@@ -0,0 +1,147 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\forum\controller;
+
+use phpbb\auth\auth;
+use phpbb\config\config;
+use phpbb\controller\helper as controller_helper;
+use phpbb\event\dispatcher;
+use phpbb\forum\birthday_helper;
+use phpbb\group\helper as group_helper;
+use phpbb\language\language;
+use phpbb\template\template;
+use phpbb\user;
+use Symfony\Component\HttpFoundation\Response;
+
+class index
+{
+ /** @var auth */
+ protected $auth;
+
+ /** @var birthday_helper */
+ protected $birthday_helper;
+
+ /** @var config */
+ protected $config;
+
+ /** @var controller_helper */
+ protected $controller_helper;
+
+ /** @var dispatcher */
+ protected $dispatcher;
+
+ /** @var group_helper */
+ protected $group_helper;
+
+ /** @var language */
+ protected $language;
+
+ /** @var user */
+ protected $user;
+
+ /** @var template */
+ protected $template;
+
+ /** @var string */
+ protected $phpbb_root_path;
+
+ /** @var string */
+ protected $phpEx;
+
+ /**
+ * Constructor
+ *
+ * @param auth $auth
+ * @param birthday_helper $birthday_helper
+ * @param config $config
+ * @param controller_helper $controller_helper
+ * @param dispatcher $dispatcher
+ * @param group_helper $group_helper
+ * @param language $language
+ * @param user $user
+ * @param template $template
+ * @param string $phpbb_root_path
+ * @param string $phpEx
+ */
+ public function __construct(auth $auth, birthday_helper $birthday_helper, config $config, controller_helper $controller_helper, dispatcher $dispatcher, group_helper $group_helper, language $language, user $user, template $template, string $phpbb_root_path, string $phpEx)
+ {
+ $this->auth = $auth;
+ $this->birthday_helper = $birthday_helper;
+ $this->config = $config;
+ $this->controller_helper = $controller_helper;
+ $this->dispatcher = $dispatcher;
+ $this->group_helper = $group_helper;
+ $this->language = $language;
+ $this->user = $user;
+ $this->template = $template;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->phpEx = $phpEx;
+ }
+
+ /**
+ * Display the index page
+ *
+ * @return Response
+ */
+ public function handle(): Response
+ {
+ if (!function_exists('display_forums'))
+ {
+ include($this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx);
+ }
+
+ if (!function_exists('get_username_string'))
+ {
+ include($this->phpbb_root_path . 'includes/functions_content.' . $this->phpEx);
+ }
+
+ $this->language->add_lang('viewforum');
+
+ display_forums('', $this->config['load_moderators']);
+
+ // This is shown only if display_online_list is true
+ $this->group_helper->display_legend();
+
+ $this->birthday_helper->display_birthdays();
+
+ $this->template->assign_vars(array(
+ 'TOTAL_POSTS' => $this->language->lang('TOTAL_POSTS_COUNT', (int) $this->config['num_posts']),
+ 'TOTAL_TOPICS' => $this->language->lang('TOTAL_TOPICS', (int) $this->config['num_topics']),
+ 'TOTAL_USERS' => $this->language->lang('TOTAL_USERS', (int) $this->config['num_users']),
+ 'NEWEST_USER' => $this->language->lang('NEWEST_USER', get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour'])),
+
+ 'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.$this->phpEx", 'mode=login'),
+ 'U_SEND_PASSWORD' => ($this->config['email_enable'] && $this->config['allow_password_reset']) ? $this->controller_helper->route('phpbb_ucp_forgot_password_controller') : '',
+ 'S_INDEX' => true,
+
+ 'U_CANONICAL' => generate_board_url() . '/',
+ 'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? $this->controller_helper->route('phpbb_index_controller', ['hash' => generate_link_hash('global'), 'mark' => 'forums', 'mark_time' => time()]) : '',
+ 'U_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.$this->phpEx", 'i=main&mode=front') : '')
+ );
+
+ $page_title = ($this->config['board_index_text'] !== '') ? $this->config['board_index_text'] : $this->language->lang('INDEX');
+
+ /**
+ * You can use this event to modify the page title and load data for the index
+ *
+ * @event core.index_modify_page_title
+ * @var string page_title Title of the index page
+ * @since 3.1.0-a1
+ */
+ $vars = array('page_title');
+ extract($this->dispatcher->trigger_event('core.index_modify_page_title', compact($vars)));
+
+ return $this->controller_helper->render('index_body.html', $page_title, 200, true);
+ }
+}
diff --git a/phpBB/phpbb/members/viewonline_helper.php b/phpBB/phpbb/members/viewonline_helper.php
index a8c9dac627b..8ead6c0e42d 100644
--- a/phpBB/phpbb/members/viewonline_helper.php
+++ b/phpBB/phpbb/members/viewonline_helper.php
@@ -184,6 +184,11 @@ public function get_location(string $session_page, int $forum_id): array
switch ($match['_route'])
{
+ case 'phpbb_index_controller':
+ $location = $this->language->lang('INDEX');
+ $location_url = $this->helper->route('phpbb_index_controller');
+ break;
+
case 'phpbb_help_bbcode_controller':
case 'phpbb_help_faq_controller':
$location = $this->language->lang('VIEWING_FAQ');
@@ -219,11 +224,6 @@ public function get_location(string $session_page, int $forum_id): array
switch ($on_page[1])
{
- case 'index':
- $location = $this->language->lang('INDEX');
- $location_url = append_sid($this->phpbb_root_path . "index." . $this->php_ex);
- break;
-
case $this->phpbb_adm_relative_path . 'index':
$location = $this->language->lang('ACP');
$location_url = append_sid($this->phpbb_root_path . "index." . $this->php_ex);
diff --git a/phpBB/phpbb/mention/controller/mention.php b/phpBB/phpbb/mention/controller/mention.php
index 37a5cfd3238..f7f9951327d 100644
--- a/phpBB/phpbb/mention/controller/mention.php
+++ b/phpBB/phpbb/mention/controller/mention.php
@@ -13,6 +13,7 @@
namespace phpbb\mention\controller;
+use phpbb\controller\helper;
use phpbb\di\service_collection;
use phpbb\request\request_interface;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -26,6 +27,9 @@ class mention
/** @var request_interface */
protected $request;
+ /** @var helper */
+ protected $helper;
+
/** @var string */
protected $phpbb_root_path;
@@ -37,13 +41,15 @@ class mention
*
* @param service_collection|array $mention_sources
* @param request_interface $request
+ * @param helper $helper
* @param string $phpbb_root_path
* @param string $phpEx
*/
- public function __construct($mention_sources, request_interface $request, string $phpbb_root_path, string $phpEx)
+ public function __construct($mention_sources, request_interface $request, helper $helper, string $phpbb_root_path, string $phpEx)
{
$this->mention_sources = $mention_sources;
$this->request = $request;
+ $this->helper = $helper;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
}
@@ -57,7 +63,7 @@ public function handle()
{
if (!$this->request->is_ajax())
{
- return new RedirectResponse(append_sid($this->phpbb_root_path . 'index.' . $this->php_ext));
+ return new RedirectResponse($this->helper->route('phpbb_index_controller'));
}
$keyword = $this->request->variable('keyword', '', true);
diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php
index 30c863bb7ff..dde80bea752 100644
--- a/phpBB/phpbb/message/admin_form.php
+++ b/phpBB/phpbb/message/admin_form.php
@@ -39,14 +39,15 @@ class admin_form extends form
* @param \phpbb\config\config $config
* @param \phpbb\config\db_text $config_text
* @param \phpbb\db\driver\driver_interface $db
+ * @param \phpbb\controller\helper $controller_helper
* @param \phpbb\user $user
* @param \phpbb\event\dispatcher_interface $dispatcher
* @param string $phpbb_root_path
* @param string $phpEx
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $controller_helper, \phpbb\user $user, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx)
{
- parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx);
+ parent::__construct($auth, $config, $db, $controller_helper, $user, $phpbb_root_path, $phpEx);
$this->config_text = $config_text;
$this->dispatcher = $dispatcher;
}
diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php
index 479d6872121..5e942473cc2 100644
--- a/phpBB/phpbb/message/form.php
+++ b/phpBB/phpbb/message/form.php
@@ -22,6 +22,8 @@ abstract class form
protected $auth;
/** @var \phpbb\config\config */
protected $config;
+ /** @var \phpbb\controller\helper */
+ protected $controller_helper;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\message\message */
@@ -47,17 +49,19 @@ abstract class form
* @param \phpbb\auth\auth $auth
* @param \phpbb\config\config $config
* @param \phpbb\db\driver\driver_interface $db
+ * @param \phpbb\controller\helper $controller_helper
* @param \phpbb\user $user
* @param string $phpbb_root_path
* @param string $phpEx
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $controller_helper, \phpbb\user $user, $phpbb_root_path, $phpEx)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
$this->user = $user;
$this->auth = $auth;
$this->config = $config;
+ $this->controller_helper = $controller_helper;
$this->db = $db;
$this->message = new message($config['server_name']);
@@ -111,7 +115,7 @@ public function check_allow()
*/
public function get_return_message()
{
- return sprintf($this->user->lang['RETURN_INDEX'], '', '');
+ return sprintf($this->user->lang['RETURN_INDEX'], '', '');
}
/**
@@ -153,7 +157,7 @@ public function submit(\phpbb\di\service_collection $messenger)
$this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx));
- meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx));
+ meta_refresh(3, $this->controller_helper->route('phpbb_index_controller'));
trigger_error($this->user->lang['EMAIL_SENT'] . '
' . $this->get_return_message());
}
}
diff --git a/phpBB/phpbb/ucp/controller/delete_cookies.php b/phpBB/phpbb/ucp/controller/delete_cookies.php
index 869227abea0..3ab0b3ee3dc 100644
--- a/phpBB/phpbb/ucp/controller/delete_cookies.php
+++ b/phpBB/phpbb/ucp/controller/delete_cookies.php
@@ -14,6 +14,7 @@
namespace phpbb\ucp\controller;
use phpbb\config\config;
+use phpbb\controller\helper;
use phpbb\event\dispatcher_interface;
use phpbb\language\language;
use phpbb\request\request_interface;
@@ -27,6 +28,9 @@ class delete_cookies
/** @var dispatcher_interface */
private $dispatcher;
+ /** @var helper */
+ private $helper;
+
/** @var language */
private $language;
@@ -47,14 +51,18 @@ class delete_cookies
*
* @param config $config
* @param dispatcher_interface $dispatcher
+ * @param helper $helper
* @param language $language
* @param request_interface $request
* @param user $user
+ * @param string $phpbb_root_path
+ * @param string $php_ext
*/
- public function __construct(config $config, dispatcher_interface $dispatcher, language $language, request_interface $request, user $user, string $phpbb_root_path, string $php_ext)
+ public function __construct(config $config, dispatcher_interface $dispatcher, helper $helper, language $language, request_interface $request, user $user, string $phpbb_root_path, string $php_ext)
{
$this->config = $config;
$this->dispatcher = $dispatcher;
+ $this->helper = $helper;
$this->language = $language;
$this->request = $request;
$this->user = $user;
@@ -119,9 +127,9 @@ public function handle()
$this->user->session_kill();
$this->user->session_begin();
- meta_refresh(3, append_sid("{$this->phpbb_root_path}index.$this->php_ext"));
+ meta_refresh(3, $this->helper->route('phpbb_index_controller'));
- $message = $this->language->lang('COOKIES_DELETED') . '
' . $this->language->lang('RETURN_INDEX', 'phpbb_root_path}index.$this->php_ext") . '">', '');
+ $message = $this->language->lang('COOKIES_DELETED') . '
' . $this->language->lang('RETURN_INDEX', '', '');
trigger_error($message);
}
else
@@ -129,6 +137,6 @@ public function handle()
confirm_box(false, 'DELETE_COOKIES', '');
}
- redirect(append_sid("{$this->phpbb_root_path}index.$this->php_ext"));
+ redirect($this->helper->route('phpbb_index_controller'));
}
}
diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php
index 790e00138c1..5d8feb8f787 100644
--- a/phpBB/phpbb/ucp/controller/reset_password.php
+++ b/phpBB/phpbb/ucp/controller/reset_password.php
@@ -214,7 +214,7 @@ public function request()
}
else
{
- $message = $this->language->lang('PASSWORD_RESET_LINK_SENT') . '
' . $this->language->lang('RETURN_INDEX', 'root_path}index.{$this->php_ext}") . '">', '');
+ $message = $this->language->lang('PASSWORD_RESET_LINK_SENT') . '
' . $this->language->lang('RETURN_INDEX', '', '');
if (empty($rowset))
{
@@ -335,7 +335,7 @@ public function reset()
$user_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $message = $this->language->lang('RESET_TOKEN_EXPIRED_OR_INVALID') . '
' . $this->language->lang('RETURN_INDEX', 'root_path}index.{$this->php_ext}") . '">', '');
+ $message = $this->language->lang('RESET_TOKEN_EXPIRED_OR_INVALID') . '
' . $this->language->lang('RETURN_INDEX', '', '');
if (empty($user_row))
{
@@ -416,7 +416,7 @@ public function reset()
'reportee_id' => $user_row['user_id'],
$user_row['username']
]);
- meta_refresh(3, append_sid("{$this->root_path}index.{$this->php_ext}"));
+ meta_refresh(3, $this->helper->route('phpbb_index_controller'));
return $this->helper->message($this->language->lang('PASSWORD_RESET'));
}
}
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 9f8cce0ead1..f5d134e06f6 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -41,6 +41,9 @@
$submit = $request->is_set_post('post') && !$refresh && !$preview;
$mode = $request->variable('mode', '');
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
+
// Only assign required URL parameters
$forum_id = 0;
$topic_id = 0;
@@ -178,7 +181,7 @@
// Was cancel pressed? If so then redirect to the appropriate page
if ($cancel)
{
- $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx")));
+ $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : $controller_helper->route('phpbb_index_controller')));
redirect($redirect);
}
@@ -306,7 +309,7 @@
// Check permissions
if ($user->data['is_bot'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
// Is the user able to read within this forum?
@@ -1916,8 +1919,6 @@
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"';
add_form_key('posting');
-/** @var \phpbb\controller\helper $controller_helper */
-$controller_helper = $phpbb_container->get('controller.helper');
// Build array of variables for main posting page
$page_data = array(
diff --git a/phpBB/search.php b/phpBB/search.php
index c6379d28559..92d431c9362 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -19,6 +19,9 @@
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
+
// Start session management
$user->session_begin();
$auth->acl($user->data);
@@ -483,7 +486,7 @@
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);
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
- $template->assign_var('U_MARK_ALL_READ', ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '');
+ $template->assign_var('U_MARK_ALL_READ', ($user->data['is_registered'] || $config['load_anon_lastread']) ? $controller_helper->route('phpbb_index_controller', ['hash' => generate_link_hash('global'), 'mark' => 'forums', 'mark_time' => time()]) : '');
break;
case 'newposts':
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 45593ffb4e5..d549674df9b 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -47,6 +47,9 @@
$module = new p_master();
$default = false;
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
+
// Basic "global" modes
switch ($mode)
{
@@ -54,7 +57,7 @@
$module->load('ucp', 'activate');
$module->display($user->lang['UCP_ACTIVATE']);
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
break;
case 'resend_act':
@@ -63,16 +66,13 @@
break;
case 'sendpassword':
- /** @var \phpbb\controller\helper $controller_helper */
- $controller_helper = $phpbb_container->get('controller.helper');
-
redirect($controller_helper->route('phpbb_ucp_forgot_password_controller'));
break;
case 'register':
if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
$module->load('ucp', 'register');
@@ -86,7 +86,7 @@
case 'login':
if ($user->data['is_registered'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
login_box($request->variable('redirect', "index.$phpEx"));
@@ -95,7 +95,7 @@
case 'login_link':
if ($user->data['is_registered'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
$module->load('ucp', 'login_link');
@@ -109,13 +109,13 @@
}
else if ($user->data['user_id'] != ANONYMOUS)
{
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ meta_refresh(3, $controller_helper->route('phpbb_index_controller'));
- $message = $user->lang['LOGOUT_FAILED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', ' ');
+ $message = $user->lang['LOGOUT_FAILED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', ' ');
trigger_error($message);
}
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
break;
case 'terms':
@@ -128,7 +128,7 @@
{
if ($user->data['is_registered'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
login_box();
@@ -154,15 +154,11 @@
break;
case 'delete_cookies':
- /** @var \phpbb\controller\helper $controller_helper */
- $controller_helper = $phpbb_container->get('controller.helper');
-
// Redirect to controller
redirect($controller_helper->route('phpbb_ucp_delete_cookies_controller'));
break;
case 'switch_perm':
-
$user_id = $request->variable('u', 0);
$sql = 'SELECT *
@@ -174,7 +170,7 @@
if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'] || !check_link_hash($request->variable('hash', ''), 'switchperm'))
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
include($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
@@ -182,12 +178,12 @@
$auth_admin = new auth_admin();
if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id']))
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_TRANSFER_PERMISSIONS', false, array($user_row['username']));
- $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
+ $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
/**
* Event to run code after permissions are switched
@@ -206,10 +202,9 @@
break;
case 'restore_perm':
-
if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm'))
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
$auth->acl_cache($user->data);
@@ -223,7 +218,7 @@
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_RESTORE_PERMISSIONS', false, array($username));
- $message = $user->lang['PERMISSIONS_RESTORED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
+ $message = $user->lang['PERMISSIONS_RESTORED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
/**
* Event to run code after permissions are restored
@@ -256,7 +251,7 @@
{
if ($user->data['is_bot'])
{
- redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
+ redirect($controller_helper->route('phpbb_index_controller'));
}
if ($id == 'pm' && $mode == 'view' && isset($_GET['p']))
diff --git a/tests/console/user/base.php b/tests/console/user/base.php
index 06e80200b52..3e26d5ad5a7 100644
--- a/tests/console/user/base.php
+++ b/tests/console/user/base.php
@@ -64,10 +64,7 @@ protected function setUp(): void
->method('lang')
->will($this->returnArgument(0));
- $user = $this->user = $this->createMock('\phpbb\user', array(), array(
- $this->language,
- '\phpbb\datetime'
- ));
+ $user = $this->user = $this->createMock('\phpbb\user');
$user->data['user_email'] = '';
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php
index 099a38c3292..b4de2f2beec 100644
--- a/tests/functional/acp_attachments_test.php
+++ b/tests/functional/acp_attachments_test.php
@@ -46,7 +46,7 @@ protected function tearDown(): void
private function upload_file($filename, $mimetype)
{
- $crawler = self::$client->request(
+ $crawler = self::request(
'GET',
'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid
);
diff --git a/tests/mention/controller_test.php b/tests/mention/controller_test.php
index 1cb2c2f789f..468a81bcf69 100644
--- a/tests/mention/controller_test.php
+++ b/tests/mention/controller_test.php
@@ -76,10 +76,7 @@ public function setUp(): void
$lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
// User
- $user = $this->createMock('\phpbb\user', array(), array(
- $lang,
- '\phpbb\datetime'
- ));
+ $user = $this->createMock('\phpbb\user');
$user->ip = '';
$user->data = array(
'user_id' => 2,
@@ -100,6 +97,9 @@ public function setUp(): void
$user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
+ // Controller helper
+ $controller_helper = $this->createMock('\phpbb\controller\helper');
+
// Container
$phpbb_container = new ContainerBuilder();
@@ -114,6 +114,7 @@ public function setUp(): void
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('cache', $cache);
$phpbb_container->set('request', $request);
+ $phpbb_container->set('controller.helper', $controller_helper);
$phpbb_container->set('group_helper', new \phpbb\group\helper(
$this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock(),
$avatar_helper,
@@ -160,7 +161,7 @@ public function setUp(): void
$mention_sources_array['mention.source.' . $source] = $class;
}
- $this->controller = new \phpbb\mention\controller\mention($mention_sources_array, $request, $phpbb_root_path, $phpEx);
+ $this->controller = new \phpbb\mention\controller\mention($mention_sources_array, $request, $controller_helper, $phpbb_root_path, $phpEx);
}
public static function handle_data()
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 0651ec321ee..6ed579ad2c0 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -968,10 +968,7 @@ protected function remove_user_group($group_name, $usernames)
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->createMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
- '\phpbb\datetime'
- ));
+ $user = $this->createMock('\phpbb\user');
$user->data['user_id'] = 2; // admin
$user->ip = '';
@@ -1009,10 +1006,7 @@ protected function add_user_group($group_name, $usernames, $default = false, $le
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->createMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
- '\phpbb\datetime'
- ));
+ $user = $this->createMock('\phpbb\user');
$user->data['user_id'] = 2; // admin
$user->ip = '';
diff --git a/tests/text_formatter/s9e/mention_helper_test.php b/tests/text_formatter/s9e/mention_helper_test.php
index 356dbb59160..bebfd2c4aa9 100644
--- a/tests/text_formatter/s9e/mention_helper_test.php
+++ b/tests/text_formatter/s9e/mention_helper_test.php
@@ -52,10 +52,7 @@ public function setUp(): void
$lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
// User
- $user = $this->createMock('\phpbb\user', array(), array(
- $lang,
- '\phpbb\datetime'
- ));
+ $user = $this->createMock('\phpbb\user');
$user->ip = '';
$user->data = array(
'user_id' => 2,
diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php
index 01a9c96edc3..d383f9b2f2b 100644
--- a/tests/viewonline/helper_test.php
+++ b/tests/viewonline/helper_test.php
@@ -111,6 +111,12 @@ public static function get_location_data()
{
return array(
// Route-based pages - routes have prefixes as defined in routing.yml
+ // index
+ array('', 0, true, 'Index page', './'),
+ array('/', 0, true, 'Index page', './'),
+ array('/app.php/', 0, true, 'Index page', './'),
+ array('index.php', 0, true, 'Index page', './index.php'),
+ array('./index.php', 0, true, 'Index page', './index.php'),
// help.yml routes have prefix /help
array('/help/bbcode', 0, true, 'Viewing FAQ', './help/faq'),
array('/help/faq', 0, true, 'Viewing FAQ', './help/faq'),
@@ -122,10 +128,6 @@ public static function get_location_data()
array('/pm/5/report', 0, true, 'Reporting post', './index.php'),
array('/post/10/report', 0, true, 'Reporting post', './index.php'),
- // Legacy pages - index
- array('index.php', 0, true, 'Index page', './index.php'),
- array('./index.php', 0, true, 'Index page', './index.php'),
-
// Legacy pages - admin
array('adm/index.php', 0, true, 'Administration Control Panel', './index.php'),
@@ -162,9 +164,6 @@ public static function get_location_data()
// Unknown route
array('/unknown/route', 0, true, 'Index page', './index.php'),
-
- // Empty page
- array('', 0, true, 'Index page', './index.php'),
);
}