]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Better check if it is not empty (means set, too). This will speed-up the code again...
[mailer.git] / inc / functions.php
index 561bbdadf576f00aeef9b519712d8f8a951f48d3..1054326b7870dc11b961c847297fc0996220dba6 100644 (file)
@@ -95,7 +95,7 @@ function generatePassword ($length = '0', $exclude = array()) {
        $localAbc = array_diff($GLOBALS['_abc'], $exclude);
 
        // $localAbc must have at least 10 entries
-       assert(count($localAbc) >= 10, 'localAbc()=' . count($localAbc) . ' is to small.');
+       assert(count($localAbc) >= 10);
 
        // Start creating password
        $password = '';
@@ -766,7 +766,13 @@ function generateHash ($plainText, $salt = '', $hash = TRUE) {
                $server = $_SERVER['PHP_SELF'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr();
 
                // Build key string
-               $keys   = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getSecretKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getDateFromRepository() . getEncryptSeparator() . getMasterSalt();
+               $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getDateFromRepository() . getEncryptSeparator() . getMasterSalt();
+
+               // Is the secret_key config entry set?
+               if (isConfigEntrySet('secret_key')) {
+                       // Add it
+                       $keys .= getEncryptSeparator() . getSecretKey();
+               } // END - if
 
                // Additional data
                $data = $plainText . getEncryptSeparator() . uniqid(mt_rand(), TRUE) . getEncryptSeparator() . time();
@@ -933,7 +939,7 @@ function encodeHashForCookie ($passHash) {
 
                        $mod = substr($mod, 0, 2);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
-                       $mod = padLeftZero($mod);
+                       $mod = padLeftZero($mod, 2);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
                        $start += 2;
                        $newHash .= $mod;
@@ -1412,7 +1418,7 @@ function doHandleExtraValues ($filterFunctions, $extraValues, $key, $entries, $u
                } // END - if
 
                // Make sure entries is not bool, then something went wrong
-               assert(!is_bool($entries), 'entries[]=bool which is not expected.');
+               assert(!is_bool($entries));
        } elseif (!empty($filterFunctions[$search])) {
                // Debug mode enabled?
                if (isDebugModeEnabled()) {
@@ -1430,7 +1436,7 @@ function doHandleExtraValues ($filterFunctions, $extraValues, $key, $entries, $u
                } // END - if
 
                // Make sure entries is not bool, then something went wrong
-               assert(!is_bool($entries), 'entries[]=bool which is not expected.');
+               assert(!is_bool($entries));
        }
 
        // Return value
@@ -1549,8 +1555,8 @@ function rebuildCache ($cache, $inc = '', $force = FALSE) {
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'inc=' . $inc . ' - LOADED!');
                                loadInclude($inc);
                        } else {
-                               // Include not found
-                               logDebugMessage(__FUNCTION__, __LINE__, 'Include ' . $inc . ' not found. cache=' . $cache);
+                               // Include not found, which needs now tracing
+                               reportBug(__FUNCTION__, __LINE__, 'Include ' . $inc . ' not found. cache=' . $cache);
                        }
                } // END - if
        } // END - if
@@ -2526,7 +2532,7 @@ function memberEditEntriesConfirm ($tableName, $columns = array(), $filterFuncti
 // Delete rows by given id numbers
 function memberDeleteEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = array(FALSE), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array(), $content = array()) {
        // Do this only for members
-       assert(isMember(), 'isMember()=false which is not expected.');
+       assert(isMember());
 
        // $tableName must be an array
        if ((!is_array($tableName)) || (count($tableName) != 1)) {
@@ -2569,7 +2575,7 @@ function memberDeleteEntriesConfirm ($tableName, $columns = array(), $filterFunc
 // @TODO cacheFiles is not yet supported
 function memberListBuilder ($listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid'), $content = array()) {
        // Do this only for logged in member
-       assert(isMember(), 'isMember()=false which is not expected.');
+       assert(isMember());
 
        // Call inner (general) function
        doGenericListBuilder('member', $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId, $content);
@@ -2647,7 +2653,7 @@ function caluculateTimeUnitValue ($seconds, $timeUnit) {
 // "Getter" for an array from given one but only one index of it
 function getArrayFromArrayIndex ($array, $key) {
        // Some simple validation
-       assert(isset($array[0][$key]), 'array[0][' . $key . '] is not set.');
+       assert(isset($array[0][$key]));
 
        // Init new array
        $newArray = array();
@@ -2718,7 +2724,7 @@ function hashSha256 ($str) {
        $hex = '';
        for ($i = 0; $i < strlen($hash); $i++) {
                // Encode char to decimal, pad it with zero, add it
-               $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))));
+               $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))), 2);
        } // END - if
 
        // Return it