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 // Send helping header
1112 setHttpStatus('302 Found');
1114 // always close the session
1115 session_write_close();
1117 // Revert entity &
1118 $url = str_replace('&', '&', $url);
1120 // check if running on IIS < 6 with CGI-PHP
1121 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1122 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1123 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1124 ($matches[1] < 6)) {
1125 // Send the IIS header
1126 addHttpHeader('Refresh: 0;url=' . $url);
1128 // Send generic header
1129 addHttpHeader('Location: ' . $url);
1136 // Determines the country of the given user id
1137 function determineCountry ($userid) {
1138 // Do we have cache?
1139 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1140 // Default is 'invalid'
1141 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1143 // Is extension country active?
1144 if (isExtensionActive('country')) {
1145 // Determine the right country code through the country id
1146 $id = getUserData('country_code');
1148 // Then handle it over
1149 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1151 // Get raw code from user data
1152 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1157 return $GLOBALS[__FUNCTION__][$userid];
1160 // "Getter" for total confirmed user accounts
1161 function getTotalConfirmedUser () {
1163 if (!isset($GLOBALS[__FUNCTION__])) {
1165 if (isExtensionActive('user')) {
1166 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1168 $GLOBALS[__FUNCTION__] = 0;
1172 // Return cached value
1173 return $GLOBALS[__FUNCTION__];
1176 // "Getter" for total unconfirmed user accounts
1177 function getTotalUnconfirmedUser () {
1179 if (!isset($GLOBALS[__FUNCTION__])) {
1181 if (isExtensionActive('user')) {
1182 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1184 $GLOBALS[__FUNCTION__] = 0;
1188 // Return cached value
1189 return $GLOBALS[__FUNCTION__];
1192 // "Getter" for total locked user accounts
1193 function getTotalLockedUser () {
1195 if (!isset($GLOBALS[__FUNCTION__])) {
1197 if (isExtensionActive('user')) {
1198 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1200 $GLOBALS[__FUNCTION__] = 0;
1204 // Return cached value
1205 return $GLOBALS[__FUNCTION__];
1208 // "Getter" for total locked user accounts
1209 function getTotalRandomRefidUser () {
1211 if (!isset($GLOBALS[__FUNCTION__])) {
1213 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1214 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
1216 $GLOBALS[__FUNCTION__] = 0;
1220 // Return cached value
1221 return $GLOBALS[__FUNCTION__];
1224 // Is given userid valid?
1225 function isValidUserId ($userid) {
1226 // Do we have cache?
1227 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1229 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1233 return $GLOBALS[__FUNCTION__][$userid];
1237 function encodeEntities ($str) {
1239 $str = secureString($str, true, true);
1241 // Encode dollar sign as well
1242 $str = str_replace('$', '$', $str);
1248 // "Getter" for date from patch_ctime
1249 function getDateFromRepository () {
1251 if (!isset($GLOBALS[__FUNCTION__])) {
1253 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1257 return $GLOBALS[__FUNCTION__];
1260 // "Getter" for date/time from patch_ctime
1261 function getDateTimeFromRepository () {
1263 if (!isset($GLOBALS[__FUNCTION__])) {
1265 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1269 return $GLOBALS[__FUNCTION__];
1272 // Getter for current year (default)
1273 function getYear ($timestamp = NULL) {
1275 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1277 if (is_null($timestamp)) {
1278 $timestamp = time();
1282 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1286 return $GLOBALS[__FUNCTION__][$timestamp];
1289 // Getter for current month (default)
1290 function getMonth ($timestamp = NULL) {
1292 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1293 // If null is set, use time()
1294 if (is_null($timestamp)) {
1295 // Use time() which is current timestamp
1296 $timestamp = time();
1300 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1304 return $GLOBALS[__FUNCTION__][$timestamp];
1307 // Getter for current hour (default)
1308 function getHour ($timestamp = NULL) {
1310 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1312 if (is_null($timestamp)) {
1313 $timestamp = time();
1317 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1321 return $GLOBALS[__FUNCTION__][$timestamp];
1324 // Getter for current day (default)
1325 function getDay ($timestamp = NULL) {
1327 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1329 if (is_null($timestamp)) {
1330 $timestamp = time();
1334 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1338 return $GLOBALS[__FUNCTION__][$timestamp];
1341 // Getter for current week (default)
1342 function getWeek ($timestamp = NULL) {
1344 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1346 if (is_null($timestamp)) $timestamp = time();
1349 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1353 return $GLOBALS[__FUNCTION__][$timestamp];
1356 // Getter for current short_hour (default)
1357 function getShortHour ($timestamp = NULL) {
1359 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1361 if (is_null($timestamp)) $timestamp = time();
1364 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1368 return $GLOBALS[__FUNCTION__][$timestamp];
1371 // Getter for current long_hour (default)
1372 function getLongHour ($timestamp = NULL) {
1374 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1376 if (is_null($timestamp)) $timestamp = time();
1379 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1383 return $GLOBALS[__FUNCTION__][$timestamp];
1386 // Getter for current second (default)
1387 function getSecond ($timestamp = NULL) {
1389 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1391 if (is_null($timestamp)) $timestamp = time();
1394 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1398 return $GLOBALS[__FUNCTION__][$timestamp];
1401 // Getter for current minute (default)
1402 function getMinute ($timestamp = NULL) {
1404 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1406 if (is_null($timestamp)) $timestamp = time();
1409 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1413 return $GLOBALS[__FUNCTION__][$timestamp];
1416 // Checks wether the title decoration is enabled
1417 function isTitleDecorationEnabled () {
1418 // Do we have cache?
1419 if (!isset($GLOBALS[__FUNCTION__])) {
1421 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1425 return $GLOBALS[__FUNCTION__];
1428 // Checks wether filter usage updates are enabled (expensive queries!)
1429 function isFilterUsageUpdateEnabled () {
1430 // Do we have cache?
1431 if (!isset($GLOBALS[__FUNCTION__])) {
1433 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1437 return $GLOBALS[__FUNCTION__];
1440 // Checks wether debugging of weekly resets is enabled
1441 function isWeeklyResetDebugEnabled () {
1442 // Do we have cache?
1443 if (!isset($GLOBALS[__FUNCTION__])) {
1445 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1449 return $GLOBALS[__FUNCTION__];
1452 // Checks wether debugging of monthly resets is enabled
1453 function isMonthlyResetDebugEnabled () {
1454 // Do we have cache?
1455 if (!isset($GLOBALS[__FUNCTION__])) {
1457 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1461 return $GLOBALS[__FUNCTION__];
1464 // Checks wether displaying of debug SQLs are enabled
1465 function isDisplayDebugSqlEnabled () {
1466 // Do we have cache?
1467 if (!isset($GLOBALS[__FUNCTION__])) {
1469 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1473 return $GLOBALS[__FUNCTION__];
1476 // Checks wether module title is enabled
1477 function isModuleTitleEnabled () {
1478 // Do we have cache?
1479 if (!isset($GLOBALS[__FUNCTION__])) {
1481 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1485 return $GLOBALS[__FUNCTION__];
1488 // Checks wether what title is enabled
1489 function isWhatTitleEnabled () {
1490 // Do we have cache?
1491 if (!isset($GLOBALS[__FUNCTION__])) {
1493 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1497 return $GLOBALS[__FUNCTION__];
1500 // Checks wether stats are enabled
1501 function ifInternalStatsEnabled () {
1502 // Do we have cache?
1503 if (!isset($GLOBALS[__FUNCTION__])) {
1504 // Then determine it
1505 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1508 // Return cached value
1509 return $GLOBALS[__FUNCTION__];
1512 // Checks wether admin-notification of certain user actions is enabled
1513 function isAdminNotificationEnabled () {
1514 // Do we have cache?
1515 if (!isset($GLOBALS[__FUNCTION__])) {
1517 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1521 return $GLOBALS[__FUNCTION__];
1524 // Checks wether random referral id selection is enabled
1525 function isRandomReferralIdEnabled () {
1526 // Do we have cache?
1527 if (!isset($GLOBALS[__FUNCTION__])) {
1529 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1533 return $GLOBALS[__FUNCTION__];
1536 // "Getter" for default language
1537 function getDefaultLanguage () {
1538 // Do we have cache?
1539 if (!isset($GLOBALS[__FUNCTION__])) {
1541 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1545 return $GLOBALS[__FUNCTION__];
1548 // "Getter" for default referral id
1549 function getDefRefid () {
1550 // Do we have cache?
1551 if (!isset($GLOBALS[__FUNCTION__])) {
1553 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1557 return $GLOBALS[__FUNCTION__];
1560 // "Getter" for path
1561 function getPath () {
1562 // Do we have cache?
1563 if (!isset($GLOBALS[__FUNCTION__])) {
1565 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1569 return $GLOBALS[__FUNCTION__];
1573 function getUrl () {
1574 // Do we have cache?
1575 if (!isset($GLOBALS[__FUNCTION__])) {
1577 $GLOBALS[__FUNCTION__] = getConfig('URL');
1581 return $GLOBALS[__FUNCTION__];
1584 // "Getter" for cache_path
1585 function getCachePath () {
1586 // Do we have cache?
1587 if (!isset($GLOBALS[__FUNCTION__])) {
1589 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1593 return $GLOBALS[__FUNCTION__];
1596 // "Getter" for secret_key
1597 function getSecretKey () {
1598 // Do we have cache?
1599 if (!isset($GLOBALS[__FUNCTION__])) {
1601 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1605 return $GLOBALS[__FUNCTION__];
1608 // "Getter" for SITE_KEY
1609 function getSiteKey () {
1610 // Do we have cache?
1611 if (!isset($GLOBALS[__FUNCTION__])) {
1613 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1617 return $GLOBALS[__FUNCTION__];
1620 // "Getter" for DATE_KEY
1621 function getDateKey () {
1622 // Do we have cache?
1623 if (!isset($GLOBALS[__FUNCTION__])) {
1625 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1629 return $GLOBALS[__FUNCTION__];
1632 // "Getter" for master_salt
1633 function getMasterSalt () {
1634 // Do we have cache?
1635 if (!isset($GLOBALS[__FUNCTION__])) {
1637 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1641 return $GLOBALS[__FUNCTION__];
1644 // "Getter" for prime
1645 function getPrime () {
1646 // Do we have cache?
1647 if (!isset($GLOBALS[__FUNCTION__])) {
1649 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1653 return $GLOBALS[__FUNCTION__];
1656 // "Getter" for encrypt_separator
1657 function getEncryptSeparator () {
1658 // Do we have cache?
1659 if (!isset($GLOBALS[__FUNCTION__])) {
1661 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1665 return $GLOBALS[__FUNCTION__];
1668 // "Getter" for mysql_prefix
1669 function getMysqlPrefix () {
1670 // Do we have cache?
1671 if (!isset($GLOBALS[__FUNCTION__])) {
1673 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1677 return $GLOBALS[__FUNCTION__];
1680 // "Getter" for table_type
1681 function getTableType () {
1682 // Do we have cache?
1683 if (!isset($GLOBALS[__FUNCTION__])) {
1685 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1689 return $GLOBALS[__FUNCTION__];
1692 // "Getter" for salt_length
1693 function getSaltLength () {
1694 // Do we have cache?
1695 if (!isset($GLOBALS[__FUNCTION__])) {
1697 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1701 return $GLOBALS[__FUNCTION__];
1704 // "Getter" for output_mode
1705 function getOutputMode () {
1706 // Do we have cache?
1707 if (!isset($GLOBALS[__FUNCTION__])) {
1709 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1713 return $GLOBALS[__FUNCTION__];
1716 // "Getter" for full_version
1717 function getFullVersion () {
1718 // Do we have cache?
1719 if (!isset($GLOBALS[__FUNCTION__])) {
1721 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1725 return $GLOBALS[__FUNCTION__];
1728 // "Getter" for title
1729 function getTitle () {
1730 // Do we have cache?
1731 if (!isset($GLOBALS[__FUNCTION__])) {
1733 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1737 return $GLOBALS[__FUNCTION__];
1740 // "Getter" for curr_svn_revision
1741 function getCurrentRepositoryRevision () {
1742 // Do we have cache?
1743 if (!isset($GLOBALS[__FUNCTION__])) {
1745 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1749 return $GLOBALS[__FUNCTION__];
1752 // "Getter" for server_url
1753 function getServerUrl () {
1754 // Do we have cache?
1755 if (!isset($GLOBALS[__FUNCTION__])) {
1757 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1761 return $GLOBALS[__FUNCTION__];
1764 // "Getter" for mt_word
1765 function getMtWord () {
1766 // Do we have cache?
1767 if (!isset($GLOBALS[__FUNCTION__])) {
1769 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1773 return $GLOBALS[__FUNCTION__];
1776 // "Getter" for mt_word2
1777 function getMtWord2 () {
1778 // Do we have cache?
1779 if (!isset($GLOBALS[__FUNCTION__])) {
1781 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1785 return $GLOBALS[__FUNCTION__];
1788 // "Getter" for main_title
1789 function getMainTitle () {
1790 // Do we have cache?
1791 if (!isset($GLOBALS[__FUNCTION__])) {
1793 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1797 return $GLOBALS[__FUNCTION__];
1800 // "Getter" for file_hash
1801 function getFileHash () {
1802 // Do we have cache?
1803 if (!isset($GLOBALS[__FUNCTION__])) {
1805 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1809 return $GLOBALS[__FUNCTION__];
1812 // "Getter" for pass_scramble
1813 function getPassScramble () {
1814 // Do we have cache?
1815 if (!isset($GLOBALS[__FUNCTION__])) {
1817 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1821 return $GLOBALS[__FUNCTION__];
1824 // "Getter" for ap_inactive_since
1825 function getApInactiveSince () {
1826 // Do we have cache?
1827 if (!isset($GLOBALS[__FUNCTION__])) {
1829 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1833 return $GLOBALS[__FUNCTION__];
1836 // "Getter" for user_min_confirmed
1837 function getUserMinConfirmed () {
1838 // Do we have cache?
1839 if (!isset($GLOBALS[__FUNCTION__])) {
1841 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1845 return $GLOBALS[__FUNCTION__];
1848 // "Getter" for auto_purge
1849 function getAutoPurge () {
1850 // Do we have cache?
1851 if (!isset($GLOBALS[__FUNCTION__])) {
1853 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1857 return $GLOBALS[__FUNCTION__];
1860 // "Getter" for bonus_userid
1861 function getBonusUserid () {
1862 // Do we have cache?
1863 if (!isset($GLOBALS[__FUNCTION__])) {
1865 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1869 return $GLOBALS[__FUNCTION__];
1872 // "Getter" for ap_inactive_time
1873 function getApInactiveTime () {
1874 // Do we have cache?
1875 if (!isset($GLOBALS[__FUNCTION__])) {
1877 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1881 return $GLOBALS[__FUNCTION__];
1884 // "Getter" for ap_dm_timeout
1885 function getApDmTimeout () {
1886 // Do we have cache?
1887 if (!isset($GLOBALS[__FUNCTION__])) {
1889 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1893 return $GLOBALS[__FUNCTION__];
1896 // "Getter" for ap_tasks_time
1897 function getApTasksTime () {
1898 // Do we have cache?
1899 if (!isset($GLOBALS[__FUNCTION__])) {
1901 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1905 return $GLOBALS[__FUNCTION__];
1908 // "Getter" for ap_unconfirmed_time
1909 function getApUnconfirmedTime () {
1910 // Do we have cache?
1911 if (!isset($GLOBALS[__FUNCTION__])) {
1913 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1917 return $GLOBALS[__FUNCTION__];
1920 // "Getter" for points
1921 function getPoints () {
1922 // Do we have cache?
1923 if (!isset($GLOBALS[__FUNCTION__])) {
1925 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1929 return $GLOBALS[__FUNCTION__];
1932 // "Getter" for slogan
1933 function getSlogan () {
1934 // Do we have cache?
1935 if (!isset($GLOBALS[__FUNCTION__])) {
1937 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1941 return $GLOBALS[__FUNCTION__];
1944 // "Getter" for copy
1945 function getCopy () {
1946 // Do we have cache?
1947 if (!isset($GLOBALS[__FUNCTION__])) {
1949 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1953 return $GLOBALS[__FUNCTION__];
1956 // "Getter" for webmaster
1957 function getWebmaster () {
1958 // Do we have cache?
1959 if (!isset($GLOBALS[__FUNCTION__])) {
1961 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1965 return $GLOBALS[__FUNCTION__];
1968 // "Getter" for sql_count
1969 function getSqlCount () {
1970 // Do we have cache?
1971 if (!isset($GLOBALS[__FUNCTION__])) {
1973 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1977 return $GLOBALS[__FUNCTION__];
1980 // "Getter" for num_templates
1981 function getNumTemplates () {
1982 // Do we have cache?
1983 if (!isset($GLOBALS[__FUNCTION__])) {
1985 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1989 return $GLOBALS[__FUNCTION__];
1992 // "Getter" for dns_cache_timeout
1993 function getDnsCacheTimeout () {
1994 // Do we have cache?
1995 if (!isset($GLOBALS[__FUNCTION__])) {
1997 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2001 return $GLOBALS[__FUNCTION__];
2004 // "Getter" for menu_blur_spacer
2005 function getMenuBlurSpacer () {
2006 // Do we have cache?
2007 if (!isset($GLOBALS[__FUNCTION__])) {
2009 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2013 return $GLOBALS[__FUNCTION__];
2016 // "Getter" for points_register
2017 function getPointsRegister () {
2018 // Do we have cache?
2019 if (!isset($GLOBALS[__FUNCTION__])) {
2021 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2025 return $GLOBALS[__FUNCTION__];
2028 // "Getter" for points_ref
2029 function getPointsRef () {
2030 // Do we have cache?
2031 if (!isset($GLOBALS[__FUNCTION__])) {
2033 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2037 return $GLOBALS[__FUNCTION__];
2040 // "Getter" for ref_payout
2041 function getRefPayout () {
2042 // Do we have cache?
2043 if (!isset($GLOBALS[__FUNCTION__])) {
2045 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2049 return $GLOBALS[__FUNCTION__];
2052 // "Getter" for online_timeout
2053 function getOnlineTimeout () {
2054 // Do we have cache?
2055 if (!isset($GLOBALS[__FUNCTION__])) {
2057 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2061 return $GLOBALS[__FUNCTION__];
2064 // "Getter" for index_home
2065 function getIndexHome () {
2066 // Do we have cache?
2067 if (!isset($GLOBALS[__FUNCTION__])) {
2069 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2073 return $GLOBALS[__FUNCTION__];
2076 // "Getter" for one_day
2077 function getOneDay () {
2078 // Do we have cache?
2079 if (!isset($GLOBALS[__FUNCTION__])) {
2081 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2085 return $GLOBALS[__FUNCTION__];
2088 // "Getter" for activate_xchange
2089 function getActivateXchange () {
2090 // Do we have cache?
2091 if (!isset($GLOBALS[__FUNCTION__])) {
2093 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2097 return $GLOBALS[__FUNCTION__];
2100 // "Getter" for img_type
2101 function getImgType () {
2102 // Do we have cache?
2103 if (!isset($GLOBALS[__FUNCTION__])) {
2105 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2109 return $GLOBALS[__FUNCTION__];
2112 // "Getter" for code_length
2113 function getCodeLength () {
2114 // Do we have cache?
2115 if (!isset($GLOBALS[__FUNCTION__])) {
2117 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2121 return $GLOBALS[__FUNCTION__];
2124 // "Getter" for least_cats
2125 function getLeastCats () {
2126 // Do we have cache?
2127 if (!isset($GLOBALS[__FUNCTION__])) {
2129 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2133 return $GLOBALS[__FUNCTION__];
2136 // "Getter" for pass_len
2137 function getPassLen () {
2138 // Do we have cache?
2139 if (!isset($GLOBALS[__FUNCTION__])) {
2141 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2145 return $GLOBALS[__FUNCTION__];
2148 // "Getter" for admin_menu
2149 function getAdminMenu () {
2150 // Do we have cache?
2151 if (!isset($GLOBALS[__FUNCTION__])) {
2153 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2157 return $GLOBALS[__FUNCTION__];
2160 // "Getter" for last_month
2161 function getLastMonth () {
2162 // Do we have cache?
2163 if (!isset($GLOBALS[__FUNCTION__])) {
2165 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2169 return $GLOBALS[__FUNCTION__];
2172 // "Getter" for max_send
2173 function getMaxSend () {
2174 // Do we have cache?
2175 if (!isset($GLOBALS[__FUNCTION__])) {
2177 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2181 return $GLOBALS[__FUNCTION__];
2184 // "Getter" for mails_page
2185 function getMailsPage () {
2186 // Do we have cache?
2187 if (!isset($GLOBALS[__FUNCTION__])) {
2189 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2193 return $GLOBALS[__FUNCTION__];
2196 // "Getter" for rand_no
2197 function getRandNo () {
2198 // Do we have cache?
2199 if (!isset($GLOBALS[__FUNCTION__])) {
2201 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2205 return $GLOBALS[__FUNCTION__];
2208 // "Getter" for __DB_NAME
2209 function getDbName () {
2210 // Do we have cache?
2211 if (!isset($GLOBALS[__FUNCTION__])) {
2213 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2217 return $GLOBALS[__FUNCTION__];
2220 // "Getter" for DOMAIN
2221 function getDomain () {
2222 // Do we have cache?
2223 if (!isset($GLOBALS[__FUNCTION__])) {
2225 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2229 return $GLOBALS[__FUNCTION__];
2232 // "Getter" for proxy_username
2233 function getProxyUsername () {
2234 // Do we have cache?
2235 if (!isset($GLOBALS[__FUNCTION__])) {
2237 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2241 return $GLOBALS[__FUNCTION__];
2244 // "Getter" for proxy_password
2245 function getProxyPassword () {
2246 // Do we have cache?
2247 if (!isset($GLOBALS[__FUNCTION__])) {
2249 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2253 return $GLOBALS[__FUNCTION__];
2256 // "Getter" for proxy_host
2257 function getProxyHost () {
2258 // Do we have cache?
2259 if (!isset($GLOBALS[__FUNCTION__])) {
2261 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2265 return $GLOBALS[__FUNCTION__];
2268 // "Getter" for proxy_port
2269 function getProxyPort () {
2270 // Do we have cache?
2271 if (!isset($GLOBALS[__FUNCTION__])) {
2273 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2277 return $GLOBALS[__FUNCTION__];
2280 // "Getter" for SMTP_HOSTNAME
2281 function getSmtpHostname () {
2282 // Do we have cache?
2283 if (!isset($GLOBALS[__FUNCTION__])) {
2285 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2289 return $GLOBALS[__FUNCTION__];
2292 // "Getter" for SMTP_USER
2293 function getSmtpUser () {
2294 // Do we have cache?
2295 if (!isset($GLOBALS[__FUNCTION__])) {
2297 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2301 return $GLOBALS[__FUNCTION__];
2304 // "Getter" for SMTP_PASSWORD
2305 function getSmtpPassword () {
2306 // Do we have cache?
2307 if (!isset($GLOBALS[__FUNCTION__])) {
2309 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2313 return $GLOBALS[__FUNCTION__];
2316 // "Getter" for points_word
2317 function getPointsWord () {
2318 // Do we have cache?
2319 if (!isset($GLOBALS[__FUNCTION__])) {
2321 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2325 return $GLOBALS[__FUNCTION__];
2328 // "Getter" for profile_lock
2329 function getProfileLock () {
2330 // Do we have cache?
2331 if (!isset($GLOBALS[__FUNCTION__])) {
2333 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2337 return $GLOBALS[__FUNCTION__];
2340 // "Getter" for url_tlock
2341 function getUrlTlock () {
2342 // Do we have cache?
2343 if (!isset($GLOBALS[__FUNCTION__])) {
2345 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2349 return $GLOBALS[__FUNCTION__];
2352 // "Getter" for title_left
2353 function getTitleLeft () {
2354 // Do we have cache?
2355 if (!isset($GLOBALS[__FUNCTION__])) {
2357 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2361 return $GLOBALS[__FUNCTION__];
2364 // "Getter" for title_right
2365 function getTitleRight () {
2366 // Do we have cache?
2367 if (!isset($GLOBALS[__FUNCTION__])) {
2369 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2373 return $GLOBALS[__FUNCTION__];
2376 // "Getter" for title_middle
2377 function getTitleMiddle () {
2378 // Do we have cache?
2379 if (!isset($GLOBALS[__FUNCTION__])) {
2381 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2385 return $GLOBALS[__FUNCTION__];
2388 // Getter for 'check_double_email'
2389 function getCheckDoubleEmail () {
2390 // Is the cache entry set?
2391 if (!isset($GLOBALS[__FUNCTION__])) {
2392 // No, so determine it
2393 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2396 // Return cached entry
2397 return $GLOBALS[__FUNCTION__];
2400 // Checks wether 'check_double_email' is 'Y'
2401 function isCheckDoubleEmailEnabled () {
2402 // Is the cache entry set?
2403 if (!isset($GLOBALS[__FUNCTION__])) {
2404 // No, so determine it
2405 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2408 // Return cached entry
2409 return $GLOBALS[__FUNCTION__];
2412 // Getter for 'display_home_in_index'
2413 function getDisplayHomeInIndex () {
2414 // Is the cache entry set?
2415 if (!isset($GLOBALS[__FUNCTION__])) {
2416 // No, so determine it
2417 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2420 // Return cached entry
2421 return $GLOBALS[__FUNCTION__];
2424 // Checks wether 'display_home_in_index' is 'Y'
2425 function isDisplayHomeInIndexEnabled () {
2426 // Is the cache entry set?
2427 if (!isset($GLOBALS[__FUNCTION__])) {
2428 // No, so determine it
2429 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2432 // Return cached entry
2433 return $GLOBALS[__FUNCTION__];
2436 // Getter for 'admin_menu_javascript'
2437 function getAdminMenuJavascript () {
2438 // Is the cache entry set?
2439 if (!isset($GLOBALS[__FUNCTION__])) {
2440 // No, so determine it
2441 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2444 // Return cached entry
2445 return $GLOBALS[__FUNCTION__];
2448 // Checks wether proxy configuration is used
2449 function isProxyUsed () {
2450 // Do we have cache?
2451 if (!isset($GLOBALS[__FUNCTION__])) {
2453 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2457 return $GLOBALS[__FUNCTION__];
2460 // Checks wether POST data contains selections
2461 function ifPostContainsSelections ($element = 'sel') {
2462 // Do we have cache?
2463 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2465 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2469 return $GLOBALS[__FUNCTION__][$element];
2472 // Checks wether verbose_sql is Y and returns true/false if so
2473 function isVerboseSqlEnabled () {
2474 // Do we have cache?
2475 if (!isset($GLOBALS[__FUNCTION__])) {
2477 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2481 return $GLOBALS[__FUNCTION__];
2484 // "Getter" for total user points
2485 function getTotalPoints ($userid) {
2486 // Do we have cache?
2487 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2488 // Init array for filter chain
2490 'userid' => $userid,
2494 // Run filter chain for getting more point values
2495 $data = runFilterChain('get_total_points', $data);
2498 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2502 return $GLOBALS[__FUNCTION__][$userid];
2505 // Wrapper to check if url_blacklist is enabled
2506 function isUrlBlacklistEnabled () {
2507 // Do we have cache?
2508 if (!isset($GLOBALS[__FUNCTION__])) {
2510 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2514 return $GLOBALS[__FUNCTION__];
2517 // Checks wether direct payment is allowed in configuration
2518 function isDirectPaymentEnabled () {
2519 // Do we have cache?
2520 if (!isset($GLOBALS[__FUNCTION__])) {
2522 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2526 return $GLOBALS[__FUNCTION__];
2529 // Checks wether JavaScript-based admin menu is enabled
2530 function isAdminMenuJavascriptEnabled () {
2531 // Do we have cache?
2532 if (!isset($GLOBALS[__FUNCTION__])) {
2534 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
2538 return $GLOBALS[__FUNCTION__];
2541 // Wrapper to check if current task is for extension (not update)
2542 function isExtensionTask ($content) {
2543 // Do we have cache?
2544 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2546 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2550 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2553 // Wrapper to check if output mode is CSS
2554 function isCssOutputMode () {
2556 return (getScriptOutputMode() == 1);
2559 // Wrapper to check if output mode is HTML
2560 function isHtmlOutputMode () {
2562 return (getScriptOutputMode() == 0);
2565 // Wrapper to check if output mode is RAW
2566 function isRawOutputMode () {
2568 return (getScriptOutputMode() == -1);
2571 // Wrapper to check if output mode is AJAX
2572 function isAjaxOutputMode () {
2574 return (getScriptOutputMode() == -2);
2577 // Wrapper to check if output mode is image
2578 function isImageOutputMode () {
2580 return (getScriptOutputMode() == -3);
2583 // Wrapper to generate a user email link
2584 function generateWrappedUserEmailLink ($email) {
2585 // Just call the inner function
2586 return generateEmailLink($email, 'user_data');
2589 // Wrapper to check if user points are locked
2590 function ifUserPointsLocked ($userid) {
2591 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2592 // Do we have cache?
2593 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2595 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2599 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2600 return $GLOBALS[__FUNCTION__][$userid];
2603 // Appends a line to an existing file or creates it instantly with given content.
2604 // This function does always add a new-line character to every line.
2605 function appendLineToFile ($file, $line) {
2606 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2607 fwrite($fp, $line . "\n");
2611 // Wrapper for changeDataInFile() but with full path added
2612 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2614 $FQFN = getPath() . $FQFN;
2616 // Call inner function
2617 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2620 // Wrapper for changing entries in config-local.php
2621 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2622 // Call the inner function
2623 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2626 // Shortens ucfirst(strtolower()) calls
2627 function firstCharUpperCase ($str) {
2628 return ucfirst(strtolower($str));
2631 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2632 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2633 // Get the configuration entry
2634 $configValue = getConfig($configEntry);
2636 // Call inner method
2637 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2640 // Shortens converting of German comma to Computer's version in POST data
2641 function convertCommaToDotInPostData ($postEntry) {
2642 // Read and convert given entry
2643 $postValue = convertCommaToDot(postRequestElement($postEntry));
2645 // ... and set it again
2646 setPostRequestElement($postEntry, $postValue);
2649 // Converts German commas to Computer's version in all entries
2650 function convertCommaToDotInPostDataArray ($postEntries) {
2651 // Replace german decimal comma with computer decimal dot
2652 foreach ($postEntries as $entry) {
2653 // Is the entry there?
2654 if (isPostRequestElementSet($entry)) {
2656 convertCommaToDotInPostData($entry);
2662 * Parses a string into a US formated float variable, taken from user comments
2663 * from PHP documentation website.
2665 * @param $floatString A string holding a float expression
2666 * @return $float Corresponding float variable
2667 * @author chris<at>georgakopoulos<dot>com
2668 * @link http://de.php.net/manual/en/function.floatval.php#92563
2670 function parseFloat ($floatString){
2672 $LocaleInfo = localeconv();
2674 // Remove thousand separators
2675 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
2677 // Convert decimal point
2678 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2680 // Return float value of converted string
2681 return floatval($floatString);
2684 // Generates a YES/NO option list from given default
2685 function generateYesNoOptionList ($defaultValue = '') {
2687 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
2690 // "Getter" for total available receivers
2691 function getTotalReceivers ($mode = 'normal') {
2693 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2699 // Wrapper "getter" to get total unconfirmed mails for given userid
2700 function getTotalUnconfirmedMails ($userid) {
2701 // Do we have cache?
2702 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2704 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2708 return $GLOBALS[__FUNCTION__][$userid];
2711 // Checks wether 'mailer_theme' was found in session
2712 function isMailerThemeSet () {
2714 return isSessionVariableSet('mailer_theme');
2718 * Setter for theme in session (This setter does return the success of
2719 * setSession() which is required e.g. for destroySponsorSession().
2721 function setMailerTheme ($newTheme) {
2722 // Set it in session
2723 return setSession('mailer_theme', $newTheme);
2727 * Getter for theme from session (This getter does return 'mailer_theme' from
2728 * session data or throws an error if not possible
2730 function getMailerTheme () {
2731 // Is 'mailer_theme' set?
2732 if (!isMailerThemeSet()) {
2733 // No, then abort here
2734 debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
2737 // Return the theme from session
2738 return getSession('mailer_theme');