From b5544b2f471ce4c93b08d19919ab062725545ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sat, 3 Jan 2015 11:39:29 +0100 Subject: [ticket/13450] Type-hint return value of $phpbb_container->get() PHPBB3-13450 --- phpBB/feed.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/feed.php') diff --git a/phpBB/feed.php b/phpBB/feed.php index e0c0b01db6..75877efd04 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -65,10 +65,12 @@ if ($forum_id || $topic_id || $mode) } // This boards URL +/* @var $phpbb_feed_helper \phpbb\feed\helper */ $phpbb_feed_helper = $phpbb_container->get('feed.helper'); $board_url = $phpbb_feed_helper->get_board_url(); // Get correct feed object +/* @var $phpbb_feed_factory \phpbb\feed\factory */ $phpbb_feed_factory = $phpbb_container->get('feed.factory'); $feed = $phpbb_feed_factory->get_feed($mode, $forum_id, $topic_id); -- cgit v1.2.1 From f6e06da4c68917dafb057bf7fe19f884a3e148c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 4 Jan 2015 20:41:04 +0100 Subject: [ticket/13455] Update calls to `request_var()` PHPBB3-13455 --- phpBB/feed.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/feed.php') diff --git a/phpBB/feed.php b/phpBB/feed.php index 75877efd04..a7428ea846 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -33,11 +33,11 @@ if (!$config['feed_enable']) // Start session $user->session_begin(); -if (!empty($config['feed_http_auth']) && request_var('auth', '') == 'http') +if (!empty($config['feed_http_auth']) && $request->variable('auth', '') == 'http') { phpbb_http_login(array( 'auth_message' => 'Feed', - 'viewonline' => request_var('viewonline', true), + 'viewonline' => $request->variable('viewonline', true), )); } @@ -45,9 +45,9 @@ $auth->acl($user->data); $user->setup('viewtopic'); // Initial var setup -$forum_id = request_var('f', 0); -$topic_id = request_var('t', 0); -$mode = request_var('mode', ''); +$forum_id = $request->variable('f', 0); +$topic_id = $request->variable('t', 0); +$mode = $request->variable('mode', ''); // We do not use a template, therefore we simply define the global template variables here $global_vars = $item_vars = array(); @@ -162,7 +162,7 @@ if ($config['gzip_compress']) } // IF debug extra is enabled and admin want to "explain" the page we need to set other headers... -if (defined('DEBUG') && request_var('explain', 0) && $auth->acl_get('a_')) +if (defined('DEBUG') && $request->variable('explain', 0) && $auth->acl_get('a_')) { header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); -- cgit v1.2.1 From 8e5e954438b232f4ce7aec6a5db3d52b974c07a8 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sun, 22 Feb 2015 23:36:27 +0100 Subject: [ticket/13645] Move the feeds to controllers PHPBB3-13645 --- phpBB/feed.php | 220 +++++---------------------------------------------------- 1 file changed, 17 insertions(+), 203 deletions(-) (limited to 'phpBB/feed.php') diff --git a/phpBB/feed.php b/phpBB/feed.php index a7428ea846..1480867d6c 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -16,6 +16,9 @@ * **/ +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\Routing\Exception\InvalidParameterException; + /** * @ignore **/ @@ -23,222 +26,33 @@ define('IN_PHPBB', true); $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); -if (!$config['feed_enable']) -{ - trigger_error('NO_FEED_ENABLED'); -} +/** @var \phpbb\controller\helper $controller_helper */ +$controller_helper = $phpbb_container->get('controller.helper'); -// Start session -$user->session_begin(); - -if (!empty($config['feed_http_auth']) && $request->variable('auth', '') == 'http') -{ - phpbb_http_login(array( - 'auth_message' => 'Feed', - 'viewonline' => $request->variable('viewonline', true), - )); -} - -$auth->acl($user->data); -$user->setup('viewtopic'); - -// Initial var setup $forum_id = $request->variable('f', 0); $topic_id = $request->variable('t', 0); -$mode = $request->variable('mode', ''); - -// We do not use a template, therefore we simply define the global template variables here -$global_vars = $item_vars = array(); -$feed_updated_time = 0; - -// Generate params array for use in append_sid() to correctly link back to this page -$params = false; -if ($forum_id || $topic_id || $mode) -{ - $params = array( - 'f' => ($forum_id) ? $forum_id : NULL, - 't' => ($topic_id) ? $topic_id : NULL, - 'mode' => ($mode) ? $mode : NULL, - ); -} - -// This boards URL -/* @var $phpbb_feed_helper \phpbb\feed\helper */ -$phpbb_feed_helper = $phpbb_container->get('feed.helper'); -$board_url = $phpbb_feed_helper->get_board_url(); - -// Get correct feed object -/* @var $phpbb_feed_factory \phpbb\feed\factory */ -$phpbb_feed_factory = $phpbb_container->get('feed.factory'); -$feed = $phpbb_feed_factory->get_feed($mode, $forum_id, $topic_id); - -// No feed found -if ($feed === false) -{ - trigger_error('NO_FEED'); -} - -// Open Feed -$feed->open(); - -// Iterate through items -while ($row = $feed->get_item()) -{ - // BBCode options to correctly disable urls, smilies, bbcode... - if ($feed->get('options') === NULL) - { - // Allow all combinations - $options = 7; - - if ($feed->get('enable_bbcode') !== NULL && $feed->get('enable_smilies') !== NULL && $feed->get('enable_magic_url') !== NULL) - { - $options = (($row[$feed->get('enable_bbcode')]) ? OPTION_FLAG_BBCODE : 0) + (($row[$feed->get('enable_smilies')]) ? OPTION_FLAG_SMILIES : 0) + (($row[$feed->get('enable_magic_url')]) ? OPTION_FLAG_LINKS : 0); - } - } - else - { - $options = $row[$feed->get('options')]; - } - - $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); - - $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0; - $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0; - - $display_attachments = ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment']) ? true : false; - - $item_row = array( - 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', - 'published' => ($published > 0) ? $phpbb_feed_helper->format_date($published) : '', - 'updated' => ($updated > 0) ? $phpbb_feed_helper->format_date($updated) : '', - 'link' => '', - 'title' => censor_text($title), - 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', - 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], ($display_attachments ? $feed->get_attachments($row['post_id']) : array()))), - 'statistics' => '', - ); - - // Adjust items, fill link, etc. - $feed->adjust_item($item_row, $row); - - $item_vars[] = $item_row; - - $feed_updated_time = max($feed_updated_time, $published, $updated); -} - -// If we do not have any items at all, sending the current time is better than sending no time. -if (!$feed_updated_time) -{ - $feed_updated_time = time(); -} - -// Some default assignments -// FEED_IMAGE is not used (atom) -$global_vars = array_merge($global_vars, array( - 'FEED_IMAGE' => '', - 'SELF_LINK' => $phpbb_feed_helper->append_sid('feed.' . $phpEx, $params), - 'FEED_LINK' => $board_url . '/index.' . $phpEx, - 'FEED_TITLE' => $config['sitename'], - 'FEED_SUBTITLE' => $config['site_desc'], - 'FEED_UPDATED' => $phpbb_feed_helper->format_date($feed_updated_time), - 'FEED_LANG' => $user->lang['USER_LANG'], - 'FEED_AUTHOR' => $config['sitename'], -)); - -$feed->close(); - -// Output page +$mode = $request->variable('mode', ''); -// gzip_compression -if ($config['gzip_compress']) +if ($forum_id !== 0) { - if (@extension_loaded('zlib') && !headers_sent()) - { - ob_start('ob_gzhandler'); - } + $url = $controller_helper->route('phpbb_feed_forum', array('forum_id' => $forum_id)); } - -// IF debug extra is enabled and admin want to "explain" the page we need to set other headers... -if (defined('DEBUG') && $request->variable('explain', 0) && $auth->acl_get('a_')) -{ - header('Content-type: text/html; charset=UTF-8'); - header('Cache-Control: private, no-cache="set-cookie"'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - if (method_exists($db, 'sql_report')) - { - $db->sql_report('display'); - } - - garbage_collection(); - exit_handler(); -} - -header("Content-Type: application/atom+xml; charset=UTF-8"); -header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT'); - -if (!empty($user->data['is_bot'])) +else if ($topic_id !== 0) { - // Let reverse proxies know we detected a bot. - header('X-PHPBB-IS-BOT: yes'); + $url = $controller_helper->route('phpbb_feed_topic', array('topic_id' => $topic_id)); } - -echo '' . "\n"; -echo '' . "\n"; -echo '' . "\n\n"; - -echo (!empty($global_vars['FEED_TITLE'])) ? '' . $global_vars['FEED_TITLE'] . '' . "\n" : ''; -echo (!empty($global_vars['FEED_SUBTITLE'])) ? '' . $global_vars['FEED_SUBTITLE'] . '' . "\n" : ''; -echo (!empty($global_vars['FEED_LINK'])) ? '' . "\n" : ''; -echo '' . $global_vars['FEED_UPDATED'] . '' . "\n\n"; - -echo '' . "\n"; -echo '' . $global_vars['SELF_LINK'] . '' . "\n"; - -foreach ($item_vars as $row) +else { - echo '' . "\n"; - - if (!empty($row['author'])) + try { - echo '' . "\n"; + $url = $controller_helper->route('phpbb_feed_overall', array('mode' => $mode)); } - - echo '' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '' . "\n"; - - if (!empty($row['published'])) + catch (InvalidParameterException $e) { - echo '' . $row['published'] . '' . "\n"; + $url = $controller_helper->route('phpbb_feed_index'); } - - echo '' . $row['link'] . '' . "\n"; - echo '' . "\n"; - echo '<![CDATA[' . $row['title'] . ']]>' . "\n\n"; - - if (!empty($row['category']) && isset($row['category_name']) && $row['category_name'] !== '') - { - echo '' . "\n"; - } - - echo '' . $user->lang['STATISTICS'] . ': ' . $row['statistics'] . '

'; - } - - echo '
' . "\n" . ']]>
' . "\n"; - echo '
' . "\n"; } -echo '
'; - -garbage_collection(); -exit_handler(); +$response = new RedirectResponse($url, 301); +$response->send(); -- cgit v1.2.1