RDF content include

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
scarabatwork
Forum Newbie
Posts: 6
Joined: Sat Mar 01, 2003 5:34 pm
Location: Dallas, TX
Contact:

RDF content include

Post by scarabatwork »

I have the following code in include the content on my website, but I'm having a little trouble with it. The script isn't mine, it came from: http://www.cyberfly.net so all kudos to him for this work.

Code: Select all

function rdfshow($rdffile) {

	$filename = CACHEPATH . md5($rdffile);
	//$filename = CACHEPATH . $rdffile;
	echo $filename . '<br>';
	if(!file_exists($filename)) &#123;
		$fp = fopen($filename, "w");
		if (!($fp == '')) &#123;
			fputs($fp, join('', file($rdffile)));
			fclose($fp);
		&#125;
	&#125; else &#123;
		echo 'no, this is true';
		exit();
		if((time() - filemtime($filename)) > CACHETIME) &#123;
			$fp = fopen($filename, "w");
			if (!($fp == '')) &#123;
				fputs($fp, join('', file($rdffile)));
				fclose($fp);
			&#125;
		&#125;
	&#125;
where = a url to an existing (tested) rdf. The error that I get is:

Warning: fopen("cache/bca9646b3da7363b1a883e0eccc0e3b9", "w") - No such file or directory in /var/www/html/newsFeeds/include.rdfshow.php on line 29

line 29 is:

Code: Select all

$fp = fopen($filename, "w");
the directory "cache" is set chmod 777 on my site and I've tested another script to write files to this directory without any problems, but for some reason, this one doesn't want to work.

Any help would be appreciated.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

you cache dir is
/var/www/html/newsFeeds/cache/
?
User avatar
scarabatwork
Forum Newbie
Posts: 6
Joined: Sat Mar 01, 2003 5:34 pm
Location: Dallas, TX
Contact:

Post by scarabatwork »

That's right... called by 'cache/' . $filename
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

is the file including that function in a different directory than the page being initially loaded by trhe web server?
User avatar
scarabatwork
Forum Newbie
Posts: 6
Joined: Sat Mar 01, 2003 5:34 pm
Location: Dallas, TX
Contact:

Post by scarabatwork »

Yes... the directory structure is as follows:

$root: /var/www/html/

the page is loaded like this:

$root/index.php includes /var/www/html/newsFeeds/index.php which includes the file rdfshow.inc.php also in /var/www/html/newsFeeds/
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

on some php setups/versions the paths are not relative to the file the function is in, but relative to the path of the file first processed by the webserver.. I recommend that you use an absolute path in the defined constant..
User avatar
scarabatwork
Forum Newbie
Posts: 6
Joined: Sat Mar 01, 2003 5:34 pm
Location: Dallas, TX
Contact:

Post by scarabatwork »

Yes... I'm going to try that.. I'm having some strange results with includes anyways, so I think I'll set the include file in php.ini and see what happens.

Thanks for you help!
Post Reply