]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
WRITE_FILLE() rewritten to try to set CHMOD, thanks to Profi-Concept
[mailer.git] / inc / functions.php
index f7c7e5be093bdba37e0ad2cb3ed14c2e8b2c3e2e..a55dda49c181db6def6913bd2a896880de657fb4 100644 (file)
@@ -1245,10 +1245,10 @@ function GEN_RANDOM_CODE ($length, $code, $uid, $DATA="") {
 
        // Build key string
        $keys   = constant('SITE_KEY').":".constant('DATE_KEY');
 
        // Build key string
        $keys   = constant('SITE_KEY').":".constant('DATE_KEY');
-       if (getConfig('secret_key') != null)  $keys .= ":".getConfig('secret_key');
-       if (getConfig('file_hash') != null)   $keys .= ":".getConfig('file_hash');
+       if (isConfigEntrySet('secret_key'))  $keys .= ":".getConfig('secret_key');
+       if (isConfigEntrySet('file_hash'))   $keys .= ":".getConfig('file_hash');
        $keys .= ":".date("d-m-Y (l-F-T)", bigintval(getConfig('patch_ctime')));
        $keys .= ":".date("d-m-Y (l-F-T)", bigintval(getConfig('patch_ctime')));
-       if (getConfig('master_salt') != null) $keys .= ":".getConfig('master_salt');
+       if (isConfigEntrySet('master_salt')) $keys .= ":".getConfig('master_salt');
 
        // Build string from misc data
        $data   = $code.":".$uid.":".$DATA;
 
        // Build string from misc data
        $data   = $code.":".$uid.":".$DATA;
@@ -1263,7 +1263,7 @@ function GEN_RANDOM_CODE ($length, $code, $uid, $DATA="") {
        // Calculate number for generating the code
        $a = $code + constant('_ADD') - 1;
 
        // Calculate number for generating the code
        $a = $code + constant('_ADD') - 1;
 
-       if (getConfig('master_hash') != null) {
+       if (isConfigEntrySet('master_hash')) {
                // Generate hash with master salt from modula of number with the prime number and other data
                $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, getConfig('master_salt'));
 
                // Generate hash with master salt from modula of number with the prime number and other data
                $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, getConfig('master_salt'));
 
@@ -3050,10 +3050,22 @@ function READ_FILE ($FQFN, $sqlPrepare = false) {
 
 // Writes content to a file
 function WRITE_FILE ($FQFN, $content) {
 
 // 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
        // 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)."!");
        } 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
                fclose($fp);
 
                // Set CHMOD rights
-               chmod($FQFN, 0644);
+               $return = chmod($FQFN, 0644);
        }
        }
+
+       // Return status
+       return $return;
 }
 
 // Generates an error code from given account status
 }
 
 // Generates an error code from given account status