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, 2010 by Mailer Developer Team *
20 * For more information visit: http://www.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 // @TODO Implement $compress
131 function encodeString ($str, $compress = true) {
132 $str = urlencode(base64_encode(compileUriCode($str)));
136 // Decode strings encoded with encodeString()
137 // @TODO Implement $decompress
138 function decodeString ($str, $decompress = true) {
139 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
143 // Decode entities in a nicer way
144 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
145 // Decode the entities to UTF-8 now
146 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
148 // Return decoded string
149 return $decodedString;
152 // Merges an array together but only if both are arrays
153 function merge_array ($array1, $array2) {
154 // Are both an array?
155 if ((!is_array($array1)) && (!is_array($array2))) {
156 // Both are not arrays
157 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
158 } elseif (!is_array($array1)) {
159 // Left one is not an array
160 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
161 } elseif (!is_array($array2)) {
162 // Right one is not an array
163 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
166 // Merge all together
167 return array_merge($array1, $array2);
170 // Check if given FQFN is a readable file
171 function isFileReadable ($FQFN) {
173 if (!isset($GLOBALS['file_readable'][$FQFN])) {
175 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
179 return $GLOBALS['file_readable'][$FQFN];
182 // Checks wether the given FQFN is a directory and not ., .. or .svn
183 function isDirectory ($FQFN) {
185 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
187 $baseName = basename($FQFN);
190 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
194 return $GLOBALS[__FUNCTION__][$FQFN];
197 // "Getter" for remote IP number
198 function detectRemoteAddr () {
199 // Get remote ip from environment
200 $remoteAddr = determineRealRemoteAddress();
202 // Is removeip installed?
203 if (isExtensionActive('removeip')) {
205 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
212 // "Getter" for remote hostname
213 function detectRemoteHostname () {
214 // Get remote ip from environment
215 $remoteHost = getenv('REMOTE_HOST');
217 // Is removeip installed?
218 if (isExtensionActive('removeip')) {
220 $remoteHost = getAnonymousRemoteHost($remoteHost);
227 // "Getter" for user agent
228 function detectUserAgent ($alwaysReal = false) {
229 // Get remote ip from environment
230 $userAgent = getenv('HTTP_USER_AGENT');
232 // Is removeip installed?
233 if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
235 $userAgent = getAnonymousUserAgent($userAgent);
242 // "Getter" for referer
243 function detectReferer () {
244 // Get remote ip from environment
245 $referer = getenv('HTTP_REFERER');
247 // Is removeip installed?
248 if (isExtensionActive('removeip')) {
250 $referer = getAnonymousReferer($referer);
257 // "Getter" for request URI
258 function detectRequestUri () {
260 return (getenv('REQUEST_URI'));
263 // "Getter" for query string
264 function detectQueryString () {
265 return str_replace('&', '&', (getenv('QUERY_STRING')));
268 // "Getter" for SERVER_NAME
269 function detectServerName () {
271 return (getenv('SERVER_NAME'));
274 // Check wether we are installing
275 function isInstalling () {
276 // Determine wether we are installing
277 if (!isset($GLOBALS['mailer_installing'])) {
278 // Check URL (css.php/js.php need this)
279 $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
283 return $GLOBALS['mailer_installing'];
286 // Check wether this script is installed
287 function isInstalled () {
289 if (!isset($GLOBALS[__FUNCTION__])) {
290 // Determine wether this script is installed
291 $GLOBALS[__FUNCTION__] = (
296 isConfigEntrySet('MXCHANGE_INSTALLED')
298 getConfig('MXCHANGE_INSTALLED') == 'Y'
302 // New config file found and loaded
303 isIncludeReadable(getCachePath() . 'config-local.php')
306 // New config file found, but not yet read
307 isIncludeReadable(getCachePath() . 'config-local.php')
310 // Only new config file is found
311 !isIncludeReadable('inc/config.php')
313 // Is installation mode
320 // Then use the cache
321 return $GLOBALS[__FUNCTION__];
324 // Check wether an admin is registered
325 function isAdminRegistered () {
327 if (!isset($GLOBALS[__FUNCTION__])) {
329 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
333 return $GLOBALS[__FUNCTION__];
336 // Checks wether the reset mode is active
337 function isResetModeEnabled () {
338 // Now simply check it
339 return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
342 // Checks wether the debug mode is enabled
343 function isDebugModeEnabled () {
345 if (!isset($GLOBALS[__FUNCTION__])) {
347 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
351 return $GLOBALS[__FUNCTION__];
354 // Checks wether SQL debugging is enabled
355 function isSqlDebuggingEnabled () {
357 if (!isset($GLOBALS[__FUNCTION__])) {
358 // Determine if SQL debugging is enabled
359 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
363 return $GLOBALS[__FUNCTION__];
366 // Checks wether we shall debug regular expressions
367 function isDebugRegularExpressionEnabled () {
369 if (!isset($GLOBALS[__FUNCTION__])) {
371 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
375 return $GLOBALS[__FUNCTION__];
378 // Checks wether the cache instance is valid
379 function isCacheInstanceValid () {
380 return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
383 // Copies a file from source to destination and verifies if that goes fine.
384 // This function should wrap the copy() command and make a nicer debug backtrace
385 // even if there is no xdebug extension installed.
386 function copyFileVerified ($source, $dest, $chmod = '') {
387 // Failed is the default
390 // Is the source file there?
391 if (!isFileReadable($source)) {
393 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
396 // Is the target directory there?
397 if (!isDirectory(dirname($dest))) {
399 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
402 // Now try to copy it
403 if (!copy($source, $dest)) {
404 // Something went wrong
405 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
408 $GLOBALS['file_readable'][$dest] = true;
411 // If there are chmod rights set, apply them
412 if (!empty($chmod)) {
414 $status = changeMode($dest, $chmod);
424 // Wrapper function for header()
425 // Send a header but checks before if we can do so
426 function sendHeader ($header) {
428 //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
429 $GLOBALS['header'][] = trim($header);
432 // Flushes all headers
433 function flushHeaders () {
434 // Is the header already sent?
435 if (headers_sent()) {
437 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
440 // Flush all headers if found
441 if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
442 foreach ($GLOBALS['header'] as $header) {
447 // Mark them as flushed
448 $GLOBALS['header'] = array();
451 // Wrapper function for chmod()
452 // @TODO Do some more sanity check here
453 function changeMode ($FQFN, $mode) {
454 // Is the file/directory there?
455 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
456 // Neither, so abort here
457 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
461 return chmod($FQFN, $mode);
464 // Wrapper for unlink()
465 function removeFile ($FQFN) {
466 // Is the file there?
467 if (isFileReadable($FQFN)) {
469 $GLOBALS['file_readable'][$FQFN] = false;
472 return unlink($FQFN);
475 // All fine if no file was removed. If we change this to 'false' or rewrite
476 // above if() block it would be to restrictive.
480 // Wrapper for $_POST['sel']
481 function countPostSelection ($element = 'sel') {
483 if (isPostRequestParameterSet($element)) {
484 // Return counted elements
485 return countSelection(postRequestParameter($element));
487 // Return zero if not found
492 // Checks wether the config-local.php is loaded
493 function isConfigLocalLoaded () {
494 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
497 // Checks wether a nickname or userid was entered and caches the result
498 function isNicknameUsed ($userid) {
499 // Is the cache there
500 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
502 $GLOBALS[__FUNCTION__][$userid] = (('' . round($userid) . '') != $userid);
506 return $GLOBALS[__FUNCTION__][$userid];
509 // Getter for 'what' value
510 function getWhat () {
515 if (isWhatSet(true)) {
517 $what = $GLOBALS['what'];
524 // Setter for 'what' value
525 function setWhat ($newWhat) {
526 $GLOBALS['what'] = SQL_ESCAPE($newWhat);
529 // Setter for 'what' from configuration
530 function setWhatFromConfig ($configEntry) {
531 // Get 'what' from config
532 $what = getConfig($configEntry);
538 // Checks wether what is set and optionally aborts on miss
539 function isWhatSet ($strict = false) {
541 $isset = isset($GLOBALS['what']);
543 // Should we abort here?
544 if (($strict === true) && ($isset === false)) {
546 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
553 // Getter for 'action' value
554 function getAction ($strict = true) {
559 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
561 $action = $GLOBALS['action'];
568 // Setter for 'action' value
569 function setAction ($newAction) {
570 $GLOBALS['action'] = SQL_ESCAPE($newAction);
573 // Checks wether action is set and optionally aborts on miss
574 function isActionSet ($strict = false) {
576 $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
578 // Should we abort here?
579 if (($strict === true) && ($isset === false)) {
581 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
588 // Getter for 'module' value
589 function getModule ($strict = true) {
594 if (isModuleSet($strict)) {
596 $module = $GLOBALS['module'];
603 // Setter for 'module' value
604 function setModule ($newModule) {
605 // Secure it and make all modules lower-case
606 $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
609 // Checks wether module is set and optionally aborts on miss
610 function isModuleSet ($strict = false) {
612 $isset = (!empty($GLOBALS['module']));
614 // Should we abort here?
615 if (($strict === true) && ($isset === false)) {
617 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
621 return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
624 // Getter for 'output_mode' value
625 function getScriptOutputMode () {
630 if (isOutputModeSet(true)) {
632 $output_mode = $GLOBALS['output_mode'];
639 // Setter for 'output_mode' value
640 function setOutputMode ($newOutputMode) {
641 $GLOBALS['output_mode'] = (int) $newOutputMode;
644 // Checks wether output_mode is set and optionally aborts on miss
645 function isOutputModeSet ($strict = false) {
647 $isset = (isset($GLOBALS['output_mode']));
649 // Should we abort here?
650 if (($strict === true) && ($isset === false)) {
652 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
659 // Enables block-mode
660 function enableBlockMode ($enabled = true) {
661 $GLOBALS['block_mode'] = $enabled;
664 // Checks wether block-mode is enabled
665 function isBlockModeEnabled () {
667 if (!isset($GLOBALS['block_mode'])) {
669 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
673 return $GLOBALS['block_mode'];
676 // Wrapper function for addPointsThroughReferalSystem()
677 function addPointsDirectly ($subject, $userid, $points) {
679 unset($GLOBALS['ref_level']);
681 // Call more complicated method (due to more parameters)
682 return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'direct');
685 // Wrapper for redirectToUrl but URL comes from a configuration entry
686 function redirectToConfiguredUrl ($configEntry) {
688 redirectToUrl(getConfig($configEntry));
691 // Wrapper function to redirect from member-only modules to index
692 function redirectToIndexMemberOnlyModule () {
693 // Do the redirect here
694 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
697 // Wrapper function to redirect to current URL
698 function redirectToRequestUri () {
699 redirectToUrl(basename(detectRequestUri()));
702 // Wrapper function to redirect to de-refered URL
703 function redirectToDereferedUrl ($URL) {
705 redirectToUrl(generateDerefererUrl($URL));
708 // Wrapper function for checking if extension is installed and newer or same version
709 function isExtensionInstalledAndNewer ($ext_name, $version) {
710 // Is an cache entry found?
711 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
713 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
715 // Cache hits should be incremented twice
716 incrementStatsEntry('cache_hits', 2);
720 //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=>'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
721 return $GLOBALS[__FUNCTION__][$ext_name][$version];
724 // Wrapper function for checking if extension is installed and older than given version
725 function isExtensionInstalledAndOlder ($ext_name, $version) {
726 // Is an cache entry found?
727 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
729 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
731 // Cache hits should be incremented twice
732 incrementStatsEntry('cache_hits', 2);
736 //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
737 return $GLOBALS[__FUNCTION__][$ext_name][$version];
741 function setUsername ($userName) {
742 $GLOBALS['username'] = (string) $userName;
746 function getUsername () {
748 if (!isset($GLOBALS['username'])) {
749 // No, so it has to be a guest
750 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
754 return $GLOBALS['username'];
757 // Wrapper function for installation phase
758 function isInstallationPhase () {
760 if (!isset($GLOBALS[__FUNCTION__])) {
762 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
766 return $GLOBALS[__FUNCTION__];
769 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
770 function isDemoModeActive () {
772 if (!isset($GLOBALS[__FUNCTION__])) {
774 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
778 return $GLOBALS[__FUNCTION__];
781 // Getter for PHP caching value
782 function getPhpCaching () {
783 return $GLOBALS['php_caching'];
786 // Checks wether the admin hash is set
787 function isAdminHashSet ($adminId) {
788 // Is the array there?
789 if (!isset($GLOBALS['cache_array']['admin'])) {
790 // Missing array should be reported
791 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
794 // Check for admin hash
795 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
798 // Setter for admin hash
799 function setAdminHash ($adminId, $hash) {
800 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
803 // Init user data array
804 function initUserData () {
805 // User id should not be zero
806 if (!isValidUserId(getCurrentUserId())) {
807 // Should be always valid
808 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
812 $GLOBALS['user_data'][getCurrentUserId()] = array();
815 // Getter for user data
816 function getUserData ($column) {
817 // User id should not be zero
818 if (!isValidUserId(getCurrentUserId())) {
819 // Should be always valid
820 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
824 return $GLOBALS['user_data'][getCurrentUserId()][$column];
827 // Geter for whole user data array
828 function getUserDataArray () {
830 $userid = getCurrentUserId();
832 // Is the current userid valid?
833 if (!isValidUserId($userid)) {
834 // Should be always valid
835 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
838 // Get the whole array if found
839 if (isset($GLOBALS['user_data'][$userid])) {
840 // Found, so return it
841 return $GLOBALS['user_data'][$userid];
843 // Return empty array
848 // Checks if the user data is valid, this may indicate that the user has logged
849 // in, but you should use isMember() if you want to find that out.
850 function isUserDataValid () {
851 // User id should not be zero so abort here
852 if (!isCurrentUserIdSet()) return false;
855 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
857 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
861 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
864 // Setter for current userid
865 function setCurrentUserId ($userid) {
867 $GLOBALS['current_userid'] = bigintval($userid);
869 // Unset it to re-determine the actual state
870 unset($GLOBALS['is_userdata_valid'][$userid]);
873 // Getter for current userid
874 function getCurrentUserId () {
875 // Userid must be set before it can be used
876 if (!isCurrentUserIdSet()) {
878 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
882 return $GLOBALS['current_userid'];
885 // Checks if current userid is set
886 function isCurrentUserIdSet () {
887 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
890 // Checks wether we are debugging template cache
891 function isDebuggingTemplateCache () {
893 if (!isset($GLOBALS[__FUNCTION__])) {
895 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
899 return $GLOBALS[__FUNCTION__];
902 // Wrapper for fetchUserData() and getUserData() calls
903 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
905 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
906 // Default is 'guest'
907 $data = '{--USERNAME_GUEST--}';
909 // Can we fetch the user data?
910 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
911 // Now get the data back
912 $data = getUserData($valueColumn);
916 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
920 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
923 // Wrapper for strpos() to ease porting from deprecated ereg() function
924 function isInString ($needle, $haystack) {
925 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
926 return (strpos($haystack, $needle) !== false);
929 // Wrapper for strpos() to ease porting from deprecated eregi() function
930 // This function is case-insensitive
931 function isInStringIgnoreCase ($needle, $haystack) {
932 return (isInString(strtolower($needle), strtolower($haystack)));
935 // Wrapper to check for if fatal errors where detected
936 function ifFatalErrorsDetected () {
937 // Just call the inner function
938 return (getTotalFatalErrors() > 0);
941 // Setter for HTTP status
942 function setHttpStatus ($status) {
943 $GLOBALS['http_status'] = (string) $status;
946 // Getter for HTTP status
947 function getHttpStatus () {
948 return $GLOBALS['http_status'];
952 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
953 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
955 * ----------------------------------------------------------------------------
956 * If you want to redirect, please use redirectToUrl(); instead
957 * ----------------------------------------------------------------------------
959 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
961 * @link http://support.microsoft.com/kb/q176113/
962 * @author Andreas Gohr <andi@splitbrain.org>
965 function sendRawRedirect ($url) {
966 // Send helping header
967 setHttpStatus('302 Found');
969 // always close the session
970 session_write_close();
972 // Revert entity &
973 $url = str_replace('&', '&', $url);
975 // check if running on IIS < 6 with CGI-PHP
976 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
977 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
978 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
980 // Send the IIS header
981 sendHeader('Refresh: 0;url=' . $url);
983 // Send generic header
984 sendHeader('Location: ' . $url);
991 // Determines the country of the given user id
992 function determineCountry ($userid) {
994 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
995 // Default is 'invalid'
996 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
998 // Is extension country active?
999 if (isExtensionActive('country')) {
1000 // Determine the right country code through the country id
1001 $id = getUserData('country_code');
1003 // Then handle it over
1004 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1006 // Get raw code from user data
1007 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1012 return $GLOBALS[__FUNCTION__][$userid];
1015 // "Getter" for total confirmed user accounts
1016 function getTotalConfirmedUser () {
1018 if (!isset($GLOBALS[__FUNCTION__])) {
1020 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1023 // Return cached value
1024 return $GLOBALS[__FUNCTION__];
1027 // "Getter" for total unconfirmed user accounts
1028 function getTotalUnconfirmedUser () {
1030 if (!isset($GLOBALS[__FUNCTION__])) {
1032 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1035 // Return cached value
1036 return $GLOBALS[__FUNCTION__];
1039 // "Getter" for total locked user accounts
1040 function getTotalLockedUser () {
1042 if (!isset($GLOBALS[__FUNCTION__])) {
1044 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1047 // Return cached value
1048 return $GLOBALS[__FUNCTION__];
1051 // Is given userid valid?
1052 function isValidUserId ($userid) {
1053 // Do we have cache?
1054 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1056 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1060 return $GLOBALS[__FUNCTION__][$userid];
1064 function encodeEntities ($str) {
1066 $str = secureString($str, true, true);
1068 // Encode dollar sign as well
1069 $str = str_replace('$', '$', $str);
1075 // "Getter" for date from patch_ctime
1076 function getDateFromPatchTime () {
1078 if (!isset($GLOBALS[__FUNCTION__])) {
1080 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1084 return $GLOBALS[__FUNCTION__];
1087 // Getter for current year (default)
1088 function getYear ($timestamp = null) {
1090 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1092 if (is_null($timestamp)) $timestamp = time();
1095 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1099 return $GLOBALS[__FUNCTION__][$timestamp];
1102 // Getter for current month (default)
1103 function getMonth ($timestamp = null) {
1105 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1106 // If null is set, use time()
1107 if (is_null($timestamp)) {
1108 // Use time() which is current timestamp
1109 $timestamp = time();
1113 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1117 return $GLOBALS[__FUNCTION__][$timestamp];
1120 // Getter for current day (default)
1121 function getDay ($timestamp = null) {
1123 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1125 if (is_null($timestamp)) $timestamp = time();
1128 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1132 return $GLOBALS[__FUNCTION__][$timestamp];
1135 // Getter for current week (default)
1136 function getWeek ($timestamp = null) {
1138 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1140 if (is_null($timestamp)) $timestamp = time();
1143 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1147 return $GLOBALS[__FUNCTION__][$timestamp];
1150 // Getter for current short_hour (default)
1151 function getShortHour ($timestamp = null) {
1153 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1155 if (is_null($timestamp)) $timestamp = time();
1158 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1162 return $GLOBALS[__FUNCTION__][$timestamp];
1165 // Getter for current long_hour (default)
1166 function getLongHour ($timestamp = null) {
1168 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1170 if (is_null($timestamp)) $timestamp = time();
1173 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1177 return $GLOBALS[__FUNCTION__][$timestamp];
1180 // Getter for current second (default)
1181 function getSecond ($timestamp = null) {
1183 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1185 if (is_null($timestamp)) $timestamp = time();
1188 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1192 return $GLOBALS[__FUNCTION__][$timestamp];
1195 // Getter for current minute (default)
1196 function getMinute ($timestamp = null) {
1198 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1200 if (is_null($timestamp)) $timestamp = time();
1203 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1207 return $GLOBALS[__FUNCTION__][$timestamp];
1210 // Checks wether the title decoration is enabled
1211 function isTitleDecorationEnabled () {
1212 // Do we have cache?
1213 if (!isset($GLOBALS[__FUNCTION__])) {
1215 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1219 return $GLOBALS[__FUNCTION__];
1222 // Checks wether filter usage updates are enabled (expensive queries!)
1223 function isFilterUsageUpdateEnabled () {
1224 // Do we have cache?
1225 if (!isset($GLOBALS[__FUNCTION__])) {
1227 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1231 return $GLOBALS[__FUNCTION__];
1234 // Checks wether debugging of weekly resets is enabled
1235 function isWeeklyResetDebugEnabled () {
1236 // Do we have cache?
1237 if (!isset($GLOBALS[__FUNCTION__])) {
1239 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1243 return $GLOBALS[__FUNCTION__];
1246 // Checks wether debugging of monthly resets is enabled
1247 function isMonthlyResetDebugEnabled () {
1248 // Do we have cache?
1249 if (!isset($GLOBALS[__FUNCTION__])) {
1251 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1255 return $GLOBALS[__FUNCTION__];
1258 // Checks wether displaying of debug SQLs are enabled
1259 function isDisplayDebugSqlEnabled () {
1260 // Do we have cache?
1261 if (!isset($GLOBALS[__FUNCTION__])) {
1263 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1267 return $GLOBALS[__FUNCTION__];
1270 // Checks wether module title is enabled
1271 function isModuleTitleEnabled () {
1272 // Do we have cache?
1273 if (!isset($GLOBALS[__FUNCTION__])) {
1275 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1279 return $GLOBALS[__FUNCTION__];
1282 // Checks wether what title is enabled
1283 function isWhatTitleEnabled () {
1284 // Do we have cache?
1285 if (!isset($GLOBALS[__FUNCTION__])) {
1287 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1291 return $GLOBALS[__FUNCTION__];
1294 // Checks wether stats are enabled
1295 function ifStatsAreEnabled () {
1296 // Do we have cache?
1297 if (!isset($GLOBALS[__FUNCTION__])) {
1298 // Then determine it
1299 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1302 // Return cached value
1303 return $GLOBALS[__FUNCTION__];
1306 // Checks wether admin-notification of certain user actions is enabled
1307 function isAdminNotificationEnabled () {
1308 // Do we have cache?
1309 if (!isset($GLOBALS[__FUNCTION__])) {
1311 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1315 return $GLOBALS[__FUNCTION__];
1318 // Checks wether random referal id selection is enabled
1319 function isRandomReferalIdEnabled () {
1320 // Do we have cache?
1321 if (!isset($GLOBALS[__FUNCTION__])) {
1323 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1327 return $GLOBALS[__FUNCTION__];
1330 // "Getter" for default language
1331 function getDefaultLanguage () {
1332 // Do we have cache?
1333 if (!isset($GLOBALS[__FUNCTION__])) {
1335 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1339 return $GLOBALS[__FUNCTION__];
1342 // "Getter" for default referal id
1343 function getDefRefid () {
1344 // Do we have cache?
1345 if (!isset($GLOBALS[__FUNCTION__])) {
1347 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1351 return $GLOBALS[__FUNCTION__];
1354 // "Getter" for path
1355 function getPath () {
1356 // Do we have cache?
1357 if (!isset($GLOBALS[__FUNCTION__])) {
1359 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1363 return $GLOBALS[__FUNCTION__];
1367 function getUrl () {
1368 // Do we have cache?
1369 if (!isset($GLOBALS[__FUNCTION__])) {
1371 $GLOBALS[__FUNCTION__] = getConfig('URL');
1375 return $GLOBALS[__FUNCTION__];
1378 // "Getter" for cache_path
1379 function getCachePath () {
1380 // Do we have cache?
1381 if (!isset($GLOBALS[__FUNCTION__])) {
1383 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1387 return $GLOBALS[__FUNCTION__];
1390 // "Getter" for secret_key
1391 function getSecretKey () {
1392 // Do we have cache?
1393 if (!isset($GLOBALS[__FUNCTION__])) {
1395 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1399 return $GLOBALS[__FUNCTION__];
1402 // "Getter" for master_salt
1403 function getMasterSalt () {
1404 // Do we have cache?
1405 if (!isset($GLOBALS[__FUNCTION__])) {
1407 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1411 return $GLOBALS[__FUNCTION__];
1414 // "Getter" for prime
1415 function getPrime () {
1416 // Do we have cache?
1417 if (!isset($GLOBALS[__FUNCTION__])) {
1419 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1423 return $GLOBALS[__FUNCTION__];
1426 // "Getter" for encrypt_seperator
1427 function getEncryptSeperator () {
1428 // Do we have cache?
1429 if (!isset($GLOBALS[__FUNCTION__])) {
1431 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1435 return $GLOBALS[__FUNCTION__];
1438 // "Getter" for mysql_prefix
1439 function getMysqlPrefix () {
1440 // Do we have cache?
1441 if (!isset($GLOBALS[__FUNCTION__])) {
1443 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1447 return $GLOBALS[__FUNCTION__];
1450 // "Getter" for table_type
1451 function getTableType () {
1452 // Do we have cache?
1453 if (!isset($GLOBALS[__FUNCTION__])) {
1455 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1459 return $GLOBALS[__FUNCTION__];
1462 // "Getter" for salt_length
1463 function getSaltLength () {
1464 // Do we have cache?
1465 if (!isset($GLOBALS[__FUNCTION__])) {
1467 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1471 return $GLOBALS[__FUNCTION__];
1474 // "Getter" for output_mode
1475 function getOutputMode () {
1476 // Do we have cache?
1477 if (!isset($GLOBALS[__FUNCTION__])) {
1479 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1483 return $GLOBALS[__FUNCTION__];
1486 // "Getter" for full_version
1487 function getFullVersion () {
1488 // Do we have cache?
1489 if (!isset($GLOBALS[__FUNCTION__])) {
1491 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1495 return $GLOBALS[__FUNCTION__];
1498 // "Getter" for title
1499 function getTitle () {
1500 // Do we have cache?
1501 if (!isset($GLOBALS[__FUNCTION__])) {
1503 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1507 return $GLOBALS[__FUNCTION__];
1510 // "Getter" for curr_svn_revision
1511 function getCurrentRepositoryRevision () {
1512 // Do we have cache?
1513 if (!isset($GLOBALS[__FUNCTION__])) {
1515 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1519 return $GLOBALS[__FUNCTION__];
1522 // "Getter" for server_url
1523 function getServerUrl () {
1524 // Do we have cache?
1525 if (!isset($GLOBALS[__FUNCTION__])) {
1527 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1531 return $GLOBALS[__FUNCTION__];
1534 // "Getter" for mt_word
1535 function getMtWord () {
1536 // Do we have cache?
1537 if (!isset($GLOBALS[__FUNCTION__])) {
1539 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1543 return $GLOBALS[__FUNCTION__];
1546 // "Getter" for mt_word2
1547 function getMtWord2 () {
1548 // Do we have cache?
1549 if (!isset($GLOBALS[__FUNCTION__])) {
1551 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1555 return $GLOBALS[__FUNCTION__];
1558 // "Getter" for main_title
1559 function getMainTitle () {
1560 // Do we have cache?
1561 if (!isset($GLOBALS[__FUNCTION__])) {
1563 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1567 return $GLOBALS[__FUNCTION__];
1570 // "Getter" for file_hash
1571 function getFileHash () {
1572 // Do we have cache?
1573 if (!isset($GLOBALS[__FUNCTION__])) {
1575 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1579 return $GLOBALS[__FUNCTION__];
1582 // "Getter" for pass_scramble
1583 function getPassScramble () {
1584 // Do we have cache?
1585 if (!isset($GLOBALS[__FUNCTION__])) {
1587 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1591 return $GLOBALS[__FUNCTION__];
1594 // "Getter" for ap_inactive_since
1595 function getApInactiveSince () {
1596 // Do we have cache?
1597 if (!isset($GLOBALS[__FUNCTION__])) {
1599 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1603 return $GLOBALS[__FUNCTION__];
1606 // "Getter" for user_min_confirmed
1607 function getUserMinConfirmed () {
1608 // Do we have cache?
1609 if (!isset($GLOBALS[__FUNCTION__])) {
1611 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1615 return $GLOBALS[__FUNCTION__];
1618 // "Getter" for auto_purge
1619 function getAutoPurge () {
1620 // Do we have cache?
1621 if (!isset($GLOBALS[__FUNCTION__])) {
1623 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1627 return $GLOBALS[__FUNCTION__];
1630 // "Getter" for bonus_userid
1631 function getBonusUserid () {
1632 // Do we have cache?
1633 if (!isset($GLOBALS[__FUNCTION__])) {
1635 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1639 return $GLOBALS[__FUNCTION__];
1642 // "Getter" for ap_inactive_time
1643 function getApInactiveTime () {
1644 // Do we have cache?
1645 if (!isset($GLOBALS[__FUNCTION__])) {
1647 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1651 return $GLOBALS[__FUNCTION__];
1654 // "Getter" for ap_dm_timeout
1655 function getApDmTimeout () {
1656 // Do we have cache?
1657 if (!isset($GLOBALS[__FUNCTION__])) {
1659 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1663 return $GLOBALS[__FUNCTION__];
1666 // "Getter" for ap_tasks_time
1667 function getApTasksTime () {
1668 // Do we have cache?
1669 if (!isset($GLOBALS[__FUNCTION__])) {
1671 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1675 return $GLOBALS[__FUNCTION__];
1678 // "Getter" for ap_unconfirmed_time
1679 function getApUnconfirmedTime () {
1680 // Do we have cache?
1681 if (!isset($GLOBALS[__FUNCTION__])) {
1683 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1687 return $GLOBALS[__FUNCTION__];
1690 // "Getter" for points
1691 function getPoints () {
1692 // Do we have cache?
1693 if (!isset($GLOBALS[__FUNCTION__])) {
1695 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1699 return $GLOBALS[__FUNCTION__];
1702 // "Getter" for slogan
1703 function getSlogan () {
1704 // Do we have cache?
1705 if (!isset($GLOBALS[__FUNCTION__])) {
1707 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1711 return $GLOBALS[__FUNCTION__];
1714 // "Getter" for copy
1715 function getCopy () {
1716 // Do we have cache?
1717 if (!isset($GLOBALS[__FUNCTION__])) {
1719 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1723 return $GLOBALS[__FUNCTION__];
1726 // "Getter" for webmaster
1727 function getWebmaster () {
1728 // Do we have cache?
1729 if (!isset($GLOBALS[__FUNCTION__])) {
1731 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1735 return $GLOBALS[__FUNCTION__];
1738 // "Getter" for sql_count
1739 function getSqlCount () {
1740 // Do we have cache?
1741 if (!isset($GLOBALS[__FUNCTION__])) {
1743 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1747 return $GLOBALS[__FUNCTION__];
1750 // "Getter" for num_templates
1751 function getNumTemplates () {
1752 // Do we have cache?
1753 if (!isset($GLOBALS[__FUNCTION__])) {
1755 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1759 return $GLOBALS[__FUNCTION__];
1762 // "Getter" for dns_cache_timeout
1763 function getDnsCacheTimeout () {
1764 // Do we have cache?
1765 if (!isset($GLOBALS[__FUNCTION__])) {
1767 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1771 return $GLOBALS[__FUNCTION__];
1774 // "Getter" for menu_blur_spacer
1775 function getMenuBlurSpacer () {
1776 // Do we have cache?
1777 if (!isset($GLOBALS[__FUNCTION__])) {
1779 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1783 return $GLOBALS[__FUNCTION__];
1786 // "Getter" for points_register
1787 function getPointsRegister () {
1788 // Do we have cache?
1789 if (!isset($GLOBALS[__FUNCTION__])) {
1791 $GLOBALS[__FUNCTION__] = getConfig('points_register');
1795 return $GLOBALS[__FUNCTION__];
1798 // "Getter" for points_ref
1799 function getPointsRef () {
1800 // Do we have cache?
1801 if (!isset($GLOBALS[__FUNCTION__])) {
1803 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
1807 return $GLOBALS[__FUNCTION__];
1810 // "Getter" for ref_payout
1811 function getRefPayout () {
1812 // Do we have cache?
1813 if (!isset($GLOBALS[__FUNCTION__])) {
1815 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
1819 return $GLOBALS[__FUNCTION__];
1822 // "Getter" for online_timeout
1823 function getOnlineTimeout () {
1824 // Do we have cache?
1825 if (!isset($GLOBALS[__FUNCTION__])) {
1827 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
1831 return $GLOBALS[__FUNCTION__];
1834 // "Getter" for index_home
1835 function getIndexHome () {
1836 // Do we have cache?
1837 if (!isset($GLOBALS[__FUNCTION__])) {
1839 $GLOBALS[__FUNCTION__] = getConfig('index_home');
1843 return $GLOBALS[__FUNCTION__];
1846 // "Getter" for one_day
1847 function getOneDay () {
1848 // Do we have cache?
1849 if (!isset($GLOBALS[__FUNCTION__])) {
1851 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
1855 return $GLOBALS[__FUNCTION__];
1858 // "Getter" for activate_xchange
1859 function getActivateXchange () {
1860 // Do we have cache?
1861 if (!isset($GLOBALS[__FUNCTION__])) {
1863 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
1867 return $GLOBALS[__FUNCTION__];
1870 // "Getter" for img_type
1871 function getImgType () {
1872 // Do we have cache?
1873 if (!isset($GLOBALS[__FUNCTION__])) {
1875 $GLOBALS[__FUNCTION__] = getConfig('img_type');
1879 return $GLOBALS[__FUNCTION__];
1882 // "Getter" for code_length
1883 function getCodeLength () {
1884 // Do we have cache?
1885 if (!isset($GLOBALS[__FUNCTION__])) {
1887 $GLOBALS[__FUNCTION__] = getConfig('code_length');
1891 return $GLOBALS[__FUNCTION__];
1894 // Checks wether proxy configuration is used
1895 function isProxyUsed () {
1896 // Do we have cache?
1897 if (!isset($GLOBALS[__FUNCTION__])) {
1899 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1903 return $GLOBALS[__FUNCTION__];
1906 // Checks wether POST data contains selections
1907 function ifPostContainsSelections ($element = 'sel') {
1908 // Do we have cache?
1909 if (!isset($GLOBALS[__FUNCTION__][$element])) {
1911 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
1915 return $GLOBALS[__FUNCTION__][$element];
1918 // Checks wether verbose_sql is Y and returns true/false if so
1919 function isVerboseSqlEnabled () {
1920 // Do we have cache?
1921 if (!isset($GLOBALS[__FUNCTION__])) {
1923 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1927 return $GLOBALS[__FUNCTION__];
1930 // "Getter" for total user points
1931 function getTotalPoints ($userid) {
1932 // Do we have cache?
1933 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1935 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
1939 return $GLOBALS[__FUNCTION__][$userid];
1942 // Wrapper to check if url_blacklist is enabled
1943 function isUrlBlacklistEnabled () {
1944 // Do we have cache?
1945 if (!isset($GLOBALS[__FUNCTION__])) {
1947 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
1951 return $GLOBALS[__FUNCTION__];
1954 // Checks wether direct payment is allowed in configuration
1955 function isDirectPaymentEnabled () {
1956 // Do we have cache?
1957 if (!isset($GLOBALS[__FUNCTION__])) {
1959 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
1963 return $GLOBALS[__FUNCTION__];
1966 // Wrapper to check if current task is for extension (not update)
1967 function isExtensionTask ($content) {
1968 // Do we have cache?
1969 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
1971 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
1975 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
1978 // Wrapper to check if output mode is CSS
1979 function isCssOutputMode () {
1981 return (getScriptOutputMode() == 1);
1984 // Wrapper to check if output mode is HTML
1985 function isHtmlOutputMode () {
1987 return (getScriptOutputMode() == 0);
1990 // Wrapper to check if output mode is RAW
1991 function isRawOutputMode () {
1993 return (getScriptOutputMode() == -1);
1996 // Wrapper to generate a user email link
1997 function generateWrappedUserEmailLink ($email) {
1998 // Just call the inner function
1999 return generateEmailLink($email, 'user_data');
2002 // Wrapper to check if user points are locked
2003 function ifUserPointsLocked ($userid) {
2004 // Do we have cache?
2005 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2007 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2011 return $GLOBALS[__FUNCTION__][$userid];