Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Mon Jul 06, 2009 2:55 pm Reply with quote

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('&amp;', ''', '&quot;', '&lt;', '&gt;'), $text);


But it doesn't seem to work, or I'm not putting it in the correct spot. Any suggestions?

My current feed location: Only registered users can see links on this board! Get registered or login!

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(
   '&nbsp;' => ' ',
   '&iexcl;' => '¡',
   '&cent;' => '¢',
   '&pound;' => '£',
   '&curren;' => '¤',
   '&yen;' => '¥',
   '&brvbar;' => '¦',
   '&sect;' => '§',
   '&uml;' => '¨',
   '&copy;' => '©',
   '&ordf;' => 'ª',
   '&laquo;' => '«',
   '&not;' => '¬',
   '&shy;' => '­',
   '&reg;' => '®',
   '&macr;' => '¯',
   '&deg;' => '°',
   '&plusmn;' => '±',
   '&sup2;' => '²',
   '&sup3;' => '³',
   '&acute;' => '´',
   '&micro;' => 'µ',
   '&para;' => '¶',
   '&middot;' => '·',
   '&cedil;' => '¸',
   '&sup1;' => '¹',
   '&ordm;' => 'º',
   '&raquo;' => '»',
   '&frac14;' => '¼',
   '&frac12;' => '½',
   '&frac34;' => '¾',
   '&iquest;' => '¿',
   '&Agrave;' => 'À',
   '&Aacute;' => 'Á',
   '&Acirc;' => 'Â',
   '&Atilde;' => 'Ã',
   '&Auml;' => 'Ä',
   '&Aring;' => 'Å',
   '&AElig;' => 'Æ',
   '&Ccedil;' => 'Ç',
   '&Egrave;' => 'È',
   '&Eacute;' => 'É',
   '&Ecirc;' => 'Ê',
   '&Euml;' => 'Ë',
   '&Igrave;' => 'Ì',
   '&Iacute;' => 'Í',
   '&Icirc;' => 'Î',
   '&Iuml;' => 'Ï',   
   '&ETH;' => 'Ð',
   '&Ntilde;' => 'Ñ',    
   '&Ograve;' => 'Ò',   
   '&Oacute;' => 'Ó',    
   '&Ocirc;' => 'Ô',
   '&Otilde;' => 'Õ',   
   '&Ouml;' => 'Ö',
   '&times;' => '×',   
   '&Oslash;' => 'Ø',   
   '&Ugrave;' => 'Ù',   
   '&Uacute;' => 'Ú',   
   '&Ucirc;' => 'Û',
   '&Uuml;' => 'Ü',
   '&Yacute;' => 'Ý',    
   '&THORN;' => 'Þ',
   '&szlig;' => 'ß',   
   '&agrave;' => 'à',   
   '&aacute;' => 'á',   
   '&acirc;' => 'â',
   '&atilde;' => 'ã',   
   '&auml;' => 'ä',    
   '&aring;' => 'å',   
   '&aelig;' => 'æ',   
   '&ccedil;' => 'ç',   
   '&egrave;' => 'è',   
   '&eacute;' => 'é',   
   '&ecirc;' => 'ê',
   '&euml;' => 'ë',
   '&igrave;' => 'ì',    
   '&iacute;' => 'í',   
   '&icirc;' => 'î',
   '&iuml;' => 'ï',
   '&eth;' => 'ð',
   '&ntilde;' => 'ñ',    
   '&ograve;' => 'ò',   
   '&oacute;' => 'ó',   
   '&ocirc;' => 'ô',
   '&otilde;' => 'õ',   
   '&ouml;' => 'ö',
   '&divide;' => '÷',    
   '&oslash;' => 'ø',   
   '&ugrave;' => 'ù',   
   '&uacute;' => 'ú',   
   '&ucirc;' => 'û',
   '&uuml;' => 'ü',
   '&yacute;' => 'ý',    
   '&thorn;' => 'þ',
   '&yuml;' => 'ÿ',
   '&fnof;' => 'ƒ',
   '&Alpha;' => 'Α',   
   '&Beta;' => 'Β',
   '&Gamma;' => 'Γ',   
   '&Delta;' => 'Δ',   
   '&Epsilon;' => 'Ε',    
   '&Zeta;' => 'Ζ',
   '&Eta;' => 'Η',
   '&Theta;' => 'Θ',    
   '&Iota;' => 'Ι',
   '&Kappa;' => 'Κ',   
   '&Lambda;' => 'Λ',   
   '&Mu;' => 'Μ',
   '&Nu;' => 'Ν',   
   '&Xi;' => 'Ξ',   
   '&Omicron;' => 'Ο',    
   '&Pi;' => 'Π',
   '&Rho;' => 'Ρ',   
   '&Sigma;' => 'Σ',    
   '&Tau;' => 'Τ',
   '&Upsilon;' => 'Υ',    
   '&Phi;' => 'Φ',
   '&Chi;' => 'Χ',
   '&Psi;' => 'Ψ',
   '&Omega;' => 'Ω',    
   '&alpha;' => 'α',   
   '&beta;' => 'β',
   '&gamma;' => 'γ',   
   '&delta;' => 'δ',   
   '&epsilon;' => 'ε',       
   '&zeta;' => 'ζ',
   '&eta;' => 'η',
   '&theta;' => 'θ',    
   '&iota;' => 'ι',   
   '&kappa;' => 'κ',    
   '&lambda;' => 'λ',   
   '&mu;' => 'μ',
   '&nu;' => 'ν',   
   '&xi;' => 'ξ',   
   '&omicron;' => 'ο',       
   '&pi;' => 'π',
   '&rho;' => 'ρ',    
   '&sigmaf;' => 'ς',       
   '&sigma;' => 'σ',   
   '&tau;' => 'τ',   
   '&upsilon;' => 'υ',       
   '&phi;' => 'φ',
   '&chi;' => 'χ',    
   '&psi;' => 'ψ',    
   '&omega;' => 'ω',    
   '&thetasym;' => 'ϑ',       
   '&upsih;' => 'ϒ',
   '&piv;' => 'ϖ',   
   '&bull;' => '•',    
   '&hellip;' => '…',       
   '&prime;' => '′',
   '&Prime;' => '″',   
   '&oline;' => '‾',   
   '&frasl;' => '⁄',   
   '&weierp;' => '℘',    
   '&image;' => 'ℑ',
   '&real;' => 'ℜ',   
   '&trade;' => '™',   
   '&alefsym;' => 'ℵ',       
   '&larr;' => '←',
   '&uarr;' => '↑',   
   '&rarr;' => '→',   
   '&darr;' => '↓',   
   '&harr;' => '↔',   
   '&crarr;' => '↵',   
   '&lArr;' => '⇐',   
   '&uArr;' => '⇑',   
   '&rArr;' => '⇒',   
   '&dArr;' => '⇓',   
   '&hArr;' => '⇔',   
   '&forall;' => '∀',       
   '&part;' => '∂',
   '&exist;' => '∃',   
   '&empty;' => '∅',   
   '&nabla;' => '∇',   
   '&isin;' => '∈',   
   '&notin;' => '∉',   
   '&ni;' => '∋',   
   '&prod;' => '∏',    
   '&sum;' => '∑',   
   '&minus;' => '−',    
   '&lowast;' => '∗',    
   '&radic;' => '√',
   '&prop;' => '∝',   
   '&infin;' => '∞',   
   '&ang;' => '∠',   
   '&and;' => '∧',    
   '&or;' => '∨',    
   '&cap;' => '∩',    
   '&cup;' => '∪',    
   '&int;' => '∫',    
   '&there4;' => '∴',       
   '&sim;' => '∼',
   '&cong;' => '≅',    
   '&asymp;' => '≈',   
   '&ne;' => '≠',   
   '&equiv;' => '≡',       
   '&le;' => '≤',   
   '&ge;' => '≥',    
   '&sub;' => '⊂',    
   '&sup;' => '⊃',    
   '&nsub;' => '⊄',    
   '&sube;' => '⊆',   
   '&supe;' => '⊇',   
   '&oplus;' => '⊕',   
   '&otimes;' => '⊗',    
   '&perp;' => '⊥',
   '&sdot;' => '⋅',   
   '&lceil;' => '⌈',   
   '&rceil;' => '⌉',   
   '&lfloor;' => '⌊',    
   '&rfloor;' => '⌋',    
   '&lang;' => '〈',
   '&rang;' => '〉',   
   '&loz;' => '◊',   
   '&spades;' => '♠',       
   '&clubs;' => '♣',
   '&hearts;' => '♥',    
   '&diams;' => '♦',
   '&quot;' => '"',   
   '&amp;' => '&',
   '&lt;' => '<',   
   '&gt;' => '>',   
   '&OElig;' => 'Œ',
   '&oelig;' => 'œ',   
   '&Scaron;' => 'Š',   
   '&scaron;' => 'š',   
   '&Yuml;' => 'Ÿ',   
   '&circ;' => 'ˆ',    
   '&tilde;' => '˜',    
   '&ensp;' => ' ',   
   '&emsp;' => ' ',   
   '&thinsp;' => ' ',       
   '&zwnj;' => '‌',
   '&zwj;' => '‍',
   '&lrm;' => '‎',   
   '&rlm;' => '‏',   
   '&ndash;' => '–',    
   '&mdash;' => '—',       
   '&lsquo;' => '‘',   
   '&rsquo;' => '’',   
   '&sbquo;' => '‚',   
   '&ldquo;' => '“',   
   '&rdquo;' => '”',   
   '&bdquo;' => '„',   
   '&dagger;' => '†',    
   '&Dagger;' => '‡',    
   '&permil;' => '‰',    
   '&lsaquo;' => '‹',
   '&rsaquo;' => '›',
   '&euro;' => '€');
   
  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&amp;file=article&amp;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";

?>
 
View user's profile Send private message
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6383

PostPosted: Mon Jul 06, 2009 3:28 pm Reply with quote

What makes this custom? Are you looking at a specific news category / topic? Have you considered nukeFEED(tm) for this?

_________________
I google, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
rogue3
PostPosted: Mon Jul 06, 2009 3:30 pm Reply with quote

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
PostPosted: Mon Jul 06, 2009 3:52 pm Reply with quote

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 Only registered users can see links on this board! Get registered or login!.
 
rogue3
PostPosted: Mon Jul 06, 2009 3:54 pm Reply with quote

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
PostPosted: Mon Jul 06, 2009 6:45 pm Reply with quote

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
PostPosted: Mon Jul 06, 2009 6:54 pm Reply with quote

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
PostPosted: Mon Jul 06, 2009 6:57 pm Reply with quote

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:
Only registered users can see links on this board! Get registered or login! (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
PostPosted: Mon Jul 06, 2009 7:07 pm Reply with quote

Someone else wanted to replace the Only registered users can see links on this board! Get registered or login! 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
PostPosted: Mon Jul 06, 2009 8:00 pm Reply with quote

Yeah, titles and text looked good.

Here's my current feed (not the nukeFEED feed):
Only registered users can see links on this board! Get registered or login!

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: Only registered users can see links on this board! Get registered or login!
 
rogue3
PostPosted: Thu Aug 20, 2009 5:04 am Reply with quote

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
PostPosted: Thu Aug 20, 2009 8:17 am Reply with quote

Please see response to this question on nukeSEO.com
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©