WRITE_FILLE() rewritten to try to set CHMOD, thanks to Profi-Concept
authorRoland Häder <roland@mxchange.org>
Fri, 27 Feb 2009 15:55:02 +0000 (15:55 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 27 Feb 2009 15:55:02 +0000 (15:55 +0000)
inc/functions.php

index 0f206df6d0b448c0c4c7200a2be7d9d2eb2bdf7b..a55dda49c181db6def6913bd2a896880de657fb4 100644 (file)
@@ -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