Author
Message
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 2:55 pm
I'm currently using a custom backend.php file for my RSS feed. A few problems I'm having:
-if I use a character like & instead of & then it kills the feed.
-if I use a ' or " then it puts a 'slash' in front of the symbol
So, is there a script I can add to my feed that will automatically fix these problems? Something where if it sees these in the title or description then it will replace them with the proper entity?
Someone recommended putting this line in:
Code: str_replace(array('&', "'", '"', '<', '>'), array('&', ''', '"', '<', '>'), $text);
But it doesn't seem to work, or I'm not putting it in the correct spot. Any suggestions?
My current feed location:
Here is my current backend file:
Code: <?php
include("mainfile.php");
global $prefix, $db, $nukeurl;
header("Content-Type: text/xml");
/* entity to unicode decimal value */
function entity_to_decimal_value($string){
$entity_to_decimal = array(
' ' => ' ',
'¡' => '¡',
'¢' => '¢',
'£' => '£',
'¤' => '¤',
'¥' => '¥',
'¦' => '¦',
'§' => '§',
'¨' => '¨',
'©' => '©',
'ª' => 'ª',
'«' => '«',
'¬' => '¬',
'­' => '',
'®' => '®',
'¯' => '¯',
'°' => '°',
'±' => '±',
'²' => '²',
'³' => '³',
'´' => '´',
'µ' => 'µ',
'¶' => '¶',
'·' => '·',
'¸' => '¸',
'¹' => '¹',
'º' => 'º',
'»' => '»',
'¼' => '¼',
'½' => '½',
'¾' => '¾',
'¿' => '¿',
'À' => 'À',
'Á' => 'Á',
'Â' => 'Â',
'Ã' => 'Ã',
'Ä' => 'Ä',
'Å' => 'Å',
'Æ' => 'Æ',
'Ç' => 'Ç',
'È' => 'È',
'É' => 'É',
'Ê' => 'Ê',
'Ë' => 'Ë',
'Ì' => 'Ì',
'Í' => 'Í',
'Î' => 'Î',
'Ï' => 'Ï',
'Ð' => 'Ð',
'Ñ' => 'Ñ',
'Ò' => 'Ò',
'Ó' => 'Ó',
'Ô' => 'Ô',
'Õ' => 'Õ',
'Ö' => 'Ö',
'×' => '×',
'Ø' => 'Ø',
'Ù' => 'Ù',
'Ú' => 'Ú',
'Û' => 'Û',
'Ü' => 'Ü',
'Ý' => 'Ý',
'Þ' => 'Þ',
'ß' => 'ß',
'à' => 'à',
'á' => 'á',
'â' => 'â',
'ã' => 'ã',
'ä' => 'ä',
'å' => 'å',
'æ' => 'æ',
'ç' => 'ç',
'è' => 'è',
'é' => 'é',
'ê' => 'ê',
'ë' => 'ë',
'ì' => 'ì',
'í' => 'í',
'î' => 'î',
'ï' => 'ï',
'ð' => 'ð',
'ñ' => 'ñ',
'ò' => 'ò',
'ó' => 'ó',
'ô' => 'ô',
'õ' => 'õ',
'ö' => 'ö',
'÷' => '÷',
'ø' => 'ø',
'ù' => 'ù',
'ú' => 'ú',
'û' => 'û',
'ü' => 'ü',
'ý' => 'ý',
'þ' => 'þ',
'ÿ' => 'ÿ',
'ƒ' => 'ƒ',
'Α' => 'Α',
'Β' => 'Β',
'Γ' => 'Γ',
'Δ' => 'Δ',
'Ε' => 'Ε',
'Ζ' => 'Ζ',
'Η' => 'Η',
'Θ' => 'Θ',
'Ι' => 'Ι',
'Κ' => 'Κ',
'Λ' => 'Λ',
'Μ' => 'Μ',
'Ν' => 'Ν',
'Ξ' => 'Ξ',
'Ο' => 'Ο',
'Π' => 'Π',
'Ρ' => 'Ρ',
'Σ' => 'Σ',
'Τ' => 'Τ',
'Υ' => 'Υ',
'Φ' => 'Φ',
'Χ' => 'Χ',
'Ψ' => 'Ψ',
'Ω' => 'Ω',
'α' => 'α',
'β' => 'β',
'γ' => 'γ',
'δ' => 'δ',
'ε' => 'ε',
'ζ' => 'ζ',
'η' => 'η',
'θ' => 'θ',
'ι' => 'ι',
'κ' => 'κ',
'λ' => 'λ',
'μ' => 'μ',
'ν' => 'ν',
'ξ' => 'ξ',
'ο' => 'ο',
'π' => 'π',
'ρ' => 'ρ',
'ς' => 'ς',
'σ' => 'σ',
'τ' => 'τ',
'υ' => 'υ',
'φ' => 'φ',
'χ' => 'χ',
'ψ' => 'ψ',
'ω' => 'ω',
'ϑ' => 'ϑ',
'ϒ' => 'ϒ',
'ϖ' => 'ϖ',
'•' => '•',
'…' => '…',
'′' => '′',
'″' => '″',
'‾' => '‾',
'⁄' => '⁄',
'℘' => '℘',
'ℑ' => 'ℑ',
'ℜ' => 'ℜ',
'™' => '™',
'ℵ' => 'ℵ',
'←' => '←',
'↑' => '↑',
'→' => '→',
'↓' => '↓',
'↔' => '↔',
'↵' => '↵',
'⇐' => '⇐',
'⇑' => '⇑',
'⇒' => '⇒',
'⇓' => '⇓',
'⇔' => '⇔',
'∀' => '∀',
'∂' => '∂',
'∃' => '∃',
'∅' => '∅',
'∇' => '∇',
'∈' => '∈',
'∉' => '∉',
'∋' => '∋',
'∏' => '∏',
'∑' => '∑',
'−' => '−',
'∗' => '∗',
'√' => '√',
'∝' => '∝',
'∞' => '∞',
'∠' => '∠',
'∧' => '∧',
'∨' => '∨',
'∩' => '∩',
'∪' => '∪',
'∫' => '∫',
'∴' => '∴',
'∼' => '∼',
'≅' => '≅',
'≈' => '≈',
'≠' => '≠',
'≡' => '≡',
'≤' => '≤',
'≥' => '≥',
'⊂' => '⊂',
'⊃' => '⊃',
'⊄' => '⊄',
'⊆' => '⊆',
'⊇' => '⊇',
'⊕' => '⊕',
'⊗' => '⊗',
'⊥' => '⊥',
'⋅' => '⋅',
'⌈' => '⌈',
'⌉' => '⌉',
'⌊' => '⌊',
'⌋' => '⌋',
'⟨' => '〈',
'⟩' => '〉',
'◊' => '◊',
'♠' => '♠',
'♣' => '♣',
'♥' => '♥',
'♦' => '♦',
'"' => '"',
'&' => '&',
'<' => '<',
'>' => '>',
'Œ' => 'Œ',
'œ' => 'œ',
'Š' => 'Š',
'š' => 'š',
'Ÿ' => 'Ÿ',
'ˆ' => 'ˆ',
'˜' => '˜',
' ' => ' ',
' ' => ' ',
' ' => ' ',
'‌' => '',
'‍' => '',
'‎' => '',
'‏' => '',
'–' => '–',
'—' => '—',
'‘' => '‘',
'’' => '’',
'‚' => '‚',
'“' => '“',
'”' => '”',
'„' => '„',
'†' => '†',
'‡' => '‡',
'‰' => '‰',
'‹' => '‹',
'›' => '›',
'€' => '€');
return preg_replace(
"/&[A-Za-z]+;/",
" ",
strtr($string,$entity_to_decimal) );
}
$gmtdiff = date("O", time());
$gmtstr = substr($gmtdiff, 0, 3) . ":" . substr($gmtdiff, 3, 9);
$now = date("Y-m-d\TH:i:s", time());
$now = $now . $gmtstr;
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><?xml-stylesheet title=\"XSL_formatting\" type=\"text/xsl\" href=\"rss_898.xsl\" ?>\n";
echo "<rss version=\"2.0\" \n";
echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n";
echo " xmlns:admin=\"http://webns.net/mvcb/\"\n";
echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n";
echo "<channel>\n";
echo "<title>".htmlspecialchars($sitename)."</title>\n";
echo "<link>".htmlspecialchars($nukeurl)."</link>\n";
echo "<description>".$slogan."</description>\n";
echo "<dc:language>".$backend_language."</dc:language>\n";
echo "<dc:creator>fake@truden.com</dc:creator>\n";
echo "<dc:date>".$now."</dc:date>\n\n";
echo "<sy:updatePeriod>hourly</sy:updatePeriod>\n";
echo "<sy:updateFrequency>1</sy:updateFrequency>\n";
echo "<sy:updateBase>".$now."</sy:updateBase>\n\n";
$result = $db->sql_query("SELECT s.sid,t.topictext,s.informant,s.title,s.time,s.hometext FROM ".$prefix."_stories s, ".$prefix."_topics t where s.topic = t.topicid ORDER BY sid DESC LIMIT 10");
while ($row = $db->sql_fetchrow($result)) {
$rsid = intval($row['sid']);
$topictext = $row['topictext'];
$informant = $row['informant'];
$title = $row['title'];
$time = $row['time'];
$hometext = $row['hometext'];
// format: 2004-08-02T12:15:23-06:00
$date = date("Y-m-d\TH:i:s", strtotime($time));
$date = $date . $gmtstr;
echo "<item>\n";
echo "<title>".$title."</title>\n";
echo "<link>$nukeurl/modules.php?name=News&file=article&sid=$rsid</link>\n";
echo "<description><![CDATA[".entity_to_decimal_value($hometext)."]]></description>\n";
echo "<guid isPermaLink=\"false\">".$rsid."@".$nukeurl."</guid>\n";
echo "<dc:subject>".$topictext."</dc:subject>\n";
echo "<dc:date>".$date."</dc:date>\n";
echo "<dc:creator>".$informant."</dc:creator>\n";
echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>\n";
?>
kguske Site Admin Joined: Jun 04, 2004 Posts: 6044
Posted:
Mon Jul 06, 2009 3:28 pm
What makes this custom? Are you looking at a specific news category / topic? Have you considered nukeFEED(tm) for this?
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 3:30 pm
kguske wrote: What makes this custom? Are you looking at a specific news category / topic? Have you considered nukeFEED(tm) for this?
Well, it was custom written. I wanted the ability to show title, date, author and category in my feeds. This was the only one I could find.
I haven't tried nukeFEED(tm). Can you tell me about it?
kguske Site Admin Joined: Jun 04, 2004 Posts: 6044
Posted:
Mon Jul 06, 2009 3:52 pm
Sure:
nukeFEED(tm) provides PHP-Nuke with the ability to:
* syndicate most types of content and easily add additional content types
* use modern syndication formats like ATOM and RSS 2.0
* significantly improve standards compliance (verses the 10 most recent news stories via the standard PHP-Nuke RSS 0.91 backend.php feed)
* display a feed map in both HTML and OMPL formats
* support auto-discovery of published (active) feeds
* define syndication feeds with more detailed attributes, including multiple sort orders (e.g. recent, popular, highest rated) at multiple levels (module, category, forum, etc.) and for a specified number of items
* maintain a list of feed aggregators and provide subscription links to these aggregators or any feed reader
* integrate with FeedBurner to cache feeds, track and report usage statistics, monetize feeds through advertising and more
* preview feeds to help visitors determine to which feeds they want to subscribe
You can download it .
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 3:54 pm
OK, I did download and install it. I will play with it to see how it does with my site. Thanks for the tip.
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 6:45 pm
OK, I have it installed, but I'm not quite sure how to use it. I got it to come up by replacing my backend.php file, but how to I configure what shows up in the feed?
kguske Site Admin Joined: Jun 04, 2004 Posts: 6044
Posted:
Mon Jul 06, 2009 6:54 pm
There are 2 feeds created when you visit the feed admin pages - one is for news, and it should do the trick. You can configure it if if default settings are to your liking.
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 6:57 pm
I found the two feeds, but when I click on the little 'configure feed' symbol nothing happens. It just reloads the page. I also replaced the backend.php file with the one in the extras folder so that it still pulls the feed through that. The feed loads ok in my reader, but not all of the columns are correct. For example, under authoer it shows:
(Chuck)
When I'd like it to just show "Chuck"
The category column is completely empty now. I'd like it to use that too.
kguske Site Admin Joined: Jun 04, 2004 Posts: 6044
Posted:
Mon Jul 06, 2009 7:07 pm
Someone else wanted to replace the with an actual email address, but I like your idea better. Just need to confirm if we can use that approach.
Hadn't thought about the category. Let me look into that, too.
Is it showing the titles and text correctly?
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Mon Jul 06, 2009 8:00 pm
Yeah, titles and text looked good.
Here's my current feed (not the nukeFEED feed):
That is how I was wanting it to look.
Oh, and the time offset is off by 7 hours. Is there any way to adjust that?
Here's a screen shot of my current backend output:
rogue3 Regular Joined: Jul 02, 2009 Posts: 63
Posted:
Thu Aug 20, 2009 5:04 am
Is there a way to keep images from showing up in the feed? If my 'homepage' text has a thumbnail, it shows up in the feed too.
kguske Site Admin Joined: Jun 04, 2004 Posts: 6044
Posted:
Thu Aug 20, 2009 8:17 am
Please see response to this question on nukeSEO.com
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum