From: Roland Häder Date: Fri, 27 Feb 2009 15:55:02 +0000 (+0000) Subject: WRITE_FILLE() rewritten to try to set CHMOD, thanks to Profi-Concept X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=9741be1a19dd09fe6a5b4f7c92e2b2d57399bd21;ds=sidebyside WRITE_FILLE() rewritten to try to set CHMOD, thanks to Profi-Concept --- 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