2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/04/2009 *
4 * =================== Last change: 04/04/2009 *
6 * -------------------------------------------------------------------- *
7 * File : wrapper-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Wrapper functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Wrapper-Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 function readFromFile ($FQFN) {
45 // Sanity-check if file is there (should be there, but just to make it sure)
46 if (!isFileReadable($FQFN)) {
47 // This should not happen
48 debug_report_bug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
49 } elseif (!isset($GLOBALS['file_content'][$FQFN])) {
51 if (function_exists('file_get_contents')) {
53 $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
55 // Fall-back to implode-file chain
56 $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
61 return $GLOBALS['file_content'][$FQFN];
64 // Writes content to a file
65 function writeToFile ($FQFN, $content, $aquireLock = false) {
66 // Is the file writeable?
67 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
69 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
75 // By default all is failed...
76 $GLOBALS['file_readable'][$FQFN] = false;
77 unset($GLOBALS['file_content'][$FQFN]);
80 // Is the function there?
81 if (function_exists('file_put_contents')) {
83 if ($aquireLock === true) {
84 // Write it directly with lock
85 $return = file_put_contents($FQFN, $content, LOCK_EX);
88 $return = file_put_contents($FQFN, $content);
91 // Write it with fopen
92 $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
94 // Do we need to aquire a lock?
95 if ($aquireLock === true) {
101 $return = fwrite($fp, $content);
107 // Was something written?
108 if ($return !== false) {
109 // Mark it as readable
110 $GLOBALS['file_readable'][$FQFN] = true;
112 // Remember content in cache
113 $GLOBALS['file_content'][$FQFN] = $content;
117 return (($return !== false) && (changeMode($FQFN, 0644)));
120 // Clears the output buffer. This function does *NOT* backup sent content.
121 function clearOutputBuffer () {
122 // Trigger an error on failure
123 if ((ob_get_length() > 0) && (!ob_end_clean())) {
125 debug_report_bug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
130 function encodeString ($str) {
131 $str = urlencode(base64_encode(compileUriCode($str)));
135 // Decode strings encoded with encodeString()
136 function decodeString ($str) {
137 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
141 // Decode entities in a nicer way
142 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
143 // Decode the entities to UTF-8 now
144 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
146 // Return decoded string
147 return $decodedString;
150 // Merges an array together but only if both are arrays
151 function merge_array ($array1, $array2) {
152 // Are both an array?
153 if ((!is_array($array1)) && (!is_array($array2))) {
154 // Both are not arrays
155 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
156 } elseif (!is_array($array1)) {
157 // Left one is not an array
158 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
159 } elseif (!is_array($array2)) {
160 // Right one is not an array
161 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
164 // Merge all together
165 return array_merge($array1, $array2);
168 // Check if given FQFN is a readable file
169 function isFileReadable ($FQFN) {
171 if (!isset($GLOBALS['file_readable'][$FQFN])) {
173 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
177 return $GLOBALS['file_readable'][$FQFN];
180 // Checks wether the given FQFN is a directory and not ., .. or .svn
181 function isDirectory ($FQFN) {
183 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
185 $baseName = basename($FQFN);
188 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
192 return $GLOBALS[__FUNCTION__][$FQFN];
195 // "Getter" for the real remote IP number
196 function detectRealIpAddress () {
197 // Get remote ip from environment
198 $remoteAddr = determineRealRemoteAddress();
200 // Is removeip installed?
201 if (isExtensionActive('removeip')) {
203 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
210 // "Getter" for remote IP number
211 function detectRemoteAddr () {
212 // Get remote ip from environment
213 $remoteAddr = determineRealRemoteAddress(true);
215 // Is removeip installed?
216 if (isExtensionActive('removeip')) {
218 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
225 // "Getter" for remote hostname
226 function detectRemoteHostname () {
227 // Get remote ip from environment
228 $remoteHost = getenv('REMOTE_HOST');
230 // Is removeip installed?
231 if (isExtensionActive('removeip')) {
233 $remoteHost = getAnonymousRemoteHost($remoteHost);
240 // "Getter" for user agent
241 function detectUserAgent ($alwaysReal = false) {
242 // Get remote ip from environment
243 $userAgent = getenv('HTTP_USER_AGENT');
245 // Is removeip installed?
246 if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
248 $userAgent = getAnonymousUserAgent($userAgent);
255 // "Getter" for referer
256 function detectReferer () {
257 // Get remote ip from environment
258 $referer = getenv('HTTP_REFERER');
260 // Is removeip installed?
261 if (isExtensionActive('removeip')) {
263 $referer = getAnonymousReferer($referer);
270 // "Getter" for request URI
271 function detectRequestUri () {
273 return (getenv('REQUEST_URI'));
276 // "Getter" for query string
277 function detectQueryString () {
278 return str_replace('&', '&', (getenv('QUERY_STRING')));
281 // "Getter" for SERVER_NAME
282 function detectServerName () {
284 return (getenv('SERVER_NAME'));
287 // Removes any existing www. from SERVER_NAME. This is very silly but enough
288 // for our purpose here.
289 function detectDomainName () {
291 if (!isset($GLOBALS[__FUNCTION__])) {
293 $domainName = detectServerName();
295 // Is there any www. ?
296 if (substr($domainName, 0, 4) == 'www.') {
298 $domainName = substr($domainName, 4);
302 $GLOBALS[__FUNCTION__] = $domainName;
306 return $GLOBALS[__FUNCTION__];
309 // Check wether we are installing
310 function isInstalling () {
311 // Determine wether we are installing
312 if (!isset($GLOBALS['mailer_installing'])) {
313 // Check URL (css.php/js.php need this)
314 $GLOBALS['mailer_installing'] = isGetRequestElementSet('installing');
318 return $GLOBALS['mailer_installing'];
321 // Check wether this script is installed
322 function isInstalled () {
324 if (!isset($GLOBALS[__FUNCTION__])) {
325 // Determine wether this script is installed
326 $GLOBALS[__FUNCTION__] = (
331 isConfigEntrySet('MXCHANGE_INSTALLED')
333 getConfig('MXCHANGE_INSTALLED') == 'Y'
337 // New config file found and loaded
338 isIncludeReadable(getCachePath() . 'config-local.php')
341 // New config file found, but not yet read
342 isIncludeReadable(getCachePath() . 'config-local.php')
345 // Only new config file is found
346 !isIncludeReadable('inc/config.php')
348 // Is installation mode
355 // Then use the cache
356 return $GLOBALS[__FUNCTION__];
359 // Check wether an admin is registered
360 function isAdminRegistered () {
362 if (!isset($GLOBALS[__FUNCTION__])) {
364 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
368 return $GLOBALS[__FUNCTION__];
371 // Checks wether the hourly reset mode is active
372 function isHourlyResetEnabled () {
373 // Now simply check it
374 return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === true));
377 // Checks wether the reset mode is active
378 function isResetModeEnabled () {
379 // Now simply check it
380 return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
383 // Checks wether the debug mode is enabled
384 function isDebugModeEnabled () {
386 if (!isset($GLOBALS[__FUNCTION__])) {
388 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
392 return $GLOBALS[__FUNCTION__];
395 // Checks wether the debug reset is enabled
396 function isDebugResetEnabled () {
398 if (!isset($GLOBALS[__FUNCTION__])) {
400 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
404 return $GLOBALS[__FUNCTION__];
407 // Checks wether SQL debugging is enabled
408 function isSqlDebuggingEnabled () {
410 if (!isset($GLOBALS[__FUNCTION__])) {
411 // Determine if SQL debugging is enabled
412 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
416 return $GLOBALS[__FUNCTION__];
419 // Checks wether we shall debug regular expressions
420 function isDebugRegularExpressionEnabled () {
422 if (!isset($GLOBALS[__FUNCTION__])) {
424 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
428 return $GLOBALS[__FUNCTION__];
431 // Checks wether the cache instance is valid
432 function isCacheInstanceValid () {
434 if (!isset($GLOBALS[__FUNCTION__])) {
436 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
440 return $GLOBALS[__FUNCTION__];
443 // Copies a file from source to destination and verifies if that goes fine.
444 // This function should wrap the copy() command and make a nicer debug backtrace
445 // even if there is no xdebug extension installed.
446 function copyFileVerified ($source, $dest, $chmod = '') {
447 // Failed is the default
450 // Is the source file there?
451 if (!isFileReadable($source)) {
453 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
456 // Is the target directory there?
457 if (!isDirectory(dirname($dest))) {
459 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
462 // Now try to copy it
463 if (!copy($source, $dest)) {
464 // Something went wrong
465 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
468 $GLOBALS['file_readable'][$dest] = true;
471 // If there are chmod rights set, apply them
472 if (!empty($chmod)) {
474 $status = changeMode($dest, $chmod);
484 // Wrapper function for chmod()
485 // @TODO Do some more sanity check here
486 function changeMode ($FQFN, $mode) {
487 // Is the file/directory there?
488 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
489 // Neither, so abort here
490 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
494 return chmod($FQFN, $mode);
497 // Wrapper for unlink()
498 function removeFile ($FQFN) {
499 // Is the file there?
500 if (isFileReadable($FQFN)) {
502 $GLOBALS['file_readable'][$FQFN] = false;
505 return unlink($FQFN);
508 // All fine if no file was removed. If we change this to 'false' or rewrite
509 // above if() block it would be to restrictive.
513 // Wrapper for $_POST['sel']
514 function countPostSelection ($element = 'sel') {
516 if (isPostRequestElementSet($element)) {
517 // Return counted elements
518 return countSelection(postRequestElement($element));
520 // Return zero if not found
525 // Checks wether the config-local.php is loaded
526 function isConfigLocalLoaded () {
527 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
530 // Checks wether a nickname or userid was entered and caches the result
531 function isNicknameUsed ($userid) {
532 // Is the cache there
533 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
535 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid) && ($userid != 'NULL'));
539 return $GLOBALS[__FUNCTION__][$userid];
542 // Getter for 'what' value
543 function getWhat () {
548 if (isWhatSet(true)) {
550 $what = $GLOBALS['what'];
557 // Setter for 'what' value
558 function setWhat ($newWhat) {
559 $GLOBALS['what'] = SQL_ESCAPE($newWhat);
562 // Setter for 'what' from configuration
563 function setWhatFromConfig ($configEntry) {
564 // Get 'what' from config
565 $what = getConfig($configEntry);
571 // Checks wether what is set and optionally aborts on miss
572 function isWhatSet ($strict = false) {
574 $isset = isset($GLOBALS['what']);
576 // Should we abort here?
577 if (($strict === true) && ($isset === false)) {
579 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
586 // Getter for 'action' value
587 function getAction ($strict = true) {
592 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
594 $action = $GLOBALS['action'];
601 // Setter for 'action' value
602 function setAction ($newAction) {
603 $GLOBALS['action'] = SQL_ESCAPE($newAction);
606 // Checks wether action is set and optionally aborts on miss
607 function isActionSet ($strict = false) {
609 $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
611 // Should we abort here?
612 if (($strict === true) && ($isset === false)) {
614 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
621 // Getter for 'module' value
622 function getModule ($strict = true) {
627 if (isModuleSet($strict)) {
629 $module = $GLOBALS['module'];
636 // Setter for 'module' value
637 function setModule ($newModule) {
638 // Secure it and make all modules lower-case
639 $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
642 // Checks wether module is set and optionally aborts on miss
643 function isModuleSet ($strict = false) {
645 $isset = (!empty($GLOBALS['module']));
647 // Should we abort here?
648 if (($strict === true) && ($isset === false)) {
650 debug_report_bug(__FUNCTION__, __LINE__, 'Module is empty.');
654 return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
657 // Getter for 'output_mode' value
658 function getScriptOutputMode () {
660 if (!isset($GLOBALS[__FUNCTION__])) {
665 if (isOutputModeSet(true)) {
667 $output_mode = $GLOBALS['output_mode'];
671 $GLOBALS[__FUNCTION__] = $output_mode;
675 return $GLOBALS[__FUNCTION__];
678 // Setter for 'output_mode' value
679 function setOutputMode ($newOutputMode) {
680 $GLOBALS['output_mode'] = (int) $newOutputMode;
683 // Checks wether output_mode is set and optionally aborts on miss
684 function isOutputModeSet ($strict = false) {
686 $isset = (isset($GLOBALS['output_mode']));
688 // Should we abort here?
689 if (($strict === true) && ($isset === false)) {
691 debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
698 // Enables block-mode
699 function enableBlockMode ($enabled = true) {
700 $GLOBALS['block_mode'] = $enabled;
703 // Checks wether block-mode is enabled
704 function isBlockModeEnabled () {
706 if (!isset($GLOBALS['block_mode'])) {
708 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
712 return $GLOBALS['block_mode'];
716 * Wrapper function for addPointsThroughReferralSystem(), you should generally
717 * avoid this function and use addPointsThroughReferralSystem() directly and add
718 * your special payment method entry to points_data instead.
720 * @param $subject A string-encoded subject for this add
721 * @param $userid The recipient (member) for given points
722 * @param $points Points to be added to member's account
723 * @return $added Wether the points has been added to the user's account
725 function addPointsDirectly ($subject, $userid, $points) {
727 initReferralSystem();
729 // Call more complicated method (due to more parameters)
730 return addPointsThroughReferralSystem($subject, $userid, $points, false, 0, 'DIRECT');
733 // Wrapper for redirectToUrl but URL comes from a configuration entry
734 function redirectToConfiguredUrl ($configEntry) {
736 redirectToUrl(getConfig($configEntry));
739 // Wrapper function to redirect from member-only modules to index
740 function redirectToIndexMemberOnlyModule () {
741 // Do the redirect here
742 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
745 // Wrapper function to redirect to current URL
746 function redirectToRequestUri () {
747 redirectToUrl(basename(detectRequestUri()));
750 // Wrapper function to redirect to de-refered URL
751 function redirectToDereferedUrl ($url) {
753 redirectToUrl(generateDerefererUrl($url));
756 // Wrapper function for checking if extension is installed and newer or same version
757 function isExtensionInstalledAndNewer ($ext_name, $version) {
758 // Is an cache entry found?
759 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
761 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
763 // Cache hits should be incremented twice
764 incrementStatsEntry('cache_hits', 2);
768 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
769 return $GLOBALS[__FUNCTION__][$ext_name][$version];
772 // Wrapper function for checking if extension is installed and older than given version
773 function isExtensionInstalledAndOlder ($ext_name, $version) {
774 // Is an cache entry found?
775 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
777 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
779 // Cache hits should be incremented twice
780 incrementStatsEntry('cache_hits', 2);
784 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
785 return $GLOBALS[__FUNCTION__][$ext_name][$version];
789 function setUsername ($userName) {
790 $GLOBALS['username'] = (string) $userName;
794 function getUsername () {
796 if (!isset($GLOBALS['username'])) {
797 // No, so it has to be a guest
798 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
802 return $GLOBALS['username'];
805 // Wrapper function for installation phase
806 function isInstallationPhase () {
808 if (!isset($GLOBALS[__FUNCTION__])) {
810 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
814 return $GLOBALS[__FUNCTION__];
817 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
818 function isDemoModeActive () {
820 if (!isset($GLOBALS[__FUNCTION__])) {
822 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
826 return $GLOBALS[__FUNCTION__];
829 // Getter for PHP caching value
830 function getPhpCaching () {
831 return $GLOBALS['php_caching'];
834 // Checks wether the admin hash is set
835 function isAdminHashSet ($adminId) {
836 // Is the array there?
837 if (!isset($GLOBALS['cache_array']['admin'])) {
838 // Missing array should be reported
839 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
842 // Check for admin hash
843 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
846 // Setter for admin hash
847 function setAdminHash ($adminId, $hash) {
848 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
851 // Getter for current admin login
852 function getCurrentAdminLogin () {
854 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
857 if (!isset($GLOBALS[__FUNCTION__])) {
859 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
863 return $GLOBALS[__FUNCTION__];
866 // Setter for admin id (and current)
867 function setAdminId ($adminId) {
869 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
872 $status = setSession('admin_id', bigintval($adminId));
875 setCurrentAdminId($adminId);
881 // Setter for admin_last
882 function setAdminLast ($adminLast) {
884 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
887 $status = setSession('admin_last', $adminLast);
893 // Setter for admin_md5
894 function setAdminMd5 ($adminMd5) {
896 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
899 $status = setSession('admin_md5', $adminMd5);
905 // Getter for admin_md5
906 function getAdminMd5 () {
908 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
911 return getSession('admin_md5');
914 // Init user data array
915 function initUserData () {
916 // User id should not be zero
917 if (!isValidUserId(getCurrentUserId())) {
918 // Should be always valid
919 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
923 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
924 $GLOBALS['user_data'][getCurrentUserId()] = array();
927 // Getter for user data
928 function getUserData ($column) {
929 // User id should not be zero
930 if (!isValidUserId(getCurrentUserId())) {
931 // Should be always valid
932 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
938 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
940 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
947 // Checks wether given user data is set to 'Y'
948 function isUserDataEnabled ($column) {
950 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
952 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
956 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
959 // Geter for whole user data array
960 function getUserDataArray () {
962 $userid = getCurrentUserId();
964 // Is the current userid valid?
965 if (!isValidUserId($userid)) {
966 // Should be always valid
967 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
970 // Get the whole array if found
971 if (isset($GLOBALS['user_data'][$userid])) {
972 // Found, so return it
973 return $GLOBALS['user_data'][$userid];
975 // Return empty array
980 // Checks if the user data is valid, this may indicate that the user has logged
981 // in, but you should use isMember() if you want to find that out.
982 function isUserDataValid () {
983 // User id should not be zero so abort here
984 if (!isCurrentUserIdSet()) {
989 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
991 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
995 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
998 // Setter for current userid
999 function setCurrentUserId ($userid) {
1001 $GLOBALS['current_userid'] = bigintval($userid);
1003 // Unset it to re-determine the actual state
1004 unset($GLOBALS['is_userdata_valid'][$userid]);
1007 // Getter for current userid
1008 function getCurrentUserId () {
1009 // Userid must be set before it can be used
1010 if (!isCurrentUserIdSet()) {
1012 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1015 // Return the userid
1016 return $GLOBALS['current_userid'];
1019 // Checks if current userid is set
1020 function isCurrentUserIdSet () {
1021 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1024 // Checks wether we are debugging template cache
1025 function isDebuggingTemplateCache () {
1026 // Do we have cache?
1027 if (!isset($GLOBALS[__FUNCTION__])) {
1029 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1033 return $GLOBALS[__FUNCTION__];
1036 // Wrapper for fetchUserData() and getUserData() calls
1037 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1038 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1040 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1044 // Can we fetch the user data?
1045 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1046 // Now get the data back
1047 $data = getUserData($valueColumn);
1051 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1055 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1056 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1059 // Wrapper for strpos() to ease porting from deprecated ereg() function
1060 function isInString ($needle, $haystack) {
1061 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1062 return (strpos($haystack, $needle) !== false);
1065 // Wrapper for strpos() to ease porting from deprecated eregi() function
1066 // This function is case-insensitive
1067 function isInStringIgnoreCase ($needle, $haystack) {
1068 return (isInString(strtolower($needle), strtolower($haystack)));
1071 // Wrapper to check for if fatal errors where detected
1072 function ifFatalErrorsDetected () {
1073 // Just call the inner function
1074 return (getTotalFatalErrors() > 0);
1077 // Setter for HTTP status
1078 function setHttpStatus ($status) {
1079 $GLOBALS['http_status'] = (string) $status;
1082 // Getter for HTTP status
1083 function getHttpStatus () {
1084 // Is the status set?
1085 if (!isset($GLOBALS['http_status'])) {
1087 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1091 return $GLOBALS['http_status'];
1095 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1096 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1098 * ----------------------------------------------------------------------------
1099 * If you want to redirect, please use redirectToUrl(); instead
1100 * ----------------------------------------------------------------------------
1102 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1104 * @link http://support.microsoft.com/kb/q176113/
1105 * @author Andreas Gohr <andi@splitbrain.org>
1108 function sendRawRedirect ($url) {
1109 // Send helping header
1110 setHttpStatus('302 Found');
1112 // always close the session
1113 session_write_close();
1115 // Revert entity &
1116 $url = str_replace('&', '&', $url);
1118 // check if running on IIS < 6 with CGI-PHP
1119 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1120 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1121 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1122 ($matches[1] < 6)) {
1123 // Send the IIS header
1124 addHttpHeader('Refresh: 0;url=' . $url);
1126 // Send generic header
1127 addHttpHeader('Location: ' . $url);
1134 // Determines the country of the given user id
1135 function determineCountry ($userid) {
1136 // Do we have cache?
1137 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1138 // Default is 'invalid'
1139 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1141 // Is extension country active?
1142 if (isExtensionActive('country')) {
1143 // Determine the right country code through the country id
1144 $id = getUserData('country_code');
1146 // Then handle it over
1147 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1149 // Get raw code from user data
1150 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1155 return $GLOBALS[__FUNCTION__][$userid];
1158 // "Getter" for total confirmed user accounts
1159 function getTotalConfirmedUser () {
1161 if (!isset($GLOBALS[__FUNCTION__])) {
1163 if (isExtensionActive('user')) {
1164 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1166 $GLOBALS[__FUNCTION__] = 0;
1170 // Return cached value
1171 return $GLOBALS[__FUNCTION__];
1174 // "Getter" for total unconfirmed user accounts
1175 function getTotalUnconfirmedUser () {
1177 if (!isset($GLOBALS[__FUNCTION__])) {
1179 if (isExtensionActive('user')) {
1180 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1182 $GLOBALS[__FUNCTION__] = 0;
1186 // Return cached value
1187 return $GLOBALS[__FUNCTION__];
1190 // "Getter" for total locked user accounts
1191 function getTotalLockedUser () {
1193 if (!isset($GLOBALS[__FUNCTION__])) {
1195 if (isExtensionActive('user')) {
1196 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1198 $GLOBALS[__FUNCTION__] = 0;
1202 // Return cached value
1203 return $GLOBALS[__FUNCTION__];
1206 // "Getter" for total locked user accounts
1207 function getTotalRandomRefidUser () {
1209 if (!isset($GLOBALS[__FUNCTION__])) {
1211 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1212 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
1214 $GLOBALS[__FUNCTION__] = 0;
1218 // Return cached value
1219 return $GLOBALS[__FUNCTION__];
1222 // Is given userid valid?
1223 function isValidUserId ($userid) {
1224 // Do we have cache?
1225 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1227 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1231 return $GLOBALS[__FUNCTION__][$userid];
1235 function encodeEntities ($str) {
1237 $str = secureString($str, true, true);
1239 // Encode dollar sign as well
1240 $str = str_replace('$', '$', $str);
1246 // "Getter" for date from patch_ctime
1247 function getDateFromRepository () {
1249 if (!isset($GLOBALS[__FUNCTION__])) {
1251 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1255 return $GLOBALS[__FUNCTION__];
1258 // "Getter" for date/time from patch_ctime
1259 function getDateTimeFromRepository () {
1261 if (!isset($GLOBALS[__FUNCTION__])) {
1263 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1267 return $GLOBALS[__FUNCTION__];
1270 // Getter for current year (default)
1271 function getYear ($timestamp = NULL) {
1273 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1275 if (is_null($timestamp)) {
1276 $timestamp = time();
1280 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1284 return $GLOBALS[__FUNCTION__][$timestamp];
1287 // Getter for current month (default)
1288 function getMonth ($timestamp = NULL) {
1290 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1291 // If null is set, use time()
1292 if (is_null($timestamp)) {
1293 // Use time() which is current timestamp
1294 $timestamp = time();
1298 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1302 return $GLOBALS[__FUNCTION__][$timestamp];
1305 // Getter for current hour (default)
1306 function getHour ($timestamp = NULL) {
1308 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1310 if (is_null($timestamp)) {
1311 $timestamp = time();
1315 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1319 return $GLOBALS[__FUNCTION__][$timestamp];
1322 // Getter for current day (default)
1323 function getDay ($timestamp = NULL) {
1325 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1327 if (is_null($timestamp)) {
1328 $timestamp = time();
1332 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1336 return $GLOBALS[__FUNCTION__][$timestamp];
1339 // Getter for current week (default)
1340 function getWeek ($timestamp = NULL) {
1342 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1344 if (is_null($timestamp)) $timestamp = time();
1347 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1351 return $GLOBALS[__FUNCTION__][$timestamp];
1354 // Getter for current short_hour (default)
1355 function getShortHour ($timestamp = NULL) {
1357 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1359 if (is_null($timestamp)) $timestamp = time();
1362 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1366 return $GLOBALS[__FUNCTION__][$timestamp];
1369 // Getter for current long_hour (default)
1370 function getLongHour ($timestamp = NULL) {
1372 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1374 if (is_null($timestamp)) $timestamp = time();
1377 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1381 return $GLOBALS[__FUNCTION__][$timestamp];
1384 // Getter for current second (default)
1385 function getSecond ($timestamp = NULL) {
1387 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1389 if (is_null($timestamp)) $timestamp = time();
1392 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1396 return $GLOBALS[__FUNCTION__][$timestamp];
1399 // Getter for current minute (default)
1400 function getMinute ($timestamp = NULL) {
1402 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1404 if (is_null($timestamp)) $timestamp = time();
1407 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1411 return $GLOBALS[__FUNCTION__][$timestamp];
1414 // Checks wether the title decoration is enabled
1415 function isTitleDecorationEnabled () {
1416 // Do we have cache?
1417 if (!isset($GLOBALS[__FUNCTION__])) {
1419 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1423 return $GLOBALS[__FUNCTION__];
1426 // Checks wether filter usage updates are enabled (expensive queries!)
1427 function isFilterUsageUpdateEnabled () {
1428 // Do we have cache?
1429 if (!isset($GLOBALS[__FUNCTION__])) {
1431 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1435 return $GLOBALS[__FUNCTION__];
1438 // Checks wether debugging of weekly resets is enabled
1439 function isWeeklyResetDebugEnabled () {
1440 // Do we have cache?
1441 if (!isset($GLOBALS[__FUNCTION__])) {
1443 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1447 return $GLOBALS[__FUNCTION__];
1450 // Checks wether debugging of monthly resets is enabled
1451 function isMonthlyResetDebugEnabled () {
1452 // Do we have cache?
1453 if (!isset($GLOBALS[__FUNCTION__])) {
1455 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1459 return $GLOBALS[__FUNCTION__];
1462 // Checks wether displaying of debug SQLs are enabled
1463 function isDisplayDebugSqlEnabled () {
1464 // Do we have cache?
1465 if (!isset($GLOBALS[__FUNCTION__])) {
1467 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1471 return $GLOBALS[__FUNCTION__];
1474 // Checks wether module title is enabled
1475 function isModuleTitleEnabled () {
1476 // Do we have cache?
1477 if (!isset($GLOBALS[__FUNCTION__])) {
1479 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1483 return $GLOBALS[__FUNCTION__];
1486 // Checks wether what title is enabled
1487 function isWhatTitleEnabled () {
1488 // Do we have cache?
1489 if (!isset($GLOBALS[__FUNCTION__])) {
1491 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1495 return $GLOBALS[__FUNCTION__];
1498 // Checks wether stats are enabled
1499 function ifInternalStatsEnabled () {
1500 // Do we have cache?
1501 if (!isset($GLOBALS[__FUNCTION__])) {
1502 // Then determine it
1503 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1506 // Return cached value
1507 return $GLOBALS[__FUNCTION__];
1510 // Checks wether admin-notification of certain user actions is enabled
1511 function isAdminNotificationEnabled () {
1512 // Do we have cache?
1513 if (!isset($GLOBALS[__FUNCTION__])) {
1515 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1519 return $GLOBALS[__FUNCTION__];
1522 // Checks wether random referral id selection is enabled
1523 function isRandomReferralIdEnabled () {
1524 // Do we have cache?
1525 if (!isset($GLOBALS[__FUNCTION__])) {
1527 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1531 return $GLOBALS[__FUNCTION__];
1534 // "Getter" for default language
1535 function getDefaultLanguage () {
1536 // Do we have cache?
1537 if (!isset($GLOBALS[__FUNCTION__])) {
1539 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1543 return $GLOBALS[__FUNCTION__];
1546 // "Getter" for default referral id
1547 function getDefRefid () {
1548 // Do we have cache?
1549 if (!isset($GLOBALS[__FUNCTION__])) {
1551 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1555 return $GLOBALS[__FUNCTION__];
1558 // "Getter" for path
1559 function getPath () {
1560 // Do we have cache?
1561 if (!isset($GLOBALS[__FUNCTION__])) {
1563 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1567 return $GLOBALS[__FUNCTION__];
1571 function getUrl () {
1572 // Do we have cache?
1573 if (!isset($GLOBALS[__FUNCTION__])) {
1575 $GLOBALS[__FUNCTION__] = getConfig('URL');
1579 return $GLOBALS[__FUNCTION__];
1582 // "Getter" for cache_path
1583 function getCachePath () {
1584 // Do we have cache?
1585 if (!isset($GLOBALS[__FUNCTION__])) {
1587 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1591 return $GLOBALS[__FUNCTION__];
1594 // "Getter" for secret_key
1595 function getSecretKey () {
1596 // Do we have cache?
1597 if (!isset($GLOBALS[__FUNCTION__])) {
1599 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1603 return $GLOBALS[__FUNCTION__];
1606 // "Getter" for SITE_KEY
1607 function getSiteKey () {
1608 // Do we have cache?
1609 if (!isset($GLOBALS[__FUNCTION__])) {
1611 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1615 return $GLOBALS[__FUNCTION__];
1618 // "Getter" for DATE_KEY
1619 function getDateKey () {
1620 // Do we have cache?
1621 if (!isset($GLOBALS[__FUNCTION__])) {
1623 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1627 return $GLOBALS[__FUNCTION__];
1630 // "Getter" for master_salt
1631 function getMasterSalt () {
1632 // Do we have cache?
1633 if (!isset($GLOBALS[__FUNCTION__])) {
1635 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1639 return $GLOBALS[__FUNCTION__];
1642 // "Getter" for prime
1643 function getPrime () {
1644 // Do we have cache?
1645 if (!isset($GLOBALS[__FUNCTION__])) {
1647 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1651 return $GLOBALS[__FUNCTION__];
1654 // "Getter" for encrypt_separator
1655 function getEncryptSeparator () {
1656 // Do we have cache?
1657 if (!isset($GLOBALS[__FUNCTION__])) {
1659 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1663 return $GLOBALS[__FUNCTION__];
1666 // "Getter" for mysql_prefix
1667 function getMysqlPrefix () {
1668 // Do we have cache?
1669 if (!isset($GLOBALS[__FUNCTION__])) {
1671 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1675 return $GLOBALS[__FUNCTION__];
1678 // "Getter" for table_type
1679 function getTableType () {
1680 // Do we have cache?
1681 if (!isset($GLOBALS[__FUNCTION__])) {
1683 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1687 return $GLOBALS[__FUNCTION__];
1690 // "Getter" for salt_length
1691 function getSaltLength () {
1692 // Do we have cache?
1693 if (!isset($GLOBALS[__FUNCTION__])) {
1695 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1699 return $GLOBALS[__FUNCTION__];
1702 // "Getter" for output_mode
1703 function getOutputMode () {
1704 // Do we have cache?
1705 if (!isset($GLOBALS[__FUNCTION__])) {
1707 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1711 return $GLOBALS[__FUNCTION__];
1714 // "Getter" for full_version
1715 function getFullVersion () {
1716 // Do we have cache?
1717 if (!isset($GLOBALS[__FUNCTION__])) {
1719 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1723 return $GLOBALS[__FUNCTION__];
1726 // "Getter" for title
1727 function getTitle () {
1728 // Do we have cache?
1729 if (!isset($GLOBALS[__FUNCTION__])) {
1731 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1735 return $GLOBALS[__FUNCTION__];
1738 // "Getter" for curr_svn_revision
1739 function getCurrentRepositoryRevision () {
1740 // Do we have cache?
1741 if (!isset($GLOBALS[__FUNCTION__])) {
1743 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1747 return $GLOBALS[__FUNCTION__];
1750 // "Getter" for server_url
1751 function getServerUrl () {
1752 // Do we have cache?
1753 if (!isset($GLOBALS[__FUNCTION__])) {
1755 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1759 return $GLOBALS[__FUNCTION__];
1762 // "Getter" for mt_word
1763 function getMtWord () {
1764 // Do we have cache?
1765 if (!isset($GLOBALS[__FUNCTION__])) {
1767 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1771 return $GLOBALS[__FUNCTION__];
1774 // "Getter" for mt_word2
1775 function getMtWord2 () {
1776 // Do we have cache?
1777 if (!isset($GLOBALS[__FUNCTION__])) {
1779 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1783 return $GLOBALS[__FUNCTION__];
1786 // "Getter" for main_title
1787 function getMainTitle () {
1788 // Do we have cache?
1789 if (!isset($GLOBALS[__FUNCTION__])) {
1791 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1795 return $GLOBALS[__FUNCTION__];
1798 // "Getter" for file_hash
1799 function getFileHash () {
1800 // Do we have cache?
1801 if (!isset($GLOBALS[__FUNCTION__])) {
1803 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1807 return $GLOBALS[__FUNCTION__];
1810 // "Getter" for pass_scramble
1811 function getPassScramble () {
1812 // Do we have cache?
1813 if (!isset($GLOBALS[__FUNCTION__])) {
1815 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1819 return $GLOBALS[__FUNCTION__];
1822 // "Getter" for ap_inactive_since
1823 function getApInactiveSince () {
1824 // Do we have cache?
1825 if (!isset($GLOBALS[__FUNCTION__])) {
1827 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1831 return $GLOBALS[__FUNCTION__];
1834 // "Getter" for user_min_confirmed
1835 function getUserMinConfirmed () {
1836 // Do we have cache?
1837 if (!isset($GLOBALS[__FUNCTION__])) {
1839 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1843 return $GLOBALS[__FUNCTION__];
1846 // "Getter" for auto_purge
1847 function getAutoPurge () {
1848 // Do we have cache?
1849 if (!isset($GLOBALS[__FUNCTION__])) {
1851 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1855 return $GLOBALS[__FUNCTION__];
1858 // "Getter" for bonus_userid
1859 function getBonusUserid () {
1860 // Do we have cache?
1861 if (!isset($GLOBALS[__FUNCTION__])) {
1863 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1867 return $GLOBALS[__FUNCTION__];
1870 // "Getter" for ap_inactive_time
1871 function getApInactiveTime () {
1872 // Do we have cache?
1873 if (!isset($GLOBALS[__FUNCTION__])) {
1875 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1879 return $GLOBALS[__FUNCTION__];
1882 // "Getter" for ap_dm_timeout
1883 function getApDmTimeout () {
1884 // Do we have cache?
1885 if (!isset($GLOBALS[__FUNCTION__])) {
1887 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1891 return $GLOBALS[__FUNCTION__];
1894 // "Getter" for ap_tasks_time
1895 function getApTasksTime () {
1896 // Do we have cache?
1897 if (!isset($GLOBALS[__FUNCTION__])) {
1899 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1903 return $GLOBALS[__FUNCTION__];
1906 // "Getter" for ap_unconfirmed_time
1907 function getApUnconfirmedTime () {
1908 // Do we have cache?
1909 if (!isset($GLOBALS[__FUNCTION__])) {
1911 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1915 return $GLOBALS[__FUNCTION__];
1918 // "Getter" for points
1919 function getPoints () {
1920 // Do we have cache?
1921 if (!isset($GLOBALS[__FUNCTION__])) {
1923 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1927 return $GLOBALS[__FUNCTION__];
1930 // "Getter" for slogan
1931 function getSlogan () {
1932 // Do we have cache?
1933 if (!isset($GLOBALS[__FUNCTION__])) {
1935 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1939 return $GLOBALS[__FUNCTION__];
1942 // "Getter" for copy
1943 function getCopy () {
1944 // Do we have cache?
1945 if (!isset($GLOBALS[__FUNCTION__])) {
1947 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1951 return $GLOBALS[__FUNCTION__];
1954 // "Getter" for webmaster
1955 function getWebmaster () {
1956 // Do we have cache?
1957 if (!isset($GLOBALS[__FUNCTION__])) {
1959 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1963 return $GLOBALS[__FUNCTION__];
1966 // "Getter" for sql_count
1967 function getSqlCount () {
1968 // Do we have cache?
1969 if (!isset($GLOBALS[__FUNCTION__])) {
1971 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1975 return $GLOBALS[__FUNCTION__];
1978 // "Getter" for num_templates
1979 function getNumTemplates () {
1980 // Do we have cache?
1981 if (!isset($GLOBALS[__FUNCTION__])) {
1983 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1987 return $GLOBALS[__FUNCTION__];
1990 // "Getter" for dns_cache_timeout
1991 function getDnsCacheTimeout () {
1992 // Do we have cache?
1993 if (!isset($GLOBALS[__FUNCTION__])) {
1995 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1999 return $GLOBALS[__FUNCTION__];
2002 // "Getter" for menu_blur_spacer
2003 function getMenuBlurSpacer () {
2004 // Do we have cache?
2005 if (!isset($GLOBALS[__FUNCTION__])) {
2007 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2011 return $GLOBALS[__FUNCTION__];
2014 // "Getter" for points_register
2015 function getPointsRegister () {
2016 // Do we have cache?
2017 if (!isset($GLOBALS[__FUNCTION__])) {
2019 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2023 return $GLOBALS[__FUNCTION__];
2026 // "Getter" for points_ref
2027 function getPointsRef () {
2028 // Do we have cache?
2029 if (!isset($GLOBALS[__FUNCTION__])) {
2031 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2035 return $GLOBALS[__FUNCTION__];
2038 // "Getter" for ref_payout
2039 function getRefPayout () {
2040 // Do we have cache?
2041 if (!isset($GLOBALS[__FUNCTION__])) {
2043 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2047 return $GLOBALS[__FUNCTION__];
2050 // "Getter" for online_timeout
2051 function getOnlineTimeout () {
2052 // Do we have cache?
2053 if (!isset($GLOBALS[__FUNCTION__])) {
2055 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2059 return $GLOBALS[__FUNCTION__];
2062 // "Getter" for index_home
2063 function getIndexHome () {
2064 // Do we have cache?
2065 if (!isset($GLOBALS[__FUNCTION__])) {
2067 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2071 return $GLOBALS[__FUNCTION__];
2074 // "Getter" for one_day
2075 function getOneDay () {
2076 // Do we have cache?
2077 if (!isset($GLOBALS[__FUNCTION__])) {
2079 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2083 return $GLOBALS[__FUNCTION__];
2086 // "Getter" for activate_xchange
2087 function getActivateXchange () {
2088 // Do we have cache?
2089 if (!isset($GLOBALS[__FUNCTION__])) {
2091 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2095 return $GLOBALS[__FUNCTION__];
2098 // "Getter" for img_type
2099 function getImgType () {
2100 // Do we have cache?
2101 if (!isset($GLOBALS[__FUNCTION__])) {
2103 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2107 return $GLOBALS[__FUNCTION__];
2110 // "Getter" for code_length
2111 function getCodeLength () {
2112 // Do we have cache?
2113 if (!isset($GLOBALS[__FUNCTION__])) {
2115 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2119 return $GLOBALS[__FUNCTION__];
2122 // "Getter" for least_cats
2123 function getLeastCats () {
2124 // Do we have cache?
2125 if (!isset($GLOBALS[__FUNCTION__])) {
2127 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2131 return $GLOBALS[__FUNCTION__];
2134 // "Getter" for pass_len
2135 function getPassLen () {
2136 // Do we have cache?
2137 if (!isset($GLOBALS[__FUNCTION__])) {
2139 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2143 return $GLOBALS[__FUNCTION__];
2146 // "Getter" for admin_menu
2147 function getAdminMenu () {
2148 // Do we have cache?
2149 if (!isset($GLOBALS[__FUNCTION__])) {
2151 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2155 return $GLOBALS[__FUNCTION__];
2158 // "Getter" for last_month
2159 function getLastMonth () {
2160 // Do we have cache?
2161 if (!isset($GLOBALS[__FUNCTION__])) {
2163 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2167 return $GLOBALS[__FUNCTION__];
2170 // "Getter" for max_send
2171 function getMaxSend () {
2172 // Do we have cache?
2173 if (!isset($GLOBALS[__FUNCTION__])) {
2175 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2179 return $GLOBALS[__FUNCTION__];
2182 // "Getter" for mails_page
2183 function getMailsPage () {
2184 // Do we have cache?
2185 if (!isset($GLOBALS[__FUNCTION__])) {
2187 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2191 return $GLOBALS[__FUNCTION__];
2194 // "Getter" for rand_no
2195 function getRandNo () {
2196 // Do we have cache?
2197 if (!isset($GLOBALS[__FUNCTION__])) {
2199 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2203 return $GLOBALS[__FUNCTION__];
2206 // "Getter" for __DB_NAME
2207 function getDbName () {
2208 // Do we have cache?
2209 if (!isset($GLOBALS[__FUNCTION__])) {
2211 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2215 return $GLOBALS[__FUNCTION__];
2218 // "Getter" for DOMAIN
2219 function getDomain () {
2220 // Do we have cache?
2221 if (!isset($GLOBALS[__FUNCTION__])) {
2223 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2227 return $GLOBALS[__FUNCTION__];
2230 // "Getter" for proxy_username
2231 function getProxyUsername () {
2232 // Do we have cache?
2233 if (!isset($GLOBALS[__FUNCTION__])) {
2235 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2239 return $GLOBALS[__FUNCTION__];
2242 // "Getter" for proxy_password
2243 function getProxyPassword () {
2244 // Do we have cache?
2245 if (!isset($GLOBALS[__FUNCTION__])) {
2247 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2251 return $GLOBALS[__FUNCTION__];
2254 // "Getter" for proxy_host
2255 function getProxyHost () {
2256 // Do we have cache?
2257 if (!isset($GLOBALS[__FUNCTION__])) {
2259 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2263 return $GLOBALS[__FUNCTION__];
2266 // "Getter" for proxy_port
2267 function getProxyPort () {
2268 // Do we have cache?
2269 if (!isset($GLOBALS[__FUNCTION__])) {
2271 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2275 return $GLOBALS[__FUNCTION__];
2278 // "Getter" for SMTP_HOSTNAME
2279 function getSmtpHostname () {
2280 // Do we have cache?
2281 if (!isset($GLOBALS[__FUNCTION__])) {
2283 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2287 return $GLOBALS[__FUNCTION__];
2290 // "Getter" for SMTP_USER
2291 function getSmtpUser () {
2292 // Do we have cache?
2293 if (!isset($GLOBALS[__FUNCTION__])) {
2295 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2299 return $GLOBALS[__FUNCTION__];
2302 // "Getter" for SMTP_PASSWORD
2303 function getSmtpPassword () {
2304 // Do we have cache?
2305 if (!isset($GLOBALS[__FUNCTION__])) {
2307 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2311 return $GLOBALS[__FUNCTION__];
2314 // "Getter" for points_word
2315 function getPointsWord () {
2316 // Do we have cache?
2317 if (!isset($GLOBALS[__FUNCTION__])) {
2319 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2323 return $GLOBALS[__FUNCTION__];
2326 // "Getter" for profile_lock
2327 function getProfileLock () {
2328 // Do we have cache?
2329 if (!isset($GLOBALS[__FUNCTION__])) {
2331 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2335 return $GLOBALS[__FUNCTION__];
2338 // "Getter" for url_tlock
2339 function getUrlTlock () {
2340 // Do we have cache?
2341 if (!isset($GLOBALS[__FUNCTION__])) {
2343 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2347 return $GLOBALS[__FUNCTION__];
2350 // "Getter" for title_left
2351 function getTitleLeft () {
2352 // Do we have cache?
2353 if (!isset($GLOBALS[__FUNCTION__])) {
2355 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2359 return $GLOBALS[__FUNCTION__];
2362 // "Getter" for title_right
2363 function getTitleRight () {
2364 // Do we have cache?
2365 if (!isset($GLOBALS[__FUNCTION__])) {
2367 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2371 return $GLOBALS[__FUNCTION__];
2374 // "Getter" for title_middle
2375 function getTitleMiddle () {
2376 // Do we have cache?
2377 if (!isset($GLOBALS[__FUNCTION__])) {
2379 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2383 return $GLOBALS[__FUNCTION__];
2386 // Getter for 'check_double_email'
2387 function getCheckDoubleEmail () {
2388 // Is the cache entry set?
2389 if (!isset($GLOBALS[__FUNCTION__])) {
2390 // No, so determine it
2391 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2394 // Return cached entry
2395 return $GLOBALS[__FUNCTION__];
2398 // Checks wether 'check_double_email' is 'Y'
2399 function isCheckDoubleEmailEnabled () {
2400 // Is the cache entry set?
2401 if (!isset($GLOBALS[__FUNCTION__])) {
2402 // No, so determine it
2403 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2406 // Return cached entry
2407 return $GLOBALS[__FUNCTION__];
2410 // Getter for 'display_home_in_index'
2411 function getDisplayHomeInIndex () {
2412 // Is the cache entry set?
2413 if (!isset($GLOBALS[__FUNCTION__])) {
2414 // No, so determine it
2415 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2418 // Return cached entry
2419 return $GLOBALS[__FUNCTION__];
2422 // Checks wether 'display_home_in_index' is 'Y'
2423 function isDisplayHomeInIndexEnabled () {
2424 // Is the cache entry set?
2425 if (!isset($GLOBALS[__FUNCTION__])) {
2426 // No, so determine it
2427 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2430 // Return cached entry
2431 return $GLOBALS[__FUNCTION__];
2434 // Checks wether proxy configuration is used
2435 function isProxyUsed () {
2436 // Do we have cache?
2437 if (!isset($GLOBALS[__FUNCTION__])) {
2439 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2443 return $GLOBALS[__FUNCTION__];
2446 // Checks wether POST data contains selections
2447 function ifPostContainsSelections ($element = 'sel') {
2448 // Do we have cache?
2449 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2451 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2455 return $GLOBALS[__FUNCTION__][$element];
2458 // Checks wether verbose_sql is Y and returns true/false if so
2459 function isVerboseSqlEnabled () {
2460 // Do we have cache?
2461 if (!isset($GLOBALS[__FUNCTION__])) {
2463 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2467 return $GLOBALS[__FUNCTION__];
2470 // "Getter" for total user points
2471 function getTotalPoints ($userid) {
2472 // Do we have cache?
2473 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2474 // Init array for filter chain
2476 'userid' => $userid,
2480 // Run filter chain for getting more point values
2481 $data = runFilterChain('get_total_points', $data);
2484 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2488 return $GLOBALS[__FUNCTION__][$userid];
2491 // Wrapper to check if url_blacklist is enabled
2492 function isUrlBlacklistEnabled () {
2493 // Do we have cache?
2494 if (!isset($GLOBALS[__FUNCTION__])) {
2496 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2500 return $GLOBALS[__FUNCTION__];
2503 // Checks wether direct payment is allowed in configuration
2504 function isDirectPaymentEnabled () {
2505 // Do we have cache?
2506 if (!isset($GLOBALS[__FUNCTION__])) {
2508 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2512 return $GLOBALS[__FUNCTION__];
2515 // Checks wether JavaScript-based admin menu is enabled
2516 function isAdminMenuJavascriptEnabled () {
2517 // Do we have cache?
2518 if (!isset($GLOBALS[__FUNCTION__])) {
2520 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
2524 return $GLOBALS[__FUNCTION__];
2527 // Wrapper to check if current task is for extension (not update)
2528 function isExtensionTask ($content) {
2529 // Do we have cache?
2530 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2532 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2536 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2539 // Wrapper to check if output mode is CSS
2540 function isCssOutputMode () {
2542 return (getScriptOutputMode() == 1);
2545 // Wrapper to check if output mode is HTML
2546 function isHtmlOutputMode () {
2548 return (getScriptOutputMode() == 0);
2551 // Wrapper to check if output mode is RAW
2552 function isRawOutputMode () {
2554 return (getScriptOutputMode() == -1);
2557 // Wrapper to generate a user email link
2558 function generateWrappedUserEmailLink ($email) {
2559 // Just call the inner function
2560 return generateEmailLink($email, 'user_data');
2563 // Wrapper to check if user points are locked
2564 function ifUserPointsLocked ($userid) {
2565 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2566 // Do we have cache?
2567 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2569 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2573 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2574 return $GLOBALS[__FUNCTION__][$userid];
2577 // Appends a line to an existing file or creates it instantly with given content.
2578 // This function does always add a new-line character to every line.
2579 function appendLineToFile ($file, $line) {
2580 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2581 fwrite($fp, $line . "\n");
2585 // Wrapper for changeDataInFile() but with full path added
2586 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2588 $FQFN = getPath() . $FQFN;
2590 // Call inner function
2591 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2594 // Wrapper for changing entries in config-local.php
2595 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2596 // Call the inner function
2597 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2600 // Shortens ucfirst(strtolower()) calls
2601 function firstCharUpperCase ($str) {
2602 return ucfirst(strtolower($str));
2605 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2606 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2607 // Get the configuration entry
2608 $configValue = getConfig($configEntry);
2610 // Call inner method
2611 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2614 // Shortens converting of German comma to Computer's version in POST data
2615 function convertCommaToDotInPostData ($postEntry) {
2616 // Read and convert given entry
2617 $postValue = convertCommaToDot(postRequestElement($postEntry));
2619 // ... and set it again
2620 setPostRequestElement($postEntry, $postValue);
2623 // Converts German commas to Computer's version in all entries
2624 function convertCommaToDotInPostDataArray ($postEntries) {
2625 // Replace german decimal comma with computer decimal dot
2626 foreach ($postEntries as $entry) {
2627 // Is the entry there?
2628 if (isPostRequestElementSet($entry)) {
2630 convertCommaToDotInPostData($entry);
2636 * Parses a string into a US formated float variable, taken from user comments
2637 * from PHP documentation website.
2639 * @param $floatString A string holding a float expression
2640 * @return $float Corresponding float variable
2641 * @author chris<at>georgakopoulos<dot>com
2642 * @link http://de.php.net/manual/en/function.floatval.php#92563
2644 function parseFloat ($floatString){
2645 $LocaleInfo = localeconv();
2646 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '', $floatString);
2647 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2648 return floatval($floatString);
2651 // Generates a YES/NO option list from given default
2652 function generateYesNoOptionList ($defaultValue = '') {
2654 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
2657 // "Getter" for total available receivers
2658 function getTotalReceivers ($mode = 'normal') {
2660 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2666 // Wrapper "getter" to get total unconfirmed mails for given userid
2667 function getTotalUnconfirmedMails ($userid) {
2668 // Do we have cache?
2669 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2671 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2675 return $GLOBALS[__FUNCTION__][$userid];