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!');
54 if (!isset($GLOBALS['file_content'][$FQFN])) {
56 if (function_exists('file_get_contents')) {
58 $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
60 // Fall-back to implode-file chain
61 $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
66 return $GLOBALS['file_content'][$FQFN];
69 // Writes content to a file
70 function writeToFile ($FQFN, $content, $aquireLock = false) {
71 // Is the file writeable?
72 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
74 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
80 // By default all is failed...
83 // Is the function there?
84 if (function_exists('file_put_contents')) {
86 if ($aquireLock === true) {
87 // Write it directly with lock
88 $return = file_put_contents($FQFN, $content, LOCK_EX);
91 $return = file_put_contents($FQFN, $content);
94 // Write it with fopen
95 $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
98 if ($aquireLock === true) flock($fp, LOCK_EX);
101 fwrite($fp, $content);
107 // Mark it as readable
108 $GLOBALS['file_readable'][$FQFN] = true;
110 // Remember content in cache
111 $GLOBALS['file_content'][$FQFN] = $content;
114 return changeMode($FQFN, 0644);
117 // Clears the output buffer. This function does *NOT* backup sent content.
118 function clearOutputBuffer () {
119 // Trigger an error on failure
120 if ((ob_get_length() > 0) && (!ob_end_clean())) {
122 debug_report_bug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
127 // @TODO Implement $compress
128 function encodeString ($str, $compress = true) {
129 $str = urlencode(base64_encode(compileUriCode($str)));
133 // Decode strings encoded with encodeString()
134 // @TODO Implement $decompress
135 function decodeString ($str, $decompress = true) {
136 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
140 // Decode entities in a nicer way
141 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
142 // Decode the entities to UTF-8 now
143 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
145 // Return decoded string
146 return $decodedString;
149 // Merges an array together but only if both are arrays
150 function merge_array ($array1, $array2) {
151 // Are both an array?
152 if ((!is_array($array1)) && (!is_array($array2))) {
153 // Both are not arrays
154 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
155 } elseif (!is_array($array1)) {
156 // Left one is not an array
157 debug_report_bug(__FILE__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
158 } elseif (!is_array($array2)) {
159 // Right one is not an array
160 debug_report_bug(__FILE__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
163 // Merge all together
164 return array_merge($array1, $array2);
167 // Check if given FQFN is a readable file
168 function isFileReadable ($FQFN) {
170 if (!isset($GLOBALS['file_readable'][$FQFN])) {
172 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
175 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($FQFN) . ' - CHECK! (' . intval($GLOBALS['file_readable'][$FQFN]) . ')');
178 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($FQFN) . ' - CACHE! (' . intval($GLOBALS['file_readable'][$FQFN]) . ')');
182 return $GLOBALS['file_readable'][$FQFN];
185 // Checks wether the given FQFN is a directory and not ., .. or .svn
186 function isDirectory ($FQFN) {
188 if (!isset($GLOBALS['is_directory'][$FQFN])) {
190 $baseName = basename($FQFN);
193 $GLOBALS['is_directory'][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
197 return $GLOBALS['is_directory'][$FQFN];
200 // "Getter" for remote IP number
201 function detectRemoteAddr () {
202 // Get remote ip from environment
203 $remoteAddr = determineRealRemoteAddress();
205 // Is removeip installed?
206 if (isExtensionActive('removeip')) {
208 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
215 // "Getter" for remote hostname
216 function detectRemoteHostname () {
217 // Get remote ip from environment
218 $remoteHost = getenv('REMOTE_HOST');
220 // Is removeip installed?
221 if (isExtensionActive('removeip')) {
223 $remoteHost = getAnonymousRemoteHost($remoteHost);
230 // "Getter" for user agent
231 function detectUserAgent ($alwaysReal = false) {
232 // Get remote ip from environment
233 $userAgent = getenv('HTTP_USER_AGENT');
235 // Is removeip installed?
236 if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
238 $userAgent = getAnonymousUserAgent($userAgent);
245 // "Getter" for referer
246 function detectReferer () {
247 // Get remote ip from environment
248 $referer = getenv('HTTP_REFERER');
250 // Is removeip installed?
251 if (isExtensionActive('removeip')) {
253 $referer = getAnonymousReferer($referer);
260 // "Getter" for request URI
261 function detectRequestUri () {
263 return (getenv('REQUEST_URI'));
266 // "Getter" for query string
267 function detectQueryString () {
268 return str_replace('&', '&', (getenv('QUERY_STRING')));
271 // "Getter" for SERVER_NAME
272 function detectServerName () {
274 return (getenv('SERVER_NAME'));
277 // Check wether we are installing
278 function isInstalling () {
279 // Determine wether we are installing
280 if (!isset($GLOBALS['mailer_installing'])) {
281 // Check URL (css.php/js.php need this)
282 $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
286 return $GLOBALS['mailer_installing'];
289 // Check wether this script is installed
290 function isInstalled () {
292 if (!isset($GLOBALS['is_installed'])) {
293 // Determine wether this script is installed
294 $GLOBALS['is_installed'] = (
299 isConfigEntrySet('MXCHANGE_INSTALLED')
301 getConfig('MXCHANGE_INSTALLED') == 'Y'
305 // New config file found and loaded
306 isIncludeReadable(getCachePath() . 'config-local.php')
309 // New config file found, but not yet read
310 isIncludeReadable(getCachePath() . 'config-local.php')
313 // Only new config file is found
314 !isIncludeReadable('inc/config.php')
316 // Is installation mode
323 // Then use the cache
324 return $GLOBALS['is_installed'];
327 // Check wether an admin is registered
328 function isAdminRegistered () {
330 if (!isset($GLOBALS['is_admin_registered'])) {
332 $GLOBALS['is_admin_registered'] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
336 return $GLOBALS['is_admin_registered'];
339 // Checks wether the reset mode is active
340 function isResetModeEnabled () {
341 // Now simply check it
342 return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
345 // Checks wether the debug mode is enabled
346 function isDebugModeEnabled () {
348 if (!isset($GLOBALS['is_debugmode_enabled'])) {
350 $GLOBALS['is_debugmode_enabled'] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
354 return $GLOBALS['is_debugmode_enabled'];
357 // Checks wether SQL debugging is enabled
358 function isSqlDebuggingEnabled () {
360 if (!isset($GLOBALS['is_sql_debug_enabled'])) {
361 // Determine if SQL debugging is enabled
362 $GLOBALS['is_sql_debug_enabled'] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
366 return $GLOBALS['is_sql_debug_enabled'];
369 // Checks wether we shall debug regular expressions
370 function isDebugRegularExpressionEnabled () {
372 if (!isset($GLOBALS['is_regular_exp_debug_enabled'])) {
374 $GLOBALS['is_regular_exp_debug_enabled'] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
378 return $GLOBALS['is_regular_exp_debug_enabled'];
381 // Checks wether the cache instance is valid
382 function isCacheInstanceValid () {
383 return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
386 // Copies a file from source to destination and verifies if that goes fine.
387 // This function should wrap the copy() command and make a nicer debug backtrace
388 // even if there is no xdebug extension installed.
389 function copyFileVerified ($source, $dest, $chmod = '') {
390 // Failed is the default
393 // Is the source file there?
394 if (!isFileReadable($source)) {
396 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
399 // Is the target directory there?
400 if (!isDirectory(dirname($dest))) {
402 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
405 // Now try to copy it
406 if (!copy($source, $dest)) {
407 // Something went wrong
408 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
411 $GLOBALS['file_readable'][$dest] = true;
414 // If there are chmod rights set, apply them
415 if (!empty($chmod)) {
417 $status = changeMode($dest, $chmod);
427 // Wrapper function for header()
428 // Send a header but checks before if we can do so
429 function sendHeader ($header) {
431 //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
432 $GLOBALS['header'][] = trim($header);
435 // Flushes all headers
436 function flushHeaders () {
437 // Is the header already sent?
438 if (headers_sent()) {
440 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
443 // Flush all headers if found
444 if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
445 foreach ($GLOBALS['header'] as $header) {
450 // Mark them as flushed
451 $GLOBALS['header'] = array();
454 // Wrapper function for chmod()
455 // @TODO Do some more sanity check here
456 function changeMode ($FQFN, $mode) {
457 // Is the file/directory there?
458 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
459 // Neither, so abort here
460 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
467 // Wrapper for unlink()
468 function removeFile ($FQFN) {
469 // Is the file there?
470 if (isFileReadable($FQFN)) {
472 $GLOBALS['file_readable'][$FQFN] = false;
475 return unlink($FQFN);
478 // All fine if no file was removed. If we change this to 'false' or rewrite
479 // above if() block it would be to restrictive.
483 // Wrapper for $_POST['sel']
484 function countPostSelection ($element = 'sel') {
486 if (isPostRequestParameterSet($element)) {
487 // Return counted elements
488 return countSelection(postRequestParameter($element));
490 // Return zero if not found
495 // Checks wether the config-local.php is loaded
496 function isConfigLocalLoaded () {
497 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
500 // Checks wether a nickname or userid was entered and caches the result
501 function isNicknameUsed ($userid) {
502 // Is the cache there
503 if (!isset($GLOBALS['is_nickname_used'][$userid])) {
505 $GLOBALS['is_nickname_used'][$userid] = (('' . round($userid) . '') != $userid);
509 return $GLOBALS['is_nickname_used'][$userid];
512 // Getter for 'what' value
513 function getWhat () {
518 if (isWhatSet(true)) {
520 $what = $GLOBALS['what'];
527 // Setter for 'what' value
528 function setWhat ($newWhat) {
529 $GLOBALS['what'] = SQL_ESCAPE($newWhat);
532 // Setter for 'what' from configuration
533 function setWhatFromConfig ($configEntry) {
534 // Get 'what' from config
535 $what = getConfig($configEntry);
541 // Checks wether what is set and optionally aborts on miss
542 function isWhatSet ($strict = false) {
544 $isset = isset($GLOBALS['what']);
546 // Should we abort here?
547 if (($strict === true) && ($isset === false)) {
549 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
556 // Getter for 'action' value
557 function getAction ($strict = true) {
562 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
564 $action = $GLOBALS['action'];
571 // Setter for 'action' value
572 function setAction ($newAction) {
573 $GLOBALS['action'] = SQL_ESCAPE($newAction);
576 // Checks wether action is set and optionally aborts on miss
577 function isActionSet ($strict = false) {
579 $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
581 // Should we abort here?
582 if (($strict === true) && ($isset === false)) {
584 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
591 // Getter for 'module' value
592 function getModule ($strict = true) {
597 if (isModuleSet($strict)) {
599 $module = $GLOBALS['module'];
606 // Setter for 'module' value
607 function setModule ($newModule) {
608 // Secure it and make all modules lower-case
609 $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
612 // Checks wether module is set and optionally aborts on miss
613 function isModuleSet ($strict = false) {
615 $isset = (!empty($GLOBALS['module']));
617 // Should we abort here?
618 if (($strict === true) && ($isset === false)) {
620 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
624 return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
627 // Getter for 'output_mode' value
628 function getScriptOutputMode () {
633 if (isOutputModeSet(true)) {
635 $output_mode = $GLOBALS['output_mode'];
642 // Setter for 'output_mode' value
643 function setOutputMode ($newOutputMode) {
644 $GLOBALS['output_mode'] = (int) $newOutputMode;
647 // Checks wether output_mode is set and optionally aborts on miss
648 function isOutputModeSet ($strict = false) {
650 $isset = (isset($GLOBALS['output_mode']));
652 // Should we abort here?
653 if (($strict === true) && ($isset === false)) {
655 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
662 // Enables block-mode
663 function enableBlockMode ($enabled = true) {
664 $GLOBALS['block_mode'] = $enabled;
667 // Checks wether block-mode is enabled
668 function isBlockModeEnabled () {
670 if (!isset($GLOBALS['block_mode'])) {
672 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
676 return $GLOBALS['block_mode'];
679 // Wrapper function for addPointsThroughReferalSystem()
680 function addPointsDirectly ($subject, $userid, $points) {
682 unset($GLOBALS['ref_level']);
684 // Call more complicated method (due to more parameters)
685 return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'direct');
688 // Wrapper for redirectToUrl but URL comes from a configuration entry
689 function redirectToConfiguredUrl ($configEntry) {
691 redirectToUrl(getConfig($configEntry));
694 // Wrapper function to redirect from member-only modules to index
695 function redirectToIndexMemberOnlyModule () {
696 // Do the redirect here
697 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
700 // Wrapper function to redirect to current URL
701 function redirectToRequestUri () {
702 redirectToUrl(basename(detectRequestUri()));
705 // Wrapper function to redirect to de-refered URL
706 function redirectToDereferedUrl ($URL) {
708 redirectToUrl(generateDerefererUrl($URL));
711 // Wrapper function for checking if extension is installed and newer or same version
712 function isExtensionInstalledAndNewer ($ext_name, $version) {
713 // Is an cache entry found?
714 if (!isset($GLOBALS['ext_installed_newer'][$ext_name][$version])) {
715 $GLOBALS['ext_installed_newer'][$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['ext_installed_newer'][$ext_name][$version]));
723 return $GLOBALS['ext_installed_newer'][$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['ext_installed_older'][$ext_name][$version])) {
730 $GLOBALS['ext_installed_older'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
732 // Cache hits should be incremented twice
733 incrementStatsEntry('cache_hits', 2);
737 //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]));
738 return $GLOBALS['ext_installed_older'][$ext_name][$version];
742 function setUsername ($userName) {
743 $GLOBALS['username'] = (string) $userName;
747 function getUsername () {
749 if (!isset($GLOBALS['username'])) {
750 // No, so it has to be a guest
751 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
755 return $GLOBALS['username'];
758 // Wrapper function for installation phase
759 function isInstallationPhase () {
761 if (!isset($GLOBALS['installation_phase'])) {
763 $GLOBALS['installation_phase'] = ((!isInstalled()) || (isInstalling()));
767 return $GLOBALS['installation_phase'];
770 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
771 function isDemoModeActive () {
773 if (!isset($GLOBALS['demo_mode_active'])) {
775 $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
779 return $GLOBALS['demo_mode_active'];
782 // Getter for PHP caching value
783 function getPhpCaching () {
784 return $GLOBALS['php_caching'];
787 // Checks wether the admin hash is set
788 function isAdminHashSet ($adminId) {
789 // Is the array there?
790 if (!isset($GLOBALS['cache_array']['admin'])) {
791 // Missing array should be reported
792 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
795 // Check for admin hash
796 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
799 // Setter for admin hash
800 function setAdminHash ($adminId, $hash) {
801 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
804 // Init user data array
805 function initUserData () {
806 // User id should not be zero
807 if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
810 $GLOBALS['user_data'][getCurrentUserId()] = array();
813 // Getter for user data
814 function getUserData ($column) {
815 // User id should not be zero
816 if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
819 return $GLOBALS['user_data'][getCurrentUserId()][$column];
822 // Geter for whole user data array
823 function getUserDataArray () {
825 $uid = getCurrentUserId();
827 // Is the current userid valid?
828 if (!isValidUserId($uid)) {
829 // Should be always valid
830 debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
833 // Get the whole array if found
834 if (isset($GLOBALS['user_data'][$uid])) {
835 // Found, so return it
836 return $GLOBALS['user_data'][$uid];
838 // Return empty array
843 // Checks if the user data is valid, this may indicate that the user has logged
844 // in, but you should use isMember() if you want to find that out.
845 function isUserDataValid () {
846 // User id should not be zero so abort here
847 if (!isCurrentUserIdSet()) return false;
850 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
852 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
856 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
859 // Setter for current userid
860 function setCurrentUserId ($userid) {
862 $GLOBALS['current_userid'] = bigintval($userid);
864 // Unset it to re-determine the actual state
865 unset($GLOBALS['is_userdata_valid'][$userid]);
868 // Getter for current userid
869 function getCurrentUserId () {
870 // Userid must be set before it can be used
871 if (!isCurrentUserIdSet()) {
873 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
877 return $GLOBALS['current_userid'];
880 // Checks if current userid is set
881 function isCurrentUserIdSet () {
882 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
885 // Checks wether we are debugging template cache
886 function isDebuggingTemplateCache () {
888 if (!isset($GLOBALS['debug_template_cache'])) {
890 $GLOBALS['debug_template_cache'] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
894 return $GLOBALS['debug_template_cache'];
897 // Wrapper for fetchUserData() and getUserData() calls
898 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
900 if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
901 // Default is 'guest'
902 $data = '{--USERNAME_GUEST--}';
904 // Can we fetch the user data?
905 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
906 // Now get the data back
907 $data = getUserData($valueColumn);
911 $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data;
915 return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn];
918 // Wrapper for strpos() to ease porting from deprecated ereg() function
919 function isInString ($needle, $haystack) {
920 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
921 return (strpos($haystack, $needle) !== false);
924 // Wrapper for strpos() to ease porting from deprecated eregi() function
925 // This function is case-insensitive
926 function isInStringIgnoreCase ($needle, $haystack) {
927 return (isInString(strtolower($needle), strtolower($haystack)));
930 // Wrapper to check for if fatal errors where detected
931 function ifFatalErrorsDetected () {
932 // Just call the inner function
933 return (getTotalFatalErrors() > 0);
936 // Setter for HTTP status
937 function setHttpStatus ($status) {
938 $GLOBALS['http_status'] = (string) $status;
941 // Getter for HTTP status
942 function getHttpStatus () {
943 return $GLOBALS['http_status'];
947 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
948 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
950 * ----------------------------------------------------------------------------
951 * If you want to redirect, please use redirectToUrl(); instead
952 * ----------------------------------------------------------------------------
954 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
956 * @link http://support.microsoft.com/kb/q176113/
957 * @author Andreas Gohr <andi@splitbrain.org>
960 function sendRawRedirect ($url) {
961 // always close the session
962 session_write_close();
964 // Revert entity &
965 $url = str_replace('&', '&', $url);
967 // check if running on IIS < 6 with CGI-PHP
968 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
969 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
970 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
972 // Send the IIS header
973 sendHeader('Refresh: 0;url=' . $url);
975 // Send generic header
976 sendHeader('Location: ' . $url);
983 // Determines the country of the given user id
984 function determineCountry ($userid) {
985 // Default is 'invalid'
986 $country = 'invalid';
988 // Is extension country active?
989 if (isExtensionActive('country')) {
990 // Determine the right country code through the country id
991 $id = getUserData('country_code');
993 // Then handle it over
994 $country = generateCountryInfo($id);
996 // Get raw code from user data
997 $country = getUserData('country');
1004 // "Getter" for total confirmed user accounts
1005 function getTotalConfirmedUser () {
1007 if (!isset($GLOBALS['total_confirmed_users'])) {
1009 $GLOBALS['total_confirmed_users'] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1012 // Return cached value
1013 return $GLOBALS['total_confirmed_users'];
1016 // "Getter" for total unconfirmed user accounts
1017 function getTotalUnconfirmedUser () {
1019 if (!isset($GLOBALS['total_unconfirmed_users'])) {
1021 $GLOBALS['total_unconfirmed_users'] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1024 // Return cached value
1025 return $GLOBALS['total_unconfirmed_users'];
1028 // "Getter" for total locked user accounts
1029 function getTotalLockedUser () {
1031 if (!isset($GLOBALS['total_locked_users'])) {
1033 $GLOBALS['total_locked_users'] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1036 // Return cached value
1037 return $GLOBALS['total_locked_users'];
1040 // Is given userid valid?
1041 function isValidUserId ($userid) {
1042 // Do we have cache?
1043 if (!isset($GLOBALS['is_valid_userid'][$userid])) {
1045 $GLOBALS['is_valid_userid'][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1049 return $GLOBALS['is_valid_userid'][$userid];
1053 function encodeEntities ($str) {
1055 $str = secureString($str, true, true);
1057 // Encode dollar sign as well
1058 $str = str_replace('$', '$', $str);
1064 // "Getter" for date from patch_ctime
1065 function getDateFromPatchTime () {
1067 if (!isset($GLOBALS[__FUNCTION__])) {
1069 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1073 return $GLOBALS[__FUNCTION__];
1076 // Getter for current year (default)
1077 function getYear ($timestamp = null) {
1079 if (!isset($GLOBALS['year'][$timestamp])) {
1081 if (is_null($timestamp)) $timestamp = time();
1084 $GLOBALS['year'][$timestamp] = date('Y', $timestamp);
1088 return $GLOBALS['year'][$timestamp];
1091 // Getter for current month (default)
1092 function getMonth ($timestamp = null) {
1094 if (!isset($GLOBALS['month'][$timestamp])) {
1096 if (is_null($timestamp)) $timestamp = time();
1099 $GLOBALS['month'][$timestamp] = date('m', $timestamp);
1103 return $GLOBALS['month'][$timestamp];
1106 // Getter for current day (default)
1107 function getDay ($timestamp = null) {
1109 if (!isset($GLOBALS['day'][$timestamp])) {
1111 if (is_null($timestamp)) $timestamp = time();
1114 $GLOBALS['day'][$timestamp] = date('d', $timestamp);
1118 return $GLOBALS['day'][$timestamp];
1121 // Getter for current week (default)
1122 function getWeek ($timestamp = null) {
1124 if (!isset($GLOBALS['week'][$timestamp])) {
1126 if (is_null($timestamp)) $timestamp = time();
1129 $GLOBALS['week'][$timestamp] = date('W', $timestamp);
1133 return $GLOBALS['week'][$timestamp];
1136 // Getter for current short_hour (default)
1137 function getShortHour ($timestamp = null) {
1139 if (!isset($GLOBALS['short_hour'][$timestamp])) {
1141 if (is_null($timestamp)) $timestamp = time();
1144 $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp);
1148 return $GLOBALS['short_hour'][$timestamp];
1151 // Getter for current long_hour (default)
1152 function getLongHour ($timestamp = null) {
1154 if (!isset($GLOBALS['long_hour'][$timestamp])) {
1156 if (is_null($timestamp)) $timestamp = time();
1159 $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp);
1163 return $GLOBALS['long_hour'][$timestamp];
1166 // Getter for current second (default)
1167 function getSecond ($timestamp = null) {
1169 if (!isset($GLOBALS['second'][$timestamp])) {
1171 if (is_null($timestamp)) $timestamp = time();
1174 $GLOBALS['second'][$timestamp] = date('s', $timestamp);
1178 return $GLOBALS['second'][$timestamp];
1181 // Getter for current minute (default)
1182 function getMinute ($timestamp = null) {
1184 if (!isset($GLOBALS['minute'][$timestamp])) {
1186 if (is_null($timestamp)) $timestamp = time();
1189 $GLOBALS['minute'][$timestamp] = date('i', $timestamp);
1193 return $GLOBALS['minute'][$timestamp];
1196 // Checks wether the title decoration is enabled
1197 function isTitleDecorationEnabled () {
1198 // Do we have cache?
1199 if (!isset($GLOBALS['title_deco_enabled'])) {
1201 $GLOBALS['title_deco_enabled'] = (getConfig('enable_title_deco') == 'Y');
1205 return $GLOBALS['title_deco_enabled'];
1208 // Checks wether filter usage updates are enabled (expensive queries!)
1209 function isFilterUsageUpdateEnabled () {
1210 // Do we have cache?
1211 if (!isset($GLOBALS['filter_usage_updates'])) {
1213 $GLOBALS['filter_usage_updates'] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1217 return $GLOBALS['filter_usage_updates'];
1220 // Checks wether debugging of weekly resets is enabled
1221 function isWeeklyResetDebugEnabled () {
1222 // Do we have cache?
1223 if (!isset($GLOBALS['weekly_reset_debug'])) {
1225 $GLOBALS['weekly_reset_debug'] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1229 return $GLOBALS['weekly_reset_debug'];
1232 // Checks wether debugging of monthly resets is enabled
1233 function isMonthlyResetDebugEnabled () {
1234 // Do we have cache?
1235 if (!isset($GLOBALS['monthly_reset_debug'])) {
1237 $GLOBALS['monthly_reset_debug'] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1241 return $GLOBALS['monthly_reset_debug'];
1244 // Checks wether displaying of debug SQLs are enabled
1245 function isDisplayDebugSqlEnabled () {
1246 // Do we have cache?
1247 if (!isset($GLOBALS['display_debug_sql'])) {
1249 $GLOBALS['display_debug_sql'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1253 return $GLOBALS['display_debug_sql'];
1256 // Checks wether module title is enabled
1257 function isModuleTitleEnabled () {
1258 // Do we have cache?
1259 if (!isset($GLOBALS['mod_title_enabled'])) {
1261 $GLOBALS['mod_title_enabled'] = (getConfig('enable_mod_title') == 'Y');
1265 return $GLOBALS['mod_title_enabled'];
1268 // Checks wether what title is enabled
1269 function isWhatTitleEnabled () {
1270 // Do we have cache?
1271 if (!isset($GLOBALS['mod_title_enabled'])) {
1273 $GLOBALS['mod_title_enabled'] = (getConfig('enable_what_title') == 'Y');
1277 return $GLOBALS['mod_title_enabled'];
1280 // Checks wether stats are enabled
1281 function ifStatsAreEnabled () {
1282 // Do we have cache?
1283 if (!isset($GLOBALS['stats_enabled'])) {
1284 // Then determine it
1285 $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y');
1288 // Return cached value
1289 return $GLOBALS['stats_enabled'];
1292 // Checks wether admin-notification of certain user actions is enabled
1293 function isAdminNotificationEnabled () {
1294 // Do we have cache?
1295 if (!isset($GLOBALS['admin_notification_enabled'])) {
1297 $GLOBALS['admin_notification_enabled'] = (getConfig('admin_notify') == 'Y');
1301 return $GLOBALS['admin_notification_enabled'];
1304 // Checks wether random referal id selection is enabled
1305 function isRandomReferalIdEnabled () {
1306 // Do we have cache?
1307 if (!isset($GLOBALS['select_user_zero_refid'])) {
1309 $GLOBALS['select_user_zero_refid'] = (getConfig('select_user_zero_refid') == 'Y');
1313 return $GLOBALS['select_user_zero_refid'];
1316 // "Getter" for default language
1317 function getDefaultLanguage () {
1318 // Do we have cache?
1319 if (!isset($GLOBALS['default_language'])) {
1321 $GLOBALS['default_language'] = getConfig('DEFAULT_LANG');
1325 return $GLOBALS['default_language'];
1328 // "Getter" for path
1329 function getPath () {
1330 // Do we have cache?
1331 if (!isset($GLOBALS['path'])) {
1333 $GLOBALS['path'] = getConfig('PATH');
1337 return $GLOBALS['path'];
1341 function getUrl () {
1342 // Do we have cache?
1343 if (!isset($GLOBALS['url'])) {
1345 $GLOBALS['url'] = getConfig('URL');
1349 return $GLOBALS['url'];
1352 // "Getter" for cache_path
1353 function getCachePath () {
1354 // Do we have cache?
1355 if (!isset($GLOBALS['cache_path'])) {
1357 $GLOBALS['cache_path'] = getConfig('CACHE_PATH');
1361 return $GLOBALS['cache_path'];
1364 // "Getter" for secret_key
1365 function getSecretKey () {
1366 // Do we have cache?
1367 if (!isset($GLOBALS['secret_key'])) {
1369 $GLOBALS['secret_key'] = getConfig('secret_key');
1373 return $GLOBALS['secret_key'];
1376 // "Getter" for master_salt
1377 function getMasterSalt () {
1378 // Do we have cache?
1379 if (!isset($GLOBALS['master_salt'])) {
1381 $GLOBALS['master_salt'] = getConfig('master_salt');
1385 return $GLOBALS['master_salt'];
1388 // "Getter" for prime
1389 function getPrime () {
1390 // Do we have cache?
1391 if (!isset($GLOBALS['prime'])) {
1393 $GLOBALS['prime'] = getConfig('_PRIME');
1397 return $GLOBALS['prime'];
1400 // "Getter" for encrypt_seperator
1401 function getEncryptSeperator () {
1402 // Do we have cache?
1403 if (!isset($GLOBALS['encrypt_seperator'])) {
1405 $GLOBALS['encrypt_seperator'] = getConfig('ENCRYPT_SEPERATOR');
1409 return $GLOBALS['encrypt_seperator'];
1412 // "Getter" for mysql_prefix
1413 function getMysqlPrefix () {
1414 // Do we have cache?
1415 if (!isset($GLOBALS['mysql_prefix'])) {
1417 $GLOBALS['mysql_prefix'] = getConfig('_MYSQL_PREFIX');
1421 return $GLOBALS['mysql_prefix'];
1424 // "Getter" for table_type
1425 function getTableType () {
1426 // Do we have cache?
1427 if (!isset($GLOBALS['table_type'])) {
1429 $GLOBALS['table_type'] = getConfig('_TABLE_TYPE');
1433 return $GLOBALS['table_type'];
1436 // "Getter" for salt_length
1437 function getSaltLength () {
1438 // Do we have cache?
1439 if (!isset($GLOBALS['salt_length'])) {
1441 $GLOBALS['salt_length'] = getConfig('salt_length');
1445 return $GLOBALS['salt_length'];
1448 // "Getter" for output_mode
1449 function getOutputMode () {
1450 // Do we have cache?
1451 if (!isset($GLOBALS['cached_output_mode'])) {
1453 $GLOBALS['cached_output_mode'] = getConfig('OUTPUT_MODE');
1457 return $GLOBALS['cached_output_mode'];
1460 // "Getter" for full_version
1461 function getFullVersion () {
1462 // Do we have cache?
1463 if (!isset($GLOBALS['full_version'])) {
1465 $GLOBALS['full_version'] = getConfig('FULL_VERSION');
1469 return $GLOBALS['full_version'];
1472 // "Getter" for title
1473 function getTitle () {
1474 // Do we have cache?
1475 if (!isset($GLOBALS['title'])) {
1477 $GLOBALS['title'] = getConfig('TITLE');
1481 return $GLOBALS['title'];
1484 // "Getter" for curr_svn_revision
1485 function getCurrSvnRevision () {
1486 // Do we have cache?
1487 if (!isset($GLOBALS['curr_svn_revision'])) {
1489 $GLOBALS['curr_svn_revision'] = getConfig('CURR_SVN_REVISION');
1493 return $GLOBALS['curr_svn_revision'];
1496 // "Getter" for server_url
1497 function getServerUrl () {
1498 // Do we have cache?
1499 if (!isset($GLOBALS['server_url'])) {
1501 $GLOBALS['server_url'] = getConfig('SERVER_URL');
1505 return $GLOBALS['server_url'];
1508 // "Getter" for mt_word
1509 function getMtWord () {
1510 // Do we have cache?
1511 if (!isset($GLOBALS['mt_word'])) {
1513 $GLOBALS['mt_word'] = getConfig('mt_word');
1517 return $GLOBALS['mt_word'];
1520 // "Getter" for mt_word2
1521 function getMtWord2 () {
1522 // Do we have cache?
1523 if (!isset($GLOBALS['mt_word2'])) {
1525 $GLOBALS['mt_word2'] = getConfig('mt_word2');
1529 return $GLOBALS['mt_word2'];
1532 // "Getter" for main_title
1533 function getMainTitle () {
1534 // Do we have cache?
1535 if (!isset($GLOBALS['main_title'])) {
1537 $GLOBALS['main_title'] = getConfig('MAIN_TITLE');
1541 return $GLOBALS['main_title'];
1544 // "Getter" for file_hash
1545 function getFileHash () {
1546 // Do we have cache?
1547 if (!isset($GLOBALS['file_hash'])) {
1549 $GLOBALS['file_hash'] = getConfig('file_hash');
1553 return $GLOBALS['file_hash'];
1556 // "Getter" for pass_scramble
1557 function getPassScramble () {
1558 // Do we have cache?
1559 if (!isset($GLOBALS['pass_scramble'])) {
1561 $GLOBALS['pass_scramble'] = getConfig('pass_scramble');
1565 return $GLOBALS['pass_scramble'];
1568 // "Getter" for ap_inactive_since
1569 function getApInactiveSince () {
1570 // Do we have cache?
1571 if (!isset($GLOBALS['ap_inactive_since'])) {
1573 $GLOBALS['ap_inactive_since'] = getConfig('ap_inactive_since');
1577 return $GLOBALS['ap_inactive_since'];
1580 // "Getter" for user_min_confirmed
1581 function getUserMinConfirmed () {
1582 // Do we have cache?
1583 if (!isset($GLOBALS['user_min_confirmed'])) {
1585 $GLOBALS['user_min_confirmed'] = getConfig('user_min_confirmed');
1589 return $GLOBALS['user_min_confirmed'];
1592 // "Getter" for auto_purge
1593 function getAutoPurge () {
1594 // Do we have cache?
1595 if (!isset($GLOBALS['auto_purge'])) {
1597 $GLOBALS['auto_purge'] = getConfig('auto_purge');
1601 return $GLOBALS['auto_purge'];
1604 // "Getter" for bonus_userid
1605 function getBonusUserid () {
1606 // Do we have cache?
1607 if (!isset($GLOBALS['bonus_userid'])) {
1609 $GLOBALS['bonus_userid'] = getConfig('bonus_userid');
1613 return $GLOBALS['bonus_userid'];
1616 // "Getter" for ap_inactive_time
1617 function getApInactiveTime () {
1618 // Do we have cache?
1619 if (!isset($GLOBALS['ap_inactive_time'])) {
1621 $GLOBALS['ap_inactive_time'] = getConfig('ap_inactive_time');
1625 return $GLOBALS['ap_inactive_time'];
1628 // "Getter" for ap_dm_timeout
1629 function getApDmTimeout () {
1630 // Do we have cache?
1631 if (!isset($GLOBALS['ap_dm_timeout'])) {
1633 $GLOBALS['ap_dm_timeout'] = getConfig('ap_dm_timeout');
1637 return $GLOBALS['ap_dm_timeout'];
1640 // "Getter" for ap_tasks_time
1641 function getApTasksTime () {
1642 // Do we have cache?
1643 if (!isset($GLOBALS['ap_tasks_time'])) {
1645 $GLOBALS['ap_tasks_time'] = getConfig('ap_tasks_time');
1649 return $GLOBALS['ap_tasks_time'];
1652 // "Getter" for ap_unconfirmed_time
1653 function getApUnconfirmedTime () {
1654 // Do we have cache?
1655 if (!isset($GLOBALS['ap_unconfirmed_time'])) {
1657 $GLOBALS['ap_unconfirmed_time'] = getConfig('ap_unconfirmed_time');
1661 return $GLOBALS['ap_unconfirmed_time'];
1664 // "Getter" for points
1665 function getPoints () {
1666 // Do we have cache?
1667 if (!isset($GLOBALS['points'])) {
1669 $GLOBALS['points'] = getConfig('POINTS');
1673 return $GLOBALS['points'];
1676 // "Getter" for slogan
1677 function getSlogan () {
1678 // Do we have cache?
1679 if (!isset($GLOBALS['slogan'])) {
1681 $GLOBALS['slogan'] = getConfig('SLOGAN');
1685 return $GLOBALS['slogan'];
1688 // "Getter" for copy
1689 function getCopy () {
1690 // Do we have cache?
1691 if (!isset($GLOBALS['copy'])) {
1693 $GLOBALS['copy'] = getConfig('COPY');
1697 return $GLOBALS['copy'];
1700 // "Getter" for webmaster
1701 function getWebmaster () {
1702 // Do we have cache?
1703 if (!isset($GLOBALS['webmaster'])) {
1705 $GLOBALS['webmaster'] = getConfig('WEBMASTER');
1709 return $GLOBALS['webmaster'];
1712 // "Getter" for sql_count
1713 function getSqlCount () {
1714 // Do we have cache?
1715 if (!isset($GLOBALS['sql_count'])) {
1717 $GLOBALS['sql_count'] = getConfig('sql_count');
1721 return $GLOBALS['sql_count'];
1724 // "Getter" for num_templates
1725 function getNumTemplates () {
1726 // Do we have cache?
1727 if (!isset($GLOBALS['num_templates'])) {
1729 $GLOBALS['num_templates'] = getConfig('num_templates');
1733 return $GLOBALS['num_templates'];
1736 // "Getter" for dns_cache_timeout
1737 function getDnsCacheTimeout () {
1738 // Do we have cache?
1739 if (!isset($GLOBALS['dns_cache_timeout'])) {
1741 $GLOBALS['dns_cache_timeout'] = getConfig('dns_cache_timeout');
1745 return $GLOBALS['dns_cache_timeout'];
1748 // "Getter" for menu_blur_spacer
1749 function getMenuBlurSpacer () {
1750 // Do we have cache?
1751 if (!isset($GLOBALS['menu_blur_spacer'])) {
1753 $GLOBALS['menu_blur_spacer'] = getConfig('menu_blur_spacer');
1757 return $GLOBALS['menu_blur_spacer'];
1760 // "Getter" for points_register
1761 function getPointsRegister () {
1762 // Do we have cache?
1763 if (!isset($GLOBALS['points_register'])) {
1765 $GLOBALS['points_register'] = getConfig('points_register');
1769 return $GLOBALS['points_register'];
1772 // "Getter" for points_ref
1773 function getPointsRef () {
1774 // Do we have cache?
1775 if (!isset($GLOBALS['points_ref'])) {
1777 $GLOBALS['points_ref'] = getConfig('points_ref');
1781 return $GLOBALS['points_ref'];
1784 // "Getter" for ref_payout
1785 function getRefPayout () {
1786 // Do we have cache?
1787 if (!isset($GLOBALS['ref_payout'])) {
1789 $GLOBALS['ref_payout'] = getConfig('ref_payout');
1793 return $GLOBALS['ref_payout'];
1796 // "Getter" for online_timeout
1797 function getOnlineTimeout () {
1798 // Do we have cache?
1799 if (!isset($GLOBALS['online_timeout'])) {
1801 $GLOBALS['online_timeout'] = getConfig('online_timeout');
1805 return $GLOBALS['online_timeout'];
1808 // "Getter" for index_home
1809 function getIndexHome () {
1810 // Do we have cache?
1811 if (!isset($GLOBALS['index_home'])) {
1813 $GLOBALS['index_home'] = getConfig('index_home');
1817 return $GLOBALS['index_home'];
1820 // "Getter" for one_day
1821 function getOneDay () {
1822 // Do we have cache?
1823 if (!isset($GLOBALS['one_day'])) {
1825 $GLOBALS['one_day'] = getConfig('ONE_DAY');
1829 return $GLOBALS['one_day'];
1832 // Checks wether proxy configuration is used
1833 function isProxyUsed () {
1834 // Do we have cache?
1835 if (!isset($GLOBALS['is_proxy_used'])) {
1837 $GLOBALS['is_proxy_used'] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1841 return $GLOBALS['is_proxy_used'];
1844 // Checks wether POST data contains selections
1845 function ifPostContainsSelections ($element = 'sel') {
1846 // Do we have cache?
1847 if (!isset($GLOBALS['post_contains_selections'][$element])) {
1849 $GLOBALS['post_contains_selections'][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
1853 return $GLOBALS['post_contains_selections'][$element];
1856 // Checks wether verbose_sql is Y and returns true/false if so
1857 function isVerboseSqlEnabled () {
1858 // Do we have cache?
1859 if (!isset($GLOBALS['is_verbose_sql_enabled'])) {
1861 $GLOBALS['is_verbose_sql_enabled'] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1865 return $GLOBALS['is_verbose_sql_enabled'];
1868 // "Getter" for total user points
1869 function getTotalPoints ($userid) {
1870 // Do we have cache?
1871 if (!isset($GLOBALS['total_points'][$userid])) {
1873 $GLOBALS['total_points'][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
1877 return $GLOBALS['total_points'][$userid];
1880 // Wrapper to check if url_blacklist is enabled
1881 function isUrlBlacklistEnabled () {
1882 // Do we have cache?
1883 if (!isset($GLOBALS['is_url_blacklist_enabled'])) {
1885 $GLOBALS['is_url_blacklist_enabled'] = (getConfig('url_blacklist') == 'Y');
1889 return $GLOBALS['is_url_blacklist_enabled'];
1892 // Checks wether direct payment is allowed in configuration
1893 function isDirectPaymentAllowed () {
1894 // Do we have cache?
1895 if (!isset($GLOBALS['is_direct_payment_allowed'])) {
1897 $GLOBALS['is_direct_payment_allowed'] = (getConfig('allow_direct_pay') == 'Y');
1901 return $GLOBALS['is_direct_payment_allowed'];
1904 // Wrapper to check if current task is for extension (not update)
1905 function isExtensionTask ($content) {
1906 // Do we have cache?
1907 if (!isset($GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']])) {
1909 $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
1913 return $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']];
1916 // Wrapper to check if output mode is CSS
1917 function isCssOutputMode () {
1919 return (getScriptOutputMode() == 1);
1922 // Wrapper to check if output mode is HTML
1923 function isHtmlOutputMode () {
1925 return (getScriptOutputMode() == 0);
1928 // Wrapper to check if output mode is RAW
1929 function isRawOutputMode () {
1931 return (getScriptOutputMode() == -1);