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) && (getScriptOutputMode() == 0))) {
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 // User id should not be zero
828 if ($uid < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
830 // Get the whole array if found
831 if (isset($GLOBALS['user_data'][$uid])) {
832 // Found, so return it
833 return $GLOBALS['user_data'][$uid];
835 // Return empty array
840 // Checks if the user data is valid, this may indicate that the user has logged
841 // in, but you should use isMember() if you want to find that out.
842 function isUserDataValid () {
843 // User id should not be zero so abort here
844 if (!isCurrentUserIdSet()) return false;
847 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
849 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
853 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
856 // Setter for current userid
857 function setCurrentUserId ($userid) {
859 $GLOBALS['current_userid'] = bigintval($userid);
861 // Unset it to re-determine the actual state
862 unset($GLOBALS['is_userdata_valid'][$userid]);
865 // Getter for current userid
866 function getCurrentUserId () {
867 // Userid must be set before it can be used
868 if (!isCurrentUserIdSet()) {
870 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
874 return $GLOBALS['current_userid'];
877 // Checks if current userid is set
878 function isCurrentUserIdSet () {
879 return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
882 // Checks wether we are debugging template cache
883 function isDebuggingTemplateCache () {
885 if (!isset($GLOBALS['debug_template_cache'])) {
887 $GLOBALS['debug_template_cache'] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
891 return $GLOBALS['debug_template_cache'];
894 // Wrapper for fetchUserData() and getUserData() calls
895 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
897 if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
898 // Default is 'guest'
899 $data = '{--USERNAME_GUEST--}';
901 // Can we fetch the user data?
902 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
903 // Now get the data back
904 $data = getUserData($valueColumn);
908 $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data;
912 return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn];
915 // Wrapper for strpos() to ease porting from deprecated ereg() function
916 function isInString ($needle, $haystack) {
917 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
918 return (strpos($haystack, $needle) !== false);
921 // Wrapper for strpos() to ease porting from deprecated eregi() function
922 // This function is case-insensitive
923 function isInStringIgnoreCase ($needle, $haystack) {
924 return (isInString(strtolower($needle), strtolower($haystack)));
927 // Wrapper to check for if fatal errors where detected
928 function ifFatalErrorsDetected () {
929 // Just call the inner function
930 return (getTotalFatalErrors() > 0);
933 // Setter for HTTP status
934 function setHttpStatus ($status) {
935 $GLOBALS['http_status'] = (string) $status;
938 // Getter for HTTP status
939 function getHttpStatus () {
940 return $GLOBALS['http_status'];
944 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
945 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
947 * ----------------------------------------------------------------------------
948 * If you want to redirect, please use redirectToUrl(); instead
949 * ----------------------------------------------------------------------------
951 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
953 * @link http://support.microsoft.com/kb/q176113/
954 * @author Andreas Gohr <andi@splitbrain.org>
957 function sendRawRedirect ($url) {
958 // always close the session
959 session_write_close();
961 // Revert entity &
962 $url = str_replace('&', '&', $url);
964 // check if running on IIS < 6 with CGI-PHP
965 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
966 (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) &&
967 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
969 // Send the IIS header
970 sendHeader('Refresh: 0;url=' . $url);
972 // Send generic header
973 sendHeader('Location: ' . $url);
980 // Determines the country of the given user id
981 function determineCountry ($userid) {
982 // Default is 'invalid'
983 $country = 'invalid';
985 // Is extension country active?
986 if (isExtensionActive('country')) {
987 // Determine the right country code through the country id
988 $id = getUserData('country_code');
990 // Then handle it over
991 $country = generateCountryInfo($id);
993 // Get raw code from user data
994 $country = getUserData('country');
1001 // "Getter" for total confirmed user accounts
1002 function getTotalConfirmedUser () {
1004 if (!isset($GLOBALS['total_confirmed_users'])) {
1006 $GLOBALS['total_confirmed_users'] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1009 // Return cached value
1010 return $GLOBALS['total_confirmed_users'];
1013 // "Getter" for total unconfirmed user accounts
1014 function getTotalUnconfirmedUser () {
1016 if (!isset($GLOBALS['total_unconfirmed_users'])) {
1018 $GLOBALS['total_unconfirmed_users'] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1021 // Return cached value
1022 return $GLOBALS['total_unconfirmed_users'];
1025 // "Getter" for total locked user accounts
1026 function getTotalLockedUser () {
1028 if (!isset($GLOBALS['total_locked_users'])) {
1030 $GLOBALS['total_locked_users'] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1033 // Return cached value
1034 return $GLOBALS['total_locked_users'];
1037 // Is given userid valid?
1038 function isValidUserId ($userid) {
1039 // Do we have cache?
1040 if (!isset($GLOBALS['is_valid_userid'][$userid])) {
1042 $GLOBALS['is_valid_userid'][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1046 return $GLOBALS['is_valid_userid'][$userid];
1050 function encodeEntities ($str) {
1052 $str = secureString($str);
1054 // Encode dollar sign as well
1055 $str = str_replace('$', '$', $str);
1061 // "Getter" for date from patch_ctime
1062 function getDateFromPatchTime () {
1064 if (!isset($GLOBALS[__FUNCTION__])) {
1066 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1070 return $GLOBALS[__FUNCTION__];
1073 // Getter for current year (default)
1074 function getYear ($timestamp = null) {
1076 if (!isset($GLOBALS['year'][$timestamp])) {
1078 if (is_null($timestamp)) $timestamp = time();
1081 $GLOBALS['year'][$timestamp] = date('Y', $timestamp);
1085 return $GLOBALS['year'][$timestamp];
1088 // Getter for current month (default)
1089 function getMonth ($timestamp = null) {
1091 if (!isset($GLOBALS['month'][$timestamp])) {
1093 if (is_null($timestamp)) $timestamp = time();
1096 $GLOBALS['month'][$timestamp] = date('m', $timestamp);
1100 return $GLOBALS['month'][$timestamp];
1103 // Getter for current day (default)
1104 function getDay ($timestamp = null) {
1106 if (!isset($GLOBALS['day'][$timestamp])) {
1108 if (is_null($timestamp)) $timestamp = time();
1111 $GLOBALS['day'][$timestamp] = date('d', $timestamp);
1115 return $GLOBALS['day'][$timestamp];
1118 // Getter for current week (default)
1119 function getWeek ($timestamp = null) {
1121 if (!isset($GLOBALS['week'][$timestamp])) {
1123 if (is_null($timestamp)) $timestamp = time();
1126 $GLOBALS['week'][$timestamp] = date('W', $timestamp);
1130 return $GLOBALS['week'][$timestamp];
1133 // Getter for current short_hour (default)
1134 function getShortHour ($timestamp = null) {
1136 if (!isset($GLOBALS['short_hour'][$timestamp])) {
1138 if (is_null($timestamp)) $timestamp = time();
1141 $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp);
1145 return $GLOBALS['short_hour'][$timestamp];
1148 // Getter for current long_hour (default)
1149 function getLongHour ($timestamp = null) {
1151 if (!isset($GLOBALS['long_hour'][$timestamp])) {
1153 if (is_null($timestamp)) $timestamp = time();
1156 $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp);
1160 return $GLOBALS['long_hour'][$timestamp];
1163 // Getter for current second (default)
1164 function getSecond ($timestamp = null) {
1166 if (!isset($GLOBALS['second'][$timestamp])) {
1168 if (is_null($timestamp)) $timestamp = time();
1171 $GLOBALS['second'][$timestamp] = date('s', $timestamp);
1175 return $GLOBALS['second'][$timestamp];
1178 // Getter for current minute (default)
1179 function getMinute ($timestamp = null) {
1181 if (!isset($GLOBALS['minute'][$timestamp])) {
1183 if (is_null($timestamp)) $timestamp = time();
1186 $GLOBALS['minute'][$timestamp] = date('i', $timestamp);
1190 return $GLOBALS['minute'][$timestamp];
1193 // Checks wether the title decoration is enabled
1194 function isTitleDecorationEnabled () {
1195 // Do we have cache?
1196 if (!isset($GLOBALS['title_deco_enabled'])) {
1198 $GLOBALS['title_deco_enabled'] = (getConfig('enable_title_deco') == 'Y');
1202 return $GLOBALS['title_deco_enabled'];
1205 // Checks wether filter usage updates are enabled (expensive queries!)
1206 function isFilterUsageUpdateEnabled () {
1207 // Do we have cache?
1208 if (!isset($GLOBALS['filter_usage_updates'])) {
1210 $GLOBALS['filter_usage_updates'] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1214 return $GLOBALS['filter_usage_updates'];
1217 // Checks wether debugging of weekly resets is enabled
1218 function isWeeklyResetDebugEnabled () {
1219 // Do we have cache?
1220 if (!isset($GLOBALS['weekly_reset_debug'])) {
1222 $GLOBALS['weekly_reset_debug'] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1226 return $GLOBALS['weekly_reset_debug'];
1229 // Checks wether debugging of monthly resets is enabled
1230 function isMonthlyResetDebugEnabled () {
1231 // Do we have cache?
1232 if (!isset($GLOBALS['monthly_reset_debug'])) {
1234 $GLOBALS['monthly_reset_debug'] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1238 return $GLOBALS['monthly_reset_debug'];
1241 // Checks wether displaying of debug SQLs are enabled
1242 function isDisplayDebugSqlEnabled () {
1243 // Do we have cache?
1244 if (!isset($GLOBALS['display_debug_sql'])) {
1246 $GLOBALS['display_debug_sql'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1250 return $GLOBALS['display_debug_sql'];
1253 // Checks wether module title is enabled
1254 function isModuleTitleEnabled () {
1255 // Do we have cache?
1256 if (!isset($GLOBALS['mod_title_enabled'])) {
1258 $GLOBALS['mod_title_enabled'] = (getConfig('enable_mod_title') == 'Y');
1262 return $GLOBALS['mod_title_enabled'];
1265 // Checks wether what title is enabled
1266 function isWhatTitleEnabled () {
1267 // Do we have cache?
1268 if (!isset($GLOBALS['mod_title_enabled'])) {
1270 $GLOBALS['mod_title_enabled'] = (getConfig('enable_what_title') == 'Y');
1274 return $GLOBALS['mod_title_enabled'];
1277 // Checks wether stats are enabled
1278 function ifStatsAreEnabled () {
1279 // Do we have cache?
1280 if (!isset($GLOBALS['stats_enabled'])) {
1281 // Then determine it
1282 $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y');
1285 // Return cached value
1286 return $GLOBALS['stats_enabled'];
1289 // Checks wether admin-notification of certain user actions is enabled
1290 function isAdminNotificationEnabled () {
1291 // Do we have cache?
1292 if (!isset($GLOBALS['admin_notification_enabled'])) {
1294 $GLOBALS['admin_notification_enabled'] = (getConfig('admin_notify') == 'Y');
1298 return $GLOBALS['admin_notification_enabled'];
1301 // Checks wether random referal id selection is enabled
1302 function isRandomReferalIdEnabled () {
1303 // Do we have cache?
1304 if (!isset($GLOBALS['select_user_zero_refid'])) {
1306 $GLOBALS['select_user_zero_refid'] = (getConfig('select_user_zero_refid') == 'Y');
1310 return $GLOBALS['select_user_zero_refid'];
1313 // "Getter" for default language
1314 function getDefaultLanguage () {
1315 // Do we have cache?
1316 if (!isset($GLOBALS['default_language'])) {
1318 $GLOBALS['default_language'] = getConfig('DEFAULT_LANG');
1322 return $GLOBALS['default_language'];
1325 // "Getter" for path
1326 function getPath () {
1327 // Do we have cache?
1328 if (!isset($GLOBALS['path'])) {
1330 $GLOBALS['path'] = getConfig('PATH');
1334 return $GLOBALS['path'];
1338 function getUrl () {
1339 // Do we have cache?
1340 if (!isset($GLOBALS['url'])) {
1342 $GLOBALS['url'] = getConfig('URL');
1346 return $GLOBALS['url'];
1349 // "Getter" for cache_path
1350 function getCachePath () {
1351 // Do we have cache?
1352 if (!isset($GLOBALS['cache_path'])) {
1354 $GLOBALS['cache_path'] = getConfig('CACHE_PATH');
1358 return $GLOBALS['cache_path'];
1361 // "Getter" for secret_key
1362 function getSecretKey () {
1363 // Do we have cache?
1364 if (!isset($GLOBALS['secret_key'])) {
1366 $GLOBALS['secret_key'] = getConfig('secret_key');
1370 return $GLOBALS['secret_key'];
1373 // "Getter" for master_salt
1374 function getMasterSalt () {
1375 // Do we have cache?
1376 if (!isset($GLOBALS['master_salt'])) {
1378 $GLOBALS['master_salt'] = getConfig('master_salt');
1382 return $GLOBALS['master_salt'];
1385 // "Getter" for prime
1386 function getPrime () {
1387 // Do we have cache?
1388 if (!isset($GLOBALS['prime'])) {
1390 $GLOBALS['prime'] = getConfig('_PRIME');
1394 return $GLOBALS['prime'];
1397 // "Getter" for encrypt_seperator
1398 function getEncryptSeperator () {
1399 // Do we have cache?
1400 if (!isset($GLOBALS['encrypt_seperator'])) {
1402 $GLOBALS['encrypt_seperator'] = getConfig('ENCRYPT_SEPERATOR');
1406 return $GLOBALS['encrypt_seperator'];
1409 // "Getter" for mysql_prefix
1410 function getMysqlPrefix () {
1411 // Do we have cache?
1412 if (!isset($GLOBALS['mysql_prefix'])) {
1414 $GLOBALS['mysql_prefix'] = getConfig('_MYSQL_PREFIX');
1418 return $GLOBALS['mysql_prefix'];
1421 // "Getter" for table_type
1422 function getTableType () {
1423 // Do we have cache?
1424 if (!isset($GLOBALS['table_type'])) {
1426 $GLOBALS['table_type'] = getConfig('_TABLE_TYPE');
1430 return $GLOBALS['table_type'];
1433 // "Getter" for salt_length
1434 function getSaltLength () {
1435 // Do we have cache?
1436 if (!isset($GLOBALS['salt_length'])) {
1438 $GLOBALS['salt_length'] = getConfig('salt_length');
1442 return $GLOBALS['salt_length'];
1445 // "Getter" for output_mode
1446 function getOutputMode () {
1447 // Do we have cache?
1448 if (!isset($GLOBALS['cached_output_mode'])) {
1450 $GLOBALS['cached_output_mode'] = getConfig('OUTPUT_MODE');
1454 return $GLOBALS['cached_output_mode'];
1457 // "Getter" for full_version
1458 function getFullVersion () {
1459 // Do we have cache?
1460 if (!isset($GLOBALS['full_version'])) {
1462 $GLOBALS['full_version'] = getConfig('FULL_VERSION');
1466 return $GLOBALS['full_version'];
1469 // "Getter" for title
1470 function getTitle () {
1471 // Do we have cache?
1472 if (!isset($GLOBALS['title'])) {
1474 $GLOBALS['title'] = getConfig('TITLE');
1478 return $GLOBALS['title'];
1481 // "Getter" for curr_svn_revision
1482 function getCurrSvnRevision () {
1483 // Do we have cache?
1484 if (!isset($GLOBALS['curr_svn_revision'])) {
1486 $GLOBALS['curr_svn_revision'] = getConfig('CURR_SVN_REVISION');
1490 return $GLOBALS['curr_svn_revision'];
1493 // "Getter" for server_url
1494 function getServerUrl () {
1495 // Do we have cache?
1496 if (!isset($GLOBALS['server_url'])) {
1498 $GLOBALS['server_url'] = getConfig('SERVER_URL');
1502 return $GLOBALS['server_url'];
1505 // "Getter" for mt_word
1506 function getMtWord () {
1507 // Do we have cache?
1508 if (!isset($GLOBALS['mt_word'])) {
1510 $GLOBALS['mt_word'] = getConfig('mt_word');
1514 return $GLOBALS['mt_word'];
1517 // "Getter" for mt_word2
1518 function getMtWord2 () {
1519 // Do we have cache?
1520 if (!isset($GLOBALS['mt_word2'])) {
1522 $GLOBALS['mt_word2'] = getConfig('mt_word2');
1526 return $GLOBALS['mt_word2'];
1529 // "Getter" for main_title
1530 function getMainTitle () {
1531 // Do we have cache?
1532 if (!isset($GLOBALS['main_title'])) {
1534 $GLOBALS['main_title'] = getConfig('MAIN_TITLE');
1538 return $GLOBALS['main_title'];
1541 // "Getter" for file_hash
1542 function getFileHash () {
1543 // Do we have cache?
1544 if (!isset($GLOBALS['file_hash'])) {
1546 $GLOBALS['file_hash'] = getConfig('file_hash');
1550 return $GLOBALS['file_hash'];
1553 // "Getter" for pass_scramble
1554 function getPassScramble () {
1555 // Do we have cache?
1556 if (!isset($GLOBALS['pass_scramble'])) {
1558 $GLOBALS['pass_scramble'] = getConfig('pass_scramble');
1562 return $GLOBALS['pass_scramble'];
1565 // "Getter" for ap_inactive_since
1566 function getApInactiveSince () {
1567 // Do we have cache?
1568 if (!isset($GLOBALS['ap_inactive_since'])) {
1570 $GLOBALS['ap_inactive_since'] = getConfig('ap_inactive_since');
1574 return $GLOBALS['ap_inactive_since'];
1577 // "Getter" for user_min_confirmed
1578 function getUserMinConfirmed () {
1579 // Do we have cache?
1580 if (!isset($GLOBALS['user_min_confirmed'])) {
1582 $GLOBALS['user_min_confirmed'] = getConfig('user_min_confirmed');
1586 return $GLOBALS['user_min_confirmed'];
1589 // "Getter" for auto_purge
1590 function getAutoPurge () {
1591 // Do we have cache?
1592 if (!isset($GLOBALS['auto_purge'])) {
1594 $GLOBALS['auto_purge'] = getConfig('auto_purge');
1598 return $GLOBALS['auto_purge'];
1601 // "Getter" for bonus_userid
1602 function getBonusUserid () {
1603 // Do we have cache?
1604 if (!isset($GLOBALS['bonus_userid'])) {
1606 $GLOBALS['bonus_userid'] = getConfig('bonus_userid');
1610 return $GLOBALS['bonus_userid'];
1613 // "Getter" for ap_inactive_time
1614 function getApInactiveTime () {
1615 // Do we have cache?
1616 if (!isset($GLOBALS['ap_inactive_time'])) {
1618 $GLOBALS['ap_inactive_time'] = getConfig('ap_inactive_time');
1622 return $GLOBALS['ap_inactive_time'];
1625 // "Getter" for ap_dm_timeout
1626 function getApDmTimeout () {
1627 // Do we have cache?
1628 if (!isset($GLOBALS['ap_dm_timeout'])) {
1630 $GLOBALS['ap_dm_timeout'] = getConfig('ap_dm_timeout');
1634 return $GLOBALS['ap_dm_timeout'];
1637 // "Getter" for ap_tasks_time
1638 function getApTasksTime () {
1639 // Do we have cache?
1640 if (!isset($GLOBALS['ap_tasks_time'])) {
1642 $GLOBALS['ap_tasks_time'] = getConfig('ap_tasks_time');
1646 return $GLOBALS['ap_tasks_time'];
1649 // "Getter" for ap_unconfirmed_time
1650 function getApUnconfirmedTime () {
1651 // Do we have cache?
1652 if (!isset($GLOBALS['ap_unconfirmed_time'])) {
1654 $GLOBALS['ap_unconfirmed_time'] = getConfig('ap_unconfirmed_time');
1658 return $GLOBALS['ap_unconfirmed_time'];
1661 // "Getter" for points
1662 function getPoints () {
1663 // Do we have cache?
1664 if (!isset($GLOBALS['points'])) {
1666 $GLOBALS['points'] = getConfig('POINTS');
1670 return $GLOBALS['points'];
1673 // "Getter" for slogan
1674 function getSlogan () {
1675 // Do we have cache?
1676 if (!isset($GLOBALS['slogan'])) {
1678 $GLOBALS['slogan'] = getConfig('SLOGAN');
1682 return $GLOBALS['slogan'];
1685 // "Getter" for copy
1686 function getCopy () {
1687 // Do we have cache?
1688 if (!isset($GLOBALS['copy'])) {
1690 $GLOBALS['copy'] = getConfig('COPY');
1694 return $GLOBALS['copy'];
1697 // "Getter" for webmaster
1698 function getWebmaster () {
1699 // Do we have cache?
1700 if (!isset($GLOBALS['webmaster'])) {
1702 $GLOBALS['webmaster'] = getConfig('WEBMASTER');
1706 return $GLOBALS['webmaster'];
1709 // "Getter" for sql_count
1710 function getSqlCount () {
1711 // Do we have cache?
1712 if (!isset($GLOBALS['sql_count'])) {
1714 $GLOBALS['sql_count'] = getConfig('sql_count');
1718 return $GLOBALS['sql_count'];
1721 // "Getter" for num_templates
1722 function getNumTemplates () {
1723 // Do we have cache?
1724 if (!isset($GLOBALS['num_templates'])) {
1726 $GLOBALS['num_templates'] = getConfig('num_templates');
1730 return $GLOBALS['num_templates'];
1733 // "Getter" for dns_cache_timeout
1734 function getDnsCacheTimeout () {
1735 // Do we have cache?
1736 if (!isset($GLOBALS['dns_cache_timeout'])) {
1738 $GLOBALS['dns_cache_timeout'] = getConfig('dns_cache_timeout');
1742 return $GLOBALS['dns_cache_timeout'];
1745 // "Getter" for menu_blur_spacer
1746 function getMenuBlurSpacer () {
1747 // Do we have cache?
1748 if (!isset($GLOBALS['menu_blur_spacer'])) {
1750 $GLOBALS['menu_blur_spacer'] = getConfig('menu_blur_spacer');
1754 return $GLOBALS['menu_blur_spacer'];
1757 // "Getter" for points_register
1758 function getPointsRegister () {
1759 // Do we have cache?
1760 if (!isset($GLOBALS['points_register'])) {
1762 $GLOBALS['points_register'] = getConfig('points_register');
1766 return $GLOBALS['points_register'];
1769 // "Getter" for points_ref
1770 function getPointsRef () {
1771 // Do we have cache?
1772 if (!isset($GLOBALS['points_ref'])) {
1774 $GLOBALS['points_ref'] = getConfig('points_ref');
1778 return $GLOBALS['points_ref'];
1781 // "Getter" for ref_payout
1782 function getRefPayout () {
1783 // Do we have cache?
1784 if (!isset($GLOBALS['ref_payout'])) {
1786 $GLOBALS['ref_payout'] = getConfig('ref_payout');
1790 return $GLOBALS['ref_payout'];
1793 // "Getter" for online_timeout
1794 function getOnlineTimeout () {
1795 // Do we have cache?
1796 if (!isset($GLOBALS['online_timeout'])) {
1798 $GLOBALS['online_timeout'] = getConfig('online_timeout');
1802 return $GLOBALS['online_timeout'];
1805 // "Getter" for index_home
1806 function getIndexHome () {
1807 // Do we have cache?
1808 if (!isset($GLOBALS['index_home'])) {
1810 $GLOBALS['index_home'] = getConfig('index_home');
1814 return $GLOBALS['index_home'];
1817 // Checks wether proxy configuration is used
1818 function isProxyUsed () {
1819 // Do we have cache?
1820 if (!isset($GLOBALS['is_proxy_used'])) {
1822 $GLOBALS['is_proxy_used'] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1826 return $GLOBALS['is_proxy_used'];
1829 // Checks wether POST data contains selections
1830 function ifPostContainsSelections ($element = 'sel') {
1831 // Do we have cache?
1832 if (!isset($GLOBALS['post_contains_selections'][$element])) {
1834 $GLOBALS['post_contains_selections'][$element] = (countPostSelection($element) > 0);
1838 return $GLOBALS['post_contains_selections'][$element];
1841 // Checks wether verbose_sql is Y and returns true/false if so
1842 function isVerboseSqlEnabled () {
1843 // Do we have cache?
1844 if (!isset($GLOBALS['is_verbose_sql_enabled'])) {
1846 $GLOBALS['is_verbose_sql_enabled'] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1850 return $GLOBALS['is_verbose_sql_enabled'];
1853 // "Getter" for total user points
1854 function getTotalPoints ($userid) {
1855 // Do we have cache?
1856 if (!isset($GLOBALS['total_points'][$userid])) {
1858 $GLOBALS['total_points'][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
1862 return $GLOBALS['total_points'][$userid];
1865 // Wrapper to check if url_blacklist is enabled
1866 function isUrlBlacklistEnabled () {
1867 // Do we have cache?
1868 if (!isset($GLOBALS['is_url_blacklist_enabled'])) {
1870 $GLOBALS['is_url_blacklist_enabled'] = (getConfig('url_blacklist') == 'Y');
1874 return $GLOBALS['is_url_blacklist_enabled'];
1877 // Checks wether direct payment is allowed in configuration
1878 function isDirectPaymentAllowed () {
1879 // Do we have cache?
1880 if (!isset($GLOBALS['is_direct_payment_allowed'])) {
1882 $GLOBALS['is_direct_payment_allowed'] = (getConfig('allow_direct_pay') == 'Y');
1886 return $GLOBALS['is_direct_payment_allowed'];
1889 // Wrapper to check if current task is for extension (not update)
1890 function isExtensionTask ($content) {
1891 // Do we have cache?
1892 if (!isset($GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']])) {
1894 $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
1898 return $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']];