From 9741be1a19dd09fe6a5b4f7c92e2b2d57399bd21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 27 Feb 2009 15:55:02 +0000 Subject: [PATCH] WRITE_FILLE() rewritten to try to set CHMOD, thanks to Profi-Concept --- inc/functions.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 0f206df6d0..a55dda49c1 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3050,10 +3050,22 @@ function READ_FILE ($FQFN, $sqlPrepare = false) { // Writes content to a file function WRITE_FILE ($FQFN, $content) { + // Is the file writeable? + if (((FILE_READABLE($FQFN)) && (!is_writeable($FQFN))) && (!chmod($FQFN, 0644)) { + // Not writeable! + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN))); + + // Failed! :( + return false; + } // END - if + + // By default all is failed... + $return = false; + // Is the function there? if (function_exists('file_put_contents')) { // Write it directly - file_put_contents($FQFN, $content); + $return = file_put_contents($FQFN, $content); } else { // Write it with fopen $fp = fopen($FQFN, 'w') or mxchange_die("Cannot write file ".basename($FQFN)."!"); @@ -3061,8 +3073,11 @@ function WRITE_FILE ($FQFN, $content) { fclose($fp); // Set CHMOD rights - chmod($FQFN, 0644); + $return = chmod($FQFN, 0644); } + + // Return status + return $return; } // Generates an error code from given account status -- 2.39.5