PDA

View Full Version : Pausing rss scroller-I give up trying to fetch RSS feed.



mmgoodwin2
04-05-2007, 04:21 AM
1) Script Title: scrollerbridge.php

2) Script URL (on DD): rsspausescroller.zip

3) Describe problem: my site is freetoiletbrush.com ...the scroller shows up and then ... "I give up trying to fetch RSS feed." displays.

I got the url_fopen enabled through my server. but still does not work. :>(

The script that I uploaded is: (thanks for any help)

<?php

/*
======================================================================
Pausing RSS Scroller bridge script
Author: Dynamic Drive (http://www.dynamicdrive.com)
Created: March 16th, 2006.
Function: Converts requested RSS feed from lastRSS into JavaScript array
======================================================================
*/

// include lastRSS
include "lastrss.php"; //path to lastRSS.php on your server relative to scrollerbridge.php

// Create lastRSS object
$rss = new lastRSS;
$rss->cache_dir = 'cache'; //path to cache directory on your server relative to scrollerbridge.php. Chmod 777!
$rss->date_format = 'M d, Y g:i:s A'; //date format of RSS item. See PHP date() function for possible input.
$rss->cache_time = 10; //Global cache time before fetching RSS feed again, in seconds.

// Define your list of RSS URLs- "RSS_id"=> "URL to RSS feed"
$rsslist=array(
"cnn" => "http://rss.cnn.com/rss/cnn_topstories.rss",
"bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
"news.com" => "http://news.com.com/2547-1_3-0-5.xml",
"slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
"dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new",
);

//Domains that are authorized to display scroller:
//Seperate multiple domains each with a comma (",")
//For example: $allowedDomains="dynamicdrive.com, javascriptkit.com"
//OR enter a blank string to allow any domain (ie: for RSS feed syndication):
$allowedDomains="";

////Beginners don't need to configure past here////////////////////

Header("content-type: application/x-javascript");
$rssid=$_GET['id'];
$rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("rsscontentdata=\"Error: Can't find requested RSS in list.\"");
$divid=$_GET['divid']; //ID of DIV scroller

// -------------------------------------------------------------------
// checkdomains()- Checks that current site is authorized to display scroller
// -------------------------------------------------------------------

function checkdomains($allowed, $referral){
if ($allowed!=""){
$found=0;
$allowlist=split (",", $allowed);
foreach ($allowlist as $allow){
$allow=trim($allow);
$found+=strpos(" ".$referral, $allow);
}
if (!$found)
die("rsscontentdata=\"This domain isn't authorized to show scroller.\"");
}
}

@checkdomains($allowedDomains, $_SERVER["HTTP_REFERER"]); //check if domain is authorized to display scroller

// -------------------------------------------------------------------
// outputRSS_JS()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format
// -------------------------------------------------------------------

function outputRSS_JS($url, $divid) {
global $rss;
if ($rs = $rss->get($url)){
echo "rsscontentdata.$divid=new Array();\n";
$i=0;
foreach ($rs['items'] as $item) {
echo "rsscontentdata.$divid" . "[$i]={link:\"" . slashit($item[link]) . "\", title:\"" . slashit($item[title]) . "\", description:\"" . slashit($item[description]) . "\", date:\"" . slashit($item[pubDate]) . "\"}\n";
$i++;
}
if ($rs['items_count'] <= 0) { echo "rsscontentdata=\"Sorry, no items found in the RSS file\""; }
}
else {
echo "rsscontentdata=\"Sorry: It's not possible to reach RSS file $url\"";
// All else fails
}
}

function slashit($what){ //Encode text for storing in JavaScript array
$newstring=str_replace('&apos;', '\'', $what); //replace those half valid apostrophe entities with actual apostrophes
return rawurlencode($newstring);
}

// ===============================================================================

outputRSS_JS($rssurl, $divid);

?>

thetestingsite
04-05-2007, 04:55 AM
What happens when you access scrollerbridge.php directly like so?


scrollerbridge.php?id=cnn

thetestingsite
04-06-2007, 02:51 AM
I just looked into the problem on your site, and have come to the conclusion that the file "lastrss.php" was not uploaded to your server. You must have this on the server in order for the script to function properly. If you do have it on the server; but in a seperate directory, you must specify the location on this line:


include "lastrss.php"; //path to lastRSS.php on your server relative to scrollerbridge.php


Edit the part in red to point to the location of this file.
Hope this helps.