RSS Feed Using PHP

apps

#1

Im relatively new to scripting and have been using canned ones from a site called Dynamic Drive.

No matter what I do, I cannot get this feed to work for me.
Nor does the demo.htm work for me.

The script is at:
http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/index.htm

I have made sure to point to the rsspausescoller file on my website.
(http://www.protestantlawyersny.org)
I have made sure to point to the PHP file in /lastRSS

The error message I get is:
Sorry: It’s not possible to reach RSS file http://rss.cnn.com/rss/cnn_topstories.rss
I give up trying to fetch RSS feed.

Please…does anyone know what I am doing wrong?
Is there something in Dreamhost that requires me to unlock the cache directory or do something I am not doing?

Thanks in advance.

Nelson


#2

It may be that the feed is not available or is at a different location. Give it a couple of days and see if it works.

Sometimes these scripts use /tmp as the temp and your script may need some adjustment if it cannot access /tmp. There have been instances when the temp folder was not set up correctly by DreamHost (allegedly) so that may be a point to ponder also.


[color=#6600CC]Norm[/color]

Opinions are my own views and are not the views of DreamHost.
Any advice offered by me should be acted upon only at your own risk.


#3

It may be that the canned script is attempting to fetch the feed using the full URL (anything beginning with http://). For security reasons, DreamHost has disabled a feature called “URL file access”, so any canned script that relies on this feature will not work.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#4

Thank you for your responses.
I have a feeling it is something peculiar to Dreamhost, which is why I asked here.

It works on the dynamic drive site, and it works for other people on their sites, for example:

http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/index.htm

http://www.norfolk-careers.co.uk/LMI/index.asp

When I try to even run the demo, AS IS, it wont work.

I tried it both ways, with the url specified as is -

and the way they suggest:

var bridgepath=“http://www.mysite.com/lastrss/scrollerbridge.php

and neither way works. I assume Dreamhost disables something.

I also had problems with a PHP-CGI form:

http://www.thesitewizard.com/wizards/feedbackform.shtml

I am really baffled guys- usually I can get these scripts to work for me!

Thanks for all your help!

Nelson


#5

Your script is probably using “fopen()” or similar, and these are disabled by DreamHost. DreamHost claims cURL is faster and safer,
http://wiki.dreamhost.com/index.php/CURL

Jack.
$97.00 off all yearly DreamHost signups, use code JED


#6

Thanks very much!

I didnt write this script, nor do I know how to, or to correct the problem, but I will read the information and see if there isnt something I can do.

Apparently, these commands will disable any such script run on Dreamhost.

Nelson


#7

Thanks to you, Jack, I have located the problem and am posting it here to alert others.

"This script works by first relying on a simple PHP RSS parser called LastRSS to retrieve/cache an RSS feed. "

When I searched LastRSS, I indeed found the “fopen” commands that you speak about:

if ($f = @fopen($cache_file, ‘w’)) {

if ($f = @fopen($rss_url, ‘r’)) {

If these commands are disabled, it well explains why this doesn’t work. I will attempt to substitute cURL commands as per the wikipedia article.

Many thanks for helping!!

Nelson


#8

I hope you’ll post some workaround code that can be substituted for “fopen()”.

Jack.
$97.00 off all yearly DreamHost signups, use code JED


#9

I’m not a programmer, so I frankly do not know how to fix up this canned RSS feed script, however, there is a workaround I found at:

http://www.wiki.dreamhost.com/index.php/Talk:Allow_url_fopen

"When the change was first made, a number of my scripts broke – but honestly, it was only a couple minute fix. Tell the extension developer to give -you- a break, fopen is not necessary to get remote files and is rather weak compared to curl.

Here’s a php class I use to get remote files as strings – feel free to pass it on to that developer. "

class curl {
var $timeout;
var $url;
var $file_contents;
function getFile($url,$timeout=0) {

use CURL library to fetch remote file

$ch = curl_init();
$this->url = $url;
$this->timeout = $timeout;
curl_setopt ($ch, CURLOPT_URL, $this->url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
$this->file_contents = curl_exec($ch);
if ( curl_getinfo($ch,CURLINFO_HTTP_CODE) !== 200 ) {
return('Bad Data File '.$this->url);
} else {
return $this->file_contents;
}
}
}


#10

Hmmm. I’m guessing this is potentially the source of some problems I’m having with some of the plugins for Wordpress. However, when I’ve grepped through the plugin files for any fopen or include operations, I’ve come up with no matches. Are there other directives that are being tripped with the allow_url_fopen being turned off? I looked through the dreamwiki info, but didn’t see anything other than fopen and include listed…?