Welcome to all phpBB2 Refugees!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. |
|
Author |
Message |
Holger Board Member
Joined: 19 Jan 2009
Posts: 509 Location: Hanover
|
Posted: Mon Sep 28, 2009 11:23 am 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 ( 'ä' => 'ä', 'ö' => 'ö', 'å' => 'å', 'Ö' => 'Ö', 'Ä' => 'Ä', 'Å' => 'Å' );
$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-Häme
|
Posted: Tue Oct 13, 2009 6: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
|
Posted: Thu Oct 15, 2009 7: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 ( 'ä' => 'ä', 'ö' => 'ö', 'å' => 'å', 'Ö' => 'Ö', 'Ä' => 'Ä', 'Å' => 'Å' );
$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 |
|
|
|
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0400 seconds using 17 queries. (SQL 0.0082 Parse 0.0005 Other 0.0312) |
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com
|
|