xoops forums

jayjay

Not too shy to talk
Posted on: 2008/4/1 6:28
jayjay
jayjay (Show more)
Not too shy to talk
Posts: 175
Since: 2003/9/10
#1

Backend.php RSS hack for valid feeds

I added this code to the template "system_rss.html" to make RSS feeds 100% compatible with all aggregators:

Line 2 - after xml version:
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">


Line 14 - after channel language:
<atom:link href="<{$xoops_url}><{$smarty.server.REQUEST_URI}>" rel="self" type="application/rss+xml" />


I use the above smarty code because hardcoding the self-address of your rss feed (eg. "http://mydomain.org/backend.php") will break your feed in other modules that use backend.php to generate RSS feeds (namely wf-downloads).

Can these changes be added to a following release?

Mamba

Moderator
Posted on: 2008/4/1 6:52
Mamba
Mamba (Show more)
Moderator
Posts: 10376
Since: 2004/4/23
#2

Re: Backend.php RSS hack for valid feeds

Entered into SourceForge Patches Tracker
Please support XOOPS & DONATE
Use 2.5.8 | Debug | Requests | Bugs

jayjay

Not too shy to talk
Posted on: 2008/4/1 7:28
jayjay
jayjay (Show more)
Not too shy to talk
Posts: 175
Since: 2003/9/10
#3

Re: Backend.php RSS hack for valid feeds

Thanks!

jayjay

Not too shy to talk
Posted on: 2008/4/1 8:14
jayjay
jayjay (Show more)
Not too shy to talk
Posts: 175
Since: 2003/9/10
#4

Re: Backend.php RSS hack for valid feeds

Quote:

jayjay wrote:

Line 14 - after channel language:
<atom:link href="<{$xoops_url}><{$smarty.server.REQUEST_URI}>" rel="self" type="application/rss+xml" />



I haven't tested this, but I think you can also use <{$xoops_requesturi}> instead of <{$smarty.server.REQUEST_URI}>. I think this has the same result.

Anonymous

Posted on: 2008/5/14 23:43
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#5

Re: Backend.php RSS hack for valid feeds

Google Webmaster Center mark all my RSS feed ( backend.php, newbb/rss.php, mylinks.rss.php, .. etc ) as invalid RSS feeds becaue it is not contain:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">


So now I convert all ROR feeds in my site to google xml sitemap !

wishcraft

Module Developer
Posted on: 2008/5/16 5:31
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3669
Since: 2007/5/18
#6

Re: Backend.php RSS hack for valid feeds

Well I have been building a separate system for sitemaps. It isn't very simple if you are not a programmer, I made a basic instruction manual for sitemaps..

In this forum post : http://www.xoops.org/modules/newbb/vi ... id=280669#forumpost280669

I want to add a sitemap system for modules so it is more autonomously generated. But it involves modifying the database.. And then you have a changed structure of the database...

grr.. so many users, so many &*(^*& up if we change the database at this stage.. with over 6 million downloads, that is an end userbase of 6000000 x (2^10) + thats alot of potential sites to go down.
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/Cipherhouse
sourceforge.net/projects/chronolabs/
facebook.com/mynamesnot

Anonymous

Posted on: 2008/5/16 6:20
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#7

Re: Backend.php RSS hack for valid feeds

Hi wishcraft,

Befor 1 year ago, I made RSS feed hack for xcgal Module and I added this RSS link to Google Webmaster Center, it is accepted and everything is ok.

Resized Image

But before few days, I saw ERRORS alert beside xcgal RSS link and all other RSS Feeds and the error type was Unsupported file format, and at google help they are say:

Quote:
Your Sitemap does not appear to be in a supported format. Please ensure it meets our Sitemap guidelines and resubmit.

Some things you might check are:

That the file uses the correct header. For a Sitemap file, the header can look like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
For a Sitemap index file, the header can look like this:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex
xmlns="http://www.sitemaps.org/schemas<wbr>/sitemap/0.9">
That the namespace in the header is "http://www.sitemaps.org/schemas/sitemap/0.9". Note that this must end in 0.9. If it ends in .9, you'll see an error.

That each XML attribute is enclosed in either single quotes (') or double quotes (") and that those quotes are straight, not curly. If you use a word processing program, such as Microsoft Word, you may find that it inserts curly quotes.


So, what I do is converting my xcgal RSS from:
<?php
//
//     XOOPS Gallery RSS 2.0 
//    displays latest photos via RSS 2.0 feed.
//  Copyright (c) 2007 Mowaffak Ali - www.arabxoops.com
//  Thanks to www.mypapit.net                 
//    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.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//    
//

include_once '../../mainfile.php';

define('IN_XCGALLERY'true);
require(
'include/init.inc.php');

$charset='windows-1256';
$sitename htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
$email checkEmail($xoopsConfig['adminmail'],false);
$slogan htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
$module $xoopsModule->getVar('name');
$channel_link XOOPS_URL.'/';
$channel_desc xoops_utf8_encode($slogan);
$channel_lastbuild formatTimestamp(time(), 'rss');
$channel_editor xoops_utf8_encode($email);
$channel_category xoops_utf8_encode($category);
$channel_generator xoops_utf8_encode($module);
$channel_language _LANGCODE;

$galpath =  XOOPS_URL.'/modules/xcgal';
$albumpath $galpath.'/albums/';

// How many items you want to show in RSS feed
$upperlimit 10

header('Content-Type:text/xml; charset='.$charset);
$title $sitename.' - '.$module;
$channel_title xoops_utf8_encode($title);
print 
"<?xml version="1.0" encoding="$charset"?>n";
print 
"<rss version="2.0">";
print 
"<channel>n";
print 
"<title>$channel_title</title>n";
print 
"<link>$channel_link</link>n";
print 
"<description>$channel_desc</description>";
print 
"<language>$channel_language</language>n";
print 
"<lastBuildDate>$channel_lastbuild</lastBuildDate>n";
print 
"<generator>$channel_generator</generator>n";
    
$result=$xoopsDB->query("SELECT pid,ctime,title,keywords,filepath,filename FROM ".$xoopsDB->prefix("xcgal_pictures")." ORDER BY pid DESC LIMIT 0,$upperlimit");
while (list(
$pid$ctime$title$keywords,$filepath,$filename) = mysql_fetch_row($result)) {
    print 
"t<item>n";
    print 
"tt<title> $title </title>n";
    print 
"tt<link>$galpath/displayimage.php?pid=$pid</link>n";
    print 
"tt<author>$channel_editor</author>n";
        print 
"tt<pubDate>$channel_lastbuild</pubDate>n";
        print 
"tt<description>";
        echo  
htmlspecialchars("<p><img src="$albumpath$filepath" . "thumb_$filename" alt="" /> </p><p>$keywords</p>");
        print 
"</description>n";
    print 
"t</item>n";
    print 
"n";
}
print 
"</channel>";
print 
"</rss>";


to:

<?php
//
//     XOOPS Gallery RSS 2.0 
//    displays latest photo via RSS 2.0 feed.
//      Copyright (c) 2007 Mowaffak Ali                  
//      http://www.arabxoops.com/ 
//                    
//    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.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//
//  
//    Thanks to http://mypapit.net/pproject
//

include_once '../../mainfile.php';

define('IN_XCGALLERY'true);
require(
'include/init.inc.php');

$charset='UTF-8';
$sitename htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
$module $xoopsModule->getVar('name');
$channel_link XOOPS_URL.'/';
$channel_lastbuild formatTimestamp(time(), 'rss');
$channel_language _LANGCODE;

$galpath =  XOOPS_URL.'/modules/xcgal';
$albumpath $galpath.'/albums/';

// How many items you want to show in RSS feed
$upperlimit 100

header('Content-Type:text/xml; charset='.$charset);
$title $sitename.' - '.$module;
$channel_title xoops_utf8_encode($title);
print 
"<?xml version="1.0" encoding="$charset"?>n";
print 
"<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">n";
    
$result=$xoopsDB->query("SELECT pid FROM ".$xoopsDB->prefix("xcgal_pictures")." ORDER BY pid DESC LIMIT 0,$upperlimit");
while (list(
$pid) = mysql_fetch_row($result)) {
    print 
"t<url>n";
    print 
"tt<loc>$galpath/displayimage.php?pid=$pid</loc>n";
    print 
"tt<changefreq>monthly</changefreq>n";
    print 
"tt<priority>0.5</priority>n";
    print 
"t</url>n";
    print 
"n";
}
print 
"</urlset>";


and now the error fixed!

I know windows-1256 is not valid charset for RSS but I use it because my site don't support UTF-8.

Am I right ? because I'm looking for convert all RSS feeds in my site to this sitemap structure.

Any comments ?

wishcraft

Module Developer
Posted on: 2008/5/16 8:06
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3669
Since: 2007/5/18
#8

Re: Backend.php RSS hack for valid feeds

Looks like your regular expressions are not right.. \t for tab \n for new line.

Thanks,

Please I am here to develop XOOPS the core...

other hints: Don't Smoke Tobacco or anything else when programming.
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/Cipherhouse
sourceforge.net/projects/chronolabs/
facebook.com/mynamesnot

wishcraft

Module Developer
Posted on: 2008/5/16 8:12
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3669
Since: 2007/5/18
#9

Re: Backend.php RSS hack for valid feeds

Quote:

Patches Tracker


Do my nicatbate QC quit smoking Patches have a tracker... With nanoscience anything could.
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/Cipherhouse
sourceforge.net/projects/chronolabs/
facebook.com/mynamesnot

Runeher

Module Developer
Posted on: 2008/5/16 10:58
Runeher
Runeher (Show more)
Module Developer
Posts: 823
Since: 2008/1/24
#10

Re: Backend.php RSS hack for valid feeds

Quote:
Don't Smoke Tobacco or anything else when programming.


Does else include creativity-boosting smoke too...