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']))) || (is_null($GLOBALS['__what'])));
576 // Should we abort here?
577 if (($strict === true) && ($isset === false)) {
579 die(debug_get_printable_backtrace());
580 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
587 // Getter for 'action' value
588 function getAction ($strict = true) {
593 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
595 $action = $GLOBALS['__action'];
602 // Setter for 'action' value
603 function setAction ($newAction) {
604 $GLOBALS['__action'] = $newAction;
607 // Checks wether action is set and optionally aborts on miss
608 function isActionSet ($strict = false) {
610 $isset = (((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action']))) || (is_null($GLOBALS['__action'])));
612 // Should we abort here?
613 if (($strict === true) && ($isset === false)) {
615 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
622 // Getter for 'module' value
623 function getModule ($strict = true) {
628 if (isModuleSet($strict)) {
630 $module = $GLOBALS['__module'];
637 // Setter for 'module' value
638 function setModule ($newModule) {
639 // Secure it and make all modules lower-case
640 $GLOBALS['__module'] = strtolower($newModule);
643 // Checks wether module is set and optionally aborts on miss
644 function isModuleSet ($strict = false) {
646 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
648 // Should we abort here?
649 if (($strict === true) && ($isset === false)) {
651 debug_report_bug(__FUNCTION__, __LINE__, 'Module is empty.');
655 return (($isset === true) && ($GLOBALS['__module'] != 'unknown')) ;
658 // Getter for 'output_mode' value
659 function getScriptOutputMode () {
661 if (!isset($GLOBALS[__FUNCTION__])) {
666 if (isOutputModeSet(true)) {
668 $output_mode = $GLOBALS['output_mode'];
672 $GLOBALS[__FUNCTION__] = $output_mode;
676 return $GLOBALS[__FUNCTION__];
679 // Setter for 'output_mode' value
680 function setOutputMode ($newOutputMode) {
681 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
682 $GLOBALS['output_mode'] = (int) $newOutputMode;
683 $GLOBALS['getScriptOutputMode'] = (int) $newOutputMode;
686 // Checks wether output_mode is set and optionally aborts on miss
687 function isOutputModeSet ($strict = false) {
689 $isset = (isset($GLOBALS['output_mode']));
691 // Should we abort here?
692 if (($strict === true) && ($isset === false)) {
694 debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
701 // Enables block-mode
702 function enableBlockMode ($enabled = true) {
703 $GLOBALS['block_mode'] = $enabled;
706 // Checks wether block-mode is enabled
707 function isBlockModeEnabled () {
709 if (!isset($GLOBALS['block_mode'])) {
711 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
715 return $GLOBALS['block_mode'];
719 * Wrapper function for addPointsThroughReferralSystem(), you should generally
720 * avoid this function and use addPointsThroughReferralSystem() directly and add
721 * your special payment method entry to points_data instead.
723 * @param $subject A string-encoded subject for this add
724 * @param $userid The recipient (member) for given points
725 * @param $points Points to be added to member's account
726 * @return $added Wether the points has been added to the user's account
728 function addPointsDirectly ($subject, $userid, $points) {
730 initReferralSystem();
732 // Call more complicated method (due to more parameters)
733 return addPointsThroughReferralSystem($subject, $userid, $points, false, 0, 'DIRECT');
736 // Wrapper for redirectToUrl but URL comes from a configuration entry
737 function redirectToConfiguredUrl ($configEntry) {
739 redirectToUrl(getConfig($configEntry));
742 // Wrapper function to redirect from member-only modules to index
743 function redirectToIndexMemberOnlyModule () {
744 // Do the redirect here
745 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
748 // Wrapper function to redirect to current URL
749 function redirectToRequestUri () {
750 redirectToUrl(basename(detectRequestUri()));
753 // Wrapper function to redirect to de-refered URL
754 function redirectToDereferedUrl ($url) {
756 redirectToUrl(generateDerefererUrl($url));
759 // Wrapper function for checking if extension is installed and newer or same version
760 function isExtensionInstalledAndNewer ($ext_name, $version) {
761 // Is an cache entry found?
762 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
764 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
766 // Cache hits should be incremented twice
767 incrementStatsEntry('cache_hits', 2);
771 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
772 return $GLOBALS[__FUNCTION__][$ext_name][$version];
775 // Wrapper function for checking if extension is installed and older than given version
776 function isExtensionInstalledAndOlder ($ext_name, $version) {
777 // Is an cache entry found?
778 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
780 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
782 // Cache hits should be incremented twice
783 incrementStatsEntry('cache_hits', 2);
787 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
788 return $GLOBALS[__FUNCTION__][$ext_name][$version];
792 function setUsername ($userName) {
793 $GLOBALS['username'] = (string) $userName;
797 function getUsername () {
799 if (!isset($GLOBALS['username'])) {
800 // No, so it has to be a guest
801 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
805 return $GLOBALS['username'];
808 // Wrapper function for installation phase
809 function isInstallationPhase () {
811 if (!isset($GLOBALS[__FUNCTION__])) {
813 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
817 return $GLOBALS[__FUNCTION__];
820 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
821 function isDemoModeActive () {
823 if (!isset($GLOBALS[__FUNCTION__])) {
825 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
829 return $GLOBALS[__FUNCTION__];
832 // Getter for PHP caching value
833 function getPhpCaching () {
834 return $GLOBALS['php_caching'];
837 // Checks wether the admin hash is set
838 function isAdminHashSet ($adminId) {
839 // Is the array there?
840 if (!isset($GLOBALS['cache_array']['admin'])) {
841 // Missing array should be reported
842 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
845 // Check for admin hash
846 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
849 // Setter for admin hash
850 function setAdminHash ($adminId, $hash) {
851 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
854 // Getter for current admin login
855 function getCurrentAdminLogin () {
857 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
860 if (!isset($GLOBALS[__FUNCTION__])) {
862 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
866 return $GLOBALS[__FUNCTION__];
869 // Setter for admin id (and current)
870 function setAdminId ($adminId) {
872 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
875 $status = setSession('admin_id', bigintval($adminId));
878 setCurrentAdminId($adminId);
884 // Setter for admin_last
885 function setAdminLast ($adminLast) {
887 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
890 $status = setSession('admin_last', $adminLast);
896 // Setter for admin_md5
897 function setAdminMd5 ($adminMd5) {
899 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
902 $status = setSession('admin_md5', $adminMd5);
908 // Getter for admin_md5
909 function getAdminMd5 () {
911 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
914 return getSession('admin_md5');
917 // Init user data array
918 function initUserData () {
919 // User id should not be zero
920 if (!isValidUserId(getCurrentUserId())) {
921 // Should be always valid
922 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
926 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
927 $GLOBALS['user_data'][getCurrentUserId()] = array();
930 // Getter for user data
931 function getUserData ($column) {
932 // User id should not be zero
933 if (!isValidUserId(getCurrentUserId())) {
934 // Should be always valid
935 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
941 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
943 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
950 // Checks wether given user data is set to 'Y'
951 function isUserDataEnabled ($column) {
953 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
955 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
959 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
962 // Geter for whole user data array
963 function getUserDataArray () {
965 $userid = getCurrentUserId();
967 // Is the current userid valid?
968 if (!isValidUserId($userid)) {
969 // Should be always valid
970 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
973 // Get the whole array if found
974 if (isset($GLOBALS['user_data'][$userid])) {
975 // Found, so return it
976 return $GLOBALS['user_data'][$userid];
978 // Return empty array
983 // Checks if the user data is valid, this may indicate that the user has logged
984 // in, but you should use isMember() if you want to find that out.
985 function isUserDataValid () {
986 // User id should not be zero so abort here
987 if (!isCurrentUserIdSet()) {
992 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
994 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
998 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1001 // Setter for current userid
1002 function setCurrentUserId ($userid) {
1004 $GLOBALS['current_userid'] = bigintval($userid);
1006 // Unset it to re-determine the actual state
1007 unset($GLOBALS['is_userdata_valid'][$userid]);
1010 // Getter for current userid
1011 function getCurrentUserId () {
1012 // Userid must be set before it can be used
1013 if (!isCurrentUserIdSet()) {
1015 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1018 // Return the userid
1019 return $GLOBALS['current_userid'];
1022 // Checks if current userid is set
1023 function isCurrentUserIdSet () {
1024 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1027 // Checks wether we are debugging template cache
1028 function isDebuggingTemplateCache () {
1029 // Do we have cache?
1030 if (!isset($GLOBALS[__FUNCTION__])) {
1032 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1036 return $GLOBALS[__FUNCTION__];
1039 // Wrapper for fetchUserData() and getUserData() calls
1040 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1041 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1043 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1047 // Can we fetch the user data?
1048 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1049 // Now get the data back
1050 $data = getUserData($valueColumn);
1054 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1058 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1059 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1062 // Wrapper for strpos() to ease porting from deprecated ereg() function
1063 function isInString ($needle, $haystack) {
1064 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1065 return (strpos($haystack, $needle) !== false);
1068 // Wrapper for strpos() to ease porting from deprecated eregi() function
1069 // This function is case-insensitive
1070 function isInStringIgnoreCase ($needle, $haystack) {
1071 return (isInString(strtolower($needle), strtolower($haystack)));
1074 // Wrapper to check for if fatal errors where detected
1075 function ifFatalErrorsDetected () {
1076 // Just call the inner function
1077 return (getTotalFatalErrors() > 0);
1080 // Setter for HTTP status
1081 function setHttpStatus ($status) {
1082 $GLOBALS['http_status'] = (string) $status;
1085 // Getter for HTTP status
1086 function getHttpStatus () {
1087 // Is the status set?
1088 if (!isset($GLOBALS['http_status'])) {
1090 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1094 return $GLOBALS['http_status'];
1098 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1099 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1101 * ----------------------------------------------------------------------------
1102 * If you want to redirect, please use redirectToUrl(); instead
1103 * ----------------------------------------------------------------------------
1105 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1107 * @link http://support.microsoft.com/kb/q176113/
1108 * @author Andreas Gohr <andi@splitbrain.org>
1111 function sendRawRedirect ($url) {
1112 // Clear output buffer
1113 clearOutputBuffer();
1115 // Clear own output buffer
1116 $GLOBALS['output'] = '';
1118 // To make redirects working (no content type), output mode must be raw
1121 // Send helping header
1122 setHttpStatus('302 Found');
1124 // always close the session
1125 session_write_close();
1127 // Revert entity &
1128 $url = str_replace('&', '&', $url);
1130 // check if running on IIS < 6 with CGI-PHP
1131 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1132 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1133 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1134 ($matches[1] < 6)) {
1135 // Send the IIS header
1136 addHttpHeader('Refresh: 0;url=' . $url);
1138 // Send generic header
1139 addHttpHeader('Location: ' . $url);
1146 // Determines the country of the given user id
1147 function determineCountry ($userid) {
1148 // Do we have cache?
1149 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1150 // Default is 'invalid'
1151 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1153 // Is extension country active?
1154 if (isExtensionActive('country')) {
1155 // Determine the right country code through the country id
1156 $id = getUserData('country_code');
1158 // Then handle it over
1159 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1161 // Get raw code from user data
1162 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1167 return $GLOBALS[__FUNCTION__][$userid];
1170 // "Getter" for total confirmed user accounts
1171 function getTotalConfirmedUser () {
1173 if (!isset($GLOBALS[__FUNCTION__])) {
1175 if (isExtensionActive('user')) {
1176 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1178 $GLOBALS[__FUNCTION__] = 0;
1182 // Return cached value
1183 return $GLOBALS[__FUNCTION__];
1186 // "Getter" for total unconfirmed user accounts
1187 function getTotalUnconfirmedUser () {
1189 if (!isset($GLOBALS[__FUNCTION__])) {
1191 if (isExtensionActive('user')) {
1192 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1194 $GLOBALS[__FUNCTION__] = 0;
1198 // Return cached value
1199 return $GLOBALS[__FUNCTION__];
1202 // "Getter" for total locked user accounts
1203 function getTotalLockedUser () {
1205 if (!isset($GLOBALS[__FUNCTION__])) {
1207 if (isExtensionActive('user')) {
1208 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1210 $GLOBALS[__FUNCTION__] = 0;
1214 // Return cached value
1215 return $GLOBALS[__FUNCTION__];
1218 // "Getter" for total locked user accounts
1219 function getTotalRandomRefidUser () {
1221 if (!isset($GLOBALS[__FUNCTION__])) {
1223 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1224 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
1226 $GLOBALS[__FUNCTION__] = 0;
1230 // Return cached value
1231 return $GLOBALS[__FUNCTION__];
1234 // Is given userid valid?
1235 function isValidUserId ($userid) {
1236 // Do we have cache?
1237 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1239 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1243 return $GLOBALS[__FUNCTION__][$userid];
1247 function encodeEntities ($str) {
1249 $str = secureString($str, true, true);
1251 // Encode dollar sign as well
1252 $str = str_replace('$', '$', $str);
1258 // "Getter" for date from patch_ctime
1259 function getDateFromRepository () {
1261 if (!isset($GLOBALS[__FUNCTION__])) {
1263 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1267 return $GLOBALS[__FUNCTION__];
1270 // "Getter" for date/time from patch_ctime
1271 function getDateTimeFromRepository () {
1273 if (!isset($GLOBALS[__FUNCTION__])) {
1275 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1279 return $GLOBALS[__FUNCTION__];
1282 // Getter for current year (default)
1283 function getYear ($timestamp = NULL) {
1285 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1287 if (is_null($timestamp)) {
1288 $timestamp = time();
1292 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1296 return $GLOBALS[__FUNCTION__][$timestamp];
1299 // Getter for current month (default)
1300 function getMonth ($timestamp = NULL) {
1302 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1303 // If null is set, use time()
1304 if (is_null($timestamp)) {
1305 // Use time() which is current timestamp
1306 $timestamp = time();
1310 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1314 return $GLOBALS[__FUNCTION__][$timestamp];
1317 // Getter for current hour (default)
1318 function getHour ($timestamp = NULL) {
1320 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1322 if (is_null($timestamp)) {
1323 $timestamp = time();
1327 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1331 return $GLOBALS[__FUNCTION__][$timestamp];
1334 // Getter for current day (default)
1335 function getDay ($timestamp = NULL) {
1337 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1339 if (is_null($timestamp)) {
1340 $timestamp = time();
1344 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1348 return $GLOBALS[__FUNCTION__][$timestamp];
1351 // Getter for current week (default)
1352 function getWeek ($timestamp = NULL) {
1354 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1356 if (is_null($timestamp)) $timestamp = time();
1359 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1363 return $GLOBALS[__FUNCTION__][$timestamp];
1366 // Getter for current short_hour (default)
1367 function getShortHour ($timestamp = NULL) {
1369 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1371 if (is_null($timestamp)) $timestamp = time();
1374 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1378 return $GLOBALS[__FUNCTION__][$timestamp];
1381 // Getter for current long_hour (default)
1382 function getLongHour ($timestamp = NULL) {
1384 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1386 if (is_null($timestamp)) $timestamp = time();
1389 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1393 return $GLOBALS[__FUNCTION__][$timestamp];
1396 // Getter for current second (default)
1397 function getSecond ($timestamp = NULL) {
1399 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1401 if (is_null($timestamp)) $timestamp = time();
1404 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1408 return $GLOBALS[__FUNCTION__][$timestamp];
1411 // Getter for current minute (default)
1412 function getMinute ($timestamp = NULL) {
1414 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1416 if (is_null($timestamp)) $timestamp = time();
1419 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1423 return $GLOBALS[__FUNCTION__][$timestamp];
1426 // Checks wether the title decoration is enabled
1427 function isTitleDecorationEnabled () {
1428 // Do we have cache?
1429 if (!isset($GLOBALS[__FUNCTION__])) {
1431 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1435 return $GLOBALS[__FUNCTION__];
1438 // Checks wether filter usage updates are enabled (expensive queries!)
1439 function isFilterUsageUpdateEnabled () {
1440 // Do we have cache?
1441 if (!isset($GLOBALS[__FUNCTION__])) {
1443 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1447 return $GLOBALS[__FUNCTION__];
1450 // Checks wether debugging of weekly resets is enabled
1451 function isWeeklyResetDebugEnabled () {
1452 // Do we have cache?
1453 if (!isset($GLOBALS[__FUNCTION__])) {
1455 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1459 return $GLOBALS[__FUNCTION__];
1462 // Checks wether debugging of monthly resets is enabled
1463 function isMonthlyResetDebugEnabled () {
1464 // Do we have cache?
1465 if (!isset($GLOBALS[__FUNCTION__])) {
1467 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1471 return $GLOBALS[__FUNCTION__];
1474 // Checks wether displaying of debug SQLs are enabled
1475 function isDisplayDebugSqlEnabled () {
1476 // Do we have cache?
1477 if (!isset($GLOBALS[__FUNCTION__])) {
1479 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1483 return $GLOBALS[__FUNCTION__];
1486 // Checks wether module title is enabled
1487 function isModuleTitleEnabled () {
1488 // Do we have cache?
1489 if (!isset($GLOBALS[__FUNCTION__])) {
1491 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1495 return $GLOBALS[__FUNCTION__];
1498 // Checks wether what title is enabled
1499 function isWhatTitleEnabled () {
1500 // Do we have cache?
1501 if (!isset($GLOBALS[__FUNCTION__])) {
1503 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1507 return $GLOBALS[__FUNCTION__];
1510 // Checks wether stats are enabled
1511 function ifInternalStatsEnabled () {
1512 // Do we have cache?
1513 if (!isset($GLOBALS[__FUNCTION__])) {
1514 // Then determine it
1515 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1518 // Return cached value
1519 return $GLOBALS[__FUNCTION__];
1522 // Checks wether admin-notification of certain user actions is enabled
1523 function isAdminNotificationEnabled () {
1524 // Do we have cache?
1525 if (!isset($GLOBALS[__FUNCTION__])) {
1527 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1531 return $GLOBALS[__FUNCTION__];
1534 // Checks wether random referral id selection is enabled
1535 function isRandomReferralIdEnabled () {
1536 // Do we have cache?
1537 if (!isset($GLOBALS[__FUNCTION__])) {
1539 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1543 return $GLOBALS[__FUNCTION__];
1546 // "Getter" for default language
1547 function getDefaultLanguage () {
1548 // Do we have cache?
1549 if (!isset($GLOBALS[__FUNCTION__])) {
1551 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1555 return $GLOBALS[__FUNCTION__];
1558 // "Getter" for default referral id
1559 function getDefRefid () {
1560 // Do we have cache?
1561 if (!isset($GLOBALS[__FUNCTION__])) {
1563 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1567 return $GLOBALS[__FUNCTION__];
1570 // "Getter" for path
1571 function getPath () {
1572 // Do we have cache?
1573 if (!isset($GLOBALS[__FUNCTION__])) {
1575 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1579 return $GLOBALS[__FUNCTION__];
1583 function getUrl () {
1584 // Do we have cache?
1585 if (!isset($GLOBALS[__FUNCTION__])) {
1587 $GLOBALS[__FUNCTION__] = getConfig('URL');
1591 return $GLOBALS[__FUNCTION__];
1594 // "Getter" for cache_path
1595 function getCachePath () {
1596 // Do we have cache?
1597 if (!isset($GLOBALS[__FUNCTION__])) {
1599 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1603 return $GLOBALS[__FUNCTION__];
1606 // "Getter" for secret_key
1607 function getSecretKey () {
1608 // Do we have cache?
1609 if (!isset($GLOBALS[__FUNCTION__])) {
1611 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1615 return $GLOBALS[__FUNCTION__];
1618 // "Getter" for SITE_KEY
1619 function getSiteKey () {
1620 // Do we have cache?
1621 if (!isset($GLOBALS[__FUNCTION__])) {
1623 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1627 return $GLOBALS[__FUNCTION__];
1630 // "Getter" for DATE_KEY
1631 function getDateKey () {
1632 // Do we have cache?
1633 if (!isset($GLOBALS[__FUNCTION__])) {
1635 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1639 return $GLOBALS[__FUNCTION__];
1642 // "Getter" for master_salt
1643 function getMasterSalt () {
1644 // Do we have cache?
1645 if (!isset($GLOBALS[__FUNCTION__])) {
1647 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1651 return $GLOBALS[__FUNCTION__];
1654 // "Getter" for prime
1655 function getPrime () {
1656 // Do we have cache?
1657 if (!isset($GLOBALS[__FUNCTION__])) {
1659 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1663 return $GLOBALS[__FUNCTION__];
1666 // "Getter" for encrypt_separator
1667 function getEncryptSeparator () {
1668 // Do we have cache?
1669 if (!isset($GLOBALS[__FUNCTION__])) {
1671 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1675 return $GLOBALS[__FUNCTION__];
1678 // "Getter" for mysql_prefix
1679 function getMysqlPrefix () {
1680 // Do we have cache?
1681 if (!isset($GLOBALS[__FUNCTION__])) {
1683 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1687 return $GLOBALS[__FUNCTION__];
1690 // "Getter" for table_type
1691 function getTableType () {
1692 // Do we have cache?
1693 if (!isset($GLOBALS[__FUNCTION__])) {
1695 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1699 return $GLOBALS[__FUNCTION__];
1702 // "Getter" for salt_length
1703 function getSaltLength () {
1704 // Do we have cache?
1705 if (!isset($GLOBALS[__FUNCTION__])) {
1707 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1711 return $GLOBALS[__FUNCTION__];
1714 // "Getter" for output_mode
1715 function getOutputMode () {
1716 // Do we have cache?
1717 if (!isset($GLOBALS[__FUNCTION__])) {
1719 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1723 return $GLOBALS[__FUNCTION__];
1726 // "Getter" for full_version
1727 function getFullVersion () {
1728 // Do we have cache?
1729 if (!isset($GLOBALS[__FUNCTION__])) {
1731 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1735 return $GLOBALS[__FUNCTION__];
1738 // "Getter" for title
1739 function getTitle () {
1740 // Do we have cache?
1741 if (!isset($GLOBALS[__FUNCTION__])) {
1743 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1747 return $GLOBALS[__FUNCTION__];
1750 // "Getter" for curr_svn_revision
1751 function getCurrentRepositoryRevision () {
1752 // Do we have cache?
1753 if (!isset($GLOBALS[__FUNCTION__])) {
1755 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1759 return $GLOBALS[__FUNCTION__];
1762 // "Getter" for server_url
1763 function getServerUrl () {
1764 // Do we have cache?
1765 if (!isset($GLOBALS[__FUNCTION__])) {
1767 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1771 return $GLOBALS[__FUNCTION__];
1774 // "Getter" for mt_word
1775 function getMtWord () {
1776 // Do we have cache?
1777 if (!isset($GLOBALS[__FUNCTION__])) {
1779 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1783 return $GLOBALS[__FUNCTION__];
1786 // "Getter" for mt_word2
1787 function getMtWord2 () {
1788 // Do we have cache?
1789 if (!isset($GLOBALS[__FUNCTION__])) {
1791 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1795 return $GLOBALS[__FUNCTION__];
1798 // "Getter" for main_title
1799 function getMainTitle () {
1800 // Do we have cache?
1801 if (!isset($GLOBALS[__FUNCTION__])) {
1803 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1807 return $GLOBALS[__FUNCTION__];
1810 // "Getter" for file_hash
1811 function getFileHash () {
1812 // Do we have cache?
1813 if (!isset($GLOBALS[__FUNCTION__])) {
1815 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1819 return $GLOBALS[__FUNCTION__];
1822 // "Getter" for pass_scramble
1823 function getPassScramble () {
1824 // Do we have cache?
1825 if (!isset($GLOBALS[__FUNCTION__])) {
1827 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1831 return $GLOBALS[__FUNCTION__];
1834 // "Getter" for ap_inactive_since
1835 function getApInactiveSince () {
1836 // Do we have cache?
1837 if (!isset($GLOBALS[__FUNCTION__])) {
1839 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1843 return $GLOBALS[__FUNCTION__];
1846 // "Getter" for user_min_confirmed
1847 function getUserMinConfirmed () {
1848 // Do we have cache?
1849 if (!isset($GLOBALS[__FUNCTION__])) {
1851 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1855 return $GLOBALS[__FUNCTION__];
1858 // "Getter" for auto_purge
1859 function getAutoPurge () {
1860 // Do we have cache?
1861 if (!isset($GLOBALS[__FUNCTION__])) {
1863 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1867 return $GLOBALS[__FUNCTION__];
1870 // "Getter" for bonus_userid
1871 function getBonusUserid () {
1872 // Do we have cache?
1873 if (!isset($GLOBALS[__FUNCTION__])) {
1875 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1879 return $GLOBALS[__FUNCTION__];
1882 // "Getter" for ap_inactive_time
1883 function getApInactiveTime () {
1884 // Do we have cache?
1885 if (!isset($GLOBALS[__FUNCTION__])) {
1887 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1891 return $GLOBALS[__FUNCTION__];
1894 // "Getter" for ap_dm_timeout
1895 function getApDmTimeout () {
1896 // Do we have cache?
1897 if (!isset($GLOBALS[__FUNCTION__])) {
1899 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1903 return $GLOBALS[__FUNCTION__];
1906 // "Getter" for ap_tasks_time
1907 function getApTasksTime () {
1908 // Do we have cache?
1909 if (!isset($GLOBALS[__FUNCTION__])) {
1911 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1915 return $GLOBALS[__FUNCTION__];
1918 // "Getter" for ap_unconfirmed_time
1919 function getApUnconfirmedTime () {
1920 // Do we have cache?
1921 if (!isset($GLOBALS[__FUNCTION__])) {
1923 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1927 return $GLOBALS[__FUNCTION__];
1930 // "Getter" for points
1931 function getPoints () {
1932 // Do we have cache?
1933 if (!isset($GLOBALS[__FUNCTION__])) {
1935 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1939 return $GLOBALS[__FUNCTION__];
1942 // "Getter" for slogan
1943 function getSlogan () {
1944 // Do we have cache?
1945 if (!isset($GLOBALS[__FUNCTION__])) {
1947 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1951 return $GLOBALS[__FUNCTION__];
1954 // "Getter" for copy
1955 function getCopy () {
1956 // Do we have cache?
1957 if (!isset($GLOBALS[__FUNCTION__])) {
1959 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1963 return $GLOBALS[__FUNCTION__];
1966 // "Getter" for webmaster
1967 function getWebmaster () {
1968 // Do we have cache?
1969 if (!isset($GLOBALS[__FUNCTION__])) {
1971 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1975 return $GLOBALS[__FUNCTION__];
1978 // "Getter" for sql_count
1979 function getSqlCount () {
1980 // Do we have cache?
1981 if (!isset($GLOBALS[__FUNCTION__])) {
1983 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1987 return $GLOBALS[__FUNCTION__];
1990 // "Getter" for num_templates
1991 function getNumTemplates () {
1992 // Do we have cache?
1993 if (!isset($GLOBALS[__FUNCTION__])) {
1995 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1999 return $GLOBALS[__FUNCTION__];
2002 // "Getter" for dns_cache_timeout
2003 function getDnsCacheTimeout () {
2004 // Do we have cache?
2005 if (!isset($GLOBALS[__FUNCTION__])) {
2007 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2011 return $GLOBALS[__FUNCTION__];
2014 // "Getter" for menu_blur_spacer
2015 function getMenuBlurSpacer () {
2016 // Do we have cache?
2017 if (!isset($GLOBALS[__FUNCTION__])) {
2019 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2023 return $GLOBALS[__FUNCTION__];
2026 // "Getter" for points_register
2027 function getPointsRegister () {
2028 // Do we have cache?
2029 if (!isset($GLOBALS[__FUNCTION__])) {
2031 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2035 return $GLOBALS[__FUNCTION__];
2038 // "Getter" for points_ref
2039 function getPointsRef () {
2040 // Do we have cache?
2041 if (!isset($GLOBALS[__FUNCTION__])) {
2043 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2047 return $GLOBALS[__FUNCTION__];
2050 // "Getter" for ref_payout
2051 function getRefPayout () {
2052 // Do we have cache?
2053 if (!isset($GLOBALS[__FUNCTION__])) {
2055 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2059 return $GLOBALS[__FUNCTION__];
2062 // "Getter" for online_timeout
2063 function getOnlineTimeout () {
2064 // Do we have cache?
2065 if (!isset($GLOBALS[__FUNCTION__])) {
2067 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2071 return $GLOBALS[__FUNCTION__];
2074 // "Getter" for index_home
2075 function getIndexHome () {
2076 // Do we have cache?
2077 if (!isset($GLOBALS[__FUNCTION__])) {
2079 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2083 return $GLOBALS[__FUNCTION__];
2086 // "Getter" for one_day
2087 function getOneDay () {
2088 // Do we have cache?
2089 if (!isset($GLOBALS[__FUNCTION__])) {
2091 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2095 return $GLOBALS[__FUNCTION__];
2098 // "Getter" for activate_xchange
2099 function getActivateXchange () {
2100 // Do we have cache?
2101 if (!isset($GLOBALS[__FUNCTION__])) {
2103 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2107 return $GLOBALS[__FUNCTION__];
2110 // "Getter" for img_type
2111 function getImgType () {
2112 // Do we have cache?
2113 if (!isset($GLOBALS[__FUNCTION__])) {
2115 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2119 return $GLOBALS[__FUNCTION__];
2122 // "Getter" for code_length
2123 function getCodeLength () {
2124 // Do we have cache?
2125 if (!isset($GLOBALS[__FUNCTION__])) {
2127 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2131 return $GLOBALS[__FUNCTION__];
2134 // "Getter" for least_cats
2135 function getLeastCats () {
2136 // Do we have cache?
2137 if (!isset($GLOBALS[__FUNCTION__])) {
2139 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2143 return $GLOBALS[__FUNCTION__];
2146 // "Getter" for pass_len
2147 function getPassLen () {
2148 // Do we have cache?
2149 if (!isset($GLOBALS[__FUNCTION__])) {
2151 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2155 return $GLOBALS[__FUNCTION__];
2158 // "Getter" for admin_menu
2159 function getAdminMenu () {
2160 // Do we have cache?
2161 if (!isset($GLOBALS[__FUNCTION__])) {
2163 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2167 return $GLOBALS[__FUNCTION__];
2170 // "Getter" for last_month
2171 function getLastMonth () {
2172 // Do we have cache?
2173 if (!isset($GLOBALS[__FUNCTION__])) {
2175 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2179 return $GLOBALS[__FUNCTION__];
2182 // "Getter" for max_send
2183 function getMaxSend () {
2184 // Do we have cache?
2185 if (!isset($GLOBALS[__FUNCTION__])) {
2187 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2191 return $GLOBALS[__FUNCTION__];
2194 // "Getter" for mails_page
2195 function getMailsPage () {
2196 // Do we have cache?
2197 if (!isset($GLOBALS[__FUNCTION__])) {
2199 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2203 return $GLOBALS[__FUNCTION__];
2206 // "Getter" for rand_no
2207 function getRandNo () {
2208 // Do we have cache?
2209 if (!isset($GLOBALS[__FUNCTION__])) {
2211 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2215 return $GLOBALS[__FUNCTION__];
2218 // "Getter" for __DB_NAME
2219 function getDbName () {
2220 // Do we have cache?
2221 if (!isset($GLOBALS[__FUNCTION__])) {
2223 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2227 return $GLOBALS[__FUNCTION__];
2230 // "Getter" for DOMAIN
2231 function getDomain () {
2232 // Do we have cache?
2233 if (!isset($GLOBALS[__FUNCTION__])) {
2235 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2239 return $GLOBALS[__FUNCTION__];
2242 // "Getter" for proxy_username
2243 function getProxyUsername () {
2244 // Do we have cache?
2245 if (!isset($GLOBALS[__FUNCTION__])) {
2247 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2251 return $GLOBALS[__FUNCTION__];
2254 // "Getter" for proxy_password
2255 function getProxyPassword () {
2256 // Do we have cache?
2257 if (!isset($GLOBALS[__FUNCTION__])) {
2259 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2263 return $GLOBALS[__FUNCTION__];
2266 // "Getter" for proxy_host
2267 function getProxyHost () {
2268 // Do we have cache?
2269 if (!isset($GLOBALS[__FUNCTION__])) {
2271 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2275 return $GLOBALS[__FUNCTION__];
2278 // "Getter" for proxy_port
2279 function getProxyPort () {
2280 // Do we have cache?
2281 if (!isset($GLOBALS[__FUNCTION__])) {
2283 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2287 return $GLOBALS[__FUNCTION__];
2290 // "Getter" for SMTP_HOSTNAME
2291 function getSmtpHostname () {
2292 // Do we have cache?
2293 if (!isset($GLOBALS[__FUNCTION__])) {
2295 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2299 return $GLOBALS[__FUNCTION__];
2302 // "Getter" for SMTP_USER
2303 function getSmtpUser () {
2304 // Do we have cache?
2305 if (!isset($GLOBALS[__FUNCTION__])) {
2307 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2311 return $GLOBALS[__FUNCTION__];
2314 // "Getter" for SMTP_PASSWORD
2315 function getSmtpPassword () {
2316 // Do we have cache?
2317 if (!isset($GLOBALS[__FUNCTION__])) {
2319 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2323 return $GLOBALS[__FUNCTION__];
2326 // "Getter" for points_word
2327 function getPointsWord () {
2328 // Do we have cache?
2329 if (!isset($GLOBALS[__FUNCTION__])) {
2331 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2335 return $GLOBALS[__FUNCTION__];
2338 // "Getter" for profile_lock
2339 function getProfileLock () {
2340 // Do we have cache?
2341 if (!isset($GLOBALS[__FUNCTION__])) {
2343 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2347 return $GLOBALS[__FUNCTION__];
2350 // "Getter" for url_tlock
2351 function getUrlTlock () {
2352 // Do we have cache?
2353 if (!isset($GLOBALS[__FUNCTION__])) {
2355 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2359 return $GLOBALS[__FUNCTION__];
2362 // "Getter" for title_left
2363 function getTitleLeft () {
2364 // Do we have cache?
2365 if (!isset($GLOBALS[__FUNCTION__])) {
2367 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2371 return $GLOBALS[__FUNCTION__];
2374 // "Getter" for title_right
2375 function getTitleRight () {
2376 // Do we have cache?
2377 if (!isset($GLOBALS[__FUNCTION__])) {
2379 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2383 return $GLOBALS[__FUNCTION__];
2386 // "Getter" for title_middle
2387 function getTitleMiddle () {
2388 // Do we have cache?
2389 if (!isset($GLOBALS[__FUNCTION__])) {
2391 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2395 return $GLOBALS[__FUNCTION__];
2398 // Getter for 'check_double_email'
2399 function getCheckDoubleEmail () {
2400 // Is the cache entry set?
2401 if (!isset($GLOBALS[__FUNCTION__])) {
2402 // No, so determine it
2403 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2406 // Return cached entry
2407 return $GLOBALS[__FUNCTION__];
2410 // Checks wether 'check_double_email' is 'Y'
2411 function isCheckDoubleEmailEnabled () {
2412 // Is the cache entry set?
2413 if (!isset($GLOBALS[__FUNCTION__])) {
2414 // No, so determine it
2415 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2418 // Return cached entry
2419 return $GLOBALS[__FUNCTION__];
2422 // Getter for 'display_home_in_index'
2423 function getDisplayHomeInIndex () {
2424 // Is the cache entry set?
2425 if (!isset($GLOBALS[__FUNCTION__])) {
2426 // No, so determine it
2427 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2430 // Return cached entry
2431 return $GLOBALS[__FUNCTION__];
2434 // Checks wether 'display_home_in_index' is 'Y'
2435 function isDisplayHomeInIndexEnabled () {
2436 // Is the cache entry set?
2437 if (!isset($GLOBALS[__FUNCTION__])) {
2438 // No, so determine it
2439 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2442 // Return cached entry
2443 return $GLOBALS[__FUNCTION__];
2446 // Getter for 'admin_menu_javascript'
2447 function getAdminMenuJavascript () {
2448 // Is the cache entry set?
2449 if (!isset($GLOBALS[__FUNCTION__])) {
2450 // No, so determine it
2451 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2454 // Return cached entry
2455 return $GLOBALS[__FUNCTION__];
2458 // Checks wether proxy configuration is used
2459 function isProxyUsed () {
2460 // Do we have cache?
2461 if (!isset($GLOBALS[__FUNCTION__])) {
2463 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2467 return $GLOBALS[__FUNCTION__];
2470 // Checks wether POST data contains selections
2471 function ifPostContainsSelections ($element = 'sel') {
2472 // Do we have cache?
2473 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2475 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
2479 return $GLOBALS[__FUNCTION__][$element];
2482 // Checks wether verbose_sql is Y and returns true/false if so
2483 function isVerboseSqlEnabled () {
2484 // Do we have cache?
2485 if (!isset($GLOBALS[__FUNCTION__])) {
2487 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2491 return $GLOBALS[__FUNCTION__];
2494 // "Getter" for total user points
2495 function getTotalPoints ($userid) {
2496 // Do we have cache?
2497 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2498 // Init array for filter chain
2500 'userid' => $userid,
2504 // Run filter chain for getting more point values
2505 $data = runFilterChain('get_total_points', $data);
2508 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
2512 return $GLOBALS[__FUNCTION__][$userid];
2515 // Wrapper to check if url_blacklist is enabled
2516 function isUrlBlacklistEnabled () {
2517 // Do we have cache?
2518 if (!isset($GLOBALS[__FUNCTION__])) {
2520 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2524 return $GLOBALS[__FUNCTION__];
2527 // Checks wether direct payment is allowed in configuration
2528 function isDirectPaymentEnabled () {
2529 // Do we have cache?
2530 if (!isset($GLOBALS[__FUNCTION__])) {
2532 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2536 return $GLOBALS[__FUNCTION__];
2539 // Checks wether JavaScript-based admin menu is enabled
2540 function isAdminMenuJavascriptEnabled () {
2541 // Do we have cache?
2542 if (!isset($GLOBALS[__FUNCTION__])) {
2544 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
2548 return $GLOBALS[__FUNCTION__];
2551 // Wrapper to check if current task is for extension (not update)
2552 function isExtensionTask ($content) {
2553 // Do we have cache?
2554 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2556 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2560 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2563 // Wrapper to check if output mode is CSS
2564 function isCssOutputMode () {
2566 return (getScriptOutputMode() == 1);
2569 // Wrapper to check if output mode is HTML
2570 function isHtmlOutputMode () {
2572 return (getScriptOutputMode() == 0);
2575 // Wrapper to check if output mode is RAW
2576 function isRawOutputMode () {
2578 return (getScriptOutputMode() == -1);
2581 // Wrapper to check if output mode is AJAX
2582 function isAjaxOutputMode () {
2584 return (getScriptOutputMode() == -2);
2587 // Wrapper to check if output mode is image
2588 function isImageOutputMode () {
2590 return (getScriptOutputMode() == -3);
2593 // Wrapper to generate a user email link
2594 function generateWrappedUserEmailLink ($email) {
2595 // Just call the inner function
2596 return generateEmailLink($email, 'user_data');
2599 // Wrapper to check if user points are locked
2600 function ifUserPointsLocked ($userid) {
2601 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2602 // Do we have cache?
2603 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2605 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2609 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2610 return $GLOBALS[__FUNCTION__][$userid];
2613 // Appends a line to an existing file or creates it instantly with given content.
2614 // This function does always add a new-line character to every line.
2615 function appendLineToFile ($file, $line) {
2616 $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2617 fwrite($fp, $line . "\n");
2621 // Wrapper for changeDataInFile() but with full path added
2622 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2624 $FQFN = getPath() . $FQFN;
2626 // Call inner function
2627 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2630 // Wrapper for changing entries in config-local.php
2631 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2632 // Call the inner function
2633 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2636 // Shortens ucfirst(strtolower()) calls
2637 function firstCharUpperCase ($str) {
2638 return ucfirst(strtolower($str));
2641 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2642 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2643 // Get the configuration entry
2644 $configValue = getConfig($configEntry);
2646 // Call inner method
2647 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2650 // Shortens converting of German comma to Computer's version in POST data
2651 function convertCommaToDotInPostData ($postEntry) {
2652 // Read and convert given entry
2653 $postValue = convertCommaToDot(postRequestElement($postEntry));
2655 // ... and set it again
2656 setPostRequestElement($postEntry, $postValue);
2659 // Converts German commas to Computer's version in all entries
2660 function convertCommaToDotInPostDataArray ($postEntries) {
2661 // Replace german decimal comma with computer decimal dot
2662 foreach ($postEntries as $entry) {
2663 // Is the entry there?
2664 if (isPostRequestElementSet($entry)) {
2666 convertCommaToDotInPostData($entry);
2672 * Parses a string into a US formated float variable, taken from user comments
2673 * from PHP documentation website.
2675 * @param $floatString A string holding a float expression
2676 * @return $float Corresponding float variable
2677 * @author chris<at>georgakopoulos<dot>com
2678 * @link http://de.php.net/manual/en/function.floatval.php#92563
2680 function parseFloat ($floatString){
2682 $LocaleInfo = localeconv();
2684 // Remove thousand separators
2685 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
2687 // Convert decimal point
2688 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
2690 // Return float value of converted string
2691 return floatval($floatString);
2694 // Generates a YES/NO option list from given default
2695 function generateYesNoOptionList ($defaultValue = '') {
2697 return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
2700 // "Getter" for total available receivers
2701 function getTotalReceivers ($mode = 'normal') {
2703 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
2709 // Wrapper "getter" to get total unconfirmed mails for given userid
2710 function getTotalUnconfirmedMails ($userid) {
2711 // Do we have cache?
2712 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2714 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
2718 return $GLOBALS[__FUNCTION__][$userid];
2721 // Checks wether 'mailer_theme' was found in session
2722 function isMailerThemeSet () {
2724 return isSessionVariableSet('mailer_theme');
2728 * Setter for theme in session (This setter does return the success of
2729 * setSession() which is required e.g. for destroySponsorSession().
2731 function setMailerTheme ($newTheme) {
2732 // Set it in session
2733 return setSession('mailer_theme', $newTheme);
2737 * Getter for theme from session (This getter does return 'mailer_theme' from
2738 * session data or throws an error if not possible
2740 function getMailerTheme () {
2741 // Is 'mailer_theme' set?
2742 if (!isMailerThemeSet()) {
2743 // No, then abort here
2744 debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
2747 // Return the theme from session
2748 return getSession('mailer_theme');