| Author |
Message |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Wed Aug 25, 2004 9:23 pm |
|
Any site running NukeSentinel(tm) that allows other sites to add their backend.php news feed needs to do the following:
Open backend.php in a text editor and find: | Code: | include("mainfile.php");
header("Content-Type: text/xml"); |
Replace it with: | Code: | //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"); |
NukeSentinel(tm) is blocking outside sites from adding your backend.php into a block on their sites and the above corrects it.
UPDATED: This post has been updated to include those items found below. |
Last edited by BobMarion on Thu Aug 26, 2004 10:15 am; edited 2 times in total |
|
|
 |
64bitguy The Mouse Is Extension Of Arm

Joined: Mar 06, 2004 Posts: 1156 Location: Sanbornton, NH USA
|
Posted:
Thu Aug 26, 2004 2:37 am |
|
Excellent Development Support = Going to lookup a solution to a problem that you just found, only to find that an annoucement was posted 4 hours earlier.
I'm getting the feeling that Bob:
A) Is A Voodoo Priest.
B) Is spending non-coding time developing ESP skills.
C) Has one hell of a crystal ball.
D) Got an email from someone that is syndicating RSS feeds wondering why they won't load anymore.
In any event, its all good to me! Thanks! |
|
|
|
 |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Thu Aug 26, 2004 2:39 am |
|
To confess, it came from a bug report on my site  |
|
|
|
 |
Muffin Client

Joined: Apr 10, 2004 Posts: 649 Location: UK
|
Posted:
Thu Aug 26, 2004 5:48 am |
|
Thanks Bob.
I had a newsfeed on my site, but in a block. It worked fine with Sentinel.
The only thing that went wonky was when the newsfeed site was down and it screwed up the display on the page. |
|
|
|
 |
mesa New Member


Joined: Jul 30, 2004 Posts: 1
|
Posted:
Thu Aug 26, 2004 6:34 am |
|
Here are the results after reediting with the code on the backend.php
--------------------------------------------------------
Sorry
This feed does not validate.
Your feed appears to be encoded as "ISO-8859-1", but your server is reporting "US-ASCII" [help]
line 9, column 26: title contains bad characters (2 occurrences) [help]
<title>Ravens PHP Scripts </title> ^
line 10, column 6: link must be a full and valid URL [help]
<link></link> ^
line 15, column 19: title contains bad characters (4 occurrences) [help]
<title>NukeSentinel and RSS feeds</title> ^
line 16, column 57: link must be a full and valid URL (10 occurrences) [help]
<link>/modules.php?name=News&file=article&sid=471</link> ^
Source:
Rssults are pull from
to reconfirm |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Aug 26, 2004 6:44 am |
|
Doesn't really say if that validater supports out of date rss 0.91 I'd guess it is for 2.0 but anyway if you hunt around there are some efforts to create updated backend.php out there. |
|
|
|
 |
molten2 New Member


Joined: Jun 27, 2004 Posts: 16
|
Posted:
Thu Aug 26, 2004 6:54 am |
|
Eliminate bad char and try to add this line to Bob's code.
| Code: |
$nukeurl = $row[nukeurl];
|
This solution work for me and validate correctly
bye |
Last edited by molten2 on Thu Aug 26, 2004 7:22 am; edited 1 time in total |
|
|
 |
GeekyGuy Client

Joined: Jun 03, 2004 Posts: 302 Location: Huber Heights Ohio
|
Posted:
Thu Aug 26, 2004 7:11 am |
|
I'll get this info added to the next update to the NukeSentinel(tm) User Guide FAQ. |
|
|
 |
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Aug 26, 2004 7:16 am |
|
I have to ask what setting has to be anabled to create this issue Bob? Because I just tested a feed and it seems to function ok without the additional code? So I assume ther are specific circumstances under which there is an issue?? |
|
|
|
 |
molten2 New Member


Joined: Jun 27, 2004 Posts: 16
|
Posted:
Thu Aug 26, 2004 7:27 am |
|
in my experience the news feeds don't work only for sentinel protected sites... |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Aug 26, 2004 7:46 am |
|
Yes the feed comes from a Sentinel protected site but its shown on a PostNuke site in a core RSS block. Thats why I was wondering what circumstances created an issue with backend.php The one I use is slightly modified but not a lot. Validates fine runs on the mentioned block fine without the updates above? The only blocker not active on the site is the proxy blocker. I surrender! If it's not borke I'm not fixing it lol! |
|
|
|
 |
molten2 New Member


Joined: Jun 27, 2004 Posts: 16
|
Posted:
Thu Aug 26, 2004 8:55 am |
|
try to use the rss reader coming from your_account module in a sentinel (2.0.1) protected site...
instead of reading it with a block. |
|
|
|
 |
chatserv The Mouse Is Extension Of Arm

Joined: May 02, 2003 Posts: 1396 Location: Puerto Rico
|
Posted:
Thu Aug 26, 2004 9:17 am |
|
If it works used on a block but doesn't on the YA module try editing its index, find:
| Code: | if ($fp) {
fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n"); |
change to:
| Code: | if ($fp) {
if ($rdf['query'] != '')
$rdf['query'] = "?" . $rdf['query'];
fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n"); |
That is the only variant i could find between the two. |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Aug 26, 2004 9:51 am |
|
Thanks molten2
I'd have never thought of using the reader in Your Account its not a feature I really think of often.
Though Ravens site will read in the reader mine won't pre or post changes guess I'll have to dig a little more. Works in the blocks fine both before and after but the reader it doesn't and also it validated fine before the changes and now it gives a couple xml parse errors Grr!
Guess I'll keep playing with it and read up on the topic a little. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Aug 26, 2004 9:51 am |
|
| molten2 wrote: | Eliminate bad char and try to add this line to Bob's code.
| Code: |
$nukeurl = $row[nukeurl];
|
This solution work for me and validate correctly
bye | I added your url code. Does the feed from here work now? |
|
|
|
 |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Thu Aug 26, 2004 9:58 am |
|
Glad I posted this, used the validator and discovered one other thing.
You also need to change the: | Code: | | header("Content-Type: text/xml"); |
To: | Code: | | header("Content-Type: application/rss+xml"); |
|
|
|
|
 |
molten2 New Member


Joined: Jun 27, 2004 Posts: 16
|
Posted:
Thu Aug 26, 2004 10:01 am |
|
Yes, It works well now
Thank-you all. |
|
|
|
 |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Thu Aug 26, 2004 10:03 am |
|
One thing about title contains bad characters. Since Raven and I both use the (tm) by way of ™ it is getting that error. Until I figure out how to strip out the htmlentities I'll continue to get that error on my feed.
I've updated my backend.php to have this: | Code: | //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"); |
Which got rid of all but the htmlentities error reported.
|
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Aug 26, 2004 10:06 am |
|
So you aren't using the updated header? |
|
|
|
 |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Thu Aug 26, 2004 10:11 am |
|
Yes I am , had to edit the post above. Had two different copies of backend.php open at the same time and copied from the wrong one  |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Aug 26, 2004 10:20 am |
|
Feed works from here on the Your Account from my site ok. I didnt' try it in a block.
I figured out why it was in part working ok on my PostNuke site in the block its because the PostNuke block adds a referer and user-agent to the fput request.
I haven't figured out why the rest was as it was yet so for the time being I have backend.php for nuke and backend1.php for myself. backend1.php has the image and copyright links though the copyright doesn't get parsed in the block as far as I can tell (From syndycation mod which I use if I move news out of the home page to run off a center block on the same site neat trick)
But anyway I can live with this cause no one gives a chit about my feeds but me lol! |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Aug 26, 2004 10:51 am |
|
This fixes the $sitename variable, but not the $backend_title as there is no allowance for the non-space character before the entity. I'm sure it can be tweaked. I hacked some code I found on the net | Code: | //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];
$backend_title = $row[backend_title];
$backend_language = $row[backend_language];
$nukeurl = $row[nukeurl];
$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: application/rss+xml");
|
|
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Aug 26, 2004 11:56 am |
|
Here's the final piece of the puzzle! Find this line | Code: | | echo "<title>".htmlspecialchars($row[title])."</title>\n"; | and modify it to | Code: | $title = $row[title];
$title = stripEntities($title);
echo "<title>".htmlspecialchars($title)."</title>\n"; |
This gives a clean report! |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Aug 26, 2004 12:00 pm |
|
To clarify, I now have this code for backend.php (this is from v6.9) | 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. */
/************************************************************************/
//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];
$backend_title = $row[backend_title];
$backend_language = $row[backend_language];
$nukeurl = $row[nukeurl];
$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: application/rss+xml");
if ($cat != "") {
$sql = "SELECT catid FROM ".$prefix."_stories_cat WHERE title LIKE '%$cat%' LIMIT 1";
$result = $db->sql_query($sql);
$catid = $db->sql_fetchrow($result);
if ($catid == "") {
$sql = "SELECT sid, title FROM ".$prefix."_stories ORDER BY sid DESC LIMIT 10";
$result = $db->sql_query($sql);
} else {
$sql = "SELECT sid, title FROM ".$prefix."_stories WHERE catid='$catid' 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\" 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)) {
echo "<item>\n";
$title = $row[title];
$title = stripEntities($title);
echo "<title>".htmlspecialchars($title)."</title>\n";
echo "<link>$nukeurl/modules.php?name=News&file=article&sid=$row[sid]</link>\n";
echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>";
?> |
|
Last edited by Raven on Thu Aug 26, 2004 12:59 pm; edited 2 times in total |
|
|
 |
BobMarion Former Admin in Good Standing

Joined: Oct 30, 2002 Posts: 1043 Location: RedNeck Land (known as Kentucky)
|
Posted:
Thu Aug 26, 2004 12:55 pm |
|
hehehehe, backend.php hasn't changed since 6.5 thru 7.4 with the exception of Chat's fixes
Anyway, the reason for commenting out the mainfile.php include line is this.
1) Your site is running NukeSentinel
2) I try to add your backend.php to my site thru Blocks Admin
3) With the mainfile pulled into backend.php my sites admin returns an error on adding yoru backend.php:
There is a problem with the RSS file URL
Please check the URL and RSS file name, then try again. |
|
|
|
 |
|
|
|
|