[ Index ]

PHP Cross Reference of phpBB-3.1.10-deutsch

title

Body

[close]

/ -> feed.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  * Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21
  13  * Original MOD: http://www.phpbb.com/community/viewtopic.php?f=69&t=1214645
  14  * MOD Author Profile: http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763
  15  * MOD Author Homepage: http://www.mssti.com/phpbb3/
  16  *
  17  **/
  18  
  19  /**
  20  * @ignore
  21  **/
  22  define('IN_PHPBB', true);
  23  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  24  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  25  include($phpbb_root_path . 'common.' . $phpEx);
  26  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  27  
  28  if (!$config['feed_enable'])
  29  {
  30      trigger_error('NO_FEED_ENABLED');
  31  }
  32  
  33  // Start session
  34  $user->session_begin();
  35  
  36  if (!empty($config['feed_http_auth']) && request_var('auth', '') == 'http')
  37  {
  38      phpbb_http_login(array(
  39          'auth_message'    => 'Feed',
  40          'viewonline'    => request_var('viewonline', true),
  41      ));
  42  }
  43  
  44  $auth->acl($user->data);
  45  $user->setup('viewtopic');
  46  
  47  // Initial var setup
  48  $forum_id    = request_var('f', 0);
  49  $topic_id    = request_var('t', 0);
  50  $mode        = request_var('mode', '');
  51  
  52  // We do not use a template, therefore we simply define the global template variables here
  53  $global_vars = $item_vars = array();
  54  $feed_updated_time = 0;
  55  
  56  // Generate params array for use in append_sid() to correctly link back to this page
  57  $params = false;
  58  if ($forum_id || $topic_id || $mode)
  59  {
  60      $params = array(
  61          'f'        => ($forum_id) ? $forum_id : NULL,
  62          't'        => ($topic_id) ? $topic_id : NULL,
  63          'mode'    => ($mode) ? $mode : NULL,
  64      );
  65  }
  66  
  67  // This boards URL
  68  $phpbb_feed_helper = $phpbb_container->get('feed.helper');
  69  $board_url = $phpbb_feed_helper->get_board_url();
  70  
  71  // Get correct feed object
  72  $phpbb_feed_factory = $phpbb_container->get('feed.factory');
  73  $feed = $phpbb_feed_factory->get_feed($mode, $forum_id, $topic_id);
  74  
  75  // No feed found
  76  if ($feed === false)
  77  {
  78      trigger_error('NO_FEED');
  79  }
  80  
  81  // Open Feed
  82  $feed->open();
  83  
  84  // Iterate through items
  85  while ($row = $feed->get_item())
  86  {
  87      /**
  88      * Event to modify the feed row
  89      *
  90      * @event core.feed_modify_feed_row
  91      * @var    int        forum_id    Forum ID
  92      * @var    string    mode        Feeds mode (forums|topics|topics_new|topics_active|news)
  93      * @var    array    row            Array with feed data
  94      * @var    int        topic_id    Topic ID
  95      *
  96      * @since 3.1.10-RC1
  97      */
  98      $vars = array('forum_id', 'mode', 'row', 'topic_id');
  99      extract($phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars)));
 100  
 101      // BBCode options to correctly disable urls, smilies, bbcode...
 102      if ($feed->get('options') === NULL)
 103      {
 104          // Allow all combinations
 105          $options = 7;
 106  
 107          if ($feed->get('enable_bbcode') !== NULL && $feed->get('enable_smilies') !== NULL && $feed->get('enable_magic_url') !== NULL)
 108          {
 109              $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);
 110          }
 111      }
 112      else
 113      {
 114          $options = $row[$feed->get('options')];
 115      }
 116  
 117      $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : '');
 118  
 119      $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0;
 120      $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0;
 121  
 122      $display_attachments = ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment']) ? true : false;
 123  
 124      $item_row = array(
 125          'author'        => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '',
 126          'published'        => ($published > 0) ? $phpbb_feed_helper->format_date($published) : '',
 127          'updated'        => ($updated > 0) ? $phpbb_feed_helper->format_date($updated) : '',
 128          'link'            => '',
 129          'title'            => censor_text($title),
 130          'category'        => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
 131          'category_name'    => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '',
 132          '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()))),
 133          'statistics'    => '',
 134      );
 135  
 136      // Adjust items, fill link, etc.
 137      $feed->adjust_item($item_row, $row);
 138  
 139      $item_vars[] = $item_row;
 140  
 141      $feed_updated_time = max($feed_updated_time, $published, $updated);
 142  }
 143  
 144  // If we do not have any items at all, sending the current time is better than sending no time.
 145  if (!$feed_updated_time)
 146  {
 147      $feed_updated_time = time();
 148  }
 149  
 150  // Some default assignments
 151  // FEED_IMAGE is not used (atom)
 152  $global_vars = array_merge($global_vars, array(
 153      'FEED_IMAGE'            => '',
 154      'SELF_LINK'                => $phpbb_feed_helper->append_sid('feed.' . $phpEx, $params),
 155      'FEED_LINK'                => $board_url . '/index.' . $phpEx,
 156      'FEED_TITLE'            => $config['sitename'],
 157      'FEED_SUBTITLE'            => $config['site_desc'],
 158      'FEED_UPDATED'            => $phpbb_feed_helper->format_date($feed_updated_time),
 159      'FEED_LANG'                => $user->lang['USER_LANG'],
 160      'FEED_AUTHOR'            => $config['sitename'],
 161  ));
 162  
 163  $feed->close();
 164  
 165  // Output page
 166  
 167  // gzip_compression
 168  if ($config['gzip_compress'])
 169  {
 170      if (@extension_loaded('zlib') && !headers_sent())
 171      {
 172          ob_start('ob_gzhandler');
 173      }
 174  }
 175  
 176  // IF debug extra is enabled and admin want to "explain" the page we need to set other headers...
 177  if (defined('DEBUG') && request_var('explain', 0) && $auth->acl_get('a_'))
 178  {
 179      header('Content-type: text/html; charset=UTF-8');
 180      header('Cache-Control: private, no-cache="set-cookie"');
 181      header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
 182  
 183      $mtime = explode(' ', microtime());
 184      $totaltime = $mtime[0] + $mtime[1] - $starttime;
 185  
 186      if (method_exists($db, 'sql_report'))
 187      {
 188          $db->sql_report('display');
 189      }
 190  
 191      garbage_collection();
 192      exit_handler();
 193  }
 194  
 195  header("Content-Type: application/atom+xml; charset=UTF-8");
 196  header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT');
 197  
 198  if (!empty($user->data['is_bot']))
 199  {
 200      // Let reverse proxies know we detected a bot.
 201      header('X-PHPBB-IS-BOT: yes');
 202  }
 203  
 204  echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
 205  echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $global_vars['FEED_LANG'] . '">' . "\n";
 206  echo '<link rel="self" type="application/atom+xml" href="' . $global_vars['SELF_LINK'] . '" />' . "\n\n";
 207  
 208  echo (!empty($global_vars['FEED_TITLE'])) ? '<title>' . $global_vars['FEED_TITLE'] . '</title>' . "\n" : '';
 209  echo (!empty($global_vars['FEED_SUBTITLE'])) ? '<subtitle>' . $global_vars['FEED_SUBTITLE'] . '</subtitle>' . "\n" : '';
 210  echo (!empty($global_vars['FEED_LINK'])) ? '<link href="' . $global_vars['FEED_LINK'] .'" />' . "\n" : '';
 211  echo '<updated>' . $global_vars['FEED_UPDATED'] . '</updated>' . "\n\n";
 212  
 213  echo '<author><name><![CDATA[' . $global_vars['FEED_AUTHOR'] . ']]></name></author>' . "\n";
 214  echo '<id>' . $global_vars['SELF_LINK'] . '</id>' . "\n";
 215  
 216  foreach ($item_vars as $row)
 217  {
 218      echo '<entry>' . "\n";
 219  
 220      if (!empty($row['author']))
 221      {
 222          echo '<author><name><![CDATA[' . $row['author'] . ']]></name></author>' . "\n";
 223      }
 224  
 225      echo '<updated>' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '</updated>' . "\n";
 226  
 227      if (!empty($row['published']))
 228      {
 229          echo '<published>' . $row['published'] . '</published>' . "\n";
 230      }
 231  
 232      echo '<id>' . $row['link'] . '</id>' . "\n";
 233      echo '<link href="' . $row['link'] . '"/>' . "\n";
 234      echo '<title type="html"><![CDATA[' . $row['title'] . ']]></title>' . "\n\n";
 235  
 236      if (!empty($row['category']) && isset($row['category_name']) && $row['category_name'] !== '')
 237      {
 238          echo '<category term="' . $row['category_name'] . '" scheme="' . $row['category'] . '" label="' . $row['category_name'] . '"/>' . "\n";
 239      }
 240  
 241      echo '<content type="html" xml:base="' . $row['link'] . '"><![CDATA[' . "\n";
 242      echo $row['description'];
 243  
 244      if (!empty($row['statistics']))
 245      {
 246          echo '<p>' . $user->lang['STATISTICS'] . ': ' . $row['statistics'] . '</p>';
 247      }
 248  
 249      echo '<hr />' . "\n" . ']]></content>' . "\n";
 250      echo '</entry>' . "\n";
 251  }
 252  
 253  echo '</feed>';
 254  
 255  garbage_collection();
 256  exit_handler();


Generated: Sun Feb 19 19:52:41 2017 Cross-referenced by PHPXref 0.7.1