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'] = $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']) && (!empty($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'] = $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'] = strtolower($newModule);
642 // Checks wether module is set and optionally aborts on miss
643 function isModuleSet ($strict = false) {
645 $isset = ((isset($GLOBALS['__module'])) && (!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 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
681 $GLOBALS['output_mode'] = (int) $newOutputMode;
682 $GLOBALS['getScriptOutputMode'] = (int) $newOutputMode;
685 // Checks wether output_mode is set and optionally aborts on miss
686 function isOutputModeSet ($strict = false) {
688 $isset = (isset($GLOBALS['output_mode']));
690 // Should we abort here?
691 if (($strict === true) && ($isset === false)) {
693 debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
700 // Enables block-mode
701 function enableBlockMode ($enabled = true) {
702 $GLOBALS['block_mode'] = $enabled;
705 // Checks wether block-mode is enabled
706 function isBlockModeEnabled () {
708 if (!isset($GLOBALS['block_mode'])) {
710 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
714 return $GLOBALS['block_mode'];
718 * Wrapper function for addPointsThroughReferralSystem(), you should generally
719 * avoid this function and use addPointsThroughReferralSystem() directly and add
720 * your special payment method entry to points_data instead.
722 * @param $subject A string-encoded subject for this add
723 * @param $userid The recipient (member) for given points
724 * @param $points Points to be added to member's account
725 * @return $added Wether the points has been added to the user's account
727 function addPointsDirectly ($subject, $userid, $points) {
729 initReferralSystem();
731 // Call more complicated method (due to more parameters)
732 return addPointsThroughReferralSystem($subject, $userid, $points, false, 0, 'DIRECT');
735 // Wrapper for redirectToUrl but URL comes from a configuration entry
736 function redirectToConfiguredUrl ($configEntry) {
738 redirectToUrl(getConfig($configEntry));
741 // Wrapper function to redirect from member-only modules to index
742 function redirectToIndexMemberOnlyModule () {
743 // Do the redirect here
744 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
747 // Wrapper function to redirect to current URL
748 function redirectToRequestUri () {
749 redirectToUrl(basename(detectRequestUri()));
752 // Wrapper function to redirect to de-refered URL
753 function redirectToDereferedUrl ($url) {
755 redirectToUrl(generateDerefererUrl($url));
758 // Wrapper function for checking if extension is installed and newer or same version
759 function isExtensionInstalledAndNewer ($ext_name, $version) {
760 // Is an cache entry found?
761 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
763 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
765 // Cache hits should be incremented twice
766 incrementStatsEntry('cache_hits', 2);
770 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
771 return $GLOBALS[__FUNCTION__][$ext_name][$version];
774 // Wrapper function for checking if extension is installed and older than given version
775 function isExtensionInstalledAndOlder ($ext_name, $version) {
776 // Is an cache entry found?
777 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
779 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
781 // Cache hits should be incremented twice
782 incrementStatsEntry('cache_hits', 2);
786 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
787 return $GLOBALS[__FUNCTION__][$ext_name][$version];
791 function setUsername ($userName) {
792 $GLOBALS['username'] = (string) $userName;
796 function getUsername () {
798 if (!isset($GLOBALS['username'])) {
799 // No, so it has to be a guest
800 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
804 return $GLOBALS['username'];
807 // Wrapper function for installation phase
808 function isInstallationPhase () {
810 if (!isset($GLOBALS[__FUNCTION__])) {
812 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
816 return $GLOBALS[__FUNCTION__];
819 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
820 function isDemoModeActive () {
822 if (!isset($GLOBALS[__FUNCTION__])) {
824 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
828 return $GLOBALS[__FUNCTION__];
831 // Getter for PHP caching value
832 function getPhpCaching () {
833 return $GLOBALS['php_caching'];
836 // Checks wether the admin hash is set
837 function isAdminHashSet ($adminId) {
838 // Is the array there?
839 if (!isset($GLOBALS['cache_array']['admin'])) {
840 // Missing array should be reported
841 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
844 // Check for admin hash
845 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
848 // Setter for admin hash
849 function setAdminHash ($adminId, $hash) {
850 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
853 // Getter for current admin login
854 function getCurrentAdminLogin () {
856 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
859 if (!isset($GLOBALS[__FUNCTION__])) {
861 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
865 return $GLOBALS[__FUNCTION__];
868 // Setter for admin id (and current)
869 function setAdminId ($adminId) {
871 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
874 $status = setSession('admin_id', bigintval($adminId));
877 setCurrentAdminId($adminId);
883 // Setter for admin_last
884 function setAdminLast ($adminLast) {
886 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
889 $status = setSession('admin_last', $adminLast);
895 // Setter for admin_md5
896 function setAdminMd5 ($adminMd5) {
898 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
901 $status = setSession('admin_md5', $adminMd5);
907 // Getter for admin_md5
908 function getAdminMd5 () {
910 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
913 return getSession('admin_md5');
916 // Init user data array
917 function initUserData () {
918 // User id should not be zero
919 if (!isValidUserId(getCurrentUserId())) {
920 // Should be always valid
921 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
925 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
926 $GLOBALS['user_data'][getCurrentUserId()] = array();
929 // Getter for user data
930 function getUserData ($column) {
931 // User id should not be zero
932 if (!isValidUserId(getCurrentUserId())) {
933 // Should be always valid
934 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
940 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
942 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
949 // Checks wether given user data is set to 'Y'
950 function isUserDataEnabled ($column) {
952 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
954 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
958 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
961 // Geter for whole user data array
962 function getUserDataArray () {
964 $userid = getCurrentUserId();
966 // Is the current userid valid?
967 if (!isValidUserId($userid)) {
968 // Should be always valid
969 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
972 // Get the whole array if found
973 if (isset($GLOBALS['user_data'][$userid])) {
974 // Found, so return it
975 return $GLOBALS['user_data'][$userid];
977 // Return empty array
982 // Checks if the user data is valid, this may indicate that the user has logged
983 // in, but you should use isMember() if you want to find that out.
984 function isUserDataValid () {
985 // User id should not be zero so abort here
986 if (!isCurrentUserIdSet()) {
991 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
993 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
997 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1000 // Setter for current userid
1001 function setCurrentUserId ($userid) {
1003 $GLOBALS['current_userid'] = bigintval($userid);
1005 // Unset it to re-determine the actual state
1006 unset($GLOBALS['is_userdata_valid'][$userid]);
1009 // Getter for current userid
1010 function getCurrentUserId () {
1011 // Userid must be set before it can be used
1012 if (!isCurrentUserIdSet()) {
1014 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1017 // Return the userid
1018 return $GLOBALS['current_userid'];
1021 // Checks if current userid is set
1022 function isCurrentUserIdSet () {
1023 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1026 // Checks wether we are debugging template cache
1027 function isDebuggingTemplateCache () {
1028 // Do we have cache?
1029 if (!isset($GLOBALS[__FUNCTION__])) {
1031 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1035 return $GLOBALS[__FUNCTION__];
1038 // Wrapper for fetchUserData() and getUserData() calls
1039 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1040 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1042 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1046 // Can we fetch the user data?
1047 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1048 // Now get the data back
1049 $data = getUserData($valueColumn);
1053 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1057 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1058 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1061 // Wrapper for strpos() to ease porting from deprecated ereg() function
1062 function isInString ($needle, $haystack) {
1063 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1064 return (strpos($haystack, $needle) !== false);
1067 // Wrapper for strpos() to ease porting from deprecated eregi() function
1068 // This function is case-insensitive
1069 function isInStringIgnoreCase ($needle, $haystack) {
1070 return (isInString(strtolower($needle), strtolower($haystack)));
1073 // Wrapper to check for if fatal errors where detected
1074 function ifFatalErrorsDetected () {
1075 // Just call the inner function
1076 return (getTotalFatalErrors() > 0);
1079 // Setter for HTTP status
1080 function setHttpStatus ($status) {
1081 $GLOBALS['http_status'] = (string) $status;
1084 // Getter for HTTP status
1085 function getHttpStatus () {
1086 // Is the status set?
1087 if (!isset($GLOBALS['http_status'])) {
1089 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1093 return $GLOBALS['http_status'];
1097 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1098 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1100 * ----------------------------------------------------------------------------
1101 * If you want to redirect, please use redirectToUrl(); instead
1102 * ----------------------------------------------------------------------------
1104 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1106 * @link http://support.microsoft.com/kb/q176113/
1107 * @author Andreas Gohr <andi@splitbrain.org>
1110 function sendRawRedirect ($url) {
1111 // Clear output buffer
1112 clearOutputBuffer();
1114 // Clear own output buffer
1115 $GLOBALS['output'] = '';
1117 // To make redirects working (no content type), output mode must be raw
1120 // Send helping header
1121 setHttpStatus('302 Found');
1123 // always close the session
1124 session_write_close();
1126 // Revert entity &
1127 $url = str_replace('&', '&', $url);
1129 // check if running on IIS < 6 with CGI-PHP
1130 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1131 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1132 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1133 ($matches[1] < 6)) {
1134 // Send the IIS header
1135 addHttpHeader('Refresh: 0;url=' . $url);
1137 // Send generic header
1138 addHttpHeader('Location: ' . $url);
1145 // Determines the country of the given user id
1146 function determineCountry ($userid) {
1147 // Do we have cache?
1148 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1149 // Default is 'invalid'
1150 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1152 // Is extension country active?
1153 if (isExtensionActive('country')) {
1154 // Determine the right country code through the country id
1155 $id = getUserData('country_code');
1157 // Then handle it over
1158 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1160 // Get raw code from user data
1161 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1166 return $GLOBALS[__FUNCTION__][$userid];
1169 // "Getter" for total confirmed user accounts
1170 function getTotalConfirmedUser () {
1172 if (!isset($GLOBALS[__FUNCTION__])) {
1174 if (isExtensionActive('user')) {
1175 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1177 $GLOBALS[__FUNCTION__] = 0;
1181 // Return cached value
1182 return $GLOBALS[__FUNCTION__];
1185 // "Getter" for total unconfirmed user accounts
1186 function getTotalUnconfirmedUser () {
1188 if (!isset($GLOBALS[__FUNCTION__])) {
1190 if (isExtensionActive('user')) {
1191 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1193 $GLOBALS[__FUNCTION__] = 0;
1197 // Return cached value
1198 return $GLOBALS[__FUNCTION__];
1201 // "Getter" for total locked user accounts
1202 function getTotalLockedUser () {
1204 if (!isset($GLOBALS[__FUNCTION__])) {
1206 if (isExtensionActive('user')) {
1207 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', '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 getTotalRandomRefidUser () {
1220 if (!isset($GLOBALS[__FUNCTION__])) {
1222 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1223 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
1225 $GLOBALS[__FUNCTION__] = 0;
1229 // Return cached value
1230 return $GLOBALS[__FUNCTION__];
1233 // Is given userid valid?
1234 function isValidUserId ($userid) {
1235 // Do we have cache?
1236 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1238 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1242 return $GLOBALS[__FUNCTION__][$userid];
1246 function encodeEntities ($str) {
1248 $str = secureString($str, true, true);
1250 // Encode dollar sign as well
1251 $str = str_replace('$', '$', $str);
1257 // "Getter" for date from patch_ctime
1258 function getDateFromRepository () {
1260 if (!isset($GLOBALS[__FUNCTION__])) {
1262 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1266 return $GLOBALS[__FUNCTION__];
1269 // "Getter" for date/time from patch_ctime
1270 function getDateTimeFromRepository () {
1272 if (!isset($GLOBALS[__FUNCTION__])) {
1274 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1278 return $GLOBALS[__FUNCTION__];
1281 // Getter for current year (default)
1282 function getYear ($timestamp = NULL) {
1284 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1286 if (is_null($timestamp)) {
1287 $timestamp = time();
1291 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1295 return $GLOBALS[__FUNCTION__][$timestamp];
1298 // Getter for current month (default)
1299 function getMonth ($timestamp = NULL) {
1301 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1302 // If null is set, use time()
1303 if (is_null($timestamp)) {
1304 // Use time() which is current timestamp
1305 $timestamp = time();
1309 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1313 return $GLOBALS[__FUNCTION__][$timestamp];
1316 // Getter for current hour (default)
1317 function getHour ($timestamp = NULL) {
1319 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1321 if (is_null($timestamp)) {
1322 $timestamp = time();
1326 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1330 return $GLOBALS[__FUNCTION__][$timestamp];
1333 // Getter for current day (default)
1334 function getDay ($timestamp = NULL) {
1336 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1338 if (is_null($timestamp)) {
1339 $timestamp = time();
1343 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1347 return $GLOBALS[__FUNCTION__][$timestamp];
1350 // Getter for current week (default)
1351 function getWeek ($timestamp = NULL) {
1353 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1355 if (is_null($timestamp)) $timestamp = time();
1358 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1362 return $GLOBALS[__FUNCTION__][$timestamp];
1365 // Getter for current short_hour (default)
1366 function getShortHour ($timestamp = NULL) {
1368 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1370 if (is_null($timestamp)) $timestamp = time();
1373 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1377 return $GLOBALS[__FUNCTION__][$timestamp];
1380 // Getter for current long_hour (default)
1381 function getLongHour ($timestamp = NULL) {
1383 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1385 if (is_null($timestamp)) $timestamp = time();
1388 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1392 return $GLOBALS[__FUNCTION__][$timestamp];
1395 // Getter for current second (default)
1396 function getSecond ($timestamp = NULL) {
1398 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1400 if (is_null($timestamp)) $timestamp = time();
1403 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1407 return $GLOBALS[__FUNCTION__][$timestamp];
1410 // Getter for current minute (default)
1411 function getMinute ($timestamp = NULL) {
1413 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1415 if (is_null($timestamp)) $timestamp = time();
1418 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1422 return $GLOBALS[__FUNCTION__][$timestamp];
1425 // Checks wether the title decoration is enabled
1426 function isTitleDecorationEnabled () {
1427 // Do we have cache?
1428 if (!isset($GLOBALS[__FUNCTION__])) {
1430 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1434 return $GLOBALS[__FUNCTION__];
1437 // Checks wether filter usage updates are enabled (expensive queries!)
1438 function isFilterUsageUpdateEnabled () {
1439 // Do we have cache?
1440 if (!isset($GLOBALS[__FUNCTION__])) {
1442 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1446 return $GLOBALS[__FUNCTION__];
1449 // Checks wether debugging of weekly resets is enabled
1450 function isWeeklyResetDebugEnabled () {
1451 // Do we have cache?
1452 if (!isset($GLOBALS[__FUNCTION__])) {
1454 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1458 return $GLOBALS[__FUNCTION__];
1461 // Checks wether debugging of monthly resets is enabled
1462 function isMonthlyResetDebugEnabled () {
1463 // Do we have cache?
1464 if (!isset($GLOBALS[__FUNCTION__])) {
1466 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1470 return $GLOBALS[__FUNCTION__];
1473 // Checks wether displaying of debug SQLs are enabled
1474 function isDisplayDebugSqlEnabled () {
1475 // Do we have cache?
1476 if (!isset($GLOBALS[__FUNCTION__])) {
1478 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1482 return $GLOBALS[__FUNCTION__];
1485 // Checks wether module title is enabled
1486 function isModuleTitleEnabled () {
1487 // Do we have cache?
1488 if (!isset($GLOBALS[__FUNCTION__])) {
1490 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1494 return $GLOBALS[__FUNCTION__];
1497 // Checks wether what title is enabled
1498 function isWhatTitleEnabled () {
1499 // Do we have cache?
1500 if (!isset($GLOBALS[__FUNCTION__])) {
1502 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1506 return $GLOBALS[__FUNCTION__];
1509 // Checks wether stats are enabled
1510 function ifInternalStatsEnabled () {
1511 // Do we have cache?
1512 if (!isset($GLOBALS[__FUNCTION__])) {
1513 // Then determine it
1514 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1517 // Return cached value
1518 return $GLOBALS[__FUNCTION__];
1521 // Checks wether admin-notification of certain user actions is enabled
1522 function isAdminNotificationEnabled () {
1523 // Do we have cache?
1524 if (!isset($GLOBALS[__FUNCTION__])) {
1526 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1530 return $GLOBALS[__FUNCTION__];
1533 // Checks wether random referral id selection is enabled
1534 function isRandomReferralIdEnabled () {
1535 // Do we have cache?
1536 if (!isset($GLOBALS[__FUNCTION__])) {
1538 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1542 return $GLOBALS[__FUNCTION__];
1545 // "Getter" for default language
1546 function getDefaultLanguage () {
1547 // Do we have cache?
1548 if (!isset($GLOBALS[__FUNCTION__])) {
1550 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1554 return $GLOBALS[__FUNCTION__];
1557 // "Getter" for default referral id
1558 function getDefRefid () {
1559 // Do we have cache?
1560 if (!isset($GLOBALS[__FUNCTION__])) {
1562 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1566 return $GLOBALS[__FUNCTION__];
1569 // "Getter" for path
1570 function getPath () {
1571 // Do we have cache?
1572 if (!isset($GLOBALS[__FUNCTION__])) {
1574 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1578 return $GLOBALS[__FUNCTION__];
1582 function getUrl () {
1583 // Do we have cache?
1584 if (!isset($GLOBALS[__FUNCTION__])) {
1586 $GLOBALS[__FUNCTION__] = getConfig('URL');
1590 return $GLOBALS[__FUNCTION__];
1593 // "Getter" for cache_path
1594 function getCachePath () {
1595 // Do we have cache?
1596 if (!isset($GLOBALS[__FUNCTION__])) {
1598 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1602 return $GLOBALS[__FUNCTION__];
1605 // "Getter" for secret_key
1606 function getSecretKey () {
1607 // Do we have cache?
1608 if (!isset($GLOBALS[__FUNCTION__])) {
1610 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1614 return $GLOBALS[__FUNCTION__];
1617 // "Getter" for SITE_KEY
1618 function getSiteKey () {
1619 // Do we have cache?
1620 if (!isset($GLOBALS[__FUNCTION__])) {
1622 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1626 return $GLOBALS[__FUNCTION__];
1629 // "Getter" for DATE_KEY
1630 function getDateKey () {
1631 // Do we have cache?
1632 if (!isset($GLOBALS[__FUNCTION__])) {
1634 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1638 return $GLOBALS[__FUNCTION__];
1641 // "Getter" for master_salt
1642 function getMasterSalt () {
1643 // Do we have cache?
1644 if (!isset($GLOBALS[__FUNCTION__])) {
1646 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1650 return $GLOBALS[__FUNCTION__];
1653 // "Getter" for prime
1654 function getPrime () {
1655 // Do we have cache?
1656 if (!isset($GLOBALS[__FUNCTION__])) {
1658 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1662 return $GLOBALS[__FUNCTION__];
1665 // "Getter" for encrypt_separator
1666 function getEncryptSeparator () {
1667 // Do we have cache?
1668 if (!isset($GLOBALS[__FUNCTION__])) {
1670 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1674 return $GLOBALS[__FUNCTION__];
1677 // "Getter" for mysql_prefix
1678 function getMysqlPrefix () {
1679 // Do we have cache?
1680 if (!isset($GLOBALS[__FUNCTION__])) {
1682 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1686 return $GLOBALS[__FUNCTION__];
1689 // "Getter" for table_type
1690 function getTableType () {
1691 // Do we have cache?
1692 if (!isset($GLOBALS[__FUNCTION__])) {
1694 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1698 return $GLOBALS[__FUNCTION__];
1701 // "Getter" for salt_length
1702 function getSaltLength () {
1703 // Do we have cache?
1704 if (!isset($GLOBALS[__FUNCTION__])) {
1706 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1710 return $GLOBALS[__FUNCTION__];
1713 // "Getter" for output_mode
1714 function getOutputMode () {
1715 // Do we have cache?
1716 if (!isset($GLOBALS[__FUNCTION__])) {
1718 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1722 return $GLOBALS[__FUNCTION__];
1725 // "Getter" for full_version
1726 function getFullVersion () {
1727 // Do we have cache?
1728 if (!isset($GLOBALS[__FUNCTION__])) {
1730 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1734 return $GLOBALS[__FUNCTION__];
1737 // "Getter" for title
1738 function getTitle () {
1739 // Do we have cache?
1740 if (!isset($GLOBALS[__FUNCTION__])) {
1742 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1746 return $GLOBALS[__FUNCTION__];
1749 // "Getter" for curr_svn_revision
1750 function getCurrentRepositoryRevision () {
1751 // Do we have cache?
1752 if (!isset($GLOBALS[__FUNCTION__])) {
1754 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1758 return $GLOBALS[__FUNCTION__];
1761 // "Getter" for server_url
1762 function getServerUrl () {
1763 // Do we have cache?
1764 if (!isset($GLOBALS[__FUNCTION__])) {
1766 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1770 return $GLOBALS[__FUNCTION__];
1773 // "Getter" for mt_word
1774 function getMtWord () {
1775 // Do we have cache?
1776 if (!isset($GLOBALS[__FUNCTION__])) {
1778 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1782 return $GLOBALS[__FUNCTION__];
1785 // "Getter" for mt_word2
1786 function getMtWord2 () {
1787 // Do we have cache?
1788 if (!isset($GLOBALS[__FUNCTION__])) {
1790 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1794 return $GLOBALS[__FUNCTION__];
1797 // "Getter" for main_title
1798 function getMainTitle () {
1799 // Do we have cache?
1800 if (!isset($GLOBALS[__FUNCTION__])) {
1802 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1806 return $GLOBALS[__FUNCTION__];
1809 // "Getter" for file_hash
1810 function getFileHash () {
1811 // Do we have cache?
1812 if (!isset($GLOBALS[__FUNCTION__])) {
1814 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1818 return $GLOBALS[__FUNCTION__];
1821 // "Getter" for pass_scramble
1822 function getPassScramble () {
1823 // Do we have cache?
1824 if (!isset($GLOBALS[__FUNCTION__])) {
1826 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1830 return $GLOBALS[__FUNCTION__];
1833 // "Getter" for ap_inactive_since
1834 function getApInactiveSince () {
1835 // Do we have cache?
1836 if (!isset($GLOBALS[__FUNCTION__])) {
1838 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1842 return $GLOBALS[__FUNCTION__];
1845 // "Getter" for user_min_confirmed
1846 function getUserMinConfirmed () {
1847 // Do we have cache?
1848 if (!isset($GLOBALS[__FUNCTION__])) {
1850 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1854 return $GLOBALS[__FUNCTION__];
1857 // "Getter" for auto_purge
1858 function getAutoPurge () {
1859 // Do we have cache?
1860 if (!isset($GLOBALS[__FUNCTION__])) {
1862 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1866 return $GLOBALS[__FUNCTION__];
1869 // "Getter" for bonus_userid
1870 function getBonusUserid () {
1871 // Do we have cache?
1872 if (!isset($GLOBALS[__FUNCTION__])) {
1874 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1878 return $GLOBALS[__FUNCTION__];
1881 // "Getter" for ap_inactive_time
1882 function getApInactiveTime () {
1883 // Do we have cache?
1884 if (!isset($GLOBALS[__FUNCTION__])) {
1886 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1890 return $GLOBALS[__FUNCTION__];
1893 // "Getter" for ap_dm_timeout
1894 function getApDmTimeout () {
1895 // Do we have cache?
1896 if (!isset($GLOBALS[__FUNCTION__])) {
1898 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1902 return $GLOBALS[__FUNCTION__];
1905 // "Getter" for ap_tasks_time
1906 function getApTasksTime () {
1907 // Do we have cache?
1908 if (!isset($GLOBALS[__FUNCTION__])) {
1910 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1914 return $GLOBALS[__FUNCTION__];
1917 // "Getter" for ap_unconfirmed_time
1918 function getApUnconfirmedTime () {
1919 // Do we have cache?
1920 if (!isset($GLOBALS[__FUNCTION__])) {
1922 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1926 return $GLOBALS[__FUNCTION__];
1929 // "Getter" for points
1930 function getPoints () {
1931 // Do we have cache?
1932 if (!isset($GLOBALS[__FUNCTION__])) {
1934 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1938 return $GLOBALS[__FUNCTION__];
1941 // "Getter" for slogan
1942 function getSlogan () {
1943 // Do we have cache?
1944 if (!isset($GLOBALS[__FUNCTION__])) {
1946 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1950 return $GLOBALS[__FUNCTION__];
1953 // "Getter" for copy
1954 function getCopy () {
1955 // Do we have cache?
1956 if (!isset($GLOBALS[__FUNCTION__])) {
1958 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1962 return $GLOBALS[__FUNCTION__];
1965 // "Getter" for webmaster
1966 function getWebmaster () {
1967 // Do we have cache?
1968 if (!isset($GLOBALS[__FUNCTION__])) {
1970 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1974 return $GLOBALS[__FUNCTION__];
1977 // "Getter" for sql_count
1978 function getSqlCount () {
1979 // Do we have cache?
1980 if (!isset($GLOBALS[__FUNCTION__])) {
1982 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1986 return $GLOBALS[__FUNCTION__];
1989 // "Getter" for num_templates
1990 function getNumTemplates () {
1991 // Do we have cache?
1992 if (!isset($GLOBALS[__FUNCTION__])) {
1994 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1998 return $GLOBALS[__FUNCTION__];
2001 // "Getter" for dns_cache_timeout
2002 function getDnsCacheTimeout () {
2003 // Do we have cache?
2004 if (!isset($GLOBALS[__FUNCTION__])) {
2006 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2010 return $GLOBALS[__FUNCTION__];
2013 // "Getter" for menu_blur_spacer
2014 function getMenuBlurSpacer () {
2015 // Do we have cache?
2016 if (!isset($GLOBALS[__FUNCTION__])) {
2018 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2022 return $GLOBALS[__FUNCTION__];
2025 // "Getter" for points_register
2026 function getPointsRegister () {
2027 // Do we have cache?
2028 if (!isset($GLOBALS[__FUNCTION__])) {
2030 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2034 return $GLOBALS[__FUNCTION__];
2037 // "Getter" for points_ref
2038 function getPointsRef () {
2039 // Do we have cache?
2040 if (!isset($GLOBALS[__FUNCTION__])) {
2042 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2046 return $GLOBALS[__FUNCTION__];
2049 // "Getter" for ref_payout
2050 function getRefPayout () {
2051 // Do we have cache?
2052 if (!isset($GLOBALS[__FUNCTION__])) {
2054 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2058 return $GLOBALS[__FUNCTION__];
2061 // "Getter" for online_timeout
2062 function getOnlineTimeout () {
2063 // Do we have cache?
2064 if (!isset($GLOBALS[__FUNCTION__])) {
2066 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2070 return $GLOBALS[__FUNCTION__];
2073 // "Getter" for index_home
2074 function getIndexHome () {
2075 // Do we have cache?
2076 if (!isset($GLOBALS[__FUNCTION__])) {
2078 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2082 return $GLOBALS[__FUNCTION__];
2085 // "Getter" for one_day
2086 function getOneDay () {
2087 // Do we have cache?
2088 if (!isset($GLOBALS[__FUNCTION__])) {
2090 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2094 return $GLOBALS[__FUNCTION__];
2097 // "Getter" for activate_xchange
2098 function getActivateXchange () {
2099 // Do we have cache?
2100 if (!isset($GLOBALS[__FUNCTION__])) {
2102 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2106 return $GLOBALS[__FUNCTION__];
2109 // "Getter" for img_type
2110 function getImgType () {
2111 // Do we have cache?
2112 if (!isset($GLOBALS[__FUNCTION__])) {
2114 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2118 return $GLOBALS[__FUNCTION__];
2121 // "Getter" for code_length
2122 function getCodeLength () {
2123 // Do we have cache?
2124 if (!isset($GLOBALS[__FUNCTION__])) {
2126 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2130 return $GLOBALS[__FUNCTION__];
2133 // "Getter" for least_cats
2134 function getLeastCats () {
2135 // Do we have cache?
2136 if (!isset($GLOBALS[__FUNCTION__])) {
2138 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2142 return $GLOBALS[__FUNCTION__];
2145 // "Getter" for pass_len
2146 function getPassLen () {
2147 // Do we have cache?
2148 if (!isset($GLOBALS[__FUNCTION__])) {
2150 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2154 return $GLOBALS[__FUNCTION__];
2157 // "Getter" for admin_menu
2158 function getAdminMenu () {
2159 // Do we have cache?
2160 if (!isset($GLOBALS[__FUNCTION__])) {
2162 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2166 return $GLOBALS[__FUNCTION__];
2169 // "Getter" for last_month
2170 function getLastMonth () {
2171 // Do we have cache?
2172 if (!isset($GLOBALS[__FUNCTION__])) {
2174 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2178 return $GLOBALS[__FUNCTION__];
2181 // "Getter" for max_send
2182 function getMaxSend () {
2183 // Do we have cache?
2184 if (!isset($GLOBALS[__FUNCTION__])) {
2186 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2190 return $GLOBALS[__FUNCTION__];
2193 // "Getter" for mails_page
2194 function getMailsPage () {
2195 // Do we have cache?
2196 if (!isset($GLOBALS[__FUNCTION__])) {
2198 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2202 return $GLOBALS[__FUNCTION__];
2205 // "Getter" for rand_no
2206 function getRandNo () {
2207 // Do we have cache?
2208 if (!isset($GLOBALS[__FUNCTION__])) {
2210 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2214 return $GLOBALS[__FUNCTION__];
2217 // "Getter" for __DB_NAME
2218 function getDbName () {
2219 // Do we have cache?
2220 if (!isset($GLOBALS[__FUNCTION__])) {
2222 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2226 return $GLOBALS[__FUNCTION__];
2229 // "Getter" for DOMAIN
2230 function getDomain () {
2231 // Do we have cache?
2232 if (!isset($GLOBALS[__FUNCTION__])) {
2234 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2238 return $GLOBALS[__FUNCTION__];
2241 // "Getter" for proxy_username
2242 function getProxyUsername () {
2243 // Do we have cache?
2244 if (!isset($GLOBALS[__FUNCTION__])) {
2246 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2250 return $GLOBALS[__FUNCTION__];
2253 // "Getter" for proxy_password
2254 function getProxyPassword () {
2255 // Do we have cache?
2256 if (!isset($GLOBALS[__FUNCTION__])) {
2258 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2262 return $GLOBALS[__FUNCTION__];
2265 // "Getter" for proxy_host
2266 function getProxyHost () {
2267 // Do we have cache?
2268 if (!isset($GLOBALS[__FUNCTION__])) {
2270 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2274 return $GLOBALS[__FUNCTION__];
2277 // "Getter" for proxy_port
2278 function getProxyPort () {
2279 // Do we have cache?
2280 if (!isset($GLOBALS[__FUNCTION__])) {
2282 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2286 return $GLOBALS[__FUNCTION__];
2289 // "Getter" for SMTP_HOSTNAME
2290 function getSmtpHostname () {
2291 // Do we have cache?
2292 if (!isset($GLOBALS[__FUNCTION__])) {
2294 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2298 return $GLOBALS[__FUNCTION__];
2301 // "Getter" for SMTP_USER
2302 function getSmtpUser () {
2303 // Do we have cache?
2304 if (!isset($GLOBALS[__FUNCTION__])) {
2306 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2310 return $GLOBALS[__FUNCTION__];
2313 // "Getter" for SMTP_PASSWORD
2314 function getSmtpPassword () {
2315 // Do we have cache?
2316 if (!isset($GLOBALS[__FUNCTION__])) {
2318 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2322 return $GLOBALS[__FUNCTION__];
2325 // "Getter" for points_word
2326 function getPointsWord () {
2327 // Do we have cache?
2328 if (!isset($GLOBALS[__FUNCTION__])) {
2330 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2334 return $GLOBALS[__FUNCTION__];
2337 // "Getter" for profile_lock
2338 function getProfileLock () {
2339 // Do we have cache?
2340 if (!isset($GLOBALS[__FUNCTION__])) {
2342 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2346 return $GLOBALS[__FUNCTION__];
2349 // "Getter" for url_tlock
2350 function getUrlTlock () {
2351 // Do we have cache?
2352 if (!isset($GLOBALS[__FUNCTION__])) {
2354 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2358 return $GLOBALS[__FUNCTION__];
2361 // "Getter" for title_left
2362 function getTitleLeft () {
2363 // Do we have cache?
2364 if (!isset($GLOBALS[__FUNCTION__])) {
2366 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2370 return $GLOBALS[__FUNCTION__];
2373 // "Getter" for title_right
2374 function getTitleRight () {
2375 // Do we have cache?
2376 if (!isset($GLOBALS[__FUNCTION__])) {
2378 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2382 return $GLOBALS[__FUNCTION__];
2385 // "Getter" for title_middle
2386 function getTitleMiddle () {
2387 // Do we have cache?
2388 if (!isset($GLOBALS[__FUNCTION__])) {
2390 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2394 return $GLOBALS[__FUNCTION__];
2397 // Getter for 'check_double_email'
2398 function getCheckDoubleEmail () {
2399 // Is the cache entry set?
2400 if (!isset($GLOBALS[__FUNCTION__])) {
2401 // No, so determine it
2402 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2405 // Return cached entry
2406 return $GLOBALS[__FUNCTION__];
2409 // Checks wether 'check_double_email' is 'Y'
2410 function isCheckDoubleEmailEnabled () {
2411 // Is the cache entry set?
2412 if (!isset($GLOBALS[__FUNCTION__])) {
2413 // No, so determine it
2414 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2417 // Return cached entry
2418 return $GLOBALS[__FUNCTION__];
2421 // Getter for 'display_home_in_index'
2422 function getDisplayHomeInIndex () {
2423 // Is the cache entry set?
2424 if (!isset($GLOBALS[__FUNCTION__])) {
2425 // No, so determine it
2426 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2429 // Return cached entry
2430 return $GLOBALS[__FUNCTION__];
2433 // Checks wether 'display_home_in_index' is 'Y'
2434 function isDisplayHomeInIndexEnabled () {
2435 // Is the cache entry set?
2436 if (!isset($GLOBALS[__FUNCTION__])) {
2437 // No, so determine it
2438 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2441 // Return cached entry
2442 return $GLOBALS[__FUNCTION__];
2445 // Getter for 'admin_menu_javascript'
2446 function getAdminMenuJavascript () {
2447 // Is the cache entry set?
2448 if (!isset($GLOBALS[__FUNCTION__])) {
2449 // No, so determine it
2450 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2453 // Return cached entry
2454 return $GLOBALS[__FUNCTION__];
2457 // Checks wether proxy configuration is used
2458 function isProxyUsed () {
2459 // Do we have cache?
2460 if (!isset($GLOBALS[__FUNCTION__])) {
2462 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2466 return $GLOBALS[__FUNCTION__];
2469 // Checks wether POST data contains selections
2470 function ifPostContainsSelections ($element = 'sel') {
2471 // Do we have cache?
2472 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2474 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2478 return $GLOBALS[__FUNCTION__][$element];
2481 // Checks wether verbose_sql is Y and returns true/false if so
2482 function isVerboseSqlEnabled () {
2483 // Do we have cache?
2484 if (!isset($GLOBALS[__FUNCTION__])) {
2486 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2490 return $GLOBALS[__FUNCTION__];
2493 // "Getter" for total user points
2494 function getTotalPoints ($userid) {
2495 // Do we have cache?
2496 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2497 // Init array for filter chain
2499 'userid' => $userid,
2503 // Run filter chain for getting more point values
2504 $data = runFilterChain('get_total_points', $data);
2507 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2511 return $GLOBALS[__FUNCTION__][$userid];
2514 // Wrapper to check if url_blacklist is enabled
2515 function isUrlBlacklistEnabled () {
2516 // Do we have cache?
2517 if (!isset($GLOBALS[__FUNCTION__])) {
2519 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2523 return $GLOBALS[__FUNCTION__];
2526 // Checks wether direct payment is allowed in configuration
2527 function isDirectPaymentEnabled () {
2528 // Do we have cache?
2529 if (!isset($GLOBALS[__FUNCTION__])) {
2531 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2535 return $GLOBALS[__FUNCTION__];
2538 // Checks wether JavaScript-based admin menu is enabled
2539 function isAdminMenuJavascriptEnabled () {
2540 // Do we have cache?
2541 if (!isset($GLOBALS[__FUNCTION__])) {
2543 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
2547 return $GLOBALS[__FUNCTION__];
2550 // Wrapper to check if current task is for extension (not update)
2551 function isExtensionTask ($content) {
2552 // Do we have cache?
2553 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2555 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2559 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2562 // Wrapper to check if output mode is CSS
2563 function isCssOutputMode () {
2565 return (getScriptOutputMode() == 1);
2568 // Wrapper to check if output mode is HTML
2569 function isHtmlOutputMode () {
2571 return (getScriptOutputMode() == 0);
2574 // Wrapper to check if output mode is RAW
2575 function isRawOutputMode () {
2577 return (getScriptOutputMode() == -1);
2580 // Wrapper to check if output mode is AJAX
2581 function isAjaxOutputMode () {
2583 return (getScriptOutputMode() == -2);
2586 // Wrapper to check if output mode is image
2587 function isImageOutputMode () {
2589 return (getScriptOutputMode() == -3);
2592 // Wrapper to generate a user email link
2593 function generateWrappedUserEmailLink ($email) {
2594 // Just call the inner function
2595 return generateEmailLink($email, 'user_data');
2598 // Wrapper to check if user points are locked
2599 function ifUserPointsLocked ($userid) {
2600 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2601 // Do we have cache?
2602 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2604 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2608 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2609 return $GLOBALS[__FUNCTION__][$userid];
2612 // Appends a line to an existing file or creates it instantly with given content.
2613 // This function does always add a new-line character to every line.
2614 function appendLineToFile ($file, $line) {
2615 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2616 fwrite($fp, $line . "\n");
2620 // Wrapper for changeDataInFile() but with full path added
2621 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2623 $FQFN = getPath() . $FQFN;
2625 // Call inner function
2626 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2629 // Wrapper for changing entries in config-local.php
2630 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2631 // Call the inner function
2632 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2635 // Shortens ucfirst(strtolower()) calls
2636 function firstCharUpperCase ($str) {
2637 return ucfirst(strtolower($str));
2640 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2641 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2642 // Get the configuration entry
2643 $configValue = getConfig($configEntry);
2645 // Call inner method
2646 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2649 // Shortens converting of German comma to Computer's version in POST data
2650 function convertCommaToDotInPostData ($postEntry) {
2651 // Read and convert given entry
2652 $postValue = convertCommaToDot(postRequestElement($postEntry));
2654 // ... and set it again
2655 setPostRequestElement($postEntry, $postValue);
2658 // Converts German commas to Computer's version in all entries
2659 function convertCommaToDotInPostDataArray ($postEntries) {
2660 // Replace german decimal comma with computer decimal dot
2661 foreach ($postEntries as $entry) {
2662 // Is the entry there?
2663 if (isPostRequestElementSet($entry)) {
2665 convertCommaToDotInPostData($entry);
2671 * Parses a string into a US formated float variable, taken from user comments
2672 * from PHP documentation website.
2674 * @param $floatString A string holding a float expression
2675 * @return $float Corresponding float variable
2676 * @author chris<at>georgakopoulos<dot>com
2677 * @link http://de.php.net/manual/en/function.floatval.php#92563
2679 function parseFloat ($floatString){
2681 $LocaleInfo = localeconv();
2683 // Remove thousand separators
2684 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
2686 // Convert decimal point
2687 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2689 // Return float value of converted string
2690 return floatval($floatString);
2693 // Generates a YES/NO option list from given default
2694 function generateYesNoOptionList ($defaultValue = '') {
2696 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
2699 // "Getter" for total available receivers
2700 function getTotalReceivers ($mode = 'normal') {
2702 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2708 // Wrapper "getter" to get total unconfirmed mails for given userid
2709 function getTotalUnconfirmedMails ($userid) {
2710 // Do we have cache?
2711 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2713 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2717 return $GLOBALS[__FUNCTION__][$userid];
2720 // Checks wether 'mailer_theme' was found in session
2721 function isMailerThemeSet () {
2723 return isSessionVariableSet('mailer_theme');
2727 * Setter for theme in session (This setter does return the success of
2728 * setSession() which is required e.g. for destroySponsorSession().
2730 function setMailerTheme ($newTheme) {
2731 // Set it in session
2732 return setSession('mailer_theme', $newTheme);
2736 * Getter for theme from session (This getter does return 'mailer_theme' from
2737 * session data or throws an error if not possible
2739 function getMailerTheme () {
2740 // Is 'mailer_theme' set?
2741 if (!isMailerThemeSet()) {
2742 // No, then abort here
2743 debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
2746 // Return the theme from session
2747 return getSession('mailer_theme');