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 header()
485 // Send a header but checks before if we can do so
486 function sendHeader ($header) {
488 //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
489 $GLOBALS['header'][] = trim($header);
492 // Flushes all headers
493 function flushHeaders () {
494 // Is the header already sent?
495 if (headers_sent()) {
497 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
500 // Flush all headers if found
501 if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
502 foreach ($GLOBALS['header'] as $header) {
507 // Mark them as flushed
508 $GLOBALS['header'] = array();
511 // Wrapper function for chmod()
512 // @TODO Do some more sanity check here
513 function changeMode ($FQFN, $mode) {
514 // Is the file/directory there?
515 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
516 // Neither, so abort here
517 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
521 return chmod($FQFN, $mode);
524 // Wrapper for unlink()
525 function removeFile ($FQFN) {
526 // Is the file there?
527 if (isFileReadable($FQFN)) {
529 $GLOBALS['file_readable'][$FQFN] = false;
532 return unlink($FQFN);
535 // All fine if no file was removed. If we change this to 'false' or rewrite
536 // above if() block it would be to restrictive.
540 // Wrapper for $_POST['sel']
541 function countPostSelection ($element = 'sel') {
543 if (isPostRequestElementSet($element)) {
544 // Return counted elements
545 return countSelection(postRequestElement($element));
547 // Return zero if not found
552 // Checks wether the config-local.php is loaded
553 function isConfigLocalLoaded () {
554 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
557 // Checks wether a nickname or userid was entered and caches the result
558 function isNicknameUsed ($userid) {
559 // Is the cache there
560 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
562 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid) && ($userid != 'NULL'));
566 return $GLOBALS[__FUNCTION__][$userid];
569 // Getter for 'what' value
570 function getWhat () {
575 if (isWhatSet(true)) {
577 $what = $GLOBALS['what'];
584 // Setter for 'what' value
585 function setWhat ($newWhat) {
586 $GLOBALS['what'] = SQL_ESCAPE($newWhat);
589 // Setter for 'what' from configuration
590 function setWhatFromConfig ($configEntry) {
591 // Get 'what' from config
592 $what = getConfig($configEntry);
598 // Checks wether what is set and optionally aborts on miss
599 function isWhatSet ($strict = false) {
601 $isset = isset($GLOBALS['what']);
603 // Should we abort here?
604 if (($strict === true) && ($isset === false)) {
606 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
613 // Getter for 'action' value
614 function getAction ($strict = true) {
619 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
621 $action = $GLOBALS['action'];
628 // Setter for 'action' value
629 function setAction ($newAction) {
630 $GLOBALS['action'] = SQL_ESCAPE($newAction);
633 // Checks wether action is set and optionally aborts on miss
634 function isActionSet ($strict = false) {
636 $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
638 // Should we abort here?
639 if (($strict === true) && ($isset === false)) {
641 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
648 // Getter for 'module' value
649 function getModule ($strict = true) {
654 if (isModuleSet($strict)) {
656 $module = $GLOBALS['module'];
663 // Setter for 'module' value
664 function setModule ($newModule) {
665 // Secure it and make all modules lower-case
666 $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
669 // Checks wether module is set and optionally aborts on miss
670 function isModuleSet ($strict = false) {
672 $isset = (!empty($GLOBALS['module']));
674 // Should we abort here?
675 if (($strict === true) && ($isset === false)) {
677 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
681 return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
684 // Getter for 'output_mode' value
685 function getScriptOutputMode () {
687 if (!isset($GLOBALS[__FUNCTION__])) {
692 if (isOutputModeSet(true)) {
694 $output_mode = $GLOBALS['output_mode'];
698 $GLOBALS[__FUNCTION__] = $output_mode;
702 return $GLOBALS[__FUNCTION__];
705 // Setter for 'output_mode' value
706 function setOutputMode ($newOutputMode) {
707 $GLOBALS['output_mode'] = (int) $newOutputMode;
710 // Checks wether output_mode is set and optionally aborts on miss
711 function isOutputModeSet ($strict = false) {
713 $isset = (isset($GLOBALS['output_mode']));
715 // Should we abort here?
716 if (($strict === true) && ($isset === false)) {
718 debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
725 // Enables block-mode
726 function enableBlockMode ($enabled = true) {
727 $GLOBALS['block_mode'] = $enabled;
730 // Checks wether block-mode is enabled
731 function isBlockModeEnabled () {
733 if (!isset($GLOBALS['block_mode'])) {
735 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
739 return $GLOBALS['block_mode'];
743 * Wrapper function for addPointsThroughReferralSystem(), you should generally
744 * avoid this function and use addPointsThroughReferralSystem() directly and add
745 * your special payment method entry to points_data instead.
747 * @param $subject A string-encoded subject for this add
748 * @param $userid The recipient (member) for given points
749 * @param $points Points to be added to member's account
750 * @return $added Wether the points has been added to the user's account
752 function addPointsDirectly ($subject, $userid, $points) {
754 initReferralSystem();
756 // Call more complicated method (due to more parameters)
757 return addPointsThroughReferralSystem($subject, $userid, $points, false, 0, 'DIRECT');
760 // Wrapper for redirectToUrl but URL comes from a configuration entry
761 function redirectToConfiguredUrl ($configEntry) {
763 redirectToUrl(getConfig($configEntry));
766 // Wrapper function to redirect from member-only modules to index
767 function redirectToIndexMemberOnlyModule () {
768 // Do the redirect here
769 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
772 // Wrapper function to redirect to current URL
773 function redirectToRequestUri () {
774 redirectToUrl(basename(detectRequestUri()));
777 // Wrapper function to redirect to de-refered URL
778 function redirectToDereferedUrl ($url) {
780 redirectToUrl(generateDerefererUrl($url));
783 // Wrapper function for checking if extension is installed and newer or same version
784 function isExtensionInstalledAndNewer ($ext_name, $version) {
785 // Is an cache entry found?
786 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
788 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
790 // Cache hits should be incremented twice
791 incrementStatsEntry('cache_hits', 2);
795 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
796 return $GLOBALS[__FUNCTION__][$ext_name][$version];
799 // Wrapper function for checking if extension is installed and older than given version
800 function isExtensionInstalledAndOlder ($ext_name, $version) {
801 // Is an cache entry found?
802 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
804 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
806 // Cache hits should be incremented twice
807 incrementStatsEntry('cache_hits', 2);
811 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
812 return $GLOBALS[__FUNCTION__][$ext_name][$version];
816 function setUsername ($userName) {
817 $GLOBALS['username'] = (string) $userName;
821 function getUsername () {
823 if (!isset($GLOBALS['username'])) {
824 // No, so it has to be a guest
825 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
829 return $GLOBALS['username'];
832 // Wrapper function for installation phase
833 function isInstallationPhase () {
835 if (!isset($GLOBALS[__FUNCTION__])) {
837 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
841 return $GLOBALS[__FUNCTION__];
844 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
845 function isDemoModeActive () {
847 if (!isset($GLOBALS[__FUNCTION__])) {
849 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
853 return $GLOBALS[__FUNCTION__];
856 // Getter for PHP caching value
857 function getPhpCaching () {
858 return $GLOBALS['php_caching'];
861 // Checks wether the admin hash is set
862 function isAdminHashSet ($adminId) {
863 // Is the array there?
864 if (!isset($GLOBALS['cache_array']['admin'])) {
865 // Missing array should be reported
866 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
869 // Check for admin hash
870 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
873 // Setter for admin hash
874 function setAdminHash ($adminId, $hash) {
875 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
878 // Getter for current admin login
879 function getCurrentAdminLogin () {
881 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
884 if (!isset($GLOBALS[__FUNCTION__])) {
886 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
890 return $GLOBALS[__FUNCTION__];
893 // Setter for admin id (and current)
894 function setAdminId ($adminId) {
896 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
899 $status = setSession('admin_id', bigintval($adminId));
902 setCurrentAdminId($adminId);
908 // Setter for admin_last
909 function setAdminLast ($adminLast) {
911 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
914 $status = setSession('admin_last', $adminLast);
920 // Setter for admin_md5
921 function setAdminMd5 ($adminMd5) {
923 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
926 $status = setSession('admin_md5', $adminMd5);
932 // Getter for admin_md5
933 function getAdminMd5 () {
935 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
938 return getSession('admin_md5');
941 // Init user data array
942 function initUserData () {
943 // User id should not be zero
944 if (!isValidUserId(getCurrentUserId())) {
945 // Should be always valid
946 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
950 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
951 $GLOBALS['user_data'][getCurrentUserId()] = array();
954 // Getter for user data
955 function getUserData ($column) {
956 // User id should not be zero
957 if (!isValidUserId(getCurrentUserId())) {
958 // Should be always valid
959 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
965 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
967 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
974 // Checks wether given user data is set to 'Y'
975 function isUserDataEnabled ($column) {
977 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
979 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
983 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
986 // Geter for whole user data array
987 function getUserDataArray () {
989 $userid = getCurrentUserId();
991 // Is the current userid valid?
992 if (!isValidUserId($userid)) {
993 // Should be always valid
994 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
997 // Get the whole array if found
998 if (isset($GLOBALS['user_data'][$userid])) {
999 // Found, so return it
1000 return $GLOBALS['user_data'][$userid];
1002 // Return empty array
1007 // Checks if the user data is valid, this may indicate that the user has logged
1008 // in, but you should use isMember() if you want to find that out.
1009 function isUserDataValid () {
1010 // User id should not be zero so abort here
1011 if (!isCurrentUserIdSet()) {
1016 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1018 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1021 // Return the result
1022 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1025 // Setter for current userid
1026 function setCurrentUserId ($userid) {
1028 $GLOBALS['current_userid'] = bigintval($userid);
1030 // Unset it to re-determine the actual state
1031 unset($GLOBALS['is_userdata_valid'][$userid]);
1034 // Getter for current userid
1035 function getCurrentUserId () {
1036 // Userid must be set before it can be used
1037 if (!isCurrentUserIdSet()) {
1039 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1042 // Return the userid
1043 return $GLOBALS['current_userid'];
1046 // Checks if current userid is set
1047 function isCurrentUserIdSet () {
1048 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1051 // Checks wether we are debugging template cache
1052 function isDebuggingTemplateCache () {
1053 // Do we have cache?
1054 if (!isset($GLOBALS[__FUNCTION__])) {
1056 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1060 return $GLOBALS[__FUNCTION__];
1063 // Wrapper for fetchUserData() and getUserData() calls
1064 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1065 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1067 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1071 // Can we fetch the user data?
1072 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1073 // Now get the data back
1074 $data = getUserData($valueColumn);
1078 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1082 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1083 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1086 // Wrapper for strpos() to ease porting from deprecated ereg() function
1087 function isInString ($needle, $haystack) {
1088 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1089 return (strpos($haystack, $needle) !== false);
1092 // Wrapper for strpos() to ease porting from deprecated eregi() function
1093 // This function is case-insensitive
1094 function isInStringIgnoreCase ($needle, $haystack) {
1095 return (isInString(strtolower($needle), strtolower($haystack)));
1098 // Wrapper to check for if fatal errors where detected
1099 function ifFatalErrorsDetected () {
1100 // Just call the inner function
1101 return (getTotalFatalErrors() > 0);
1104 // Setter for HTTP status
1105 function setHttpStatus ($status) {
1106 $GLOBALS['http_status'] = (string) $status;
1109 // Getter for HTTP status
1110 function getHttpStatus () {
1111 // Is the status set?
1112 if (!isset($GLOBALS['http_status'])) {
1114 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1118 return $GLOBALS['http_status'];
1122 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1123 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1125 * ----------------------------------------------------------------------------
1126 * If you want to redirect, please use redirectToUrl(); instead
1127 * ----------------------------------------------------------------------------
1129 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1131 * @link http://support.microsoft.com/kb/q176113/
1132 * @author Andreas Gohr <andi@splitbrain.org>
1135 function sendRawRedirect ($url) {
1136 // Send helping header
1137 setHttpStatus('302 Found');
1139 // always close the session
1140 session_write_close();
1142 // Revert entity &
1143 $url = str_replace('&', '&', $url);
1145 // check if running on IIS < 6 with CGI-PHP
1146 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1147 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1148 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1149 ($matches[1] < 6)) {
1150 // Send the IIS header
1151 sendHeader('Refresh: 0;url=' . $url);
1153 // Send generic header
1154 sendHeader('Location: ' . $url);
1161 // Determines the country of the given user id
1162 function determineCountry ($userid) {
1163 // Do we have cache?
1164 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1165 // Default is 'invalid'
1166 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1168 // Is extension country active?
1169 if (isExtensionActive('country')) {
1170 // Determine the right country code through the country id
1171 $id = getUserData('country_code');
1173 // Then handle it over
1174 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1176 // Get raw code from user data
1177 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1182 return $GLOBALS[__FUNCTION__][$userid];
1185 // "Getter" for total confirmed user accounts
1186 function getTotalConfirmedUser () {
1188 if (!isset($GLOBALS[__FUNCTION__])) {
1190 if (isExtensionActive('user')) {
1191 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1193 $GLOBALS[__FUNCTION__] = 0;
1197 // Return cached value
1198 return $GLOBALS[__FUNCTION__];
1201 // "Getter" for total unconfirmed user accounts
1202 function getTotalUnconfirmedUser () {
1204 if (!isset($GLOBALS[__FUNCTION__])) {
1206 if (isExtensionActive('user')) {
1207 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1209 $GLOBALS[__FUNCTION__] = 0;
1213 // Return cached value
1214 return $GLOBALS[__FUNCTION__];
1217 // "Getter" for total locked user accounts
1218 function getTotalLockedUser () {
1220 if (!isset($GLOBALS[__FUNCTION__])) {
1222 if (isExtensionActive('user')) {
1223 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1225 $GLOBALS[__FUNCTION__] = 0;
1229 // Return cached value
1230 return $GLOBALS[__FUNCTION__];
1233 // "Getter" for total locked user accounts
1234 function getTotalRandomRefidUser () {
1236 if (!isset($GLOBALS[__FUNCTION__])) {
1238 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1239 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
1241 $GLOBALS[__FUNCTION__] = 0;
1245 // Return cached value
1246 return $GLOBALS[__FUNCTION__];
1249 // Is given userid valid?
1250 function isValidUserId ($userid) {
1251 // Do we have cache?
1252 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1254 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1258 return $GLOBALS[__FUNCTION__][$userid];
1262 function encodeEntities ($str) {
1264 $str = secureString($str, true, true);
1266 // Encode dollar sign as well
1267 $str = str_replace('$', '$', $str);
1273 // "Getter" for date from patch_ctime
1274 function getDateFromRepository () {
1276 if (!isset($GLOBALS[__FUNCTION__])) {
1278 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1282 return $GLOBALS[__FUNCTION__];
1285 // "Getter" for date/time from patch_ctime
1286 function getDateTimeFromRepository () {
1288 if (!isset($GLOBALS[__FUNCTION__])) {
1290 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1294 return $GLOBALS[__FUNCTION__];
1297 // Getter for current year (default)
1298 function getYear ($timestamp = NULL) {
1300 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1302 if (is_null($timestamp)) {
1303 $timestamp = time();
1307 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1311 return $GLOBALS[__FUNCTION__][$timestamp];
1314 // Getter for current month (default)
1315 function getMonth ($timestamp = NULL) {
1317 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1318 // If null is set, use time()
1319 if (is_null($timestamp)) {
1320 // Use time() which is current timestamp
1321 $timestamp = time();
1325 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1329 return $GLOBALS[__FUNCTION__][$timestamp];
1332 // Getter for current hour (default)
1333 function getHour ($timestamp = NULL) {
1335 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1337 if (is_null($timestamp)) {
1338 $timestamp = time();
1342 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1346 return $GLOBALS[__FUNCTION__][$timestamp];
1349 // Getter for current day (default)
1350 function getDay ($timestamp = NULL) {
1352 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1354 if (is_null($timestamp)) {
1355 $timestamp = time();
1359 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1363 return $GLOBALS[__FUNCTION__][$timestamp];
1366 // Getter for current week (default)
1367 function getWeek ($timestamp = NULL) {
1369 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1371 if (is_null($timestamp)) $timestamp = time();
1374 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1378 return $GLOBALS[__FUNCTION__][$timestamp];
1381 // Getter for current short_hour (default)
1382 function getShortHour ($timestamp = NULL) {
1384 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1386 if (is_null($timestamp)) $timestamp = time();
1389 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1393 return $GLOBALS[__FUNCTION__][$timestamp];
1396 // Getter for current long_hour (default)
1397 function getLongHour ($timestamp = NULL) {
1399 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1401 if (is_null($timestamp)) $timestamp = time();
1404 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1408 return $GLOBALS[__FUNCTION__][$timestamp];
1411 // Getter for current second (default)
1412 function getSecond ($timestamp = NULL) {
1414 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1416 if (is_null($timestamp)) $timestamp = time();
1419 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1423 return $GLOBALS[__FUNCTION__][$timestamp];
1426 // Getter for current minute (default)
1427 function getMinute ($timestamp = NULL) {
1429 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1431 if (is_null($timestamp)) $timestamp = time();
1434 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1438 return $GLOBALS[__FUNCTION__][$timestamp];
1441 // Checks wether the title decoration is enabled
1442 function isTitleDecorationEnabled () {
1443 // Do we have cache?
1444 if (!isset($GLOBALS[__FUNCTION__])) {
1446 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1450 return $GLOBALS[__FUNCTION__];
1453 // Checks wether filter usage updates are enabled (expensive queries!)
1454 function isFilterUsageUpdateEnabled () {
1455 // Do we have cache?
1456 if (!isset($GLOBALS[__FUNCTION__])) {
1458 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1462 return $GLOBALS[__FUNCTION__];
1465 // Checks wether debugging of weekly resets is enabled
1466 function isWeeklyResetDebugEnabled () {
1467 // Do we have cache?
1468 if (!isset($GLOBALS[__FUNCTION__])) {
1470 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1474 return $GLOBALS[__FUNCTION__];
1477 // Checks wether debugging of monthly resets is enabled
1478 function isMonthlyResetDebugEnabled () {
1479 // Do we have cache?
1480 if (!isset($GLOBALS[__FUNCTION__])) {
1482 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1486 return $GLOBALS[__FUNCTION__];
1489 // Checks wether displaying of debug SQLs are enabled
1490 function isDisplayDebugSqlEnabled () {
1491 // Do we have cache?
1492 if (!isset($GLOBALS[__FUNCTION__])) {
1494 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1498 return $GLOBALS[__FUNCTION__];
1501 // Checks wether module title is enabled
1502 function isModuleTitleEnabled () {
1503 // Do we have cache?
1504 if (!isset($GLOBALS[__FUNCTION__])) {
1506 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1510 return $GLOBALS[__FUNCTION__];
1513 // Checks wether what title is enabled
1514 function isWhatTitleEnabled () {
1515 // Do we have cache?
1516 if (!isset($GLOBALS[__FUNCTION__])) {
1518 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1522 return $GLOBALS[__FUNCTION__];
1525 // Checks wether stats are enabled
1526 function ifStatsAreEnabled () {
1527 // Do we have cache?
1528 if (!isset($GLOBALS[__FUNCTION__])) {
1529 // Then determine it
1530 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1533 // Return cached value
1534 return $GLOBALS[__FUNCTION__];
1537 // Checks wether admin-notification of certain user actions is enabled
1538 function isAdminNotificationEnabled () {
1539 // Do we have cache?
1540 if (!isset($GLOBALS[__FUNCTION__])) {
1542 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1546 return $GLOBALS[__FUNCTION__];
1549 // Checks wether random referral id selection is enabled
1550 function isRandomReferralIdEnabled () {
1551 // Do we have cache?
1552 if (!isset($GLOBALS[__FUNCTION__])) {
1554 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1558 return $GLOBALS[__FUNCTION__];
1561 // "Getter" for default language
1562 function getDefaultLanguage () {
1563 // Do we have cache?
1564 if (!isset($GLOBALS[__FUNCTION__])) {
1566 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1570 return $GLOBALS[__FUNCTION__];
1573 // "Getter" for default referral id
1574 function getDefRefid () {
1575 // Do we have cache?
1576 if (!isset($GLOBALS[__FUNCTION__])) {
1578 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1582 return $GLOBALS[__FUNCTION__];
1585 // "Getter" for path
1586 function getPath () {
1587 // Do we have cache?
1588 if (!isset($GLOBALS[__FUNCTION__])) {
1590 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1594 return $GLOBALS[__FUNCTION__];
1598 function getUrl () {
1599 // Do we have cache?
1600 if (!isset($GLOBALS[__FUNCTION__])) {
1602 $GLOBALS[__FUNCTION__] = getConfig('URL');
1606 return $GLOBALS[__FUNCTION__];
1609 // "Getter" for cache_path
1610 function getCachePath () {
1611 // Do we have cache?
1612 if (!isset($GLOBALS[__FUNCTION__])) {
1614 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1618 return $GLOBALS[__FUNCTION__];
1621 // "Getter" for secret_key
1622 function getSecretKey () {
1623 // Do we have cache?
1624 if (!isset($GLOBALS[__FUNCTION__])) {
1626 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1630 return $GLOBALS[__FUNCTION__];
1633 // "Getter" for SITE_KEY
1634 function getSiteKey () {
1635 // Do we have cache?
1636 if (!isset($GLOBALS[__FUNCTION__])) {
1638 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1642 return $GLOBALS[__FUNCTION__];
1645 // "Getter" for DATE_KEY
1646 function getDateKey () {
1647 // Do we have cache?
1648 if (!isset($GLOBALS[__FUNCTION__])) {
1650 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1654 return $GLOBALS[__FUNCTION__];
1657 // "Getter" for master_salt
1658 function getMasterSalt () {
1659 // Do we have cache?
1660 if (!isset($GLOBALS[__FUNCTION__])) {
1662 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1666 return $GLOBALS[__FUNCTION__];
1669 // "Getter" for prime
1670 function getPrime () {
1671 // Do we have cache?
1672 if (!isset($GLOBALS[__FUNCTION__])) {
1674 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1678 return $GLOBALS[__FUNCTION__];
1681 // "Getter" for encrypt_separator
1682 function getEncryptSeparator () {
1683 // Do we have cache?
1684 if (!isset($GLOBALS[__FUNCTION__])) {
1686 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1690 return $GLOBALS[__FUNCTION__];
1693 // "Getter" for mysql_prefix
1694 function getMysqlPrefix () {
1695 // Do we have cache?
1696 if (!isset($GLOBALS[__FUNCTION__])) {
1698 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1702 return $GLOBALS[__FUNCTION__];
1705 // "Getter" for table_type
1706 function getTableType () {
1707 // Do we have cache?
1708 if (!isset($GLOBALS[__FUNCTION__])) {
1710 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1714 return $GLOBALS[__FUNCTION__];
1717 // "Getter" for salt_length
1718 function getSaltLength () {
1719 // Do we have cache?
1720 if (!isset($GLOBALS[__FUNCTION__])) {
1722 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1726 return $GLOBALS[__FUNCTION__];
1729 // "Getter" for output_mode
1730 function getOutputMode () {
1731 // Do we have cache?
1732 if (!isset($GLOBALS[__FUNCTION__])) {
1734 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1738 return $GLOBALS[__FUNCTION__];
1741 // "Getter" for full_version
1742 function getFullVersion () {
1743 // Do we have cache?
1744 if (!isset($GLOBALS[__FUNCTION__])) {
1746 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1750 return $GLOBALS[__FUNCTION__];
1753 // "Getter" for title
1754 function getTitle () {
1755 // Do we have cache?
1756 if (!isset($GLOBALS[__FUNCTION__])) {
1758 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1762 return $GLOBALS[__FUNCTION__];
1765 // "Getter" for curr_svn_revision
1766 function getCurrentRepositoryRevision () {
1767 // Do we have cache?
1768 if (!isset($GLOBALS[__FUNCTION__])) {
1770 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1774 return $GLOBALS[__FUNCTION__];
1777 // "Getter" for server_url
1778 function getServerUrl () {
1779 // Do we have cache?
1780 if (!isset($GLOBALS[__FUNCTION__])) {
1782 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1786 return $GLOBALS[__FUNCTION__];
1789 // "Getter" for mt_word
1790 function getMtWord () {
1791 // Do we have cache?
1792 if (!isset($GLOBALS[__FUNCTION__])) {
1794 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1798 return $GLOBALS[__FUNCTION__];
1801 // "Getter" for mt_word2
1802 function getMtWord2 () {
1803 // Do we have cache?
1804 if (!isset($GLOBALS[__FUNCTION__])) {
1806 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1810 return $GLOBALS[__FUNCTION__];
1813 // "Getter" for main_title
1814 function getMainTitle () {
1815 // Do we have cache?
1816 if (!isset($GLOBALS[__FUNCTION__])) {
1818 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1822 return $GLOBALS[__FUNCTION__];
1825 // "Getter" for file_hash
1826 function getFileHash () {
1827 // Do we have cache?
1828 if (!isset($GLOBALS[__FUNCTION__])) {
1830 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1834 return $GLOBALS[__FUNCTION__];
1837 // "Getter" for pass_scramble
1838 function getPassScramble () {
1839 // Do we have cache?
1840 if (!isset($GLOBALS[__FUNCTION__])) {
1842 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1846 return $GLOBALS[__FUNCTION__];
1849 // "Getter" for ap_inactive_since
1850 function getApInactiveSince () {
1851 // Do we have cache?
1852 if (!isset($GLOBALS[__FUNCTION__])) {
1854 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1858 return $GLOBALS[__FUNCTION__];
1861 // "Getter" for user_min_confirmed
1862 function getUserMinConfirmed () {
1863 // Do we have cache?
1864 if (!isset($GLOBALS[__FUNCTION__])) {
1866 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1870 return $GLOBALS[__FUNCTION__];
1873 // "Getter" for auto_purge
1874 function getAutoPurge () {
1875 // Do we have cache?
1876 if (!isset($GLOBALS[__FUNCTION__])) {
1878 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1882 return $GLOBALS[__FUNCTION__];
1885 // "Getter" for bonus_userid
1886 function getBonusUserid () {
1887 // Do we have cache?
1888 if (!isset($GLOBALS[__FUNCTION__])) {
1890 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1894 return $GLOBALS[__FUNCTION__];
1897 // "Getter" for ap_inactive_time
1898 function getApInactiveTime () {
1899 // Do we have cache?
1900 if (!isset($GLOBALS[__FUNCTION__])) {
1902 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1906 return $GLOBALS[__FUNCTION__];
1909 // "Getter" for ap_dm_timeout
1910 function getApDmTimeout () {
1911 // Do we have cache?
1912 if (!isset($GLOBALS[__FUNCTION__])) {
1914 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1918 return $GLOBALS[__FUNCTION__];
1921 // "Getter" for ap_tasks_time
1922 function getApTasksTime () {
1923 // Do we have cache?
1924 if (!isset($GLOBALS[__FUNCTION__])) {
1926 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1930 return $GLOBALS[__FUNCTION__];
1933 // "Getter" for ap_unconfirmed_time
1934 function getApUnconfirmedTime () {
1935 // Do we have cache?
1936 if (!isset($GLOBALS[__FUNCTION__])) {
1938 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1942 return $GLOBALS[__FUNCTION__];
1945 // "Getter" for points
1946 function getPoints () {
1947 // Do we have cache?
1948 if (!isset($GLOBALS[__FUNCTION__])) {
1950 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1954 return $GLOBALS[__FUNCTION__];
1957 // "Getter" for slogan
1958 function getSlogan () {
1959 // Do we have cache?
1960 if (!isset($GLOBALS[__FUNCTION__])) {
1962 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1966 return $GLOBALS[__FUNCTION__];
1969 // "Getter" for copy
1970 function getCopy () {
1971 // Do we have cache?
1972 if (!isset($GLOBALS[__FUNCTION__])) {
1974 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1978 return $GLOBALS[__FUNCTION__];
1981 // "Getter" for webmaster
1982 function getWebmaster () {
1983 // Do we have cache?
1984 if (!isset($GLOBALS[__FUNCTION__])) {
1986 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1990 return $GLOBALS[__FUNCTION__];
1993 // "Getter" for sql_count
1994 function getSqlCount () {
1995 // Do we have cache?
1996 if (!isset($GLOBALS[__FUNCTION__])) {
1998 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2002 return $GLOBALS[__FUNCTION__];
2005 // "Getter" for num_templates
2006 function getNumTemplates () {
2007 // Do we have cache?
2008 if (!isset($GLOBALS[__FUNCTION__])) {
2010 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2014 return $GLOBALS[__FUNCTION__];
2017 // "Getter" for dns_cache_timeout
2018 function getDnsCacheTimeout () {
2019 // Do we have cache?
2020 if (!isset($GLOBALS[__FUNCTION__])) {
2022 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2026 return $GLOBALS[__FUNCTION__];
2029 // "Getter" for menu_blur_spacer
2030 function getMenuBlurSpacer () {
2031 // Do we have cache?
2032 if (!isset($GLOBALS[__FUNCTION__])) {
2034 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2038 return $GLOBALS[__FUNCTION__];
2041 // "Getter" for points_register
2042 function getPointsRegister () {
2043 // Do we have cache?
2044 if (!isset($GLOBALS[__FUNCTION__])) {
2046 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2050 return $GLOBALS[__FUNCTION__];
2053 // "Getter" for points_ref
2054 function getPointsRef () {
2055 // Do we have cache?
2056 if (!isset($GLOBALS[__FUNCTION__])) {
2058 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2062 return $GLOBALS[__FUNCTION__];
2065 // "Getter" for ref_payout
2066 function getRefPayout () {
2067 // Do we have cache?
2068 if (!isset($GLOBALS[__FUNCTION__])) {
2070 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2074 return $GLOBALS[__FUNCTION__];
2077 // "Getter" for online_timeout
2078 function getOnlineTimeout () {
2079 // Do we have cache?
2080 if (!isset($GLOBALS[__FUNCTION__])) {
2082 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2086 return $GLOBALS[__FUNCTION__];
2089 // "Getter" for index_home
2090 function getIndexHome () {
2091 // Do we have cache?
2092 if (!isset($GLOBALS[__FUNCTION__])) {
2094 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2098 return $GLOBALS[__FUNCTION__];
2101 // "Getter" for one_day
2102 function getOneDay () {
2103 // Do we have cache?
2104 if (!isset($GLOBALS[__FUNCTION__])) {
2106 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2110 return $GLOBALS[__FUNCTION__];
2113 // "Getter" for activate_xchange
2114 function getActivateXchange () {
2115 // Do we have cache?
2116 if (!isset($GLOBALS[__FUNCTION__])) {
2118 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2122 return $GLOBALS[__FUNCTION__];
2125 // "Getter" for img_type
2126 function getImgType () {
2127 // Do we have cache?
2128 if (!isset($GLOBALS[__FUNCTION__])) {
2130 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2134 return $GLOBALS[__FUNCTION__];
2137 // "Getter" for code_length
2138 function getCodeLength () {
2139 // Do we have cache?
2140 if (!isset($GLOBALS[__FUNCTION__])) {
2142 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2146 return $GLOBALS[__FUNCTION__];
2149 // "Getter" for least_cats
2150 function getLeastCats () {
2151 // Do we have cache?
2152 if (!isset($GLOBALS[__FUNCTION__])) {
2154 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2158 return $GLOBALS[__FUNCTION__];
2161 // "Getter" for pass_len
2162 function getPassLen () {
2163 // Do we have cache?
2164 if (!isset($GLOBALS[__FUNCTION__])) {
2166 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2170 return $GLOBALS[__FUNCTION__];
2173 // "Getter" for admin_menu
2174 function getAdminMenu () {
2175 // Do we have cache?
2176 if (!isset($GLOBALS[__FUNCTION__])) {
2178 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2182 return $GLOBALS[__FUNCTION__];
2185 // "Getter" for last_month
2186 function getLastMonth () {
2187 // Do we have cache?
2188 if (!isset($GLOBALS[__FUNCTION__])) {
2190 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2194 return $GLOBALS[__FUNCTION__];
2197 // "Getter" for max_send
2198 function getMaxSend () {
2199 // Do we have cache?
2200 if (!isset($GLOBALS[__FUNCTION__])) {
2202 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2206 return $GLOBALS[__FUNCTION__];
2209 // "Getter" for mails_page
2210 function getMailsPage () {
2211 // Do we have cache?
2212 if (!isset($GLOBALS[__FUNCTION__])) {
2214 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2218 return $GLOBALS[__FUNCTION__];
2221 // "Getter" for rand_no
2222 function getRandNo () {
2223 // Do we have cache?
2224 if (!isset($GLOBALS[__FUNCTION__])) {
2226 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2230 return $GLOBALS[__FUNCTION__];
2233 // "Getter" for __DB_NAME
2234 function getDbName () {
2235 // Do we have cache?
2236 if (!isset($GLOBALS[__FUNCTION__])) {
2238 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2242 return $GLOBALS[__FUNCTION__];
2245 // "Getter" for DOMAIN
2246 function getDomain () {
2247 // Do we have cache?
2248 if (!isset($GLOBALS[__FUNCTION__])) {
2250 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2254 return $GLOBALS[__FUNCTION__];
2257 // "Getter" for proxy_username
2258 function getProxyUsername () {
2259 // Do we have cache?
2260 if (!isset($GLOBALS[__FUNCTION__])) {
2262 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2266 return $GLOBALS[__FUNCTION__];
2269 // "Getter" for proxy_password
2270 function getProxyPassword () {
2271 // Do we have cache?
2272 if (!isset($GLOBALS[__FUNCTION__])) {
2274 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2278 return $GLOBALS[__FUNCTION__];
2281 // "Getter" for proxy_host
2282 function getProxyHost () {
2283 // Do we have cache?
2284 if (!isset($GLOBALS[__FUNCTION__])) {
2286 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2290 return $GLOBALS[__FUNCTION__];
2293 // "Getter" for proxy_port
2294 function getProxyPort () {
2295 // Do we have cache?
2296 if (!isset($GLOBALS[__FUNCTION__])) {
2298 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2302 return $GLOBALS[__FUNCTION__];
2305 // "Getter" for SMTP_HOSTNAME
2306 function getSmtpHostname () {
2307 // Do we have cache?
2308 if (!isset($GLOBALS[__FUNCTION__])) {
2310 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2314 return $GLOBALS[__FUNCTION__];
2317 // "Getter" for SMTP_USER
2318 function getSmtpUser () {
2319 // Do we have cache?
2320 if (!isset($GLOBALS[__FUNCTION__])) {
2322 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2326 return $GLOBALS[__FUNCTION__];
2329 // "Getter" for SMTP_PASSWORD
2330 function getSmtpPassword () {
2331 // Do we have cache?
2332 if (!isset($GLOBALS[__FUNCTION__])) {
2334 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2338 return $GLOBALS[__FUNCTION__];
2341 // "Getter" for points_word
2342 function getPointsWord () {
2343 // Do we have cache?
2344 if (!isset($GLOBALS[__FUNCTION__])) {
2346 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2350 return $GLOBALS[__FUNCTION__];
2353 // "Getter" for profile_lock
2354 function getProfileLock () {
2355 // Do we have cache?
2356 if (!isset($GLOBALS[__FUNCTION__])) {
2358 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2362 return $GLOBALS[__FUNCTION__];
2365 // "Getter" for url_tlock
2366 function getUrlTlock () {
2367 // Do we have cache?
2368 if (!isset($GLOBALS[__FUNCTION__])) {
2370 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2374 return $GLOBALS[__FUNCTION__];
2377 // "Getter" for title_left
2378 function getTitleLeft () {
2379 // Do we have cache?
2380 if (!isset($GLOBALS[__FUNCTION__])) {
2382 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2386 return $GLOBALS[__FUNCTION__];
2389 // "Getter" for title_right
2390 function getTitleRight () {
2391 // Do we have cache?
2392 if (!isset($GLOBALS[__FUNCTION__])) {
2394 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2398 return $GLOBALS[__FUNCTION__];
2401 // "Getter" for title_middle
2402 function getTitleMiddle () {
2403 // Do we have cache?
2404 if (!isset($GLOBALS[__FUNCTION__])) {
2406 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2410 return $GLOBALS[__FUNCTION__];
2413 // Getter for 'check_double_email'
2414 function getCheckDoubleEmail () {
2415 // Is the cache entry set?
2416 if (!isset($GLOBALS[__FUNCTION__])) {
2417 // No, so determine it
2418 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2421 // Return cached entry
2422 return $GLOBALS[__FUNCTION__];
2425 // Checks wether 'check_double_email' is 'Y'
2426 function isCheckDoubleEmailEnabled () {
2427 // Is the cache entry set?
2428 if (!isset($GLOBALS[__FUNCTION__])) {
2429 // No, so determine it
2430 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2433 // Return cached entry
2434 return $GLOBALS[__FUNCTION__];
2437 // Getter for 'display_home_in_index'
2438 function getDisplayHomeInIndex () {
2439 // Is the cache entry set?
2440 if (!isset($GLOBALS[__FUNCTION__])) {
2441 // No, so determine it
2442 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2445 // Return cached entry
2446 return $GLOBALS[__FUNCTION__];
2449 // Checks wether 'display_home_in_index' is 'Y'
2450 function isDisplayHomeInIndexEnabled () {
2451 // Is the cache entry set?
2452 if (!isset($GLOBALS[__FUNCTION__])) {
2453 // No, so determine it
2454 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2457 // Return cached entry
2458 return $GLOBALS[__FUNCTION__];
2461 // Checks wether proxy configuration is used
2462 function isProxyUsed () {
2463 // Do we have cache?
2464 if (!isset($GLOBALS[__FUNCTION__])) {
2466 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2470 return $GLOBALS[__FUNCTION__];
2473 // Checks wether POST data contains selections
2474 function ifPostContainsSelections ($element = 'sel') {
2475 // Do we have cache?
2476 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2478 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2482 return $GLOBALS[__FUNCTION__][$element];
2485 // Checks wether verbose_sql is Y and returns true/false if so
2486 function isVerboseSqlEnabled () {
2487 // Do we have cache?
2488 if (!isset($GLOBALS[__FUNCTION__])) {
2490 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2494 return $GLOBALS[__FUNCTION__];
2497 // "Getter" for total user points
2498 function getTotalPoints ($userid) {
2499 // Do we have cache?
2500 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2501 // Init array for filter chain
2503 'userid' => $userid,
2507 // Run filter chain for getting more point values
2508 $data = runFilterChain('get_total_points', $data);
2511 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2515 return $GLOBALS[__FUNCTION__][$userid];
2518 // Wrapper to check if url_blacklist is enabled
2519 function isUrlBlacklistEnabled () {
2520 // Do we have cache?
2521 if (!isset($GLOBALS[__FUNCTION__])) {
2523 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2527 return $GLOBALS[__FUNCTION__];
2530 // Checks wether direct payment is allowed in configuration
2531 function isDirectPaymentEnabled () {
2532 // Do we have cache?
2533 if (!isset($GLOBALS[__FUNCTION__])) {
2535 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2539 return $GLOBALS[__FUNCTION__];
2542 // Wrapper to check if current task is for extension (not update)
2543 function isExtensionTask ($content) {
2544 // Do we have cache?
2545 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2547 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2551 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2554 // Wrapper to check if output mode is CSS
2555 function isCssOutputMode () {
2557 return (getScriptOutputMode() == 1);
2560 // Wrapper to check if output mode is HTML
2561 function isHtmlOutputMode () {
2563 return (getScriptOutputMode() == 0);
2566 // Wrapper to check if output mode is RAW
2567 function isRawOutputMode () {
2569 return (getScriptOutputMode() == -1);
2572 // Wrapper to generate a user email link
2573 function generateWrappedUserEmailLink ($email) {
2574 // Just call the inner function
2575 return generateEmailLink($email, 'user_data');
2578 // Wrapper to check if user points are locked
2579 function ifUserPointsLocked ($userid) {
2580 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2581 // Do we have cache?
2582 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2584 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2588 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2589 return $GLOBALS[__FUNCTION__][$userid];
2592 // Appends a line to an existing file or creates it instantly with given content.
2593 // This function does always add a new-line character to every line.
2594 function appendLineToFile ($file, $line) {
2595 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2596 fwrite($fp, $line . "\n");
2600 // Wrapper for changeDataInFile() but with full path added
2601 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2603 $FQFN = getPath() . $FQFN;
2605 // Call inner function
2606 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2609 // Wrapper for changing entries in config-local.php
2610 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2611 // Call the inner function
2612 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2615 // Shortens ucfirst(strtolower()) calls
2616 function firstCharUpperCase ($str) {
2617 return ucfirst(strtolower($str));
2620 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2621 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2622 // Get the configuration entry
2623 $configValue = getConfig($configEntry);
2625 // Call inner method
2626 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2629 // Shortens converting of German comma to Computer's version in POST data
2630 function convertCommaToDotInPostData ($postEntry) {
2631 // Read and convert given entry
2632 $postValue = convertCommaToDot(postRequestElement($postEntry));
2634 // ... and set it again
2635 setPostRequestElement($postEntry, $postValue);
2638 // Converts German commas to Computer's version in all entries
2639 function convertCommaToDotInPostDataArray ($postEntries) {
2640 // Replace german decimal comma with computer decimal dot
2641 foreach ($postEntries as $entry) {
2642 // Is the entry there?
2643 if (isPostRequestElementSet($entry)) {
2645 convertCommaToDotInPostData($entry);
2651 * Parses a string into a US formated float variable, taken from user comments
2652 * from PHP documentation website.
2654 * @param $floatString A string holding a float expression
2655 * @return $float Corresponding float variable
2656 * @author chris<at>georgakopoulos<dot>com
2657 * @link http://de.php.net/manual/en/function.floatval.php#92563
2659 function parseFloat ($floatString){
2660 $LocaleInfo = localeconv();
2661 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '', $floatString);
2662 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2663 return floatval($floatString);
2666 // Generates a YES/NO option list from given default
2667 function generateYesNoOptionList ($configValue = '') {
2669 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $configValue);
2672 // "Getter" for total available receivers
2673 function getTotalReceivers ($mode = 'normal') {
2675 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2681 // Wrapper "getter" to get total unconfirmed mails for given userid
2682 function getTotalUnconfirmedMails ($userid) {
2683 // Do we have cache?
2684 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2686 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2690 return $GLOBALS[__FUNCTION__][$userid];