]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Extension ext-surfbar continued:
[mailer.git] / inc / functions.php
index 7702331fc7ce559c380a422473a7917a616cdea1..91ef0668200e4cdceaf4e7e274243fad32a2841c 100644 (file)
@@ -89,27 +89,29 @@ function generatePassword ($length = '0', $exclude =  array()) {
                $length = getPassLen();
        } // END - if
 
-       // Initialize array with all allowed chars
-       $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.');
-
        // Exclude some entries
-       $ABC = array_diff($ABC, $exclude);
+       $localAbc = array_diff($GLOBALS['_abc'], $exclude);
+
+       // $localAbc must have at least 10 entries
+       assert(count($localAbc) >= 10);
 
        // Start creating password
-       $PASS = '';
-       for ($i = '0'; $i < $length; $i++) {
-               $PASS .= $ABC[mt_rand(0, count($ABC) -1)];
-       } // END - for
+       $password = '';
+       while (strlen($password) < $length) {
+               $password .= $localAbc[mt_rand(0, count($localAbc) -1)];
+       } // END - while
 
-       // When the size is below 40 we can also add additional security by scrambling
-       // it. Otherwise we may corrupt hashes
-       if (strlen($PASS) <= 40) {
+       /*
+        * When the size is below 40 we can also add additional security by
+        * scrambling it. Otherwise the hash may corrupted..
+        */
+       if (strlen($password) <= 40) {
                // Also scramble the password
-               $PASS = scrambleString($PASS);
+               $password = scrambleString($password);
        } // END - if
 
        // Return the password
-       return $PASS;
+       return $password;
 }
 
 // Generates a human-readable timestamp from the Uni* stamp
@@ -332,15 +334,18 @@ function translateMenuVisibleLocked ($content, $prefix = '') {
 // Generates an URL for the dereferer
 function generateDereferrerUrl ($url) {
        // Don't de-refer our own links!
-       if (substr($url, 0, strlen(getUrl())) != getUrl()) {
+       if ((!empty($url)) && (substr($url, 0, strlen(getUrl())) != getUrl())) {
                // Encode URL
                $encodedUrl = encodeString(compileUriCode($url));
 
-               // Log plain URL
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url);
+               // Generate hash
+               $hash = generateHash($url . getSiteKey() . getDateKey());
+
+               // Log plain URL and hash
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ',hash=' . $hash . '(' . strlen($hash) . ')');
 
                // De-refer this URL
-               $url = '{%url=modules.php?module=loader&amp;url=' . $encodedUrl . '&amp;hash=' . encodeHashForCookie(generateHash($url)) . '%}';
+               $url = '{%url=modules.php?module=loader&amp;url=' . $encodedUrl . '&amp;hash=' . encodeHashForCookie($hash) . '&amp;salt=' . substr($hash, 0, getSaltLength()) . '%}';
        } // END - if
 
        // Return link
@@ -707,7 +712,7 @@ function isUrlValid ($url, $compile = TRUE) {
 // Generate a hash for extra-security for all passwords
 function generateHash ($plainText, $salt = '', $hash = TRUE) {
        // Debug output
-       //* DEBUG: */ debugOutput('plainText('.strlen($plainText).')=' . $plainText . ',salt('.strlen($salt).')=' . $salt . ',hash=' . intval($hash));
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'plainText('.strlen($plainText).')=' . $plainText . ',salt('.strlen($salt).')=' . $salt . ',hash=' . intval($hash));
 
        // Is the required extension 'sql_patches' there and a salt is not given?
        // 123                            4                      43    3     4     432    2                  3             32    2                             3                32    2      3     3      21
@@ -744,20 +749,20 @@ function generateHash ($plainText, $salt = '', $hash = TRUE) {
 
                // Generate SHA1 sum from modula of number and the prime number
                $sha1 = sha1(($a % getPrime()) . $server . getEncryptSeparator() . $keys . getEncryptSeparator() . $data . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . $a);
-               //* DEBUG: */ debugOutput('SHA1=' . $sha1.' ('.strlen($sha1).')<br />');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SHA1=' . $sha1.' ('.strlen($sha1).')');
                $sha1 = scrambleString($sha1);
-               //* DEBUG: */ debugOutput('Scrambled=' . $sha1.' ('.strlen($sha1).')<br />');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Scrambled=' . $sha1.' ('.strlen($sha1).')');
                //* DEBUG: */ $sha1b = descrambleString($sha1);
-               //* DEBUG: */ debugOutput('Descrambled=' . $sha1b.' ('.strlen($sha1b).')<br />');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Descrambled=' . $sha1b.' ('.strlen($sha1b).')');
 
                // Generate the password salt string
                $salt = substr($sha1, 0, getSaltLength());
-               //* DEBUG: */ debugOutput($salt.' ('.strlen($salt).')<br />');
+               //* DEBUG: */ debugOutput($salt.' ('.strlen($salt).')');
        } else {
                // Use given salt
-               //* DEBUG: */ debugOutput('salt=' . $salt);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . $salt);
                $salt = substr($salt, 0, getSaltLength());
-               //* DEBUG: */ debugOutput('salt=' . $salt . '(' . strlen($salt) . '/' . getSaltLength() . ')<br />');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . $salt . '(' . strlen($salt) . '/' . getSaltLength() . ')');
 
                // Sanity check on salt
                if (strlen($salt) != getSaltLength()) {
@@ -770,7 +775,7 @@ function generateHash ($plainText, $salt = '', $hash = TRUE) {
        $finalHash = $salt . sha1($salt . $plainText);
 
        // Debug output
-       //* DEBUG: */ debugOutput('finalHash('.strlen($finalHash).')=' . $finalHash);
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'finalHash('.strlen($finalHash).')=' . $finalHash);
 
        // Return hash
        return $finalHash;
@@ -875,32 +880,39 @@ function encodeHashForCookie ($passHash) {
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '/' . strlen(getSecretKey()));
                if ((strlen($passHash) != 49) || (strlen(getSecretKey()) != 40)) {
                        // Both keys must have same length so return unencrypted
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '!=49/' . strlen(getSecretKey()) . '!=40');
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '!=49/' . strlen(getSecretKey()) . '!=40 -  EXIT!');
                        return $ret;
                } // END - if
 
                $newHash = ''; $start = 9;
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'passHash=' . $passHash . '(' . strlen($passHash) . ')');
                for ($idx = 0; $idx < 20; $idx++) {
-                       $part1 = hexdec(substr($passHash, ($idx * 2) + (strlen($passHash) - strlen(getSecretKey())), 2));
+                       // Get hash parts and convert them (00-FF) to matching ASCII value (0-255)
+                       $part1 = hexdec(substr($passHash     , $start, 2));
                        $part2 = hexdec(substr(getSecretKey(), $start, 2));
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'part1=' . $part1 . '/part2=' . $part2);
+
+                       // Default is hexadecimal of index if both are same
                        $mod = dechex($idx);
+                       // Is part1 larger or part2 than its counter part?
                        if ($part1 > $part2) {
+                               // part1 is larger
                                $mod = dechex(sqrt(($part1 - $part2) * getPrime() / pi()));
                        } elseif ($part2 > $part1) {
+                               // part2 is larger
                                $mod = dechex(sqrt(($part2 - $part1) * getPrime() / pi()));
                        }
+
                        $mod = substr($mod, 0, 2);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
-                       $mod = str_repeat(0, (2 - strlen($mod))) . $mod;
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
+                       $mod = str_repeat('0', (2 - strlen($mod))) . $mod;
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
                        $start += 2;
                        $newHash .= $mod;
                } // END - for
 
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $passHash . ',' . $newHash . ' (' . strlen($newHash) . ')');
-               $ret = generateHash($newHash, getMasterSalt());
+               // Just copy it over, as the master salt is not really helpful here
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $passHash . '(' . strlen($passHash) . '),' . $newHash . ' (' . strlen($newHash) . ')');
+               $ret = $newHash;
        } // END - if
 
        // Return result
@@ -1233,7 +1245,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0
                                        if ($next > -1) {
                                                if ($next === $seek) {
                                                        $next = -1;
-                                                       $line = $prefix . $inserted . $suffix . chr(10);
+                                                       $line = $prefix . $inserted . $suffix . PHP_EOL;
                                                } else {
                                                        $next++;
                                                }
@@ -1277,7 +1289,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) {
        // Is debug mode enabled?
        if ((isDebugModeEnabled()) || ($force === TRUE)) {
                // Remove CRLF
-               $message = str_replace(array(chr(13), chr(10)), array('', ''), $message);
+               $message = str_replace(array(chr(13), PHP_EOL), array('', ''), $message);
 
                // Log this message away
                appendLineToFile(getPath() . getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(FALSE) . '|' . basename($funcFile) . '|' . $line . '|' . $message);
@@ -1290,46 +1302,115 @@ function handleExtraValues ($filterFunction, $value, $extraValue) {
        $ret = $value;
 
        // Is there a special filter function?
-       if (!empty($filterFunction)) {
-               // Does the filter function exist?
-               if (function_exists($filterFunction)) {
-                       // Is there extra parameters here?
-                       if ((!is_null($extraValue)) && (!empty($extraValue))) {
-                               // Put both parameters in one new array by default
-                               $args = array($value, $extraValue);
-
-                               // If we have an array simply use it and pre-extend it with our value
-                               if (is_array($extraValue)) {
-                                       // Make the new args array
-                                       $args = merge_array(array($value), $extraValue);
-                               } // END - if
+       if ((empty($filterFunction)) || (!function_exists($filterFunction))) {
+               // Call-back function does not exist or is empty
+               reportBug(__FUNCTION__, __LINE__, 'Filter function ' . $filterFunction . ' does not exist or is empty: value[' . gettype($value) . ']=' . $value . ',extraValue[' . gettype($extraValue) . ']=' . $extraValue);
+       } // END - if
 
-                               // Call the multi-parameter call-back
-                               $ret = call_user_func_array($filterFunction, $args);
+       // Is there extra parameters here?
+       if ((!is_null($extraValue)) && (!empty($extraValue))) {
+               // Put both parameters in one new array by default
+               $args = array($value, $extraValue);
 
-                               // Is $ret 'true'?
-                               if ($ret === TRUE) {
-                                       // Test passed, so write direct value
-                                       $ret = $args;
-                               } // END - if
-                       } else {
-                               // One parameter call
-                               $ret = call_user_func($filterFunction, $value);
-                               //* BUG */ die('ret['.gettype($ret).']=' . $ret . ',value=' . $value.',filterFunction=' . $filterFunction);
-
-                               // Is $ret 'true'?
-                               if ($ret === TRUE) {
-                                       // Test passed, so write direct value
-                                       $ret = $value;
-                               } // END - if
-                       }
+               // If we have an array simply use it and pre-extend it with our value
+               if (is_array($extraValue)) {
+                       // Make the new args array
+                       $args = merge_array(array($value), $extraValue);
                } // END - if
-       } // END - if
+
+               // Call the multi-parameter call-back
+               $ret = call_user_func_array($filterFunction, $args);
+
+               // Is $ret 'true'?
+               if ($ret === TRUE) {
+                       // Test passed, so write direct value
+                       $ret = $args;
+               } // END - if
+       } else {
+               // One parameter call
+               $ret = call_user_func($filterFunction, $value);
+               //* BUG */ die('ret['.gettype($ret).']=' . $ret . ',value=' . $value.',filterFunction=' . $filterFunction);
+
+               // Is $ret 'true'?
+               if ($ret === TRUE) {
+                       // Test passed, so write direct value
+                       $ret = $value;
+               } // END - if
+       }
 
        // Return the value
        return $ret;
 }
 
+// Tries to determine if call-back functions and/or extra values shall be parsed
+function doHandleExtraValues ($filterFunctions, $extraValues, $key, $entries, $userIdColumn, $search, $id = NULL) {
+       // Debug mode enabled?
+       if (isDebugModeEnabled()) {
+               // Debug message
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',entries=' . $entries . ',userIdColumn=' . $userIdColumn[0] . ',search=' . $search . ',filterFunctions=' . print_r($filterFunctions, TRUE) . ',extraValues=' . print_r($extraValues, TRUE));
+       } // END - if
+
+       // Send data through the filter function if found
+       if ($key == $userIdColumn[0]) {
+               // Is the userid, we have to process it with convertZeroToNull()
+               $entries = convertZeroToNull($entries);
+       } elseif ((!empty($filterFunctions[$key])) && (isset($extraValues[$key]))) {
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . $extraValues[$key] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries) . ']=' . $entries . ' - BEFORE!');
+               } // END - if
+
+               // Filter function + extra value set
+               $entries = handleExtraValues($filterFunctions[$key], $entries, $extraValues[$key]);
+
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . $extraValues[$key] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries) . ']=' . $entries . ' - AFTER!');
+               } // END - if
+       } elseif ((!empty($filterFunctions[$search])) && (!empty($extraValues[$search]))) {
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - BEFORE!');
+               } // END - if
+
+               // Handle extra values
+               $entries = handleExtraValues($filterFunctions[$search], $entries, $extraValues[$search]);
+
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - AFTER!');
+               } // END - if
+
+               // Make sure entries is not bool, then something went wrong
+               assert(!is_bool($entries));
+       } elseif (!empty($filterFunctions[$search])) {
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - BEFORE!');
+               } // END - if
+
+               // Handle extra values
+               $entries = handleExtraValues($filterFunctions[$search], $entries, NULL);
+
+               // Debug mode enabled?
+               if (isDebugModeEnabled()) {
+                       // Then log it
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - AFTER!');
+               } // END - if
+
+               // Make sure entries is not bool, then something went wrong
+               assert(!is_bool($entries));
+       }
+
+       // Return value
+       return $entries;
+}
+
 // Converts timestamp selections into a timestamp
 function convertSelectionsToEpocheTime (array &$postData, array &$content, &$id, &$skip) {
        // Init test variable
@@ -1865,7 +1946,7 @@ function encodeUrl ($url, $outputMode = '0') {
        } // END - if
 
        // Is there a valid session?
-       if (((!isset($GLOBALS['valid_session'])) || ($GLOBALS['valid_session'] === FALSE) || (!isset($_COOKIE[session_name()]))) && (isSpider() === FALSE)) {
+       if ((!isSessionValid()) && (!isSpider())) {
                // Determine right separator
                $separator = '&amp;';
                if (!isInString('?', $url)) {
@@ -1873,10 +1954,8 @@ function encodeUrl ($url, $outputMode = '0') {
                        $separator = '?';
                } // END - if
 
-               // Add it to URL
-               if (session_id() != '') {
-                       $url .= $separator . session_name() . '=' . session_id();
-               } // END - if
+               // Then add it to URL
+               $url .= $separator . session_name() . '=' . session_id();
        } // END - if
 
        // Add {?URL?} ?
@@ -1885,10 +1964,15 @@ function encodeUrl ($url, $outputMode = '0') {
                $url = '{?URL?}/' . $url;
        } // END - if
 
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ',isHtmlOutputMode()=' . intval(isHtmlOutputMode()) . ',outputMode=' . $outputMode);
+
        // Is there to decode entities?
        if ((!isHtmlOutputMode()) || ($outputMode != '0')) {
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ' - BEFORE DECODING');
                // Decode them for e.g. JavaScript parts
                $url = decodeEntities($url);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ' - AFTER DECODING');
        } // END - if
 
        // Debug log
@@ -1903,10 +1987,10 @@ function isSpider () {
        // Get the UA and trim it down
        $userAgent = trim(detectUserAgent(TRUE));
 
-       // It should not be empty, if so it is better a spider/bot
+       // It should not be empty, if so it is better a browser
        if (empty($userAgent)) {
-               // It is a spider/bot
-               return TRUE;
+               // It is a browser that blocks its UA string
+               return FALSE;
        } // END - if
 
        // Is it a spider?
@@ -1994,13 +2078,10 @@ function convertZeroToNull ($number) {
 // Converts a NULL to zero
 function convertNullToZero ($number) {
        // Is it a valid username?
-       if ((!is_null($number)) && (!empty($number)) && ($number > 0)) {
-               // Always secure it
-               $number = bigintval($number);
-       } else {
+       if ((is_null($number)) || (empty($number)) || ($number < 1)) {
                // Is not valid or zero
                $number = '0';
-       }
+       } // END - if
 
        // Return it
        return $number;
@@ -2115,7 +2196,7 @@ function isHexadecimal ($hex) {
 }
 
 /**
- * Replace chr(13) with "[r]" and chr(10) with "[n]" and add a final new-line to make
+ * Replace chr(13) with "[r]" and PHP_EOL with "[n]" and add a final new-line to make
  * them visible to the developer. Use this function to debug e.g. buggy HTTP
  * response handler functions.
  *
@@ -2123,7 +2204,7 @@ function isHexadecimal ($hex) {
  * @return     $str    Overworked string
  */
 function replaceReturnNewLine ($str) {
-       return str_replace(array(chr(13), chr(10)), array('[r]', '[n]'), $str);
+       return str_replace(array(chr(13), PHP_EOL), array('[r]', '[n]'), $str);
 }
 
 // Converts a given string by splitting it up with given delimiter similar to
@@ -2157,7 +2238,7 @@ function detectMultiBytePrefix ($str) {
        return $mbPrefix;
 }
 
-// Searches the given array for a sub-string match and returns all found keys in an array
+// Searches given array for a sub-string match and returns all found keys in an array
 function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) {
        // Init array for all found keys
        $keys = array();
@@ -2235,7 +2316,7 @@ function convertStringToBoolean ($str) {
                } // END - if
 
                // Determine it
-               $GLOBALS[__FUNCTION__][$str] = (($strTrimmed == 'true') ? true : false);
+               $GLOBALS[__FUNCTION__][$str] = ($strTrimmed == 'true');
        } // END - if
 
        // Return cache
@@ -2308,7 +2389,7 @@ function memberAddEntries ($tableName, $columns = array(), $filterFunctions = ar
 }
 
 // Edit rows by given id numbers
-function memberEditEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $editNow = array(FALSE), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array()) {
+function memberEditEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $editNow = array(FALSE), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array(), $content = array()) {
        // $tableName must be an array
        if ((!is_array($tableName)) || (count($tableName) != 1)) {
                // No tableName specified
@@ -2342,12 +2423,12 @@ function memberEditEntriesConfirm ($tableName, $columns = array(), $filterFuncti
                }
        } else {
                // List for editing
-               memberListBuilder('edit', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+               memberListBuilder('edit', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId, $content);
        }
 }
 
 // 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()) {
+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());
 
@@ -2384,17 +2465,18 @@ function memberDeleteEntriesConfirm ($tableName, $columns = array(), $filterFunc
                }
        } else {
                // List for deletion confirmation
-               memberListBuilder('delete', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+               memberListBuilder('delete', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUSerId, $content);
        }
 }
 
 // Build a special template list
-function memberListBuilder ($listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid')) {
+// @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());
 
        // Call inner (general) function
-       doGenericListBuilder('member', $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId);
+       doGenericListBuilder('member', $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId, $content);
 }
 
 // Checks whether given address is IPv4
@@ -2409,6 +2491,21 @@ function isIp4AddressValid ($address) {
        return $GLOBALS[__FUNCTION__][$address];
 }
 
+// Returns the string if not empty or FALSE if empty
+function validateIsEmpty ($str) {
+       // Trim it
+       $trimmed = trim($str);
+
+       // Is the string empty?
+       if (empty($trimmed)) {
+               // Then set FALSE
+               $str = FALSE;
+       } // END - if
+
+       // Return it
+       return $str;
+}
+
 // ----------------------------------------------------------------------------
 //              "Translatation" functions for points_data table
 // ----------------------------------------------------------------------------
@@ -2449,37 +2546,43 @@ function translatePointsSubject ($subject) {
        return translateGeneric('POINTS_SUBJECT', $subject);
 }
 
-// "Translates" the given points account type
+// "Translates" given points account type
 function translatePointsAccountType ($accountType) {
        // Return it
        return translateGeneric('POINTS_ACCOUNT_TYPE', $accountType);
 }
 
-// "Translates" the given points "locked mode"
+// "Translates" given points "locked mode"
 function translatePointsLockedMode ($lockedMode) {
        // Return it
        return translateGeneric('POINTS_LOCKED_MODE', $lockedMode);
 }
 
-// "Translates" the given points payment method
+// "Translates" given points payment method
 function translatePointsPaymentMethod ($paymentMethod) {
        // Return it
        return translateGeneric('POINTS_PAYMENT_METHOD', $paymentMethod);
 }
 
-// "Translates" the given points account provider
+// "Translates" given points account provider
 function translatePointsAccountProvider ($accountProvider) {
        // Return it
        return translateGeneric('POINTS_ACCOUNT_PROVIDER', $accountProvider);
 }
 
-// "Translates" the given points notify recipient
+// "Translates" given points notify recipient
 function translatePointsNotifyRecipient ($notifyRecipient) {
        // Return it
        return translateGeneric('POINTS_NOTIFY_RECIPIENT', $notifyRecipient);
 }
 
-// Translates task type to a human-readable version
+// "Translates" given mode to a human-readable version
+function translatePointsMode ($pointsMode) {
+       // Return it
+       return translateGeneric('POINTS_MODE', $pointsMode);
+}
+
+// "Translates" task type to a human-readable version
 function translateTaskType ($taskType) {
        // Return it
        return translateGeneric('ADMIN_TASK_TYPE', $taskType);