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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 function readFromFile ($FQFN) {
47 // Sanity-check if file is there (should be there, but just to make it sure)
48 if (!isFileReadable($FQFN)) {
49 // This should not happen
50 debug_report_bug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
51 } elseif (!isset($GLOBALS['file_content'][$FQFN])) {
53 if (function_exists('file_get_contents')) {
55 $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
57 // Fall-back to implode-file chain
58 $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
63 return $GLOBALS['file_content'][$FQFN];
66 // Writes content to a file
67 function writeToFile ($FQFN, $content, $aquireLock = false) {
68 // Is the file writeable?
69 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
71 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
77 // By default all is failed...
78 $GLOBALS['file_readable'][$FQFN] = false;
79 unset($GLOBALS['file_content'][$FQFN]);
82 // Is the function there?
83 if (function_exists('file_put_contents')) {
85 if ($aquireLock === true) {
86 // Write it directly with lock
87 $return = file_put_contents($FQFN, $content, LOCK_EX);
90 $return = file_put_contents($FQFN, $content);
93 // Write it with fopen
94 $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
96 // Do we need to aquire a lock?
97 if ($aquireLock === true) {
103 $return = fwrite($fp, $content);
109 // Was something written?
110 if ($return !== false) {
111 // Mark it as readable
112 $GLOBALS['file_readable'][$FQFN] = true;
114 // Remember content in cache
115 $GLOBALS['file_content'][$FQFN] = $content;
119 return (($return !== false) && (changeMode($FQFN, 0644)));
122 // Clears the output buffer. This function does *NOT* backup sent content.
123 function clearOutputBuffer () {
124 // Trigger an error on failure
125 if ((ob_get_length() > 0) && (!ob_end_clean())) {
127 debug_report_bug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
132 // @TODO Implement $compress
133 function encodeString ($str, $compress = true) {
134 $str = urlencode(base64_encode(compileUriCode($str)));
138 // Decode strings encoded with encodeString()
139 // @TODO Implement $decompress
140 function decodeString ($str, $decompress = true) {
141 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
145 // Decode entities in a nicer way
146 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
147 // Decode the entities to UTF-8 now
148 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
150 // Return decoded string
151 return $decodedString;
154 // Merges an array together but only if both are arrays
155 function merge_array ($array1, $array2) {
156 // Are both an array?
157 if ((!is_array($array1)) && (!is_array($array2))) {
158 // Both are not arrays
159 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
160 } elseif (!is_array($array1)) {
161 // Left one is not an array
162 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
163 } elseif (!is_array($array2)) {
164 // Right one is not an array
165 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
168 // Merge all together
169 return array_merge($array1, $array2);
172 // Check if given FQFN is a readable file
173 function isFileReadable ($FQFN) {
175 if (!isset($GLOBALS['file_readable'][$FQFN])) {
177 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
181 return $GLOBALS['file_readable'][$FQFN];
184 // Checks wether the given FQFN is a directory and not ., .. or .svn
185 function isDirectory ($FQFN) {
187 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
189 $baseName = basename($FQFN);
192 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
196 return $GLOBALS[__FUNCTION__][$FQFN];
199 // "Getter" for remote IP number
200 function detectRemoteAddr () {
201 // Get remote ip from environment
202 $remoteAddr = determineRealRemoteAddress();
204 // Is removeip installed?
205 if (isExtensionActive('removeip')) {
207 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
214 // "Getter" for remote hostname
215 function detectRemoteHostname () {
216 // Get remote ip from environment
217 $remoteHost = getenv('REMOTE_HOST');
219 // Is removeip installed?
220 if (isExtensionActive('removeip')) {
222 $remoteHost = getAnonymousRemoteHost($remoteHost);
229 // "Getter" for user agent
230 function detectUserAgent ($alwaysReal = false) {
231 // Get remote ip from environment
232 $userAgent = getenv('HTTP_USER_AGENT');
234 // Is removeip installed?
235 if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
237 $userAgent = getAnonymousUserAgent($userAgent);
244 // "Getter" for referer
245 function detectReferer () {
246 // Get remote ip from environment
247 $referer = getenv('HTTP_REFERER');
249 // Is removeip installed?
250 if (isExtensionActive('removeip')) {
252 $referer = getAnonymousReferer($referer);
259 // "Getter" for request URI
260 function detectRequestUri () {
262 return (getenv('REQUEST_URI'));
265 // "Getter" for query string
266 function detectQueryString () {
267 return str_replace('&', '&', (getenv('QUERY_STRING')));
270 // "Getter" for SERVER_NAME
271 function detectServerName () {
273 return (getenv('SERVER_NAME'));
276 // Check wether we are installing
277 function isInstalling () {
278 // Determine wether we are installing
279 if (!isset($GLOBALS['mailer_installing'])) {
280 // Check URL (css.php/js.php need this)
281 $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
285 return $GLOBALS['mailer_installing'];
288 // Check wether this script is installed
289 function isInstalled () {
291 if (!isset($GLOBALS[__FUNCTION__])) {
292 // Determine wether this script is installed
293 $GLOBALS[__FUNCTION__] = (
298 isConfigEntrySet('MXCHANGE_INSTALLED')
300 getConfig('MXCHANGE_INSTALLED') == 'Y'
304 // New config file found and loaded
305 isIncludeReadable(getCachePath() . 'config-local.php')
308 // New config file found, but not yet read
309 isIncludeReadable(getCachePath() . 'config-local.php')
312 // Only new config file is found
313 !isIncludeReadable('inc/config.php')
315 // Is installation mode
322 // Then use the cache
323 return $GLOBALS[__FUNCTION__];
326 // Check wether an admin is registered
327 function isAdminRegistered () {
329 if (!isset($GLOBALS[__FUNCTION__])) {
331 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
335 return $GLOBALS[__FUNCTION__];
338 // Checks wether the reset mode is active
339 function isResetModeEnabled () {
340 // Now simply check it
341 return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
344 // Checks wether the debug mode is enabled
345 function isDebugModeEnabled () {
347 if (!isset($GLOBALS[__FUNCTION__])) {
349 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
353 return $GLOBALS[__FUNCTION__];
356 // Checks wether SQL debugging is enabled
357 function isSqlDebuggingEnabled () {
359 if (!isset($GLOBALS[__FUNCTION__])) {
360 // Determine if SQL debugging is enabled
361 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
365 return $GLOBALS[__FUNCTION__];
368 // Checks wether we shall debug regular expressions
369 function isDebugRegularExpressionEnabled () {
371 if (!isset($GLOBALS[__FUNCTION__])) {
373 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
377 return $GLOBALS[__FUNCTION__];
380 // Checks wether the cache instance is valid
381 function isCacheInstanceValid () {
382 return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
385 // Copies a file from source to destination and verifies if that goes fine.
386 // This function should wrap the copy() command and make a nicer debug backtrace
387 // even if there is no xdebug extension installed.
388 function copyFileVerified ($source, $dest, $chmod = '') {
389 // Failed is the default
392 // Is the source file there?
393 if (!isFileReadable($source)) {
395 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
398 // Is the target directory there?
399 if (!isDirectory(dirname($dest))) {
401 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
404 // Now try to copy it
405 if (!copy($source, $dest)) {
406 // Something went wrong
407 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
410 $GLOBALS['file_readable'][$dest] = true;
413 // If there are chmod rights set, apply them
414 if (!empty($chmod)) {
416 $status = changeMode($dest, $chmod);
426 // Wrapper function for header()
427 // Send a header but checks before if we can do so
428 function sendHeader ($header) {
430 //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
431 $GLOBALS['header'][] = trim($header);
434 // Flushes all headers
435 function flushHeaders () {
436 // Is the header already sent?
437 if (headers_sent()) {
439 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
442 // Flush all headers if found
443 if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
444 foreach ($GLOBALS['header'] as $header) {
449 // Mark them as flushed
450 $GLOBALS['header'] = array();
453 // Wrapper function for chmod()
454 // @TODO Do some more sanity check here
455 function changeMode ($FQFN, $mode) {
456 // Is the file/directory there?
457 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
458 // Neither, so abort here
459 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
463 return chmod($FQFN, $mode);
466 // Wrapper for unlink()
467 function removeFile ($FQFN) {
468 // Is the file there?
469 if (isFileReadable($FQFN)) {
471 $GLOBALS['file_readable'][$FQFN] = false;
474 return unlink($FQFN);
477 // All fine if no file was removed. If we change this to 'false' or rewrite
478 // above if() block it would be to restrictive.
482 // Wrapper for $_POST['sel']
483 function countPostSelection ($element = 'sel') {
485 if (isPostRequestParameterSet($element)) {
486 // Return counted elements
487 return countSelection(postRequestParameter($element));
489 // Return zero if not found
494 // Checks wether the config-local.php is loaded
495 function isConfigLocalLoaded () {
496 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
499 // Checks wether a nickname or userid was entered and caches the result
500 function isNicknameUsed ($userid) {
501 // Is the cache there
502 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
504 $GLOBALS[__FUNCTION__][$userid] = (('' . round($userid) . '') != $userid);
508 return $GLOBALS[__FUNCTION__][$userid];
511 // Getter for 'what' value
512 function getWhat () {
517 if (isWhatSet(true)) {
519 $what = $GLOBALS['what'];
526 // Setter for 'what' value
527 function setWhat ($newWhat) {
528 $GLOBALS['what'] = SQL_ESCAPE($newWhat);
531 // Setter for 'what' from configuration
532 function setWhatFromConfig ($configEntry) {
533 // Get 'what' from config
534 $what = getConfig($configEntry);
540 // Checks wether what is set and optionally aborts on miss
541 function isWhatSet ($strict = false) {
543 $isset = isset($GLOBALS['what']);
545 // Should we abort here?
546 if (($strict === true) && ($isset === false)) {
548 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
555 // Getter for 'action' value
556 function getAction ($strict = true) {
561 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
563 $action = $GLOBALS['action'];
570 // Setter for 'action' value
571 function setAction ($newAction) {
572 $GLOBALS['action'] = SQL_ESCAPE($newAction);
575 // Checks wether action is set and optionally aborts on miss
576 function isActionSet ($strict = false) {
578 $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
580 // Should we abort here?
581 if (($strict === true) && ($isset === false)) {
583 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
590 // Getter for 'module' value
591 function getModule ($strict = true) {
596 if (isModuleSet($strict)) {
598 $module = $GLOBALS['module'];
605 // Setter for 'module' value
606 function setModule ($newModule) {
607 // Secure it and make all modules lower-case
608 $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
611 // Checks wether module is set and optionally aborts on miss
612 function isModuleSet ($strict = false) {
614 $isset = (!empty($GLOBALS['module']));
616 // Should we abort here?
617 if (($strict === true) && ($isset === false)) {
619 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
623 return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
626 // Getter for 'output_mode' value
627 function getScriptOutputMode () {
632 if (isOutputModeSet(true)) {
634 $output_mode = $GLOBALS['output_mode'];
641 // Setter for 'output_mode' value
642 function setOutputMode ($newOutputMode) {
643 $GLOBALS['output_mode'] = (int) $newOutputMode;
646 // Checks wether output_mode is set and optionally aborts on miss
647 function isOutputModeSet ($strict = false) {
649 $isset = (isset($GLOBALS['output_mode']));
651 // Should we abort here?
652 if (($strict === true) && ($isset === false)) {
654 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
661 // Enables block-mode
662 function enableBlockMode ($enabled = true) {
663 $GLOBALS['block_mode'] = $enabled;
666 // Checks wether block-mode is enabled
667 function isBlockModeEnabled () {
669 if (!isset($GLOBALS['block_mode'])) {
671 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
675 return $GLOBALS['block_mode'];
678 // Wrapper function for addPointsThroughReferalSystem()
679 function addPointsDirectly ($subject, $userid, $points) {
681 unset($GLOBALS['ref_level']);
683 // Call more complicated method (due to more parameters)
684 return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'direct');
687 // Wrapper for redirectToUrl but URL comes from a configuration entry
688 function redirectToConfiguredUrl ($configEntry) {
690 redirectToUrl(getConfig($configEntry));
693 // Wrapper function to redirect from member-only modules to index
694 function redirectToIndexMemberOnlyModule () {
695 // Do the redirect here
696 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
699 // Wrapper function to redirect to current URL
700 function redirectToRequestUri () {
701 redirectToUrl(basename(detectRequestUri()));
704 // Wrapper function to redirect to de-refered URL
705 function redirectToDereferedUrl ($URL) {
707 redirectToUrl(generateDerefererUrl($URL));
710 // Wrapper function for checking if extension is installed and newer or same version
711 function isExtensionInstalledAndNewer ($ext_name, $version) {
712 // Is an cache entry found?
713 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
715 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
717 // Cache hits should be incremented twice
718 incrementStatsEntry('cache_hits', 2);
722 //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=>'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
723 return $GLOBALS[__FUNCTION__][$ext_name][$version];
726 // Wrapper function for checking if extension is installed and older than given version
727 function isExtensionInstalledAndOlder ($ext_name, $version) {
728 // Is an cache entry found?
729 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
731 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
733 // Cache hits should be incremented twice
734 incrementStatsEntry('cache_hits', 2);
738 //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
739 return $GLOBALS[__FUNCTION__][$ext_name][$version];
743 function setUsername ($userName) {
744 $GLOBALS['username'] = (string) $userName;
748 function getUsername () {
750 if (!isset($GLOBALS['username'])) {
751 // No, so it has to be a guest
752 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
756 return $GLOBALS['username'];
759 // Wrapper function for installation phase
760 function isInstallationPhase () {
762 if (!isset($GLOBALS[__FUNCTION__])) {
764 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
768 return $GLOBALS[__FUNCTION__];
771 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
772 function isDemoModeActive () {
774 if (!isset($GLOBALS[__FUNCTION__])) {
776 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
780 return $GLOBALS[__FUNCTION__];
783 // Getter for PHP caching value
784 function getPhpCaching () {
785 return $GLOBALS['php_caching'];
788 // Checks wether the admin hash is set
789 function isAdminHashSet ($adminId) {
790 // Is the array there?
791 if (!isset($GLOBALS['cache_array']['admin'])) {
792 // Missing array should be reported
793 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
796 // Check for admin hash
797 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
800 // Setter for admin hash
801 function setAdminHash ($adminId, $hash) {
802 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
805 // Init user data array
806 function initUserData () {
807 // User id should not be zero
808 if (!isValidUserId(getCurrentUserId())) {
809 // Should be always valid
810 debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
814 $GLOBALS['user_data'][getCurrentUserId()] = array();
817 // Getter for user data
818 function getUserData ($column) {
819 // User id should not be zero
820 if (!isValidUserId(getCurrentUserId())) {
821 // Should be always valid
822 debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
826 return $GLOBALS['user_data'][getCurrentUserId()][$column];
829 // Geter for whole user data array
830 function getUserDataArray () {
832 $userid = getCurrentUserId();
834 // Is the current userid valid?
835 if (!isValidUserId($userid)) {
836 // Should be always valid
837 debug_report_bug(__FUNCTION__, __LINE__, 'User id is invalid.');
840 // Get the whole array if found
841 if (isset($GLOBALS['user_data'][$userid])) {
842 // Found, so return it
843 return $GLOBALS['user_data'][$userid];
845 // Return empty array
850 // Checks if the user data is valid, this may indicate that the user has logged
851 // in, but you should use isMember() if you want to find that out.
852 function isUserDataValid () {
853 // User id should not be zero so abort here
854 if (!isCurrentUserIdSet()) return false;
857 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
859 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
863 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
866 // Setter for current userid
867 function setCurrentUserId ($userid) {
869 $GLOBALS['current_userid'] = bigintval($userid);
871 // Unset it to re-determine the actual state
872 unset($GLOBALS['is_userdata_valid'][$userid]);
875 // Getter for current userid
876 function getCurrentUserId () {
877 // Userid must be set before it can be used
878 if (!isCurrentUserIdSet()) {
880 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
884 return $GLOBALS['current_userid'];
887 // Checks if current userid is set
888 function isCurrentUserIdSet () {
889 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
892 // Checks wether we are debugging template cache
893 function isDebuggingTemplateCache () {
895 if (!isset($GLOBALS[__FUNCTION__])) {
897 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
901 return $GLOBALS[__FUNCTION__];
904 // Wrapper for fetchUserData() and getUserData() calls
905 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
907 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
908 // Default is 'guest'
909 $data = '{--USERNAME_GUEST--}';
911 // Can we fetch the user data?
912 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
913 // Now get the data back
914 $data = getUserData($valueColumn);
918 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
922 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
925 // Wrapper for strpos() to ease porting from deprecated ereg() function
926 function isInString ($needle, $haystack) {
927 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
928 return (strpos($haystack, $needle) !== false);
931 // Wrapper for strpos() to ease porting from deprecated eregi() function
932 // This function is case-insensitive
933 function isInStringIgnoreCase ($needle, $haystack) {
934 return (isInString(strtolower($needle), strtolower($haystack)));
937 // Wrapper to check for if fatal errors where detected
938 function ifFatalErrorsDetected () {
939 // Just call the inner function
940 return (getTotalFatalErrors() > 0);
943 // Setter for HTTP status
944 function setHttpStatus ($status) {
945 $GLOBALS['http_status'] = (string) $status;
948 // Getter for HTTP status
949 function getHttpStatus () {
950 return $GLOBALS['http_status'];
954 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
955 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
957 * ----------------------------------------------------------------------------
958 * If you want to redirect, please use redirectToUrl(); instead
959 * ----------------------------------------------------------------------------
961 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
963 * @link http://support.microsoft.com/kb/q176113/
964 * @author Andreas Gohr <andi@splitbrain.org>
967 function sendRawRedirect ($url) {
968 // Send helping header
969 setHttpStatus('302 Found');
971 // always close the session
972 session_write_close();
974 // Revert entity &
975 $url = str_replace('&', '&', $url);
977 // check if running on IIS < 6 with CGI-PHP
978 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
979 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
980 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
982 // Send the IIS header
983 sendHeader('Refresh: 0;url=' . $url);
985 // Send generic header
986 sendHeader('Location: ' . $url);
993 // Determines the country of the given user id
994 function determineCountry ($userid) {
996 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
997 // Default is 'invalid'
998 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1000 // Is extension country active?
1001 if (isExtensionActive('country')) {
1002 // Determine the right country code through the country id
1003 $id = getUserData('country_code');
1005 // Then handle it over
1006 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1008 // Get raw code from user data
1009 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1014 return $GLOBALS[__FUNCTION__][$userid];
1017 // "Getter" for total confirmed user accounts
1018 function getTotalConfirmedUser () {
1020 if (!isset($GLOBALS[__FUNCTION__])) {
1022 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1025 // Return cached value
1026 return $GLOBALS[__FUNCTION__];
1029 // "Getter" for total unconfirmed user accounts
1030 function getTotalUnconfirmedUser () {
1032 if (!isset($GLOBALS[__FUNCTION__])) {
1034 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1037 // Return cached value
1038 return $GLOBALS[__FUNCTION__];
1041 // "Getter" for total locked user accounts
1042 function getTotalLockedUser () {
1044 if (!isset($GLOBALS[__FUNCTION__])) {
1046 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1049 // Return cached value
1050 return $GLOBALS[__FUNCTION__];
1053 // Is given userid valid?
1054 function isValidUserId ($userid) {
1055 // Do we have cache?
1056 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1058 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1062 return $GLOBALS[__FUNCTION__][$userid];
1066 function encodeEntities ($str) {
1068 $str = secureString($str, true, true);
1070 // Encode dollar sign as well
1071 $str = str_replace('$', '$', $str);
1077 // "Getter" for date from patch_ctime
1078 function getDateFromPatchTime () {
1080 if (!isset($GLOBALS[__FUNCTION__])) {
1082 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1086 return $GLOBALS[__FUNCTION__];
1089 // Getter for current year (default)
1090 function getYear ($timestamp = null) {
1092 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1094 if (is_null($timestamp)) $timestamp = time();
1097 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1101 return $GLOBALS[__FUNCTION__][$timestamp];
1104 // Getter for current month (default)
1105 function getMonth ($timestamp = null) {
1107 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1109 if (is_null($timestamp)) $timestamp = time();
1112 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1116 return $GLOBALS[__FUNCTION__][$timestamp];
1119 // Getter for current day (default)
1120 function getDay ($timestamp = null) {
1122 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1124 if (is_null($timestamp)) $timestamp = time();
1127 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1131 return $GLOBALS[__FUNCTION__][$timestamp];
1134 // Getter for current week (default)
1135 function getWeek ($timestamp = null) {
1137 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1139 if (is_null($timestamp)) $timestamp = time();
1142 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1146 return $GLOBALS[__FUNCTION__][$timestamp];
1149 // Getter for current short_hour (default)
1150 function getShortHour ($timestamp = null) {
1152 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1154 if (is_null($timestamp)) $timestamp = time();
1157 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1161 return $GLOBALS[__FUNCTION__][$timestamp];
1164 // Getter for current long_hour (default)
1165 function getLongHour ($timestamp = null) {
1167 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1169 if (is_null($timestamp)) $timestamp = time();
1172 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1176 return $GLOBALS[__FUNCTION__][$timestamp];
1179 // Getter for current second (default)
1180 function getSecond ($timestamp = null) {
1182 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1184 if (is_null($timestamp)) $timestamp = time();
1187 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1191 return $GLOBALS[__FUNCTION__][$timestamp];
1194 // Getter for current minute (default)
1195 function getMinute ($timestamp = null) {
1197 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1199 if (is_null($timestamp)) $timestamp = time();
1202 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1206 return $GLOBALS[__FUNCTION__][$timestamp];
1209 // Checks wether the title decoration is enabled
1210 function isTitleDecorationEnabled () {
1211 // Do we have cache?
1212 if (!isset($GLOBALS[__FUNCTION__])) {
1214 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1218 return $GLOBALS[__FUNCTION__];
1221 // Checks wether filter usage updates are enabled (expensive queries!)
1222 function isFilterUsageUpdateEnabled () {
1223 // Do we have cache?
1224 if (!isset($GLOBALS[__FUNCTION__])) {
1226 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1230 return $GLOBALS[__FUNCTION__];
1233 // Checks wether debugging of weekly resets is enabled
1234 function isWeeklyResetDebugEnabled () {
1235 // Do we have cache?
1236 if (!isset($GLOBALS[__FUNCTION__])) {
1238 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1242 return $GLOBALS[__FUNCTION__];
1245 // Checks wether debugging of monthly resets is enabled
1246 function isMonthlyResetDebugEnabled () {
1247 // Do we have cache?
1248 if (!isset($GLOBALS[__FUNCTION__])) {
1250 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1254 return $GLOBALS[__FUNCTION__];
1257 // Checks wether displaying of debug SQLs are enabled
1258 function isDisplayDebugSqlEnabled () {
1259 // Do we have cache?
1260 if (!isset($GLOBALS[__FUNCTION__])) {
1262 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1266 return $GLOBALS[__FUNCTION__];
1269 // Checks wether module title is enabled
1270 function isModuleTitleEnabled () {
1271 // Do we have cache?
1272 if (!isset($GLOBALS[__FUNCTION__])) {
1274 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1278 return $GLOBALS[__FUNCTION__];
1281 // Checks wether what title is enabled
1282 function isWhatTitleEnabled () {
1283 // Do we have cache?
1284 if (!isset($GLOBALS[__FUNCTION__])) {
1286 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1290 return $GLOBALS[__FUNCTION__];
1293 // Checks wether stats are enabled
1294 function ifStatsAreEnabled () {
1295 // Do we have cache?
1296 if (!isset($GLOBALS[__FUNCTION__])) {
1297 // Then determine it
1298 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1301 // Return cached value
1302 return $GLOBALS[__FUNCTION__];
1305 // Checks wether admin-notification of certain user actions is enabled
1306 function isAdminNotificationEnabled () {
1307 // Do we have cache?
1308 if (!isset($GLOBALS[__FUNCTION__])) {
1310 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1314 return $GLOBALS[__FUNCTION__];
1317 // Checks wether random referal id selection is enabled
1318 function isRandomReferalIdEnabled () {
1319 // Do we have cache?
1320 if (!isset($GLOBALS[__FUNCTION__])) {
1322 $GLOBALS[__FUNCTION__] = (getConfig('select_user_zero_refid') == 'Y');
1326 return $GLOBALS[__FUNCTION__];
1329 // "Getter" for default language
1330 function getDefaultLanguage () {
1331 // Do we have cache?
1332 if (!isset($GLOBALS[__FUNCTION__])) {
1334 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1338 return $GLOBALS[__FUNCTION__];
1341 // "Getter" for path
1342 function getPath () {
1343 // Do we have cache?
1344 if (!isset($GLOBALS[__FUNCTION__])) {
1346 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1350 return $GLOBALS[__FUNCTION__];
1354 function getUrl () {
1355 // Do we have cache?
1356 if (!isset($GLOBALS[__FUNCTION__])) {
1358 $GLOBALS[__FUNCTION__] = getConfig('URL');
1362 return $GLOBALS[__FUNCTION__];
1365 // "Getter" for cache_path
1366 function getCachePath () {
1367 // Do we have cache?
1368 if (!isset($GLOBALS[__FUNCTION__])) {
1370 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1374 return $GLOBALS[__FUNCTION__];
1377 // "Getter" for secret_key
1378 function getSecretKey () {
1379 // Do we have cache?
1380 if (!isset($GLOBALS[__FUNCTION__])) {
1382 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1386 return $GLOBALS[__FUNCTION__];
1389 // "Getter" for master_salt
1390 function getMasterSalt () {
1391 // Do we have cache?
1392 if (!isset($GLOBALS[__FUNCTION__])) {
1394 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1398 return $GLOBALS[__FUNCTION__];
1401 // "Getter" for prime
1402 function getPrime () {
1403 // Do we have cache?
1404 if (!isset($GLOBALS[__FUNCTION__])) {
1406 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1410 return $GLOBALS[__FUNCTION__];
1413 // "Getter" for encrypt_seperator
1414 function getEncryptSeperator () {
1415 // Do we have cache?
1416 if (!isset($GLOBALS[__FUNCTION__])) {
1418 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1422 return $GLOBALS[__FUNCTION__];
1425 // "Getter" for mysql_prefix
1426 function getMysqlPrefix () {
1427 // Do we have cache?
1428 if (!isset($GLOBALS[__FUNCTION__])) {
1430 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1434 return $GLOBALS[__FUNCTION__];
1437 // "Getter" for table_type
1438 function getTableType () {
1439 // Do we have cache?
1440 if (!isset($GLOBALS[__FUNCTION__])) {
1442 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1446 return $GLOBALS[__FUNCTION__];
1449 // "Getter" for salt_length
1450 function getSaltLength () {
1451 // Do we have cache?
1452 if (!isset($GLOBALS[__FUNCTION__])) {
1454 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1458 return $GLOBALS[__FUNCTION__];
1461 // "Getter" for output_mode
1462 function getOutputMode () {
1463 // Do we have cache?
1464 if (!isset($GLOBALS[__FUNCTION__])) {
1466 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1470 return $GLOBALS[__FUNCTION__];
1473 // "Getter" for full_version
1474 function getFullVersion () {
1475 // Do we have cache?
1476 if (!isset($GLOBALS[__FUNCTION__])) {
1478 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1482 return $GLOBALS[__FUNCTION__];
1485 // "Getter" for title
1486 function getTitle () {
1487 // Do we have cache?
1488 if (!isset($GLOBALS[__FUNCTION__])) {
1490 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1494 return $GLOBALS[__FUNCTION__];
1497 // "Getter" for curr_svn_revision
1498 function getCurrSvnRevision () {
1499 // Do we have cache?
1500 if (!isset($GLOBALS[__FUNCTION__])) {
1502 $GLOBALS[__FUNCTION__] = getConfig('CURR_SVN_REVISION');
1506 return $GLOBALS[__FUNCTION__];
1509 // "Getter" for server_url
1510 function getServerUrl () {
1511 // Do we have cache?
1512 if (!isset($GLOBALS[__FUNCTION__])) {
1514 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1518 return $GLOBALS[__FUNCTION__];
1521 // "Getter" for mt_word
1522 function getMtWord () {
1523 // Do we have cache?
1524 if (!isset($GLOBALS[__FUNCTION__])) {
1526 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1530 return $GLOBALS[__FUNCTION__];
1533 // "Getter" for mt_word2
1534 function getMtWord2 () {
1535 // Do we have cache?
1536 if (!isset($GLOBALS[__FUNCTION__])) {
1538 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1542 return $GLOBALS[__FUNCTION__];
1545 // "Getter" for main_title
1546 function getMainTitle () {
1547 // Do we have cache?
1548 if (!isset($GLOBALS[__FUNCTION__])) {
1550 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1554 return $GLOBALS[__FUNCTION__];
1557 // "Getter" for file_hash
1558 function getFileHash () {
1559 // Do we have cache?
1560 if (!isset($GLOBALS[__FUNCTION__])) {
1562 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1566 return $GLOBALS[__FUNCTION__];
1569 // "Getter" for pass_scramble
1570 function getPassScramble () {
1571 // Do we have cache?
1572 if (!isset($GLOBALS[__FUNCTION__])) {
1574 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1578 return $GLOBALS[__FUNCTION__];
1581 // "Getter" for ap_inactive_since
1582 function getApInactiveSince () {
1583 // Do we have cache?
1584 if (!isset($GLOBALS[__FUNCTION__])) {
1586 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1590 return $GLOBALS[__FUNCTION__];
1593 // "Getter" for user_min_confirmed
1594 function getUserMinConfirmed () {
1595 // Do we have cache?
1596 if (!isset($GLOBALS[__FUNCTION__])) {
1598 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1602 return $GLOBALS[__FUNCTION__];
1605 // "Getter" for auto_purge
1606 function getAutoPurge () {
1607 // Do we have cache?
1608 if (!isset($GLOBALS[__FUNCTION__])) {
1610 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1614 return $GLOBALS[__FUNCTION__];
1617 // "Getter" for bonus_userid
1618 function getBonusUserid () {
1619 // Do we have cache?
1620 if (!isset($GLOBALS[__FUNCTION__])) {
1622 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1626 return $GLOBALS[__FUNCTION__];
1629 // "Getter" for ap_inactive_time
1630 function getApInactiveTime () {
1631 // Do we have cache?
1632 if (!isset($GLOBALS[__FUNCTION__])) {
1634 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1638 return $GLOBALS[__FUNCTION__];
1641 // "Getter" for ap_dm_timeout
1642 function getApDmTimeout () {
1643 // Do we have cache?
1644 if (!isset($GLOBALS[__FUNCTION__])) {
1646 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1650 return $GLOBALS[__FUNCTION__];
1653 // "Getter" for ap_tasks_time
1654 function getApTasksTime () {
1655 // Do we have cache?
1656 if (!isset($GLOBALS[__FUNCTION__])) {
1658 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1662 return $GLOBALS[__FUNCTION__];
1665 // "Getter" for ap_unconfirmed_time
1666 function getApUnconfirmedTime () {
1667 // Do we have cache?
1668 if (!isset($GLOBALS[__FUNCTION__])) {
1670 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1674 return $GLOBALS[__FUNCTION__];
1677 // "Getter" for points
1678 function getPoints () {
1679 // Do we have cache?
1680 if (!isset($GLOBALS[__FUNCTION__])) {
1682 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1686 return $GLOBALS[__FUNCTION__];
1689 // "Getter" for slogan
1690 function getSlogan () {
1691 // Do we have cache?
1692 if (!isset($GLOBALS[__FUNCTION__])) {
1694 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1698 return $GLOBALS[__FUNCTION__];
1701 // "Getter" for copy
1702 function getCopy () {
1703 // Do we have cache?
1704 if (!isset($GLOBALS[__FUNCTION__])) {
1706 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1710 return $GLOBALS[__FUNCTION__];
1713 // "Getter" for webmaster
1714 function getWebmaster () {
1715 // Do we have cache?
1716 if (!isset($GLOBALS[__FUNCTION__])) {
1718 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1722 return $GLOBALS[__FUNCTION__];
1725 // "Getter" for sql_count
1726 function getSqlCount () {
1727 // Do we have cache?
1728 if (!isset($GLOBALS[__FUNCTION__])) {
1730 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1734 return $GLOBALS[__FUNCTION__];
1737 // "Getter" for num_templates
1738 function getNumTemplates () {
1739 // Do we have cache?
1740 if (!isset($GLOBALS[__FUNCTION__])) {
1742 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1746 return $GLOBALS[__FUNCTION__];
1749 // "Getter" for dns_cache_timeout
1750 function getDnsCacheTimeout () {
1751 // Do we have cache?
1752 if (!isset($GLOBALS[__FUNCTION__])) {
1754 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1758 return $GLOBALS[__FUNCTION__];
1761 // "Getter" for menu_blur_spacer
1762 function getMenuBlurSpacer () {
1763 // Do we have cache?
1764 if (!isset($GLOBALS[__FUNCTION__])) {
1766 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1770 return $GLOBALS[__FUNCTION__];
1773 // "Getter" for points_register
1774 function getPointsRegister () {
1775 // Do we have cache?
1776 if (!isset($GLOBALS[__FUNCTION__])) {
1778 $GLOBALS[__FUNCTION__] = getConfig('points_register');
1782 return $GLOBALS[__FUNCTION__];
1785 // "Getter" for points_ref
1786 function getPointsRef () {
1787 // Do we have cache?
1788 if (!isset($GLOBALS[__FUNCTION__])) {
1790 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
1794 return $GLOBALS[__FUNCTION__];
1797 // "Getter" for ref_payout
1798 function getRefPayout () {
1799 // Do we have cache?
1800 if (!isset($GLOBALS[__FUNCTION__])) {
1802 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
1806 return $GLOBALS[__FUNCTION__];
1809 // "Getter" for online_timeout
1810 function getOnlineTimeout () {
1811 // Do we have cache?
1812 if (!isset($GLOBALS[__FUNCTION__])) {
1814 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
1818 return $GLOBALS[__FUNCTION__];
1821 // "Getter" for index_home
1822 function getIndexHome () {
1823 // Do we have cache?
1824 if (!isset($GLOBALS[__FUNCTION__])) {
1826 $GLOBALS[__FUNCTION__] = getConfig('index_home');
1830 return $GLOBALS[__FUNCTION__];
1833 // "Getter" for one_day
1834 function getOneDay () {
1835 // Do we have cache?
1836 if (!isset($GLOBALS[__FUNCTION__])) {
1838 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
1842 return $GLOBALS[__FUNCTION__];
1845 // Checks wether proxy configuration is used
1846 function isProxyUsed () {
1847 // Do we have cache?
1848 if (!isset($GLOBALS[__FUNCTION__])) {
1850 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1854 return $GLOBALS[__FUNCTION__];
1857 // Checks wether POST data contains selections
1858 function ifPostContainsSelections ($element = 'sel') {
1859 // Do we have cache?
1860 if (!isset($GLOBALS[__FUNCTION__][$element])) {
1862 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
1866 return $GLOBALS[__FUNCTION__][$element];
1869 // Checks wether verbose_sql is Y and returns true/false if so
1870 function isVerboseSqlEnabled () {
1871 // Do we have cache?
1872 if (!isset($GLOBALS[__FUNCTION__])) {
1874 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1878 return $GLOBALS[__FUNCTION__];
1881 // "Getter" for total user points
1882 function getTotalPoints ($userid) {
1883 // Do we have cache?
1884 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1886 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
1890 return $GLOBALS[__FUNCTION__][$userid];
1893 // Wrapper to check if url_blacklist is enabled
1894 function isUrlBlacklistEnabled () {
1895 // Do we have cache?
1896 if (!isset($GLOBALS[__FUNCTION__])) {
1898 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
1902 return $GLOBALS[__FUNCTION__];
1905 // Checks wether direct payment is allowed in configuration
1906 function isDirectPaymentEnabled () {
1907 // Do we have cache?
1908 if (!isset($GLOBALS[__FUNCTION__])) {
1910 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
1914 return $GLOBALS[__FUNCTION__];
1917 // Wrapper to check if current task is for extension (not update)
1918 function isExtensionTask ($content) {
1919 // Do we have cache?
1920 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
1922 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
1926 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
1929 // Wrapper to check if output mode is CSS
1930 function isCssOutputMode () {
1932 return (getScriptOutputMode() == 1);
1935 // Wrapper to check if output mode is HTML
1936 function isHtmlOutputMode () {
1938 return (getScriptOutputMode() == 0);
1941 // Wrapper to check if output mode is RAW
1942 function isRawOutputMode () {
1944 return (getScriptOutputMode() == -1);
1947 // Wrapper to generate a user email link
1948 function generateWrappedUserEmailLink ($email) {
1949 // Just call the inner function
1950 return generateEmailLink($email, 'user_data');