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 ($strict = true) {
548 if (isWhatSet($strict)) {
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) {
1236 if (is_null($userid)) {
1237 // Do not handle this as of below isset() will always return false
1241 // Do we have cache?
1242 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1244 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1248 return $GLOBALS[__FUNCTION__][$userid];
1252 function encodeEntities ($str) {
1254 $str = secureString($str, true, true);
1256 // Encode dollar sign as well
1257 $str = str_replace('$', '$', $str);
1263 // "Getter" for date from patch_ctime
1264 function getDateFromRepository () {
1266 if (!isset($GLOBALS[__FUNCTION__])) {
1268 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1272 return $GLOBALS[__FUNCTION__];
1275 // "Getter" for date/time from patch_ctime
1276 function getDateTimeFromRepository () {
1278 if (!isset($GLOBALS[__FUNCTION__])) {
1280 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1284 return $GLOBALS[__FUNCTION__];
1287 // Getter for current year (default)
1288 function getYear ($timestamp = NULL) {
1290 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1292 if (is_null($timestamp)) {
1293 $timestamp = time();
1297 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1301 return $GLOBALS[__FUNCTION__][$timestamp];
1304 // Getter for current month (default)
1305 function getMonth ($timestamp = NULL) {
1307 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1308 // If null is set, use time()
1309 if (is_null($timestamp)) {
1310 // Use time() which is current timestamp
1311 $timestamp = time();
1315 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1319 return $GLOBALS[__FUNCTION__][$timestamp];
1322 // Getter for current hour (default)
1323 function getHour ($timestamp = NULL) {
1325 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1327 if (is_null($timestamp)) {
1328 $timestamp = time();
1332 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1336 return $GLOBALS[__FUNCTION__][$timestamp];
1339 // Getter for current day (default)
1340 function getDay ($timestamp = NULL) {
1342 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1344 if (is_null($timestamp)) {
1345 $timestamp = time();
1349 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1353 return $GLOBALS[__FUNCTION__][$timestamp];
1356 // Getter for current week (default)
1357 function getWeek ($timestamp = NULL) {
1359 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1361 if (is_null($timestamp)) $timestamp = time();
1364 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1368 return $GLOBALS[__FUNCTION__][$timestamp];
1371 // Getter for current short_hour (default)
1372 function getShortHour ($timestamp = NULL) {
1374 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1376 if (is_null($timestamp)) $timestamp = time();
1379 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1383 return $GLOBALS[__FUNCTION__][$timestamp];
1386 // Getter for current long_hour (default)
1387 function getLongHour ($timestamp = NULL) {
1389 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1391 if (is_null($timestamp)) $timestamp = time();
1394 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1398 return $GLOBALS[__FUNCTION__][$timestamp];
1401 // Getter for current second (default)
1402 function getSecond ($timestamp = NULL) {
1404 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1406 if (is_null($timestamp)) $timestamp = time();
1409 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1413 return $GLOBALS[__FUNCTION__][$timestamp];
1416 // Getter for current minute (default)
1417 function getMinute ($timestamp = NULL) {
1419 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1421 if (is_null($timestamp)) $timestamp = time();
1424 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1428 return $GLOBALS[__FUNCTION__][$timestamp];
1431 // Checks wether the title decoration is enabled
1432 function isTitleDecorationEnabled () {
1433 // Do we have cache?
1434 if (!isset($GLOBALS[__FUNCTION__])) {
1436 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1440 return $GLOBALS[__FUNCTION__];
1443 // Checks wether filter usage updates are enabled (expensive queries!)
1444 function isFilterUsageUpdateEnabled () {
1445 // Do we have cache?
1446 if (!isset($GLOBALS[__FUNCTION__])) {
1448 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1452 return $GLOBALS[__FUNCTION__];
1455 // Checks wether debugging of weekly resets is enabled
1456 function isWeeklyResetDebugEnabled () {
1457 // Do we have cache?
1458 if (!isset($GLOBALS[__FUNCTION__])) {
1460 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1464 return $GLOBALS[__FUNCTION__];
1467 // Checks wether debugging of monthly resets is enabled
1468 function isMonthlyResetDebugEnabled () {
1469 // Do we have cache?
1470 if (!isset($GLOBALS[__FUNCTION__])) {
1472 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1476 return $GLOBALS[__FUNCTION__];
1479 // Checks wether displaying of debug SQLs are enabled
1480 function isDisplayDebugSqlEnabled () {
1481 // Do we have cache?
1482 if (!isset($GLOBALS[__FUNCTION__])) {
1484 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1488 return $GLOBALS[__FUNCTION__];
1491 // Checks wether module title is enabled
1492 function isModuleTitleEnabled () {
1493 // Do we have cache?
1494 if (!isset($GLOBALS[__FUNCTION__])) {
1496 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1500 return $GLOBALS[__FUNCTION__];
1503 // Checks wether what title is enabled
1504 function isWhatTitleEnabled () {
1505 // Do we have cache?
1506 if (!isset($GLOBALS[__FUNCTION__])) {
1508 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1512 return $GLOBALS[__FUNCTION__];
1515 // Checks wether stats are enabled
1516 function ifInternalStatsEnabled () {
1517 // Do we have cache?
1518 if (!isset($GLOBALS[__FUNCTION__])) {
1519 // Then determine it
1520 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1523 // Return cached value
1524 return $GLOBALS[__FUNCTION__];
1527 // Checks wether admin-notification of certain user actions is enabled
1528 function isAdminNotificationEnabled () {
1529 // Do we have cache?
1530 if (!isset($GLOBALS[__FUNCTION__])) {
1532 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1536 return $GLOBALS[__FUNCTION__];
1539 // Checks wether random referral id selection is enabled
1540 function isRandomReferralIdEnabled () {
1541 // Do we have cache?
1542 if (!isset($GLOBALS[__FUNCTION__])) {
1544 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1548 return $GLOBALS[__FUNCTION__];
1551 // "Getter" for default language
1552 function getDefaultLanguage () {
1553 // Do we have cache?
1554 if (!isset($GLOBALS[__FUNCTION__])) {
1556 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1560 return $GLOBALS[__FUNCTION__];
1563 // "Getter" for default referral id
1564 function getDefRefid () {
1565 // Do we have cache?
1566 if (!isset($GLOBALS[__FUNCTION__])) {
1568 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1572 return $GLOBALS[__FUNCTION__];
1575 // "Getter" for path
1576 function getPath () {
1577 // Do we have cache?
1578 if (!isset($GLOBALS[__FUNCTION__])) {
1580 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1584 return $GLOBALS[__FUNCTION__];
1588 function getUrl () {
1589 // Do we have cache?
1590 if (!isset($GLOBALS[__FUNCTION__])) {
1592 $GLOBALS[__FUNCTION__] = getConfig('URL');
1596 return $GLOBALS[__FUNCTION__];
1599 // "Getter" for cache_path
1600 function getCachePath () {
1601 // Do we have cache?
1602 if (!isset($GLOBALS[__FUNCTION__])) {
1604 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1608 return $GLOBALS[__FUNCTION__];
1611 // "Getter" for secret_key
1612 function getSecretKey () {
1613 // Do we have cache?
1614 if (!isset($GLOBALS[__FUNCTION__])) {
1616 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1620 return $GLOBALS[__FUNCTION__];
1623 // "Getter" for SITE_KEY
1624 function getSiteKey () {
1625 // Do we have cache?
1626 if (!isset($GLOBALS[__FUNCTION__])) {
1628 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1632 return $GLOBALS[__FUNCTION__];
1635 // "Getter" for DATE_KEY
1636 function getDateKey () {
1637 // Do we have cache?
1638 if (!isset($GLOBALS[__FUNCTION__])) {
1640 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1644 return $GLOBALS[__FUNCTION__];
1647 // "Getter" for master_salt
1648 function getMasterSalt () {
1649 // Do we have cache?
1650 if (!isset($GLOBALS[__FUNCTION__])) {
1652 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1656 return $GLOBALS[__FUNCTION__];
1659 // "Getter" for prime
1660 function getPrime () {
1661 // Do we have cache?
1662 if (!isset($GLOBALS[__FUNCTION__])) {
1664 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1668 return $GLOBALS[__FUNCTION__];
1671 // "Getter" for encrypt_separator
1672 function getEncryptSeparator () {
1673 // Do we have cache?
1674 if (!isset($GLOBALS[__FUNCTION__])) {
1676 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1680 return $GLOBALS[__FUNCTION__];
1683 // "Getter" for mysql_prefix
1684 function getMysqlPrefix () {
1685 // Do we have cache?
1686 if (!isset($GLOBALS[__FUNCTION__])) {
1688 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1692 return $GLOBALS[__FUNCTION__];
1695 // "Getter" for table_type
1696 function getTableType () {
1697 // Do we have cache?
1698 if (!isset($GLOBALS[__FUNCTION__])) {
1700 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1704 return $GLOBALS[__FUNCTION__];
1707 // "Getter" for salt_length
1708 function getSaltLength () {
1709 // Do we have cache?
1710 if (!isset($GLOBALS[__FUNCTION__])) {
1712 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1716 return $GLOBALS[__FUNCTION__];
1719 // "Getter" for output_mode
1720 function getOutputMode () {
1721 // Do we have cache?
1722 if (!isset($GLOBALS[__FUNCTION__])) {
1724 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1728 return $GLOBALS[__FUNCTION__];
1731 // "Getter" for full_version
1732 function getFullVersion () {
1733 // Do we have cache?
1734 if (!isset($GLOBALS[__FUNCTION__])) {
1736 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1740 return $GLOBALS[__FUNCTION__];
1743 // "Getter" for title
1744 function getTitle () {
1745 // Do we have cache?
1746 if (!isset($GLOBALS[__FUNCTION__])) {
1748 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1752 return $GLOBALS[__FUNCTION__];
1755 // "Getter" for curr_svn_revision
1756 function getCurrentRepositoryRevision () {
1757 // Do we have cache?
1758 if (!isset($GLOBALS[__FUNCTION__])) {
1760 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1764 return $GLOBALS[__FUNCTION__];
1767 // "Getter" for server_url
1768 function getServerUrl () {
1769 // Do we have cache?
1770 if (!isset($GLOBALS[__FUNCTION__])) {
1772 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1776 return $GLOBALS[__FUNCTION__];
1779 // "Getter" for mt_word
1780 function getMtWord () {
1781 // Do we have cache?
1782 if (!isset($GLOBALS[__FUNCTION__])) {
1784 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1788 return $GLOBALS[__FUNCTION__];
1791 // "Getter" for mt_word2
1792 function getMtWord2 () {
1793 // Do we have cache?
1794 if (!isset($GLOBALS[__FUNCTION__])) {
1796 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1800 return $GLOBALS[__FUNCTION__];
1803 // "Getter" for main_title
1804 function getMainTitle () {
1805 // Do we have cache?
1806 if (!isset($GLOBALS[__FUNCTION__])) {
1808 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1812 return $GLOBALS[__FUNCTION__];
1815 // "Getter" for file_hash
1816 function getFileHash () {
1817 // Do we have cache?
1818 if (!isset($GLOBALS[__FUNCTION__])) {
1820 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1824 return $GLOBALS[__FUNCTION__];
1827 // "Getter" for pass_scramble
1828 function getPassScramble () {
1829 // Do we have cache?
1830 if (!isset($GLOBALS[__FUNCTION__])) {
1832 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1836 return $GLOBALS[__FUNCTION__];
1839 // "Getter" for ap_inactive_since
1840 function getApInactiveSince () {
1841 // Do we have cache?
1842 if (!isset($GLOBALS[__FUNCTION__])) {
1844 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1848 return $GLOBALS[__FUNCTION__];
1851 // "Getter" for user_min_confirmed
1852 function getUserMinConfirmed () {
1853 // Do we have cache?
1854 if (!isset($GLOBALS[__FUNCTION__])) {
1856 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1860 return $GLOBALS[__FUNCTION__];
1863 // "Getter" for auto_purge
1864 function getAutoPurge () {
1865 // Do we have cache?
1866 if (!isset($GLOBALS[__FUNCTION__])) {
1868 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1872 return $GLOBALS[__FUNCTION__];
1875 // "Getter" for bonus_userid
1876 function getBonusUserid () {
1877 // Do we have cache?
1878 if (!isset($GLOBALS[__FUNCTION__])) {
1880 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1884 return $GLOBALS[__FUNCTION__];
1887 // "Getter" for ap_inactive_time
1888 function getApInactiveTime () {
1889 // Do we have cache?
1890 if (!isset($GLOBALS[__FUNCTION__])) {
1892 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1896 return $GLOBALS[__FUNCTION__];
1899 // "Getter" for ap_dm_timeout
1900 function getApDmTimeout () {
1901 // Do we have cache?
1902 if (!isset($GLOBALS[__FUNCTION__])) {
1904 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1908 return $GLOBALS[__FUNCTION__];
1911 // "Getter" for ap_tasks_time
1912 function getApTasksTime () {
1913 // Do we have cache?
1914 if (!isset($GLOBALS[__FUNCTION__])) {
1916 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1920 return $GLOBALS[__FUNCTION__];
1923 // "Getter" for ap_unconfirmed_time
1924 function getApUnconfirmedTime () {
1925 // Do we have cache?
1926 if (!isset($GLOBALS[__FUNCTION__])) {
1928 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1932 return $GLOBALS[__FUNCTION__];
1935 // "Getter" for points
1936 function getPoints () {
1937 // Do we have cache?
1938 if (!isset($GLOBALS[__FUNCTION__])) {
1940 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1944 return $GLOBALS[__FUNCTION__];
1947 // "Getter" for slogan
1948 function getSlogan () {
1949 // Do we have cache?
1950 if (!isset($GLOBALS[__FUNCTION__])) {
1952 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1956 return $GLOBALS[__FUNCTION__];
1959 // "Getter" for copy
1960 function getCopy () {
1961 // Do we have cache?
1962 if (!isset($GLOBALS[__FUNCTION__])) {
1964 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1968 return $GLOBALS[__FUNCTION__];
1971 // "Getter" for webmaster
1972 function getWebmaster () {
1973 // Do we have cache?
1974 if (!isset($GLOBALS[__FUNCTION__])) {
1976 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1980 return $GLOBALS[__FUNCTION__];
1983 // "Getter" for sql_count
1984 function getSqlCount () {
1985 // Do we have cache?
1986 if (!isset($GLOBALS[__FUNCTION__])) {
1988 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1992 return $GLOBALS[__FUNCTION__];
1995 // "Getter" for num_templates
1996 function getNumTemplates () {
1997 // Do we have cache?
1998 if (!isset($GLOBALS[__FUNCTION__])) {
2000 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2004 return $GLOBALS[__FUNCTION__];
2007 // "Getter" for dns_cache_timeout
2008 function getDnsCacheTimeout () {
2009 // Do we have cache?
2010 if (!isset($GLOBALS[__FUNCTION__])) {
2012 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2016 return $GLOBALS[__FUNCTION__];
2019 // "Getter" for menu_blur_spacer
2020 function getMenuBlurSpacer () {
2021 // Do we have cache?
2022 if (!isset($GLOBALS[__FUNCTION__])) {
2024 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2028 return $GLOBALS[__FUNCTION__];
2031 // "Getter" for points_register
2032 function getPointsRegister () {
2033 // Do we have cache?
2034 if (!isset($GLOBALS[__FUNCTION__])) {
2036 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2040 return $GLOBALS[__FUNCTION__];
2043 // "Getter" for points_ref
2044 function getPointsRef () {
2045 // Do we have cache?
2046 if (!isset($GLOBALS[__FUNCTION__])) {
2048 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2052 return $GLOBALS[__FUNCTION__];
2055 // "Getter" for ref_payout
2056 function getRefPayout () {
2057 // Do we have cache?
2058 if (!isset($GLOBALS[__FUNCTION__])) {
2060 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2064 return $GLOBALS[__FUNCTION__];
2067 // "Getter" for online_timeout
2068 function getOnlineTimeout () {
2069 // Do we have cache?
2070 if (!isset($GLOBALS[__FUNCTION__])) {
2072 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2076 return $GLOBALS[__FUNCTION__];
2079 // "Getter" for index_home
2080 function getIndexHome () {
2081 // Do we have cache?
2082 if (!isset($GLOBALS[__FUNCTION__])) {
2084 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2088 return $GLOBALS[__FUNCTION__];
2091 // "Getter" for one_day
2092 function getOneDay () {
2093 // Do we have cache?
2094 if (!isset($GLOBALS[__FUNCTION__])) {
2096 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2100 return $GLOBALS[__FUNCTION__];
2103 // "Getter" for activate_xchange
2104 function getActivateXchange () {
2105 // Do we have cache?
2106 if (!isset($GLOBALS[__FUNCTION__])) {
2108 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2112 return $GLOBALS[__FUNCTION__];
2115 // "Getter" for img_type
2116 function getImgType () {
2117 // Do we have cache?
2118 if (!isset($GLOBALS[__FUNCTION__])) {
2120 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2124 return $GLOBALS[__FUNCTION__];
2127 // "Getter" for code_length
2128 function getCodeLength () {
2129 // Do we have cache?
2130 if (!isset($GLOBALS[__FUNCTION__])) {
2132 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2136 return $GLOBALS[__FUNCTION__];
2139 // "Getter" for least_cats
2140 function getLeastCats () {
2141 // Do we have cache?
2142 if (!isset($GLOBALS[__FUNCTION__])) {
2144 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2148 return $GLOBALS[__FUNCTION__];
2151 // "Getter" for pass_len
2152 function getPassLen () {
2153 // Do we have cache?
2154 if (!isset($GLOBALS[__FUNCTION__])) {
2156 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2160 return $GLOBALS[__FUNCTION__];
2163 // "Getter" for admin_menu
2164 function getAdminMenu () {
2165 // Do we have cache?
2166 if (!isset($GLOBALS[__FUNCTION__])) {
2168 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2172 return $GLOBALS[__FUNCTION__];
2175 // "Getter" for last_month
2176 function getLastMonth () {
2177 // Do we have cache?
2178 if (!isset($GLOBALS[__FUNCTION__])) {
2180 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2184 return $GLOBALS[__FUNCTION__];
2187 // "Getter" for max_send
2188 function getMaxSend () {
2189 // Do we have cache?
2190 if (!isset($GLOBALS[__FUNCTION__])) {
2192 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2196 return $GLOBALS[__FUNCTION__];
2199 // "Getter" for mails_page
2200 function getMailsPage () {
2201 // Do we have cache?
2202 if (!isset($GLOBALS[__FUNCTION__])) {
2204 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2208 return $GLOBALS[__FUNCTION__];
2211 // "Getter" for rand_no
2212 function getRandNo () {
2213 // Do we have cache?
2214 if (!isset($GLOBALS[__FUNCTION__])) {
2216 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2220 return $GLOBALS[__FUNCTION__];
2223 // "Getter" for __DB_NAME
2224 function getDbName () {
2225 // Do we have cache?
2226 if (!isset($GLOBALS[__FUNCTION__])) {
2228 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2232 return $GLOBALS[__FUNCTION__];
2235 // "Getter" for DOMAIN
2236 function getDomain () {
2237 // Do we have cache?
2238 if (!isset($GLOBALS[__FUNCTION__])) {
2240 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2244 return $GLOBALS[__FUNCTION__];
2247 // "Getter" for proxy_username
2248 function getProxyUsername () {
2249 // Do we have cache?
2250 if (!isset($GLOBALS[__FUNCTION__])) {
2252 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2256 return $GLOBALS[__FUNCTION__];
2259 // "Getter" for proxy_password
2260 function getProxyPassword () {
2261 // Do we have cache?
2262 if (!isset($GLOBALS[__FUNCTION__])) {
2264 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2268 return $GLOBALS[__FUNCTION__];
2271 // "Getter" for proxy_host
2272 function getProxyHost () {
2273 // Do we have cache?
2274 if (!isset($GLOBALS[__FUNCTION__])) {
2276 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2280 return $GLOBALS[__FUNCTION__];
2283 // "Getter" for proxy_port
2284 function getProxyPort () {
2285 // Do we have cache?
2286 if (!isset($GLOBALS[__FUNCTION__])) {
2288 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2292 return $GLOBALS[__FUNCTION__];
2295 // "Getter" for SMTP_HOSTNAME
2296 function getSmtpHostname () {
2297 // Do we have cache?
2298 if (!isset($GLOBALS[__FUNCTION__])) {
2300 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2304 return $GLOBALS[__FUNCTION__];
2307 // "Getter" for SMTP_USER
2308 function getSmtpUser () {
2309 // Do we have cache?
2310 if (!isset($GLOBALS[__FUNCTION__])) {
2312 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2316 return $GLOBALS[__FUNCTION__];
2319 // "Getter" for SMTP_PASSWORD
2320 function getSmtpPassword () {
2321 // Do we have cache?
2322 if (!isset($GLOBALS[__FUNCTION__])) {
2324 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2328 return $GLOBALS[__FUNCTION__];
2331 // "Getter" for points_word
2332 function getPointsWord () {
2333 // Do we have cache?
2334 if (!isset($GLOBALS[__FUNCTION__])) {
2336 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2340 return $GLOBALS[__FUNCTION__];
2343 // "Getter" for profile_lock
2344 function getProfileLock () {
2345 // Do we have cache?
2346 if (!isset($GLOBALS[__FUNCTION__])) {
2348 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2352 return $GLOBALS[__FUNCTION__];
2355 // "Getter" for url_tlock
2356 function getUrlTlock () {
2357 // Do we have cache?
2358 if (!isset($GLOBALS[__FUNCTION__])) {
2360 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2364 return $GLOBALS[__FUNCTION__];
2367 // "Getter" for title_left
2368 function getTitleLeft () {
2369 // Do we have cache?
2370 if (!isset($GLOBALS[__FUNCTION__])) {
2372 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2376 return $GLOBALS[__FUNCTION__];
2379 // "Getter" for title_right
2380 function getTitleRight () {
2381 // Do we have cache?
2382 if (!isset($GLOBALS[__FUNCTION__])) {
2384 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2388 return $GLOBALS[__FUNCTION__];
2391 // "Getter" for title_middle
2392 function getTitleMiddle () {
2393 // Do we have cache?
2394 if (!isset($GLOBALS[__FUNCTION__])) {
2396 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2400 return $GLOBALS[__FUNCTION__];
2403 // Getter for 'check_double_email'
2404 function getCheckDoubleEmail () {
2405 // Is the cache entry set?
2406 if (!isset($GLOBALS[__FUNCTION__])) {
2407 // No, so determine it
2408 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2411 // Return cached entry
2412 return $GLOBALS[__FUNCTION__];
2415 // Checks wether 'check_double_email' is 'Y'
2416 function isCheckDoubleEmailEnabled () {
2417 // Is the cache entry set?
2418 if (!isset($GLOBALS[__FUNCTION__])) {
2419 // No, so determine it
2420 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2423 // Return cached entry
2424 return $GLOBALS[__FUNCTION__];
2427 // Getter for 'display_home_in_index'
2428 function getDisplayHomeInIndex () {
2429 // Is the cache entry set?
2430 if (!isset($GLOBALS[__FUNCTION__])) {
2431 // No, so determine it
2432 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2435 // Return cached entry
2436 return $GLOBALS[__FUNCTION__];
2439 // Checks wether 'display_home_in_index' is 'Y'
2440 function isDisplayHomeInIndexEnabled () {
2441 // Is the cache entry set?
2442 if (!isset($GLOBALS[__FUNCTION__])) {
2443 // No, so determine it
2444 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2447 // Return cached entry
2448 return $GLOBALS[__FUNCTION__];
2451 // Getter for 'admin_menu_javascript'
2452 function getAdminMenuJavascript () {
2453 // Is the cache entry set?
2454 if (!isset($GLOBALS[__FUNCTION__])) {
2455 // No, so determine it
2456 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2459 // Return cached entry
2460 return $GLOBALS[__FUNCTION__];
2463 // Checks wether proxy configuration is used
2464 function isProxyUsed () {
2465 // Do we have cache?
2466 if (!isset($GLOBALS[__FUNCTION__])) {
2468 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2472 return $GLOBALS[__FUNCTION__];
2475 // Checks wether POST data contains selections
2476 function ifPostContainsSelections ($element = 'sel') {
2477 // Do we have cache?
2478 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2480 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2484 return $GLOBALS[__FUNCTION__][$element];
2487 // Checks wether verbose_sql is Y and returns true/false if so
2488 function isVerboseSqlEnabled () {
2489 // Do we have cache?
2490 if (!isset($GLOBALS[__FUNCTION__])) {
2492 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2496 return $GLOBALS[__FUNCTION__];
2499 // "Getter" for total user points
2500 function getTotalPoints ($userid) {
2501 // Do we have cache?
2502 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2503 // Init array for filter chain
2505 'userid' => $userid,
2509 // Run filter chain for getting more point values
2510 $data = runFilterChain('get_total_points', $data);
2513 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2517 return $GLOBALS[__FUNCTION__][$userid];
2520 // Wrapper to check if url_blacklist is enabled
2521 function isUrlBlacklistEnabled () {
2522 // Do we have cache?
2523 if (!isset($GLOBALS[__FUNCTION__])) {
2525 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2529 return $GLOBALS[__FUNCTION__];
2532 // Checks wether direct payment is allowed in configuration
2533 function isDirectPaymentEnabled () {
2534 // Do we have cache?
2535 if (!isset($GLOBALS[__FUNCTION__])) {
2537 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2541 return $GLOBALS[__FUNCTION__];
2544 // Checks wether JavaScript-based admin menu is enabled
2545 function isAdminMenuJavascriptEnabled () {
2546 // Do we have cache?
2547 if (!isset($GLOBALS[__FUNCTION__])) {
2549 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
2553 return $GLOBALS[__FUNCTION__];
2556 // Wrapper to check if current task is for extension (not update)
2557 function isExtensionTask ($content) {
2558 // Do we have cache?
2559 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2561 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2565 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2568 // Wrapper to check if output mode is CSS
2569 function isCssOutputMode () {
2571 return (getScriptOutputMode() == 1);
2574 // Wrapper to check if output mode is HTML
2575 function isHtmlOutputMode () {
2577 return (getScriptOutputMode() == 0);
2580 // Wrapper to check if output mode is RAW
2581 function isRawOutputMode () {
2583 return (getScriptOutputMode() == -1);
2586 // Wrapper to check if output mode is AJAX
2587 function isAjaxOutputMode () {
2589 return (getScriptOutputMode() == -2);
2592 // Wrapper to check if output mode is image
2593 function isImageOutputMode () {
2595 return (getScriptOutputMode() == -3);
2598 // Wrapper to generate a user email link
2599 function generateWrappedUserEmailLink ($email) {
2600 // Just call the inner function
2601 return generateEmailLink($email, 'user_data');
2604 // Wrapper to check if user points are locked
2605 function ifUserPointsLocked ($userid) {
2606 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2607 // Do we have cache?
2608 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2610 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2614 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2615 return $GLOBALS[__FUNCTION__][$userid];
2618 // Appends a line to an existing file or creates it instantly with given content.
2619 // This function does always add a new-line character to every line.
2620 function appendLineToFile ($file, $line) {
2621 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2622 fwrite($fp, $line . "\n");
2626 // Wrapper for changeDataInFile() but with full path added
2627 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2629 $FQFN = getPath() . $FQFN;
2631 // Call inner function
2632 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2635 // Wrapper for changing entries in config-local.php
2636 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2637 // Call the inner function
2638 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2641 // Shortens ucfirst(strtolower()) calls
2642 function firstCharUpperCase ($str) {
2643 return ucfirst(strtolower($str));
2646 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2647 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2648 // Get the configuration entry
2649 $configValue = getConfig($configEntry);
2651 // Call inner method
2652 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2655 // Shortens converting of German comma to Computer's version in POST data
2656 function convertCommaToDotInPostData ($postEntry) {
2657 // Read and convert given entry
2658 $postValue = convertCommaToDot(postRequestElement($postEntry));
2660 // ... and set it again
2661 setPostRequestElement($postEntry, $postValue);
2664 // Converts German commas to Computer's version in all entries
2665 function convertCommaToDotInPostDataArray ($postEntries) {
2666 // Replace german decimal comma with computer decimal dot
2667 foreach ($postEntries as $entry) {
2668 // Is the entry there?
2669 if (isPostRequestElementSet($entry)) {
2671 convertCommaToDotInPostData($entry);
2677 * Parses a string into a US formated float variable, taken from user comments
2678 * from PHP documentation website.
2680 * @param $floatString A string holding a float expression
2681 * @return $float Corresponding float variable
2682 * @author chris<at>georgakopoulos<dot>com
2683 * @link http://de.php.net/manual/en/function.floatval.php#92563
2685 function parseFloat ($floatString){
2687 $LocaleInfo = localeconv();
2689 // Remove thousand separators
2690 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
2692 // Convert decimal point
2693 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2695 // Return float value of converted string
2696 return floatval($floatString);
2699 // Generates a YES/NO option list from given default
2700 function generateYesNoOptionList ($defaultValue = '') {
2702 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
2705 // "Getter" for total available receivers
2706 function getTotalReceivers ($mode = 'normal') {
2708 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2714 // Wrapper "getter" to get total unconfirmed mails for given userid
2715 function getTotalUnconfirmedMails ($userid) {
2716 // Do we have cache?
2717 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2719 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2723 return $GLOBALS[__FUNCTION__][$userid];
2726 // Checks wether 'mailer_theme' was found in session
2727 function isMailerThemeSet () {
2729 return isSessionVariableSet('mailer_theme');
2733 * Setter for theme in session (This setter does return the success of
2734 * setSession() which is required e.g. for destroySponsorSession().
2736 function setMailerTheme ($newTheme) {
2737 // Set it in session
2738 return setSession('mailer_theme', $newTheme);
2742 * Getter for theme from session (This getter does return 'mailer_theme' from
2743 * session data or throws an error if not possible
2745 function getMailerTheme () {
2746 // Is 'mailer_theme' set?
2747 if (!isMailerThemeSet()) {
2748 // No, then abort here
2749 debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
2752 // Return the theme from session
2753 return getSession('mailer_theme');