phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Anyone with knowledge about RSS?


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Mon Sep 28, 2009 3:23 pm 
Post subject: Anyone with knowledge about RSS?

Hi,

I am using the phpCA mod and its RSS.
It is not giving the correct result in the RSS.
This is the file ads_rss2.php provided with the mod:
Code:
<?
/***************************************************************************
*                               ads_rss2.php
*                            -------------------
*   begin                : Wednesday, Feb 15, 2006
*   copyright            : (C) 2006 Peter Mansion
*   email                : support@phpca.net
*
*   $Id: ads_rss2.php,v0.5.0 2005/10/30 20:10:00 pmansion Exp $
*
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$ads_root_path = $phpbb_root_path . 'ads_mod/';
include($ads_root_path . 'ads_common.'.$phpEx);

header("Content-Type: text/xml");

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

$sql = 'SELECT *
      FROM '. ADS_ADVERTS_TABLE .'
      ORDER BY id DESC
      LIMIT 0,5';

$result = $db->sql_query($sql);

$date = date("m/d/Y; G:i:s A T");

$rss_title = "".$board_config['sitename']." Syndication";
$website_url = $server_protocol.$board_config['server_name']."".$board_config['script_path']."".append_sid("index.".$phpEx)."";
$home_url = $server_protocol.$board_config['server_name']."".$board_config['script_path']."";

print ("<!-- RSS generated by ". htmlentities($rss_title) ." on ". htmlentities($date) ." -->\n");
print ("<rss version=\"2.0\">\n\n");
print ("<channel>\n");
print ("<title>". htmlentities($rss_title) ."</title>\n");
print ("<link>". htmlentities($home_url) ."</link>\n");
print ("<description>". htmlentities($rss_title) ."</description>\n");
print ("<language>en-gb</language>\n\n");

while ($row = $db->sql_fetchrow($result))
{
   // Replace censored words
   $title = preg_replace($orig_word, $replacement_word, $row['title']);
   $short_desc = preg_replace($orig_word, $replacement_word, $row['short_desc']);
   $rss_desc =  $row['short_desc'];
   $array = array ( '' => '&auml;', '' => '&ouml;', '' => '&aring;', '' => '&Ouml;', '' => '&Auml;', '' => '&Aring;' );
   $title = strtr($title, $array );
   $rss_desc = strtr($rss_desc, $array );

   print ("<item>\n");
   print ("<title>" . htmlentities($title) . "</title>\n");
   print ("<link>". htmlentities($home_url) ."ads_item.".$phpEx."?id=" . htmlentities($row['id']) . "</link>\n");
   print ("<description>". htmlentities($rss_desc) . "</description>\n");
   print ("</item>\n\n");
}

print ("</channel>\n");
print ("</rss>");

$db->sql_close();
?>


Using this RSS-feed results in the feed not showing a correct title.
http://www.maskinisten.net/ads_rss2.php
The title is filled with the first line of the short description.
The table phpbb_ads_adverts has fields for title and short_desc so I am a little bit confused why this does not work.

Maybe someone here can see the error.

/Holger
Back to top
Merri
Board Member



Joined: 02 Feb 2009

Posts: 63
Location: Kanta-Hme


flag
PostPosted: Tue Oct 13, 2009 10:24 pm 
Post subject: Re: Anyone with knowledge about RSS?

You've probably noticed the errors with the non-English latin characters? entities are handled in incorrect order, they should be applied after htmlentities and not before. A better way is to remove the hack altogether and instead define a character set for the RSS feed, ie. change header("Content-Type: text/xml"); to header("Content-Type: text/xml; charset=iso-8859-1");
_________________
Comboa Twitter
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Oct 15, 2009 11:15 am 
Post subject: Re: Anyone with knowledge about RSS?

This is what I have now:
Code:
<?
/***************************************************************************
*                               ads_rss2.php
*                            -------------------
*   begin                : Wednesday, Feb 15, 2006
*   copyright            : (C) 2006 Peter Mansion
*   email                : support@phpca.net
*
*   $Id: ads_rss2.php,v0.5.0 2005/10/30 20:10:00 pmansion Exp $
*
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$ads_root_path = $phpbb_root_path . 'ads_mod/';
include($ads_root_path . 'ads_common.'.$phpEx);

header("Content-Type: text/xml");

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

$sql = 'SELECT *
      FROM '. ADS_ADVERTS_TABLE .'
      ORDER BY id DESC
      LIMIT 0,5';

$result = $db->sql_query($sql);

$date = date("m/d/Y; G:i:s A T");

$rss_title = "".$board_config['sitename']."s Marknadsplats";
$website_url = $server_protocol.$board_config['server_name']."".$board_config['script_path']."".append_sid("index.".$phpEx)."";
$home_url = $server_protocol.$board_config['server_name']."".$board_config['script_path']."";

print ("<!-- RSS generated by ". htmlentities($rss_title) ." on ". htmlentities($date) ." -->\n");
print ("<rss version=\"2.0\">\n\n");
print ("<channel>\n");
print ("<title>". htmlentities($rss_title) ."</title>\n");
print ("<link>". htmlentities($home_url) ."</link>\n");
print ("<description>". htmlentities($rss_title) ."</description>\n");
print ("<language>en-gb</language>\n\n");

while ($row = $db->sql_fetchrow($result))
{
   $title = $row['title'];
   $rss_desc =  $row['short_desc'];
   $array = array ( '' => '&auml;', '' => '&ouml;', '' => '&aring;', '' => '&Ouml;', '' => '&Auml;', '' => '&Aring;' );
   $title = strtr($title, $array);
   $rss_desc = strtr($rss_desc, $array);

   print ("<item>\n");
   print ("<title>". htmlentities($title) ."</title>\n");
   print ("<link>". htmlentities($home_url) ."ads_item.".$phpEx."?id=" . htmlentities($row['id']) . "</link>\n");
   print ("<description>". htmlentities($rss_desc) . "</description>\n");
   print ("</item>\n\n");
}

print ("</channel>\n");
print ("</rss>");

$db->sql_close();
?>

It works rather well now, besides I still have issues with the RSS feed import mod "FIND INPUT".
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0305 seconds using 15 queries. (SQL 0.0027 Parse 0.0009 Other 0.0270)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo