// 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)."!");
fclose($fp);
// Set CHMOD rights
- chmod($FQFN, 0644);
+ $return = chmod($FQFN, 0644);
}
+
+ // Return status
+ return $return;
}
// Generates an error code from given account status