Hi,
Modx 2.2.10
MySQL : 5.5.32
PHP : 5.4.19
I want to create text file with this snippet :
$parent = $modx->runSnippet('UltimateParent',array('topLevel' => 3));
$path = 'assets/contenu/docs/bibliographies/biblio'.$parent.'.txt';
$filename = MODX_BASE_PATH . $path;
if (file_exists($filename))
{
// If File exist, get the content
return file_get_contents($filename);
} else {
// Create file, if the file does not exist
$fp =fopen($filename,'w');
fclose($fp);
};
The « file_get_contents » is working fine, but the « fopen » does not working.
I got this message sometimes :
Parse error: syntax error, unexpected '<' in /home/ceromqcc/public_html/core/cache/includes/elements/modsnippet/70.include.cache.php on line 7
Something strange with the « fopen », the snippet does not want to save it.
I have to pass by PhpMyAdmin to write it directly in the database.
Does anyone ever experience this problem?
Thank you
[ed. note: jber last edited this post 12 years, 10 months ago.]
-
☆ A M B ☆
- 24,524 Posts
Sounds like a mod_security type problem; something doesn't like a form's POST with fopen in it. Usually those will just abort the whole POST process with some kind of server error, though.
Thank SottWell,
I will contact my Web Hosting Company, with this problem.
It sounds like you have two problems. The snippet not saving is likely mod_security as Susan suggests. The failure of fopen() is more likely a problem with the permissions or ownership of the directory you're writing the file to.
Now I can write a file. But I still can not save my snippet with the «fopen»
I await the response from my Web Hosting Company about this problem. As soon as I have their answer to my problem, I will share it with you.
Thank
SottWell was right, it was the mod_security.
They disabled mod_security et voila! Now I can save my snippet.