Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   This topic is locked: you cannot edit posts or make replies.    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: Wed Aug 25, 2004 9:23 pm Reply with quote

Any site running NukeSentinel™ 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™ 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.

_________________
Bob Marion
Codito Ergo Sum
http://www.nukescripts.net

Last edited by BobMarion on Thu Aug 26, 2004 10:15 am; edited 2 times in total 
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 2:37 am Reply with quote

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!

_________________
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 2:39 am Reply with quote

To confess, it came from a bug report on my site Smile
 
Muffin
Client



Joined: Apr 10, 2004
Posts: 649
Location: UK

PostPosted: Thu Aug 26, 2004 5:48 am Reply with quote

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.

_________________
Classic Mini rules the bends & bends the rules!
[img] 
View user's profile Send private message
mesa
New Member
New Member



Joined: Jul 30, 2004
Posts: 1

PostPosted: Thu Aug 26, 2004 6:34 am Reply with quote

Here are the results after reediting with the code on the backend.php

[ Only registered users can see links on this board! Get registered or login! ]
--------------------------------------------------------
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&amp;file=article&amp;sid=471</link> ^
Source: [ Only registered users can see links on this board! Get registered or login! ]



Rssults are pull from [ Only registered users can see links on this board! Get registered or login! ]

to reconfirm http://feeds.archive.org/validator/check.cgi?url=http%3A%2F%2Fravenphpscripts.com%2Fbackend.php
 
View user's profile Send private message Visit poster's website
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Thu Aug 26, 2004 6:44 am Reply with quote

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.

_________________
[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
molten2
New Member
New Member



Joined: Jun 27, 2004
Posts: 16

PostPosted: Thu Aug 26, 2004 6:54 am Reply with quote

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 [ Only registered users can see links on this board! Get registered or login! ]

bye


Last edited by molten2 on Thu Aug 26, 2004 7:22 am; edited 1 time in total 
View user's profile Send private message Send e-mail Visit poster's website
GeekyGuy
Client



Joined: Jun 03, 2004
Posts: 302
Location: Huber Heights Ohio

PostPosted: Thu Aug 26, 2004 7:11 am Reply with quote

I'll get this info added to the next update to the NukeSentinel™ User Guide FAQ.

_________________
"The Daytona 500 is ours! We won it, we won it, we won it!", Dale Earnhardt, February 15th, 1998, Daytona 500 
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
sixonetonoffun







PostPosted: Thu Aug 26, 2004 7:16 am Reply with quote

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







PostPosted: Thu Aug 26, 2004 7:27 am Reply with quote

in my experience the news feeds don't work only for sentinel protected sites...
 
sixonetonoffun







PostPosted: Thu Aug 26, 2004 7:46 am Reply with quote

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







PostPosted: Thu Aug 26, 2004 8:55 am Reply with quote

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
Member Emeritus



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Thu Aug 26, 2004 9:17 am Reply with quote

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.
 
View user's profile Send private message Visit poster's website
sixonetonoffun







PostPosted: Thu Aug 26, 2004 9:51 am Reply with quote

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: 17088

PostPosted: Thu Aug 26, 2004 9:51 am Reply with quote

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 [ Only registered users can see links on this board! Get registered or login! ]

bye
I added your url code. Does the feed from here work now?
 
View user's profile Send private message
BobMarion







PostPosted: Thu Aug 26, 2004 9:58 am Reply with quote

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







PostPosted: Thu Aug 26, 2004 10:01 am Reply with quote

Yes, It works well now Smile
Thank-you all.
 
BobMarion







PostPosted: Thu Aug 26, 2004 10:03 am Reply with quote

One thing about title contains bad characters. Since Raven and I both use the (tm) by way of &trade; 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.
[ Only registered users can see links on this board! Get registered or login! ]
 
Raven







PostPosted: Thu Aug 26, 2004 10:06 am Reply with quote

So you aren't using the updated header?
 
BobMarion







PostPosted: Thu Aug 26, 2004 10:11 am Reply with quote

Yes I am Smile, had to edit the post above. Had two different copies of backend.php open at the same time and copied from the wrong one Bang Head
 
sixonetonoffun







PostPosted: Thu Aug 26, 2004 10:20 am Reply with quote

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 [ Only registered users can see links on this board! Get registered or login! ] 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







PostPosted: Thu Aug 26, 2004 10:51 am Reply with quote

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







PostPosted: Thu Aug 26, 2004 11:56 am Reply with quote

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! [ Only registered users can see links on this board! Get registered or login! ]
 
Raven







PostPosted: Thu Aug 26, 2004 12:00 pm Reply with quote

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&amp;file=article&amp;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







PostPosted: Thu Aug 26, 2004 12:55 pm Reply with quote

hehehehe, backend.php hasn't changed since 6.5 thru 7.4 with the exception of Chat's fixes Wink

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.
 
Display posts from previous:       
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 ©