Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel(tm)
Author Message
BobMarion
Former Admin in Good Standing



Joined: Oct 30, 2002
Posts: 1037
Location: RedNeck Land (known as Kentucky)

PostPosted: Thu Aug 26, 2004 11:27 pm Reply with quote

I'm starting this as a new thread due to the previous thread covering much more then we find it needing to.

Now in the old thread we went thru several options for keeping NukeSentinel from blocking another site pulling your backend.php into one of their blocks. I've done some more testing and found a very simple solution, after genoxide pointed out the DOS protection, that can be added to the includes/sentinel.php file.

Open includes/sentinel.php in a text editor and find the following:
Code:
// DOS Attack Blocker

// Submitted by telli (telli@codezwiz.com)
if($ab_config['prevent_dos'] == 1) {
add to it:
Code:
 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php")
it will now look like:
Code:
// DOS Attack Blocker

// Submitted by telli (telli@codezwiz.com)
if($ab_config['prevent_dos'] == 1 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php")) {


Now find the following:
Code:
// Force to NUKEURL

if($ab_config['force_nukeurl'] == 1) {
add to it:
Code:
 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php")
it will now look like:
Code:
// Force to NUKEURL

if($ab_config['force_nukeurl'] == 1 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php")) {


If you have a backend file that is named different or more then one backend file you will need to either alter:
Code:
 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php")
to match the correct backend file name or add it multiple times for each backend filename you have.



There was another issue that was brought up but with the above it is no longer an issue but I will post that here as well to be more clear. This other issue revolved around these two lines from the original backend.php file:
Code:
header("Content-Type: text/xml");

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";

These two lines are/were not compatible without causing a validator to report a language error. To fix the language error I posted to change:
Code:
header("Content-Type: text/xml");
to:
Code:
header("Content-Type: application/rss+xml");


This cured the error report but if you just entered your backend.php file location into yoru browser's address bar it forced it to download instead of rendering it. The easier way to fix the language error is to change:
Code:
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
to:
Code:
echo "<?xml version=\"1.0\"?>\n\n";
My reading showed that the "encoding" was not required and by changing this instead of the content type your browser will still render it like before without forcing it to download.


In a nut shell we found that the native backend.php was not validating as a clean RSS feed. This was due to special characters that nuke allows but RSS validators do not. Now this is going to be a long post so get something to drink and I'll cover it as in depth as I possibly can.

A native backend.php file looks like this:
Code:
<?php


/************************************************************************/
/* PHP-NUKE: Advanced Content Management System                         */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* 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.       */
/*                                                                      */
/************************************************************************/
/* Additional security checking code 2003 by chatserv                   */
/* http://www.nukefixes.com -- http://www.nukeresources.com             */
/************************************************************************/

include("mainfile.php");
global $prefix, $db, $nukeurl;
header("Content-Type: text/xml");
    $cat = intval($cat);
if ($cat != "") {
    $catid = $db->sql_fetchrow($db->sql_query("SELECT catid FROM ".$prefix."_stories_cat WHERE title LIKE '%$cat%' LIMIT 1"));
    if ($catid == "") {
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
    } else {
   $catid = intval($catid);
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories WHERE catid='$catid' ORDER BY sid DESC LIMIT 10");
    }
} else {
    $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
}

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n";
echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
echo "<rss version=\"0.91\">\n\n";
echo "<channel>\n";
echo "<title>".htmlspecialchars($sitename)."</title>\n";
echo "<link>$nukeurl</link>\n";
echo "<description>".htmlspecialchars($backend_title)."</description>\n";
echo "<language>$backend_language</language>\n\n";

while ($row = $db->sql_fetchrow($result)) {
    $rsid = intval($row['sid']);
    $rtitle = $row['title'];
    echo "<item>\n";
    echo "<title>".htmlspecialchars($rtitle)."</title>\n";
    echo "<link>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$rsid</link>\n";
    echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>";

?>


What's wrong with this file, on the outside nothing other then a few things to patch.

Now here's the patched copy:
Code:
<?php


/************************************************************************/
/* PHP-NUKE: Advanced Content Management System                         */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* 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.       */
/************************************************************************/
/* Additional security checking code 2003 by chatserv                   */
/* http://www.nukefixes.com -- http://www.nukeresources.com             */
/************************************************************************/

include("mainfile.php");
$sitename = stripEntities($sitename);
$backend_title = stripEntities($backend_title);

function stripEntities($s) {
   $s = preg_replace('!&[^;\s]+;!','',$s);         ## remove HTML entities.
   $s = preg_replace('![^\w\s]!','',$s);           ## remove non-word/space chars.
   return $s;
}

header("Content-Type: text/xml");
$cat = intval($cat);
$topic = intval($topic);
if ($cat != "") {
    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE catid='$cat' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} elseif ($topic != "") {
    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE topic='$topic' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} else  {
    $sql = "SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
}

echo "<?xml version=\"1.0\"?>\n\n";
echo "<rss version=\"0.91\">\n\n";
echo "  <channel>\n";
echo "    <title>".htmlspecialchars($sitename)."</title>\n";
echo "    <link>$nukeurl</link>\n";
echo "    <description>".htmlspecialchars($backend_title)."</description>\n";
echo "    <language>$backend_language</language>\n\n";
echo "    <image>\n";
echo "      <title>".htmlspecialchars($sitename)."</title>\n";
echo "      <url>$nukeurl/images/YOURIMAGE.png</url>\n";
echo "      <link>$nukeurl</link>\n";
echo "      <width>YOUR IMAGE WIDTH</width>\n"; // Max width is 144 pixels
echo "      <height>YOUR IMAGE HEIGHT</height>\n"; // Max height is 400 pixels
echo "      <description>".htmlspecialchars($backend_title)."</description>\n";
echo "    </image>\n\n";
while ($row = $db->sql_fetchrow($result)) {
    echo "    <item>\n";
    $rsid = intval($row['sid']);
    $rtitle = $row['title'];
    $rtitle = stripEntities($rtitle);
    echo "      <title>".htmlspecialchars($rtitle)."</title>\n";
    echo "      <link>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$rsid</link>\n";
    echo "    </item>\n\n";
}
echo "  </channel>\n";
echo "</rss>";

?>


You will notice that the global line is gone, Raven added the stripEntities( function, I added the ability to have it feed a select topic, and there are a few other minor fixes included.

You will also notice this conforms to the RSS 0.91 standard. I've built, after doing all this reading today, a RSS 2.0 standard backend.php file. It is very similar in structure but includes much more information for RSS readers outside of nuke. This RSS 2 backend file is as follows:
Code:
<?php


/********************************************************/
/* NukeSentinel(tm) Universal                           */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2004 by NukeScripts Network         */
/********************************************************/
/* Based on:                                            */
/* PHP-NUKE's: backend.php file                         */
/********************************************************/

include("mainfile.php");
$sitename = stripEntities($sitename);
$backend_title = stripEntities($backend_title);
$last_built = date("D, d M Y H:i:s T");
$copy_year = "Copyright ".date("Y");

function stripEntities($s) {
   $s = preg_replace('!&[^;\s]+;!','',$s);         ## remove HTML entities.
   $s = preg_replace('![^\w\s]!','',$s);           ## remove non-word/space chars.
   return $s;
}

header("Content-Type: text/xml");
$cat = intval($cat);
$topic = intval($topic);
if ($cat != "") {
    $sql = "SELECT * FROM ".$prefix."_stories WHERE catid='$catid' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} elseif ($topic != "") {
    $sql = "SELECT * FROM ".$prefix."_stories WHERE topic='$topic' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} else {
    $sql = "SELECT * FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
}

echo "<?xml version=\"1.0\"?>\n\n";
echo "<rss version=\"2.0\">\n\n";
echo "  <channel>\n";
echo "    <title>".htmlspecialchars($sitename)."</title>\n";
echo "    <link>$nukeurl</link>\n";
echo "    <description>".htmlspecialchars($backend_title)."</description>\n";
echo "    <copyright>$copy_year $sitename</copyright>\n";
echo "    <generator>$sitename $Version_Num</generator>\n";
echo "    <language>$backend_language</language>\n";
echo "    <lastBuildDate>$last_built</lastBuildDate>\n";
echo "    <managingEditor>$adminmail</managingEditor>\n";
echo "    <webMaster>$adminmail</webMaster>\n";
echo "    <ttl>60</ttl>\n\n";
echo "    <image>\n";
echo "      <title>".htmlspecialchars($sitename)."</title>\n";
echo "      <url>$nukeurl/images/YOURIMAGE.png</url>\n";
echo "      <link>$nukeurl</link>\n";
echo "      <width>YOUR IMAGE WIDTH</width>\n"; // Max width is 144 pixels
echo "      <height>YOUR IMAGE HEIGHT</height>\n"; // Max height is 400 pixels
echo "      <description>".htmlspecialchars($backend_title)."</description>\n";
echo "    </image>\n\n";

while ($row = $db->sql_fetchrow($result)) {
    $title = $row[title];
    $title = stripEntities($title);
    $hometext = $row[hometext];
    $hometext = str_replace("<br>", "", $hometext);
    $hometext = str_replace("<br />", "", $hometext);
    $hometext = stripEntities($hometext);
    $pubdate = date("D, d M Y H:i:s T", strtotime($row['time']));
    echo "    <item>\n";
    echo "      <title>".htmlspecialchars($title)."</title>\n";
    echo "      <link>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$row[sid]</link>\n";
    echo "      <description>$hometext</description>\n";
    echo "      <pubDate>$pubdate</pubDate>\n";
    echo "      <guid>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$row[sid]</guid>\n";
    echo "    </item>\n\n";
}
echo "    </channel>\n\n";
echo "</rss>";

?>

_________________
Bob Marion
Codito Ergo Sum
http://www.nukescripts.net 
View user's profile Send private message Send e-mail Visit poster's website
64bitguy
The Mouse Is Extension Of Arm



Joined: Mar 06, 2004
Posts: 1164

PostPosted: Thu Aug 26, 2004 11:49 pm Reply with quote

So just so I'm straight on this:

Since you have compatibility with both RSS Readers using dual backend.php files (err... okay.. backend.php and backend2.php) then your includes/sentinel.php would look like this:

Code:
// DOS Attack Blocker 

// Submitted by telli (telli@codezwiz.com)
if($ab_config['prevent_dos'] == 1 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php") AND !stristr($_SERVER['SCRIPT_NAME'], "backend2.php")){

and
Code:
// Force to NUKEURL 

if($ab_config['force_nukeurl'] == 1 AND !stristr($_SERVER['SCRIPT_NAME'], "backend.php") AND !stristr($_SERVER['SCRIPT_NAME'], "backend2.php")){

And then you would use both the backend.php and backend2.php files that you included below....

Last question before I start cutting and pasting... Are all of these things utilizing and conforming to the Chatserv 2.5 patches?

Thanks!

_________________
Steph Benoit
100% Section 508 and W3C HTML5 and CSS Compliant (Truly) Code, because I love compliance. 
View user's profile Send private message
BobMarion







PostPosted: Thu Aug 26, 2004 11:53 pm Reply with quote

Yes, Yes, and Yes

If you want you can replace your current backend.php with my backend2.php if you want it to be RSS 2.0 instead of RSS 0.91 or you can have both and allow your users to choose between them Smile
 
64bitguy







PostPosted: Sun Aug 29, 2004 1:59 am Reply with quote

Okay, but my I'm still having issues with your sites feeds, as well as with some of the others including this site. Did you get a chance to review the PM I sent you regarding what I have with Chatserv's 7.4 backend.php?

Also, your 2.0 feed looks just like your 0.91 feed to my reader.... no single quotes, no periods.....

See my Syndicated News feed for different examples of sites using various RSS feed formats. Also, I should note that this looks identical (for good reason I suppose) to what I see in Chatserv Patched 2.5 / 7.4's Your_Account... Same church, different pew.
 
BobMarion







PostPosted: Sun Aug 29, 2004 8:45 am Reply with quote

I will look at it today and let you know.
 
Deseroka
Client



Joined: Apr 15, 2003
Posts: 466
Location: FL

PostPosted: Sun Aug 29, 2004 8:46 am Reply with quote

I've decided it is not that important. If they want to see my news, let them visit my site. I made all the changes and still had trouble.
 
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Sun Aug 29, 2004 9:01 am Reply with quote

I've noticed some readers have a problem with double spaces between words. These readers get kinda fussy and lack consistency from one to the next. I guess that called flexability?

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
Deseroka







PostPosted: Sun Aug 29, 2004 9:28 am Reply with quote

I'll give it a shot again later, it is not a pressing imprtance for me. You should know by now how bad I am at starting projects, moving to another, coming back, moving to another....
 
BobMarion







PostPosted: Sun Aug 29, 2004 9:29 am Reply with quote

64bitguy wrote:
Okay, but my I'm still having issues with your sites feeds, as well as with some of the others including this site. Did you get a chance to review the PM I sent you regarding what I have with Chatserv's 7.4 backend.php?

Also, your 2.0 feed looks just like your 0.91 feed to my reader.... no single quotes, no periods.....

See my Syndicated News feed for different examples of sites using various RSS feed formats. Also, I should note that this looks identical (for good reason I suppose) to what I see in Chatserv Patched 2.5 / 7.4's Your_Account... Same church, different pew.


Okay, in a nut shell backend.php has not changed from 6.5 to 7.4 with the exception of ChatServ's work Smile The primary difference between CS's and mine is as follows:
Code:
global $prefix, $db, $nukeurl;

header("Content-Type: text/xml");
    $cat = intval($cat);
if ($cat != "") {
    $catid = $db->sql_fetchrow($db->sql_query("SELECT catid FROM ".$prefix."_stories_cat WHERE title LIKE '%$cat%' LIMIT 1"));
    if ($catid == "") {
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
    } else {
   $catid = intval($catid);
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories WHERE catid='$catid' ORDER BY sid DESC LIMIT 10");
    }
} else {
    $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
}


That is CS's and this is mine:
Code:
$cat = intval($cat);

$topic = intval($topic);
if ($cat != "") {
    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE catid='$cat' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} elseif ($topic != "") {
    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE topic='$topic' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
} else  {
    $sql = "SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);
}


The global line was removed, it's just not needed since you pull mainfile.php into it. I also replaced
Code:
    $catid = $db->sql_fetchrow($db->sql_query("SELECT catid FROM ".$prefix."_stories_cat WHERE title LIKE '%$cat%' LIMIT 1"));

    if ($catid == "") {
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
    } else {
   $catid = intval($catid);
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories WHERE catid='$catid' ORDER BY sid DESC LIMIT 10");
    }


This section can be changed to:
Code:
    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE catid='$cat' ORDER BY sid DESC LIMIT 10";

    $result = $db->sql_query($sql);
Reason for this change is that $cst is forced to be a number not text so why waste a sql query tring to find a catid for title comparision?
Next I added
Code:
} elseif ($topic != "") {

    $sql = "SELECT sid, title FROM ".$prefix."_stories WHERE topic='$topic' ORDER BY sid DESC LIMIT 10";
    $result = $db->sql_query($sql);

Before the backend.php file would list the last 10 articles or the last 10 articles in a selected category. With mine it will also allow the last 10 articles in a selected topic to be listed. The samples I gave were based on the original 0.91 feed with CS's fixes.

Onto your question about how my 0.91 feed looks like the 2.0 feed. If you view the source of each feed you will see much more data in the 2.00 feed then in hte 0.91 but it greatly depends on your feed reader. In nuke you will only see what FB decided you need to see not what the full feed gives.
 
sixonetonoffun







PostPosted: Sun Aug 29, 2004 10:09 am Reply with quote

Try this until someone comes up with something cleaner. [ Only registered users can see links on this board! Get registered or login! ]
I'm sure it misses something but works on the basic entities used for copyright euro trademark and more.
 
64bitguy







PostPosted: Sun Aug 29, 2004 10:13 am Reply with quote

Quote:
Onto your question about how my 0.91 feed looks like the 2.0 feed. If you view the source of each feed you will see much more data in the 2.00 feed then in hte 0.91 but it greatly depends on your feed reader. In nuke you will only see what FB decided you need to see not what the full feed gives.


Well given this is all about PHP-Nuke sites viewing PHP-Nuke sites, I think it's only appropriate that our readers can properly interpret OUR OWN outputs. If not, this entire excersize is somewhat of a waste of time is it not? If we want a real solution, we need to develop one or more backend.php solution(s) that output the data in the UTF-8 format so AT LEAST PHP-Nuke sites can properly interpret, import and present data from other PHP-Nuke sites. I mean, not go off or anything, but who do we think is reading our outputs? NON-PHP-Nuke sites? Not likely, to say the least.


Last edited by 64bitguy on Sun Aug 29, 2004 10:26 am; edited 1 time in total 
sixonetonoffun







PostPosted: Sun Aug 29, 2004 10:24 am Reply with quote

Whats with the tude there? The reader in phpnuke is way out dated and the file I posted above will do what you want I believe.
 
64bitguy







PostPosted: Sun Aug 29, 2004 10:29 am Reply with quote

Nice try, but no, it doesn't work six.
 
sixonetonoffun







PostPosted: Sun Aug 29, 2004 10:34 am Reply with quote

Works for me in nuke, postnuke, validaters and magpie could it be your using some really dated code?
 
Deseroka







PostPosted: Sun Aug 29, 2004 10:41 am Reply with quote

I still get the "problem with news from this site" six==but you know if it can be messed up--I can do it!
 
64bitguy







PostPosted: Sun Aug 29, 2004 10:42 am Reply with quote

I can't speak for the rest of the group, but I'm using 7.4 patched 2.5. All files have been verified as the latest and greatest (which regarding news probably isn't saying a whole lot).

Quote:
// *************************************************
// ** cfx-NewsGrabber **
// ** version v0.6, codename: "Greenfield" **
// ** **
// ** version 0.6 was released 07.02.2004 **
// ** **
// ** Coded by Ohad Barzilay (civax / cfxweb.net) **
// *************************************************


All I get is this in my reader.

".htmlspecialchars($title)."
 
Deseroka







PostPosted: Sun Aug 29, 2004 10:48 am Reply with quote

I just tested your backend on my site 64bit---reads good for me
 
sixonetonoffun







PostPosted: Sun Aug 29, 2004 10:52 am Reply with quote

[ Only registered users can see links on this board! Get registered or login! ]
That site is running specifically the configuration you listed. The only issue with any of the feeds as you can see if the one with my theme and the default rss block ravens feed is running in.
 
64bitguy







PostPosted: Sun Aug 29, 2004 11:09 am Reply with quote

My backend is feeding fine (though I don't have any single quotes or periods in any of my news items for the reasons described above). I'm also still using the old Chatserv version of backend.php for feeding (as provided by Chatserv in 7.4 Patched 2.5)

I can't read the [ Only registered users can see links on this board! Get registered or login! ] and I still have the problems described in this post, and a couple others on this site.
 
BobMarion







PostPosted: Sun Aug 29, 2004 11:44 am Reply with quote

sixonetonoffun wrote:
Try this until someone comes up with something cleaner. [ Only registered users can see links on this board! Get registered or login! ]
I'm sure it misses something but works on the basic entities used for copyright euro trademark and more.


I'm going to give this one a try. I like it since it strips the superhtmlenties out and leaves the normal ones.

I'll post back on how well it validates for me.
 
64bitguy







PostPosted: Sun Aug 29, 2004 3:04 pm Reply with quote

Let me know if you come up with a way to incorporate Magpie into Nuke as the reader.
 
BobMarion







PostPosted: Sun Aug 29, 2004 3:34 pm Reply with quote

64bitguy wrote:
Let me know if you come up with a way to incorporate Magpie into Nuke as the reader.


That I'm not even going to try to do. I have alot of work I have yet to do on my own scripts to take time away from them to upgrade PHP-Nuke's reader.
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Aug 29, 2004 9:07 pm Reply with quote

Deseroka,

I just tried my backend.php from your website and it reads just fine.
 
View user's profile Send private message
64bitguy







PostPosted: Tue Aug 31, 2004 12:24 am Reply with quote

Just so everyone is straight on this, after several attempts to work these issues out, it has been determined that the other code provided in this thread is bad and non-functional for distributing properly formatted feeds.

The below code is what should be used in your backend.php files and not any other code in this thread.

This code enables apostrophes ('), periods(.), parentheses() and other symbols from being inadvertently stripped from your feeds to sites that utilize your backend.php. This is also the code provided by Chatserv in his "Patched 2.5" solution available at [ Only registered users can see links on this board! Get registered or login! ]

The only modification to this code is the exclusion of the mainfile.php section that prevents backend.php from creating problems with Sentinel as was originally provided by Bob Marion. This code has been tested and functions properly as indicated by the posts found at: [ Only registered users can see links on this board! Get registered or login! ]

Again, the other code provided in this thread SHOULD NOT BE USED as it corrupts the data in your feeds, whereas this code does not.

Code:
<?php 


/************************************************************************/
/* PHP-NUKE: Advanced Content Management System                         */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* 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.       */
/*                                                                      */
/************************************************************************/
/* Additional security checking code 2003 by chatserv                   */
/* http://www.nukefixes.com -- http://www.nukeresources.com             */
/************************************************************************/

//include("mainfile.php");
require_once("config.php");
require_once("db/db.php");
$row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_config"));
$sitename = $row[sitename];
$nukeurl = $row[nukeurl];
$backend_title = $row[backend_title];
$backend_language = $row[backend_language];

header("Content-Type: application/rss+xml");
    $cat = intval($cat);
if ($cat != "") {
    $catid = $db->sql_fetchrow($db->sql_query("SELECT catid FROM ".$prefix."_stories_cat WHERE title LIKE '%$cat%' LIMIT 1"));
    if ($catid == "") {
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
    } else {
   $catid = intval($catid);
   $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories WHERE catid='$catid' ORDER BY sid DESC LIMIT 10");
    }
} else {
    $result = $db->sql_query("SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10");
}

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n";
echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
echo "<rss version=\"0.91\">\n\n";
echo "<channel>\n";
echo "<title>".htmlspecialchars($sitename)."</title>\n";
echo "<link>$nukeurl</link>\n";
echo "<description>".htmlspecialchars($backend_title)."</description>\n";
echo "<language>$backend_language</language>\n\n";

while ($row = $db->sql_fetchrow($result)) {
    $rsid = intval($row['sid']);
    $rtitle = $row['title'];
    echo "<item>\n";
    echo "<title>".htmlspecialchars($rtitle)."</title>\n";
    echo "<link>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$rsid</link>\n";
    echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>";

?>


Special thanks to Chatserv for providing this excellent code and thank you AGAIN to Raven for testing this code and confirming its validity!
 
VxJasonxV
New Member
New Member



Joined: Sep 01, 2004
Posts: 6

PostPosted: Tue Aug 31, 2004 11:53 pm Reply with quote

And what about is RSS2? Sad
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel(tm)

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 ©