Error in menu - functions fopen,fwrite, fclose have permition problems

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
kolesar

Error in menu - functions fopen,fwrite, fclose have permition problems

Post by kolesar »

Hi there folks  ;D

First thing first: I realy like using CMSMS, It is a great piece of software and I would like to thank all the contributers to this project. GREAT WORK GUYS! When I will get some money, I will sure donate at my best.

Ok now lets get to the real problem:

- I'm using this version: CMS Made Simple 1.0.2 "Maui"

and for the last couple of days I'm getting this error message:
Warning: fopen(/home/bla bla bla/domains/mysite.com/public_html/tmp/cache/contentcache.php) [function.fopen]: failed to open stream: Permission denied in /home/blablabla/domains/mysite.com/public_html/lib/classes/class.contentoperations.inc.php on line 557

Warning: fwrite(): supplied argument is not a valid stream resource in /home/blablabla/domains/mysite.com/public_html/lib/classes/class.contentoperations.inc.php on line 558

Warning: fclose(): supplied argument is not a valid stream resource in /home/blablabla/domains/mysite.com/public_html/lib/classes/class.contentoperations.inc.php on line 559


this error meaasge is located here:
Image
and just above the menu in the "frontend" of my page

I've allready searcshe your forum for simmilar problems and found this topics:
http://forum.cmsmadesimple.org/index.ph ... 064.0.html
http://www.google.com/translate?u=http% ... en&ie=UTF8
http://forum.cmsmadesimple.org/index.ph ... l#msg37979

If I have understood this posts in the right way - to fix this problem, I must set chmod 777 to tmp/cache/contentcache.php
but, here comes the problem:
When I set chmod 777 to this file, error message dissapears ...  ???
but in some time this error massage comes back ??? and the chmod is back to 644  :o

What should I do?
Please help me  :-[
Last edited by kolesar on Sat Jan 13, 2007 3:17 pm, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Error in menu - functions fopen,fwrite, fclose have permition problems

Post by Dee »

The webserver needs to be able to write to the Smarty cache directories (tmp/cache and tmp/templates_c), make sure you set the right permissions on the directories as well, not only the files inside.
Chmod 777 isn't really needed, you could also change ownership of the tmp/cache and tmp/templates_c to apache/nobody for example.

Regards,
D
kolesar

Re: Error in menu - functions fopen,fwrite, fclose have permition problems

Post by kolesar »

But I have allready set chmod 777 to both directories

/tmp/cache - 777
/tmp/templates_c - 777
/tmp - 755

this is my current chmod for the listed directories
kolesar

Re: Error in menu - functions fopen,fwrite, fclose have permition problems

Post by kolesar »

anybody? help me over here  :-[ :-\ please  :'(
kolesar

Re: Error in menu - functions fopen,fwrite, fclose have permition problems

Post by kolesar »

Ok here is what I think that might solve my problem:


look at this file: lib/classes/class.content.inc.php
line 1233: $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php';

the variable $contentcache contains the string that is a path to contentcache.php
... so contentcache.php file must be CHMOD 777 in order to fix my problem

this variable is also found here (the error lines 557 to 559 in /lib/classes/class.contentoperations.inc.php):
here are the lines from 554 to 560 in class.contentoperations.inc.php, where the error seems to appear

if (!$loadedcache && $usecache)
{
debug_buffer("Serializing...");
$handle = fopen($cachefilename, "w");
fwrite($handle, ''.serialize($tree));
fclose($handle);
}

so what if i would add this line:
would that solve my problem?

if (!$loadedcache && $usecache)
{
debug_buffer("Serializing...");
$handle = fopen($cachefilename, "w");
                            chmod($cachefilename, 777);
fwrite($handle, ''.serialize($tree));
fclose($handle);
}
Locked

Return to “CMSMS Core”