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])) {
1107 if (is_null($timestamp)) $timestamp = time();
1110 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1114 return $GLOBALS[__FUNCTION__][$timestamp];
1117 // Getter for current day (default)
1118 function getDay ($timestamp = null) {
1120 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1122 if (is_null($timestamp)) $timestamp = time();
1125 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1129 return $GLOBALS[__FUNCTION__][$timestamp];
1132 // Getter for current week (default)
1133 function getWeek ($timestamp = null) {
1135 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1137 if (is_null($timestamp)) $timestamp = time();
1140 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1144 return $GLOBALS[__FUNCTION__][$timestamp];
1147 // Getter for current short_hour (default)
1148 function getShortHour ($timestamp = null) {
1150 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1152 if (is_null($timestamp)) $timestamp = time();
1155 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1159 return $GLOBALS[__FUNCTION__][$timestamp];
1162 // Getter for current long_hour (default)
1163 function getLongHour ($timestamp = null) {
1165 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1167 if (is_null($timestamp)) $timestamp = time();
1170 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1174 return $GLOBALS[__FUNCTION__][$timestamp];
1177 // Getter for current second (default)
1178 function getSecond ($timestamp = null) {
1180 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1182 if (is_null($timestamp)) $timestamp = time();
1185 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1189 return $GLOBALS[__FUNCTION__][$timestamp];
1192 // Getter for current minute (default)
1193 function getMinute ($timestamp = null) {
1195 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1197 if (is_null($timestamp)) $timestamp = time();
1200 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1204 return $GLOBALS[__FUNCTION__][$timestamp];
1207 // Checks wether the title decoration is enabled
1208 function isTitleDecorationEnabled () {
1209 // Do we have cache?
1210 if (!isset($GLOBALS[__FUNCTION__])) {
1212 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1216 return $GLOBALS[__FUNCTION__];
1219 // Checks wether filter usage updates are enabled (expensive queries!)
1220 function isFilterUsageUpdateEnabled () {
1221 // Do we have cache?
1222 if (!isset($GLOBALS[__FUNCTION__])) {
1224 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1228 return $GLOBALS[__FUNCTION__];
1231 // Checks wether debugging of weekly resets is enabled
1232 function isWeeklyResetDebugEnabled () {
1233 // Do we have cache?
1234 if (!isset($GLOBALS[__FUNCTION__])) {
1236 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1240 return $GLOBALS[__FUNCTION__];
1243 // Checks wether debugging of monthly resets is enabled
1244 function isMonthlyResetDebugEnabled () {
1245 // Do we have cache?
1246 if (!isset($GLOBALS[__FUNCTION__])) {
1248 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1252 return $GLOBALS[__FUNCTION__];
1255 // Checks wether displaying of debug SQLs are enabled
1256 function isDisplayDebugSqlEnabled () {
1257 // Do we have cache?
1258 if (!isset($GLOBALS[__FUNCTION__])) {
1260 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1264 return $GLOBALS[__FUNCTION__];
1267 // Checks wether module title is enabled
1268 function isModuleTitleEnabled () {
1269 // Do we have cache?
1270 if (!isset($GLOBALS[__FUNCTION__])) {
1272 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1276 return $GLOBALS[__FUNCTION__];
1279 // Checks wether what title is enabled
1280 function isWhatTitleEnabled () {
1281 // Do we have cache?
1282 if (!isset($GLOBALS[__FUNCTION__])) {
1284 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1288 return $GLOBALS[__FUNCTION__];
1291 // Checks wether stats are enabled
1292 function ifStatsAreEnabled () {
1293 // Do we have cache?
1294 if (!isset($GLOBALS[__FUNCTION__])) {
1295 // Then determine it
1296 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1299 // Return cached value
1300 return $GLOBALS[__FUNCTION__];
1303 // Checks wether admin-notification of certain user actions is enabled
1304 function isAdminNotificationEnabled () {
1305 // Do we have cache?
1306 if (!isset($GLOBALS[__FUNCTION__])) {
1308 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1312 return $GLOBALS[__FUNCTION__];
1315 // Checks wether random referal id selection is enabled
1316 function isRandomReferalIdEnabled () {
1317 // Do we have cache?
1318 if (!isset($GLOBALS[__FUNCTION__])) {
1320 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1324 return $GLOBALS[__FUNCTION__];
1327 // "Getter" for default language
1328 function getDefaultLanguage () {
1329 // Do we have cache?
1330 if (!isset($GLOBALS[__FUNCTION__])) {
1332 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1336 return $GLOBALS[__FUNCTION__];
1339 // "Getter" for default referal id
1340 function getDefRefid () {
1341 // Do we have cache?
1342 if (!isset($GLOBALS[__FUNCTION__])) {
1344 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1348 return $GLOBALS[__FUNCTION__];
1351 // "Getter" for path
1352 function getPath () {
1353 // Do we have cache?
1354 if (!isset($GLOBALS[__FUNCTION__])) {
1356 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1360 return $GLOBALS[__FUNCTION__];
1364 function getUrl () {
1365 // Do we have cache?
1366 if (!isset($GLOBALS[__FUNCTION__])) {
1368 $GLOBALS[__FUNCTION__] = getConfig('URL');
1372 return $GLOBALS[__FUNCTION__];
1375 // "Getter" for cache_path
1376 function getCachePath () {
1377 // Do we have cache?
1378 if (!isset($GLOBALS[__FUNCTION__])) {
1380 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1384 return $GLOBALS[__FUNCTION__];
1387 // "Getter" for secret_key
1388 function getSecretKey () {
1389 // Do we have cache?
1390 if (!isset($GLOBALS[__FUNCTION__])) {
1392 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1396 return $GLOBALS[__FUNCTION__];
1399 // "Getter" for master_salt
1400 function getMasterSalt () {
1401 // Do we have cache?
1402 if (!isset($GLOBALS[__FUNCTION__])) {
1404 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1408 return $GLOBALS[__FUNCTION__];
1411 // "Getter" for prime
1412 function getPrime () {
1413 // Do we have cache?
1414 if (!isset($GLOBALS[__FUNCTION__])) {
1416 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1420 return $GLOBALS[__FUNCTION__];
1423 // "Getter" for encrypt_seperator
1424 function getEncryptSeperator () {
1425 // Do we have cache?
1426 if (!isset($GLOBALS[__FUNCTION__])) {
1428 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1432 return $GLOBALS[__FUNCTION__];
1435 // "Getter" for mysql_prefix
1436 function getMysqlPrefix () {
1437 // Do we have cache?
1438 if (!isset($GLOBALS[__FUNCTION__])) {
1440 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1444 return $GLOBALS[__FUNCTION__];
1447 // "Getter" for table_type
1448 function getTableType () {
1449 // Do we have cache?
1450 if (!isset($GLOBALS[__FUNCTION__])) {
1452 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1456 return $GLOBALS[__FUNCTION__];
1459 // "Getter" for salt_length
1460 function getSaltLength () {
1461 // Do we have cache?
1462 if (!isset($GLOBALS[__FUNCTION__])) {
1464 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1468 return $GLOBALS[__FUNCTION__];
1471 // "Getter" for output_mode
1472 function getOutputMode () {
1473 // Do we have cache?
1474 if (!isset($GLOBALS[__FUNCTION__])) {
1476 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1480 return $GLOBALS[__FUNCTION__];
1483 // "Getter" for full_version
1484 function getFullVersion () {
1485 // Do we have cache?
1486 if (!isset($GLOBALS[__FUNCTION__])) {
1488 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1492 return $GLOBALS[__FUNCTION__];
1495 // "Getter" for title
1496 function getTitle () {
1497 // Do we have cache?
1498 if (!isset($GLOBALS[__FUNCTION__])) {
1500 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1504 return $GLOBALS[__FUNCTION__];
1507 // "Getter" for curr_svn_revision
1508 function getCurrentRepositoryRevision () {
1509 // Do we have cache?
1510 if (!isset($GLOBALS[__FUNCTION__])) {
1512 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1516 return $GLOBALS[__FUNCTION__];
1519 // "Getter" for server_url
1520 function getServerUrl () {
1521 // Do we have cache?
1522 if (!isset($GLOBALS[__FUNCTION__])) {
1524 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1528 return $GLOBALS[__FUNCTION__];
1531 // "Getter" for mt_word
1532 function getMtWord () {
1533 // Do we have cache?
1534 if (!isset($GLOBALS[__FUNCTION__])) {
1536 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1540 return $GLOBALS[__FUNCTION__];
1543 // "Getter" for mt_word2
1544 function getMtWord2 () {
1545 // Do we have cache?
1546 if (!isset($GLOBALS[__FUNCTION__])) {
1548 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1552 return $GLOBALS[__FUNCTION__];
1555 // "Getter" for main_title
1556 function getMainTitle () {
1557 // Do we have cache?
1558 if (!isset($GLOBALS[__FUNCTION__])) {
1560 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1564 return $GLOBALS[__FUNCTION__];
1567 // "Getter" for file_hash
1568 function getFileHash () {
1569 // Do we have cache?
1570 if (!isset($GLOBALS[__FUNCTION__])) {
1572 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1576 return $GLOBALS[__FUNCTION__];
1579 // "Getter" for pass_scramble
1580 function getPassScramble () {
1581 // Do we have cache?
1582 if (!isset($GLOBALS[__FUNCTION__])) {
1584 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1588 return $GLOBALS[__FUNCTION__];
1591 // "Getter" for ap_inactive_since
1592 function getApInactiveSince () {
1593 // Do we have cache?
1594 if (!isset($GLOBALS[__FUNCTION__])) {
1596 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1600 return $GLOBALS[__FUNCTION__];
1603 // "Getter" for user_min_confirmed
1604 function getUserMinConfirmed () {
1605 // Do we have cache?
1606 if (!isset($GLOBALS[__FUNCTION__])) {
1608 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1612 return $GLOBALS[__FUNCTION__];
1615 // "Getter" for auto_purge
1616 function getAutoPurge () {
1617 // Do we have cache?
1618 if (!isset($GLOBALS[__FUNCTION__])) {
1620 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1624 return $GLOBALS[__FUNCTION__];
1627 // "Getter" for bonus_userid
1628 function getBonusUserid () {
1629 // Do we have cache?
1630 if (!isset($GLOBALS[__FUNCTION__])) {
1632 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1636 return $GLOBALS[__FUNCTION__];
1639 // "Getter" for ap_inactive_time
1640 function getApInactiveTime () {
1641 // Do we have cache?
1642 if (!isset($GLOBALS[__FUNCTION__])) {
1644 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1648 return $GLOBALS[__FUNCTION__];
1651 // "Getter" for ap_dm_timeout
1652 function getApDmTimeout () {
1653 // Do we have cache?
1654 if (!isset($GLOBALS[__FUNCTION__])) {
1656 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1660 return $GLOBALS[__FUNCTION__];
1663 // "Getter" for ap_tasks_time
1664 function getApTasksTime () {
1665 // Do we have cache?
1666 if (!isset($GLOBALS[__FUNCTION__])) {
1668 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1672 return $GLOBALS[__FUNCTION__];
1675 // "Getter" for ap_unconfirmed_time
1676 function getApUnconfirmedTime () {
1677 // Do we have cache?
1678 if (!isset($GLOBALS[__FUNCTION__])) {
1680 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1684 return $GLOBALS[__FUNCTION__];
1687 // "Getter" for points
1688 function getPoints () {
1689 // Do we have cache?
1690 if (!isset($GLOBALS[__FUNCTION__])) {
1692 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1696 return $GLOBALS[__FUNCTION__];
1699 // "Getter" for slogan
1700 function getSlogan () {
1701 // Do we have cache?
1702 if (!isset($GLOBALS[__FUNCTION__])) {
1704 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1708 return $GLOBALS[__FUNCTION__];
1711 // "Getter" for copy
1712 function getCopy () {
1713 // Do we have cache?
1714 if (!isset($GLOBALS[__FUNCTION__])) {
1716 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1720 return $GLOBALS[__FUNCTION__];
1723 // "Getter" for webmaster
1724 function getWebmaster () {
1725 // Do we have cache?
1726 if (!isset($GLOBALS[__FUNCTION__])) {
1728 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1732 return $GLOBALS[__FUNCTION__];
1735 // "Getter" for sql_count
1736 function getSqlCount () {
1737 // Do we have cache?
1738 if (!isset($GLOBALS[__FUNCTION__])) {
1740 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1744 return $GLOBALS[__FUNCTION__];
1747 // "Getter" for num_templates
1748 function getNumTemplates () {
1749 // Do we have cache?
1750 if (!isset($GLOBALS[__FUNCTION__])) {
1752 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1756 return $GLOBALS[__FUNCTION__];
1759 // "Getter" for dns_cache_timeout
1760 function getDnsCacheTimeout () {
1761 // Do we have cache?
1762 if (!isset($GLOBALS[__FUNCTION__])) {
1764 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1768 return $GLOBALS[__FUNCTION__];
1771 // "Getter" for menu_blur_spacer
1772 function getMenuBlurSpacer () {
1773 // Do we have cache?
1774 if (!isset($GLOBALS[__FUNCTION__])) {
1776 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1780 return $GLOBALS[__FUNCTION__];
1783 // "Getter" for points_register
1784 function getPointsRegister () {
1785 // Do we have cache?
1786 if (!isset($GLOBALS[__FUNCTION__])) {
1788 $GLOBALS[__FUNCTION__] = getConfig('points_register');
1792 return $GLOBALS[__FUNCTION__];
1795 // "Getter" for points_ref
1796 function getPointsRef () {
1797 // Do we have cache?
1798 if (!isset($GLOBALS[__FUNCTION__])) {
1800 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
1804 return $GLOBALS[__FUNCTION__];
1807 // "Getter" for ref_payout
1808 function getRefPayout () {
1809 // Do we have cache?
1810 if (!isset($GLOBALS[__FUNCTION__])) {
1812 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
1816 return $GLOBALS[__FUNCTION__];
1819 // "Getter" for online_timeout
1820 function getOnlineTimeout () {
1821 // Do we have cache?
1822 if (!isset($GLOBALS[__FUNCTION__])) {
1824 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
1828 return $GLOBALS[__FUNCTION__];
1831 // "Getter" for index_home
1832 function getIndexHome () {
1833 // Do we have cache?
1834 if (!isset($GLOBALS[__FUNCTION__])) {
1836 $GLOBALS[__FUNCTION__] = getConfig('index_home');
1840 return $GLOBALS[__FUNCTION__];
1843 // "Getter" for one_day
1844 function getOneDay () {
1845 // Do we have cache?
1846 if (!isset($GLOBALS[__FUNCTION__])) {
1848 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
1852 return $GLOBALS[__FUNCTION__];
1855 // Checks wether proxy configuration is used
1856 function isProxyUsed () {
1857 // Do we have cache?
1858 if (!isset($GLOBALS[__FUNCTION__])) {
1860 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1864 return $GLOBALS[__FUNCTION__];
1867 // Checks wether POST data contains selections
1868 function ifPostContainsSelections ($element = 'sel') {
1869 // Do we have cache?
1870 if (!isset($GLOBALS[__FUNCTION__][$element])) {
1872 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
1876 return $GLOBALS[__FUNCTION__][$element];
1879 // Checks wether verbose_sql is Y and returns true/false if so
1880 function isVerboseSqlEnabled () {
1881 // Do we have cache?
1882 if (!isset($GLOBALS[__FUNCTION__])) {
1884 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1888 return $GLOBALS[__FUNCTION__];
1891 // "Getter" for total user points
1892 function getTotalPoints ($userid) {
1893 // Do we have cache?
1894 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1896 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
1900 return $GLOBALS[__FUNCTION__][$userid];
1903 // Wrapper to check if url_blacklist is enabled
1904 function isUrlBlacklistEnabled () {
1905 // Do we have cache?
1906 if (!isset($GLOBALS[__FUNCTION__])) {
1908 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
1912 return $GLOBALS[__FUNCTION__];
1915 // Checks wether direct payment is allowed in configuration
1916 function isDirectPaymentEnabled () {
1917 // Do we have cache?
1918 if (!isset($GLOBALS[__FUNCTION__])) {
1920 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
1924 return $GLOBALS[__FUNCTION__];
1927 // Wrapper to check if current task is for extension (not update)
1928 function isExtensionTask ($content) {
1929 // Do we have cache?
1930 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
1932 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
1936 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
1939 // Wrapper to check if output mode is CSS
1940 function isCssOutputMode () {
1942 return (getScriptOutputMode() == 1);
1945 // Wrapper to check if output mode is HTML
1946 function isHtmlOutputMode () {
1948 return (getScriptOutputMode() == 0);
1951 // Wrapper to check if output mode is RAW
1952 function isRawOutputMode () {
1954 return (getScriptOutputMode() == -1);
1957 // Wrapper to generate a user email link
1958 function generateWrappedUserEmailLink ($email) {
1959 // Just call the inner function
1960 return generateEmailLink($email, 'user_data');
1963 // Wrapper to check if user points are locked
1964 function ifUserPointsLocked ($userid) {
1965 // Do we have cache?
1966 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1968 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
1972 return $GLOBALS[__FUNCTION__][$userid];