Page 1 of 1

RDF content include

Posted: Sat Mar 01, 2003 5:34 pm
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.

Posted: Sat Mar 01, 2003 7:28 pm
by Stoker
you cache dir is
/var/www/html/newsFeeds/cache/
?

Posted: Sat Mar 01, 2003 8:27 pm
by scarabatwork
That's right... called by 'cache/' . $filename

Posted: Sat Mar 01, 2003 8:39 pm
by Stoker
is the file including that function in a different directory than the page being initially loaded by trhe web server?

Posted: Sat Mar 01, 2003 10:58 pm
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/

Posted: Sat Mar 01, 2003 11:10 pm
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..

Posted: Sat Mar 01, 2003 11:37 pm
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!