1 (edited by daris 2008-03-03 15:17)

Topic: include/cache.php - why not file_put_contents() instead fwrite ?

My hosting (hostsnake.com) disabled function fopen and when i tried run punbb it shows me an error:

Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory 'cache'

but this directory exists and has chmod 777. After removing @ from fopen it says:

Warning: fopen() has been disabled for security reasons in /www/hostsnake.com/d/a/r/daris/htdocs/include/cache.php on line 91

I replaced fwrite with file_put_contents and now it works.

Why cache.php not use file_put_contents instead of fwrite?

Re: include/cache.php - why not file_put_contents() instead fwrite ?

Because file_put_contents is a PHP5 only function.
And I have NEVER heard of a host removing fopen like that. I would get a new host if I were you, it doesn't seem like they know what they're doing.

3 (edited by daris 2008-03-03 15:25)

Re: include/cache.php - why not file_put_contents() instead fwrite ?

And I have NEVER heard of a host removing fopen like that.

I never heard too wink

I found this topic on hostsnake forums.

But in ealier version of punbb i saw in functions.php code like this:

if (!function_exists('file_get_contents'))
function file_get_contents...
fopen...

Re: include/cache.php - why not file_put_contents() instead fwrite ?

That doesn't mean completely disabling the fopen function is something a competent host would do wink

And yes, we reimplemented var_export in 1.2 because we needed that functionality and couldn't get it another way. fopen/fwrite provides equivalent functionality to the function you're talking about, however, and shouldn't be disabled in any case.

To be honest, this is like saying we should be using the ereg functions because some host could disable the preg functions. Yes, they could. If they do, you should find a host that knows what they're doing.