[ PHPXref.com ] [ Generated: Sun Jul 20 20:57:59 2008 ] [ vtiger Forums 1.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> rss.php (source)

   1  <?php

   2  /***************************************************************************


   3  *                   rss.php


   4  *                 -------------------


   5  *   begin         : Monday, July 7, 2003


   6  *   notes         : This code is based on the work of the original


   7  *               developer below.  Portions of this code


   8  *               'borrowed' from phpbb_fetch_posts, an


   9  *               untitled rdf content syndicator posted at


  10  *               phpbb.com, and phpbb itself.


  11  *   email         : rss@wickedwisdom.com


  12  *


  13  *


  14  *   $Id: rss.php,v 1.2 2005/03/31 12:28:53 isaac Exp $


  15  *


  16  *


  17  ***************************************************************************/

  18  

  19  /***************************************************************************


  20  *                   rdf.php


  21  *                 -------------------


  22  *   begin         : Saturday, Mar 2, 2002


  23  *   copyright         : (C) 2002 Matthijs van de Water


  24  *                    Sascha Carlin


  25  *   email         : phpbb@matthijs.net


  26  *               sc@itst.org


  27  *


  28  *   $Id: rss.php,v 1.2 2005/03/31 12:28:53 isaac Exp $


  29  *


  30  *


  31  ***************************************************************************/

  32  

  33  /***************************************************************************


  34  *


  35  *   This program is free software; you can redistribute it and/or modify


  36  *   it under the terms of the GNU General Public License as published by


  37  *   the Free Software Foundation; either version 2 of the License, or


  38  *   (at your option) any later version.


  39  *


  40  ***************************************************************************/

  41  

  42  //


  43  // BEGIN Configuration


  44  //


  45  // Set the relative path from this file to your phpBB root folder


  46  $phpbb_root_path = './';

  47  // How many posts do you want to returnd (count)?  Specified in the URL with "c=".  Defaults to 15, upper limit of 50.


  48  $count = ( isset($HTTP_GET_VARS['c']) ) ? intval($HTTP_GET_VARS['c']) : 15;

  49  $count = ( $count == 0 ) ? 15 : $count;

  50  $count = ( $count > 50 ) ? 50 : $count;

  51  // Which forum do you want posts from (forum_id)?  specified in the url with "f=".  Defaults to all (public) forums.


  52  $forum_id = ( isset($HTTP_GET_VARS['f']) ) ? intval($HTTP_GET_VARS['f']) : '';

  53  $sql_forum_where = ( !empty($forum_id) ) ? ' AND f.forum_id = ' . $forum_id : ' ';

  54  // Return topics only, or all posts?  Specified in the URL with "t=".  Defaults to all posts (0).


  55  $topics_only = (isset($HTTP_GET_VARS['t']) ) ? intval($HTTP_GET_VARS['t']) : 0;

  56  $sql_topics_only_where = '';

  57  if ( $topics_only == 1 )

  58  {

  59      $sql_topics_only_where = 'AND p.post_id = t.topic_first_post_id';

  60  }

  61  //


  62  // END Configuration


  63  //


  64  

  65  //


  66  // BEGIN Includes of phpBB scripts


  67  //


  68  define ('IN_PHPBB', true);

  69  include ($phpbb_root_path . 'extension.inc');

  70  include($phpbb_root_path . 'common.'.$phpEx);

  71  include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

  72  //


  73  // END Includes of phpBB scripts


  74  //


  75  

  76  //


  77  // BEGIN Session management


  78  //


  79  $userdata = session_pagestart($user_ip, PAGE_INDEX);

  80  init_userprefs($userdata);

  81  //


  82  // End session management


  83  //


  84  

  85  //


  86  // BEGIN Create main board information (some code borrowed from functions_post.php)


  87  //


  88  // Build URL components


  89  $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));

  90  $viewpost = ( $script_name != '' ) ? $script_name . '/viewtopic.' . $phpEx : 'viewtopic.'. $phpEx;

  91  $index = ( $script_name != '' ) ? $script_name . '/index.' . $phpEx : 'index.'. $phpEx;

  92  $server_name = trim($board_config['server_name']);

  93  $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';

  94  $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

  95  // Assemble URL components


  96  $index_url = $server_protocol . $server_name . $server_port . $script_name . '/';

  97  $viewpost_url = $server_protocol . $server_name . $server_port . $viewpost;

  98  // Reformat site name and description


  99  $site_name = strip_tags($board_config['sitename']);

 100  $site_description = strip_tags($board_config['site_desc']);

 101  // Set the fully qualified url to your smilies folder


 102  $smilies_path = $board_config['smilies_path'];

 103  $smilies_url = $index_url . $smilies_path;

 104  $smilies_path = preg_replace("/\//", "\/", $smilies_path);

 105  //


 106  // END Create main board information


 107  //


 108  

 109  //


 110  // BEGIN Initialise template


 111  //


 112  $template->set_filenames(array(

 113      "body" => "rss_body.tpl")

 114  );

 115  //


 116  // END Initialise template


 117  //


 118  

 119  //


 120  // BEGIN Assign static variables to template


 121  //


 122  // Variable reassignment for Topic Replies


 123  $l_topic_replies = $lang['Topic'] . ' ' . $lang['Replies'];

 124  $template->assign_vars(array(

 125      'S_CONTENT_ENCODING' => $lang['ENCODING'],

 126      'BOARD_URL' => $index_url,

 127      'BOARD_TITLE' => $site_name,

 128      'BOARD_DESCRIPTION' => $site_description,

 129      'BOARD_MANAGING_EDITOR' => $board_config['board_email'],

 130      'BOARD_WEBMASTER' => $board_config['board_email'],

 131      'BUILD_DATE' => gmdate('D, d M Y H:i:s', time()) . ' GMT', 

 132      'L_AUTHOR' => $lang['Author'],

 133      'L_POSTED' => $lang['Posted'],

 134      'L_TOPIC_REPLIES' => $l_topic_replies,

 135      'L_POST' => $lang['Post'])

 136  );

 137  //


 138  // END Assign static variabless to template


 139  //


 140  

 141  //


 142  // BEGIN SQL statement to fetch active posts of public forums


 143  //


 144  $sql = "SELECT f.forum_name, t.topic_title, u.user_id, u.username, u.user_sig, u.user_sig_bbcode_uid, p.post_id, pt.post_text, pt.post_subject, pt.bbcode_uid, p.post_time, t.topic_replies, t.topic_first_post_id

 145      FROM " . FORUMS_TABLE . " AS f, " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS p, " . POSTS_TEXT_TABLE . " as pt

 146      WHERE

 147          t.forum_id = f.forum_id

 148              AND f.auth_view = " . AUTH_ALL . "

 149              AND p.poster_id = u.user_id

 150              AND pt.post_id = p.post_id

 151              AND p.topic_id = t.topic_id

 152              $sql_topics_only_where

 153              $sql_forum_where

 154      ORDER BY p.post_time DESC LIMIT $count";

 155  $posts_query = $db->sql_query($sql);

 156  //


 157  // END SQL statement to fetch active posts of public forums


 158  //


 159  

 160  //


 161  // BEGIN Query failure check


 162  //


 163  if ( !$posts_query )

 164  {

 165      message_die(GENERAL_ERROR, "Could not query list of active posts", "", __LINE__, __FILE__, $sql);

 166  }

 167  else if ( !$db->sql_numrows($posts_query) )

 168  {

 169      message_die(GENERAL_MESSAGE, $lang['No_match']);

 170  }

 171  else

 172  {

 173  //


 174  // END Query failure check


 175  //


 176  

 177  //


 178  // BEGIN "item" loop


 179  //


 180      while ($post = $db->sql_fetchrow($posts_query))

 181      {

 182  

 183  // Variable reassignment and reformatting for post text


 184  $post_text = $post['post_text'];

 185  $post_text = str_replace("\n", "\n<br />\n", $post_text);

 186  $post_text = bbencode_second_pass($post_text, $post['bbcode_uid']);

 187  $post_text = smilies_pass($post_text);

 188  $post_text = preg_replace("/$smilies_path/", $smilies_url, $post_text);

 189  $post_text = make_clickable($post_text);

 190  // Variable reassignment and reformatting for user sig


 191  $user_sig = $post['user_sig'];

 192  $user_sig = bbencode_second_pass($user_sig, $post['user_sig_bbcode_uid']);

 193  $user_sig = smilies_pass($user_sig);

 194  $user_sig = preg_replace("/$smilies_path/", $smilies_url, $user_sig);

 195  $user_sig = make_clickable($user_sig);

 196      if ( $user_sig != '' )

 197  {

 198          $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);

 199  }

 200  // Variable reassignment and reformatting for post subject


 201  $post_subject = $post['post_subject'];

 202      if ( $post_subject != '' )

 203  {

 204          $post_subject = $lang['Subject'] . ': ' . htmlspecialchars($post_subject) . '<br />';

 205  }

 206  // Variable reassignment for topic title, and show whether it is the start of topic, or a reply


 207  $topic_title = $post['topic_title'];

 208  if ( $post['post_id'] != $post['topic_first_post_id'] )

 209  {

 210      $topic_title = 'RE: ' . $topic_title;

 211  }

 212  // Variable reassignment and reformatting for author


 213  $author = $post['username'];

 214  if ( $post['user_id'] != -1 )

 215  {

 216          $author = '<a href="' . $index_url . 'profile.' . $phpEx . '?mode=viewprofile&u=' . $post['user_id'] . '" target="_blank">'

 217   . $author . '</a>';

 218  }

 219  $author = make_clickable($author);

 220  // Assign "item" variables to template


 221          $template->assign_block_vars('post_item', array(

 222              'POST_URL' => $viewpost_url . '?' . POST_POST_URL . '=' . $post['post_id'] . '#' . $post['post_id'],

 223              'TOPIC_TITLE' => htmlspecialchars($topic_title),

 224              'AUTHOR' => htmlspecialchars($author),

 225              'POST_TIME' => create_date($board_config['default_dateformat'], $post['post_time'], $board_config['board_timezone']).' (GMT ' . $board_config['board_timezone'] . ')',

 226              'post_subjecT' => htmlspecialchars($post_subject),

 227              'FORUM_NAME' => htmlspecialchars($post['forum_name']),

 228              'POST_TEXT' => htmlspecialchars($post_text),

 229              'USER_SIG' => htmlspecialchars($user_sig),

 230              'TOPIC_REPLIES' => $post['topic_replies']

 231  )

 232          );

 233      }

 234  }

 235  //


 236  // END "item" loop


 237  //


 238  

 239  //


 240  // BEGIN XML and nocaching headers (copied from page_header.php)


 241  //


 242  if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))

 243  {

 244      header ('Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0');

 245  }

 246  else

 247  {

 248      header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');

 249  }

 250  header ('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');

 251  header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

 252  header ('Content-Type: text/xml');

 253  //


 254  // End XML and nocaching headers


 255  //


 256  

 257  //


 258  // BEGIN Output XML page


 259  //


 260  $template->pparse('body');

 261  //


 262  // END Output XML page


 263  //


 264  

 265  ?>



[ Powered by PHPXref - Served by Debian GNU/Linux ]