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 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
39 function readFromFile ($FQFN) {
40 // Sanity-check if file is there (should be there, but just to make it sure)
41 if (!isFileReadable($FQFN)) {
42 // This should not happen
43 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
47 if (function_exists('file_get_contents')) {
49 $fileContent = file_get_contents($FQFN);
51 // Fall-back to implode-file chain
52 $fileContent = implode('', file($FQFN));
59 // Writes content to a file
60 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
61 // Is the file writeable?
62 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
64 logDebugMessage(__FUNCTION__, __LINE__, sprintf('File %s not writeable or cannot change CHMOD to 0644.', basename($FQFN)));
70 // By default all is failed...
71 $GLOBALS['file_readable'][$FQFN] = FALSE;
74 // Is the function there?
75 if (function_exists('file_put_contents')) {
77 if ($aquireLock === TRUE) {
78 // Write it directly with lock
79 $return = file_put_contents($FQFN, $content, LOCK_EX);
82 $return = file_put_contents($FQFN, $content);
85 // Write it with fopen
86 $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
89 if ($aquireLock === TRUE) {
95 $return = fwrite($fp, $content);
101 // Was something written?
102 if ($return !== FALSE) {
103 // Mark it as readable
104 $GLOBALS['file_readable'][$FQFN] = TRUE;
108 return (($return !== FALSE) && (changeMode($FQFN, 0644)));
111 // Clears the output buffer. This function does *NOT* backup sent content.
112 function clearOutputBuffer () {
113 // Make sure this function is not called twice (no double-cleaning!)
114 if (isset($GLOBALS[__FUNCTION__])) {
115 // This function is called twice
116 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
117 } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
119 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
122 // Mark this function as called
123 $GLOBALS[__FUNCTION__] = TRUE;
127 function encodeString ($str) {
128 $str = urlencode(base64_encode(compileUriCode($str)));
132 // Decode strings encoded with encodeString()
133 function decodeString ($str) {
134 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
138 // Decode entities in a nicer way
139 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
140 // Decode the entities to UTF-8 now
141 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
143 // Return decoded string
144 return $decodedString;
147 // Merges an array together but only if both are arrays
148 function merge_array ($array1, $array2, $keepIndex = FALSE) {
149 // Are both an array?
150 if ((!is_array($array1)) && (!is_array($array2))) {
151 // Both are not arrays
152 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
153 } elseif (!is_array($array1)) {
154 // Left one is not an array
155 reportBug(__FUNCTION__, __LINE__, sprintf('array1 is not an array. array != %s', gettype($array1)));
156 } elseif (!is_array($array2)) {
157 // Right one is not an array
158 reportBug(__FUNCTION__, __LINE__, sprintf('array2 is not an array. array != %s', gettype($array2)));
161 // Maintain index of array2?
162 if ($keepIndex === TRUE) {
163 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
164 foreach ($array2 as $key => $value) {
166 $array1[$key] = $value;
172 // Merge both together normally
173 return array_merge($array1, $array2);
177 // Check if given FQFN is a readable file
178 function isFileReadable ($FQFN) {
180 if (!isset($GLOBALS['file_readable'][$FQFN])) {
182 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
186 return $GLOBALS['file_readable'][$FQFN];
189 // Checks whether the given FQFN is a directory and not ., .. or .svn
190 function isDirectory ($FQFN) {
192 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
194 $baseName = basename($FQFN);
197 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
201 return $GLOBALS[__FUNCTION__][$FQFN];
204 // "Getter" for the real remote IP number
205 function detectRealIpAddress ($alwaysReal = FALSE) {
206 // Get remote ip from environment
207 $remoteAddr = determineRealRemoteAddress();
209 // Is removeip installed?
210 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
212 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
219 // "Getter" for remote IP number
220 function detectRemoteAddr ($alwaysReal = FALSE) {
221 // Get remote ip from environment
222 $remoteAddr = determineRealRemoteAddress(TRUE);
224 // Is removeip installed?
225 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
227 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
234 // "Getter" for remote hostname
235 function detectRemoteHostname ($alwaysReal = FALSE) {
236 // Get remote ip from environment
237 $remoteHost = getenv('REMOTE_HOST');
239 // Is removeip installed?
240 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
242 $remoteHost = getAnonymousRemoteHost($remoteHost);
249 // "Getter" for user agent
250 function detectUserAgent ($alwaysReal = FALSE) {
251 // Get remote ip from environment
252 $userAgent = getenv('HTTP_USER_AGENT');
254 // Is removeip installed?
255 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
257 $userAgent = getAnonymousUserAgent($userAgent);
264 // "Getter" for referer
265 function detectReferer ($alwaysReal = FALSE) {
266 // Get remote ip from environment
267 $referer = getenv('HTTP_REFERER');
269 // Is removeip installed?
270 if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
272 $referer = getAnonymousReferer($referer);
279 // "Getter" for request URI
280 function detectRequestUri () {
282 return (getenv('REQUEST_URI'));
285 // "Getter" for query string
286 function detectQueryString () {
287 return str_replace('&', '&', (getenv('QUERY_STRING')));
290 // "Getter" for SERVER_NAME
291 function detectServerName () {
293 return (getenv('SERVER_NAME'));
296 // Removes any existing www. from SERVER_NAME. This is very silly but enough
297 // for our purpose here.
298 function detectDomainName () {
300 if (!isset($GLOBALS[__FUNCTION__])) {
302 $domainName = detectServerName();
304 // Is there any www. ?
305 if (substr($domainName, 0, 4) == 'www.') {
307 $domainName = substr($domainName, 4);
311 $GLOBALS[__FUNCTION__] = $domainName;
315 return $GLOBALS[__FUNCTION__];
318 // Check whether we are installing
319 function isInstalling () {
320 // Determine whether we are installing
321 if (!isset($GLOBALS['__mailer_installing'])) {
322 // Check URL (css.php/js.php need this)
323 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isAjaxOutputMode()) && (isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
327 return $GLOBALS['__mailer_installing'];
330 // Check whether this script is installed
331 function isInstalled () {
333 if (!isset($GLOBALS[__FUNCTION__])) {
334 // Determine whether this script is installed
335 $GLOBALS[__FUNCTION__] = (
340 isConfigEntrySet('MAILER_INSTALLED')
342 getConfig('MAILER_INSTALLED') == 'Y'
346 // New config file found and loaded
347 isIncludeReadable(getCachePath() . 'config-local.php')
350 // New config file found, but not yet read
351 isIncludeReadable(getCachePath() . 'config-local.php')
354 // Only new config file is found
355 !isIncludeReadable('inc/config.php')
357 // Is installation mode
364 // Then use the cache
365 return $GLOBALS[__FUNCTION__];
368 // Check whether an admin is registered
369 function isAdminRegistered () {
371 if (!isset($GLOBALS[__FUNCTION__])) {
373 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
377 return $GLOBALS[__FUNCTION__];
380 // Checks whether the hourly reset mode is active
381 function isHourlyResetEnabled () {
382 // Now simply check it
383 return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
386 // Checks whether the daily reset mode is active
387 function isDailyResetEnabled () {
388 // Now simply check it
389 return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
392 // Checks whether the weekly reset mode is active
393 function isWeeklyResetEnabled () {
394 // Now simply check it
395 return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
398 // Checks whether the monthly reset mode is active
399 function isMonthlyResetEnabled () {
400 // Now simply check it
401 return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
404 // Checks whether the yearly reset mode is active
405 function isYearlyResetEnabled () {
406 // Now simply check it
407 return ((isset($GLOBALS['yearly_enabled'])) && ($GLOBALS['yearly_enabled'] === TRUE));
410 // Checks whether one of the reset modes is enabled
411 function isResetModeEnabled () {
412 // Now simply check it
413 return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()) || (isYearlyResetEnabled()));
416 // Checks whether the debug mode is enabled
417 function isDebugModeEnabled () {
419 if (!isset($GLOBALS[__FUNCTION__])) {
421 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
425 return $GLOBALS[__FUNCTION__];
428 // Checks whether the debug hourly is enabled
429 function isDebugHourlyEnabled () {
431 if (!isset($GLOBALS[__FUNCTION__])) {
433 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
437 return $GLOBALS[__FUNCTION__];
440 // Checks whether the debug daily is enabled
441 function isDebugDailyEnabled () {
443 if (!isset($GLOBALS[__FUNCTION__])) {
445 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
449 return $GLOBALS[__FUNCTION__];
452 // Checks whether the debug weekly is enabled
453 function isDebugWeeklyEnabled () {
455 if (!isset($GLOBALS[__FUNCTION__])) {
457 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
461 return $GLOBALS[__FUNCTION__];
464 // Checks whether the debug monthly is enabled
465 function isDebugMonthlyEnabled () {
467 if (!isset($GLOBALS[__FUNCTION__])) {
469 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
473 return $GLOBALS[__FUNCTION__];
476 // Checks whether the debug yearly is enabled
477 function isDebugYearlyEnabled () {
479 if (!isset($GLOBALS[__FUNCTION__])) {
481 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
485 return $GLOBALS[__FUNCTION__];
488 // Checks whether SQL debugging is enabled
489 function isSqlDebuggingEnabled () {
491 if (!isset($GLOBALS[__FUNCTION__])) {
492 // Determine if SQL debugging is enabled
493 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
497 return $GLOBALS[__FUNCTION__];
500 // Checks whether we shall debug regular expressions
501 function isDebugRegularExpressionEnabled () {
503 if (!isset($GLOBALS[__FUNCTION__])) {
505 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
509 return $GLOBALS[__FUNCTION__];
512 // Checks whether debugging of build mails is enabled
513 function isDebugBuildMailsEnabled () {
515 if (!isset($GLOBALS[__FUNCTION__])) {
517 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
521 return $GLOBALS[__FUNCTION__];
524 // Checks whether the cache instance is valid
525 function isValidCacheInstance () {
527 if (!isset($GLOBALS[__FUNCTION__])) {
529 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
533 return $GLOBALS[__FUNCTION__];
536 // Copies a file from source to destination and verifies if that goes fine.
537 // This function should wrap the copy() command and make a nicer debug backtrace
538 // even if there is no xdebug extension installed.
539 function copyFileVerified ($source, $dest, $chmod = '') {
540 // Failed is the default
543 // Is the source file there?
544 if (!isFileReadable($source)) {
546 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
549 // Is the target directory there?
550 if (!isDirectory(dirname($dest))) {
552 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
555 // Now try to copy it
556 if (!copy($source, $dest)) {
557 // Something went wrong
558 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
561 $GLOBALS['file_readable'][$dest] = TRUE;
564 // All fine by default
567 // If there are chmod rights set, apply them
568 if (!empty($chmod)) {
570 $status = changeMode($dest, $chmod);
577 // Wrapper function for chmod()
578 // @TODO Do some more sanity check here
579 function changeMode ($FQFN, $mode) {
580 // Is the file/directory there?
581 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
582 // Neither, so abort here
583 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
587 return chmod($FQFN, $mode);
590 // Wrapper for unlink()
591 function removeFile ($FQFN) {
592 // Is the file there?
593 if (isFileReadable($FQFN)) {
595 $GLOBALS['file_readable'][$FQFN] = FALSE;
598 return unlink($FQFN);
601 // All fine if no file was removed. If we change this to 'false' or rewrite
602 // above if() block it would be to restrictive.
606 // Wrapper for $_POST['sel']
607 function countPostSelection ($element = 'sel') {
609 if (!isset($GLOBALS[__FUNCTION__][$element])) {
611 $GLOBALS[__FUNCTION__][$element] = '0';
614 if (isPostRequestElementSet($element)) {
615 // Return counted elements
616 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
620 // Return cached value
621 return $GLOBALS[__FUNCTION__][$element];
624 // Checks whether the config-local.php is loaded
625 function isConfigLocalLoaded () {
626 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
629 // Checks whether a nickname or userid was entered and caches the result
630 function isNicknameUsed ($userid) {
631 // Is the cache there
632 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
634 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
638 return $GLOBALS[__FUNCTION__][$userid];
641 // Getter for 'what' value
642 function getWhat ($strict = TRUE) {
647 if (isWhatSet($strict)) {
649 $what = $GLOBALS['__what'];
656 // Setter for 'what' value
657 function setWhat ($newWhat) {
658 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
659 $GLOBALS['__what'] = $newWhat;
662 // Setter for 'what' from configuration
663 function setWhatFromConfig ($configEntry) {
664 // Get 'what' from config
665 $what = getConfig($configEntry);
671 // Checks whether what is set and optionally aborts on miss
672 function isWhatSet ($strict = FALSE) {
674 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
676 // Should we abort here?
677 if (($strict === TRUE) && ($isset === FALSE)) {
679 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
686 // Getter for 'action' value
687 function getAction ($strict = TRUE) {
692 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
694 $action = $GLOBALS['__action'];
701 // Setter for 'action' value
702 function setAction ($newAction) {
703 $GLOBALS['__action'] = $newAction;
706 // Checks whether action is set and optionally aborts on miss
707 function isActionSet ($strict = FALSE) {
709 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
711 // Should we abort here?
712 if (($strict === TRUE) && ($isset === FALSE)) {
714 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
721 // Getter for 'module' value
722 function getModule ($strict = TRUE) {
727 if (isModuleSet($strict)) {
729 $module = $GLOBALS['__module'];
736 // Setter for 'module' value
737 function setModule ($newModule) {
738 // Secure it and make all modules lower-case
739 $GLOBALS['__module'] = strtolower($newModule);
742 // Wrapper to get extra module names
743 function getExtraModule () {
747 // Is 'tab/step' set?
748 if (isPostRequestElementSet('tab')) {
750 $extra = 'tab=' . postRequestElement('tab');
751 } elseif (isPostRequestElementSet('step')) {
753 $extra = 'step=' . postRequestElement('step');
754 } elseif ((isActionSet()) && (isWhatSet())) {
756 $extra = 'action=' . getAction() . ':what=' . getWhat();
763 // Checks whether module is set and optionally aborts on miss
764 function isModuleSet ($strict = FALSE) {
766 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
768 // Should we abort here?
769 if (($strict === TRUE) && ($isset === FALSE)) {
771 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
775 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
778 // Getter for 'output_mode' value
779 function getScriptOutputMode () {
781 if (!isset($GLOBALS[__FUNCTION__])) {
782 // Is the output mode set?
783 if (!isOutputModeSet()) {
784 // No, then abort here
785 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
789 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
793 return $GLOBALS[__FUNCTION__];
796 // Setter for 'output_mode' value
797 function setScriptOutputMode ($newOutputMode) {
798 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
799 $GLOBALS['__output_mode'] = (int) $newOutputMode;
802 // Checks whether output_mode is set and optionally aborts on miss
803 function isOutputModeSet ($strict = FALSE) {
805 $isset = (isset($GLOBALS['__output_mode']));
807 // Should we abort here?
808 if (($strict === TRUE) && ($isset === FALSE)) {
810 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
817 // Enables block-mode
818 function enableBlockMode ($enabled = TRUE) {
819 $GLOBALS['__block_mode'] = $enabled;
822 // Checks whether block-mode is enabled
823 function isBlockModeEnabled () {
825 if (!isset($GLOBALS['__block_mode'])) {
827 reportBug(__FUNCTION__, __LINE__, '__block_mode is not set.');
831 return $GLOBALS['__block_mode'];
834 // Wrapper for redirectToUrl but URL comes from a configuration entry
835 function redirectToConfiguredUrl ($configEntry) {
837 redirectToUrl(getConfig($configEntry));
840 // Wrapper function to redirect from member-only modules to index
841 function redirectToIndexMemberOnlyModule () {
842 // Do the redirect here
843 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
846 // Wrapper function to redirect to current URL
847 function redirectToRequestUri () {
848 redirectToUrl(basename(detectRequestUri()));
851 // Wrapper function to redirect to de-refered URL
852 function redirectToDereferedUrl ($url) {
854 redirectToUrl(generateDereferrerUrl($url));
857 // Wrapper function for checking if extension is installed and newer or same version
858 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
859 // Is an cache entry found?
860 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
862 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
864 // Cache hits should be incremented twice
865 incrementStatsEntry('cache_hits', 2);
869 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
870 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
873 // Wrapper function for checking if extension is installed and older than given version
874 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
875 // Is an cache entry found?
876 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
878 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
880 // Cache hits should be incremented twice
881 incrementStatsEntry('cache_hits', 2);
885 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
886 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
890 function setUsername ($userName) {
891 $GLOBALS['username'] = (string) $userName;
895 function getUsername () {
897 if (!isset($GLOBALS['username'])) {
898 // No, so it has to be a guest
899 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
903 return $GLOBALS['username'];
906 // Wrapper function for installation phase
907 function isInstaller () {
909 if (!isset($GLOBALS[__FUNCTION__])) {
911 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
915 return $GLOBALS[__FUNCTION__];
918 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
919 function isDemoModeActive () {
921 if (!isset($GLOBALS[__FUNCTION__])) {
923 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
927 return $GLOBALS[__FUNCTION__];
930 // Getter for PHP caching value
931 function getPhpCaching () {
932 return $GLOBALS['php_caching'];
935 // Checks whether the admin hash is set
936 function isAdminHashSet ($adminId) {
937 // Is the array there?
938 if (!isset($GLOBALS['cache_array']['admin'])) {
939 // Missing array should be reported
940 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
943 // Check for admin hash
944 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
947 // Setter for admin hash
948 function setAdminHash ($adminId, $hash) {
949 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
952 // Getter for current admin login
953 function getCurrentAdminLogin () {
955 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
958 if (!isset($GLOBALS[__FUNCTION__])) {
960 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
964 return $GLOBALS[__FUNCTION__];
967 // Setter for admin id (and current)
968 function setAdminId ($adminId) {
970 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
973 $status = setSession('admin_id', bigintval($adminId));
976 setCurrentAdminId($adminId);
982 // Setter for admin_last
983 function setAdminLast ($adminLast) {
985 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
988 $status = setSession('admin_last', $adminLast);
994 // Setter for admin_md5
995 function setAdminMd5 ($adminMd5) {
997 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
1000 $status = setSession('admin_md5', $adminMd5);
1006 // Getter for admin_md5
1007 function getAdminMd5 () {
1008 // Log debug message
1009 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1012 return getSession('admin_md5');
1015 // Init user data array
1016 function initUserData () {
1017 // User id should not be zero
1018 if (!isValidId(getCurrentUserId())) {
1019 // Should be always valid
1020 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1024 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1025 $GLOBALS['user_data'][getCurrentUserId()] = array();
1028 // Getter for user data
1029 function getUserData ($column) {
1030 // User id should not be zero
1031 if (!isValidId(getCurrentUserId())) {
1032 // Should be always valid
1033 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1039 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1041 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1048 // Checks whether given user data is set to 'Y'
1049 function isUserDataEnabled ($column) {
1051 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1053 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1057 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1060 // Geter for whole user data array
1061 function getUserDataArray () {
1063 $userid = getCurrentUserId();
1065 // Is the current userid valid?
1066 if (!isValidId($userid)) {
1067 // Should be always valid
1068 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1071 // Get the whole array if found
1072 if (isset($GLOBALS['user_data'][$userid])) {
1073 // Found, so return it
1074 return $GLOBALS['user_data'][$userid];
1076 // Return empty array
1081 // Checks if the user data is valid, this may indicate that the user has logged
1082 // in, but you should use isMember() if you want to find that out.
1083 function isValidUserData () {
1084 // User id should not be zero so abort here
1085 if (!isCurrentUserIdSet()) {
1086 // Debug message, may be noisy
1087 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1094 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1096 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1099 // Return the result
1100 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1103 // Setter for current userid
1104 function setCurrentUserId ($userid) {
1106 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1108 // Is the cache from below functions different?
1109 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1111 unsetCurrentUserId();
1115 $GLOBALS['current_userid'] = bigintval($userid);
1117 // Unset it to re-determine the actual state
1118 unset($GLOBALS['is_userdata_valid'][$userid]);
1121 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1124 // Getter for current userid
1125 function getCurrentUserId () {
1127 if (!isset($GLOBALS[__FUNCTION__])) {
1128 // Userid must be set before it can be used
1129 if (!isCurrentUserIdSet()) {
1131 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1134 // Set userid in cache
1135 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1139 return $GLOBALS[__FUNCTION__];
1142 // Checks if current userid is set
1143 function isCurrentUserIdSet () {
1145 if (!isset($GLOBALS[__FUNCTION__])) {
1147 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1151 return $GLOBALS[__FUNCTION__];
1154 // Unsets current userid
1155 function unsetCurrentUserId () {
1157 if (isset($GLOBALS['current_userid'])) {
1159 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1162 // Unset all cache entries
1163 unset($GLOBALS['current_userid']);
1164 unset($GLOBALS['getCurrentUserId']);
1165 unset($GLOBALS['isCurrentUserIdSet']);
1168 // Checks whether we are debugging template cache
1169 function isDebugTemplateCacheEnabled () {
1171 if (!isset($GLOBALS[__FUNCTION__])) {
1173 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_TEMPLATE_CACHE')) && (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'));
1177 return $GLOBALS[__FUNCTION__];
1180 // Wrapper for fetchUserData() and getUserData() calls
1181 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1182 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1184 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1188 // Can we fetch the user data?
1189 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1190 // Now get the data back
1191 $data = getUserData($valueColumn);
1195 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1199 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1200 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1203 // Wrapper for strpos() to ease porting from deprecated ereg() function
1204 function isInString ($needle, $haystack) {
1205 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1206 return (strpos($haystack, $needle) !== FALSE);
1209 // Wrapper for strpos() to ease porting from deprecated eregi() function
1210 // This function is case-insensitive
1211 function isInStringIgnoreCase ($needle, $haystack) {
1212 return (isInString(strtolower($needle), strtolower($haystack)));
1215 // Wrapper to check for if fatal errors where detected
1216 function ifFatalErrorsDetected () {
1217 // Just call the inner function
1218 return (getTotalFatalErrors() > 0);
1221 // Checks whether a HTTP status has been set
1222 function isHttpStatusSet () {
1223 // Is it set and not empty?
1224 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1227 // Setter for HTTP status
1228 function setHttpStatus ($status) {
1229 $GLOBALS['http_status'] = (string) $status;
1232 // Getter for HTTP status
1233 function getHttpStatus () {
1234 // Is the status set?
1235 if (!isHttpStatusSet()) {
1237 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1241 return $GLOBALS['http_status'];
1245 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1246 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1248 * ----------------------------------------------------------------------------
1249 * If you want to redirect, please use redirectToUrl(); instead
1250 * ----------------------------------------------------------------------------
1252 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1254 * @link http://support.microsoft.com/kb/q176113/
1255 * @author Andreas Gohr <andi@splitbrain.org>
1258 function sendRawRedirect ($url) {
1259 // Clear output buffer
1260 clearOutputBuffer();
1262 // Clear own output buffer
1263 $GLOBALS['__output'] = '';
1265 // To make redirects working (no content type), output mode must be raw
1266 setScriptOutputMode(-1);
1268 // Send helping header
1269 setHttpStatus('302 Found');
1271 // always close the session
1272 session_write_close();
1274 // Revert entity &
1275 $url = str_replace('&', '&', $url);
1277 // check if running on IIS < 6 with CGI-PHP
1278 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1279 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1280 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1281 ($matches[1] < 6)) {
1282 // Send the IIS header
1283 addHttpHeader('Refresh: 0;url=' . $url);
1285 // Send generic header
1286 addHttpHeader('Location: ' . $url);
1293 // Determines the country of the given user id
1294 function determineCountry ($userid) {
1296 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1297 // Default is 'invalid'
1298 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1300 // Is extension country active?
1301 if (isExtensionActive('country')) {
1302 // Determine the right country code through the country id
1303 $id = getUserData('country_code');
1305 // Then handle it over
1306 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1308 // Get raw code from user data
1309 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1314 return $GLOBALS[__FUNCTION__][$userid];
1317 // "Getter" for total confirmed user accounts
1318 function getTotalConfirmedUser () {
1320 if (!isset($GLOBALS[__FUNCTION__])) {
1322 if (isExtensionActive('user')) {
1323 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1325 $GLOBALS[__FUNCTION__] = 0;
1329 // Return cached value
1330 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1331 return $GLOBALS[__FUNCTION__];
1334 // "Getter" for total unconfirmed user accounts
1335 function getTotalUnconfirmedUser () {
1337 if (!isset($GLOBALS[__FUNCTION__])) {
1339 if (isExtensionActive('user')) {
1340 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1342 $GLOBALS[__FUNCTION__] = 0;
1346 // Return cached value
1347 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1348 return $GLOBALS[__FUNCTION__];
1351 // "Getter" for total locked user accounts
1352 function getTotalLockedUser () {
1354 if (!isset($GLOBALS[__FUNCTION__])) {
1356 if (isExtensionActive('user')) {
1357 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1359 $GLOBALS[__FUNCTION__] = 0;
1363 // Return cached value
1364 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1365 return $GLOBALS[__FUNCTION__];
1368 // "Getter" for total locked user accounts
1369 function getTotalRandomRefidUser () {
1371 if (!isset($GLOBALS[__FUNCTION__])) {
1373 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1374 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1376 $GLOBALS[__FUNCTION__] = 0;
1380 // Return cached value
1381 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1382 return $GLOBALS[__FUNCTION__];
1385 // Is given id number valid?
1386 function isValidId ($id) {
1388 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1391 if (!isset($GLOBALS[__FUNCTION__][$id])) {
1393 $GLOBALS[__FUNCTION__][$id] = ((isValidNumber($id)) && (!is_bool($id)) && ($id != '00000') && ($id > 0));
1397 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1398 return $GLOBALS[__FUNCTION__][$id];
1401 // Checks whether a valid number is given
1402 function isValidNumber ($num) {
1404 return ((!is_null($num)) && (!empty($num)) && ('*' . bigintval($num, TRUE, FALSE) . '*' == '*' . $num . '*'));
1408 function encodeEntities ($str) {
1410 $str = secureString($str, TRUE, TRUE);
1412 // Encode dollar sign as well
1413 $str = str_replace('$', '$', $str);
1419 // Getter for current year (default)
1420 function getYear ($timestamp = NULL) {
1422 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1423 // If NULL is set, use time()
1424 if (is_null($timestamp)) {
1425 $timestamp = time();
1429 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1433 return $GLOBALS[__FUNCTION__][$timestamp];
1436 // Getter for current month (default)
1437 function getMonth ($timestamp = NULL) {
1439 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1440 // If NULL is set, use time()
1441 if (is_null($timestamp)) {
1442 // Use time() which is current timestamp
1443 $timestamp = time();
1447 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1451 return $GLOBALS[__FUNCTION__][$timestamp];
1454 // Getter for current hour (default)
1455 function getHour ($timestamp = NULL) {
1457 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1459 if (is_null($timestamp)) {
1460 $timestamp = time();
1464 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1468 return $GLOBALS[__FUNCTION__][$timestamp];
1471 // Getter for current day (default)
1472 function getDay ($timestamp = NULL) {
1474 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1476 if (is_null($timestamp)) {
1477 $timestamp = time();
1481 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1485 return $GLOBALS[__FUNCTION__][$timestamp];
1488 // Getter for current week (default)
1489 function getWeek ($timestamp = NULL) {
1491 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1493 if (is_null($timestamp)) $timestamp = time();
1496 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1500 return $GLOBALS[__FUNCTION__][$timestamp];
1503 // Getter for current short_hour (default)
1504 function getShortHour ($timestamp = NULL) {
1506 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1508 if (is_null($timestamp)) $timestamp = time();
1511 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1515 return $GLOBALS[__FUNCTION__][$timestamp];
1518 // Getter for current long_hour (default)
1519 function getLongHour ($timestamp = NULL) {
1521 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1523 if (is_null($timestamp)) $timestamp = time();
1526 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1530 return $GLOBALS[__FUNCTION__][$timestamp];
1533 // Getter for current second (default)
1534 function getSecond ($timestamp = NULL) {
1536 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1538 if (is_null($timestamp)) $timestamp = time();
1541 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1545 return $GLOBALS[__FUNCTION__][$timestamp];
1548 // Getter for current minute (default)
1549 function getMinute ($timestamp = NULL) {
1551 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1553 if (is_null($timestamp)) $timestamp = time();
1556 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1560 return $GLOBALS[__FUNCTION__][$timestamp];
1563 // Checks whether the title decoration is enabled
1564 function isTitleDecorationEnabled () {
1566 if (!isset($GLOBALS[__FUNCTION__])) {
1568 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_title_deco')) && (getConfig('enable_title_deco') == 'Y'));
1572 return $GLOBALS[__FUNCTION__];
1575 // Checks whether filter usage updates are enabled (expensive queries!)
1576 function isFilterUsageUpdateEnabled () {
1578 if (!isset($GLOBALS[__FUNCTION__])) {
1580 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1584 return $GLOBALS[__FUNCTION__];
1587 // Checks whether debugging of weekly resets is enabled
1588 function isWeeklyResetDebugEnabled () {
1590 if (!isset($GLOBALS[__FUNCTION__])) {
1592 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1596 return $GLOBALS[__FUNCTION__];
1599 // Checks whether debugging of monthly resets is enabled
1600 function isMonthlyResetDebugEnabled () {
1602 if (!isset($GLOBALS[__FUNCTION__])) {
1604 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1608 return $GLOBALS[__FUNCTION__];
1611 // Checks whether debugging of yearly resets is enabled
1612 function isYearlyResetDebugEnabled () {
1614 if (!isset($GLOBALS[__FUNCTION__])) {
1616 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
1620 return $GLOBALS[__FUNCTION__];
1623 // Checks whether displaying of debug SQLs are enabled
1624 function isDisplayDebugSqlEnabled () {
1626 if (!isset($GLOBALS[__FUNCTION__])) {
1628 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (isConfigEntrySet('display_debug_sql')) && (getDisplayDebugSqls() == 'Y'));
1632 return $GLOBALS[__FUNCTION__];
1635 // Checks whether module title is enabled
1636 function isModuleTitleEnabled () {
1638 if (!isset($GLOBALS[__FUNCTION__])) {
1640 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_mod_title')) && (getConfig('enable_mod_title') == 'Y'));
1644 return $GLOBALS[__FUNCTION__];
1647 // Checks whether what title is enabled
1648 function isWhatTitleEnabled () {
1650 if (!isset($GLOBALS[__FUNCTION__])) {
1652 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_what_title')) && (getConfig('enable_what_title') == 'Y'));
1656 return $GLOBALS[__FUNCTION__];
1659 // "Getter" for internal_stats
1660 function getInternalStats () {
1662 if (!isset($GLOBALS[__FUNCTION__])) {
1664 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1668 return $GLOBALS[__FUNCTION__];
1671 // Checks whether stats are enabled
1672 function ifInternalStatsEnabled () {
1674 if (!isset($GLOBALS[__FUNCTION__])) {
1675 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1676 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1679 // Return cached value
1680 return $GLOBALS[__FUNCTION__];
1683 // Checks whether admin-notification of certain user actions is enabled
1684 function isAdminNotificationEnabled () {
1686 if (!isset($GLOBALS[__FUNCTION__])) {
1688 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isConfigEntrySet('admin_notify')) && (getAdminNotify() == 'Y'));
1692 return $GLOBALS[__FUNCTION__];
1695 // Checks whether random referral id selection is enabled
1696 function isRandomReferralIdEnabled () {
1698 if (!isset($GLOBALS[__FUNCTION__])) {
1700 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isConfigEntrySet('select_user_zero_refid')) && (getSelectUserZeroRefid() == 'Y'));
1704 return $GLOBALS[__FUNCTION__];
1707 // "Getter" for default language
1708 function getDefaultLanguage () {
1710 if (!isset($GLOBALS[__FUNCTION__])) {
1712 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1716 return $GLOBALS[__FUNCTION__];
1719 // "Getter" for default referral id
1720 function getDefRefid () {
1722 if (!isset($GLOBALS[__FUNCTION__])) {
1724 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1728 return $GLOBALS[__FUNCTION__];
1731 // "Getter" for path
1732 function getPath () {
1734 if (!isset($GLOBALS[__FUNCTION__])) {
1736 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1740 return $GLOBALS[__FUNCTION__];
1744 function getUrl () {
1746 if (!isset($GLOBALS[__FUNCTION__])) {
1748 $GLOBALS[__FUNCTION__] = getConfig('URL');
1752 return $GLOBALS[__FUNCTION__];
1755 // "Getter" for cache_path
1756 function getCachePath () {
1758 if (!isset($GLOBALS[__FUNCTION__])) {
1760 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1764 return $GLOBALS[__FUNCTION__];
1767 // "Getter" for cache_extension
1768 function getCacheExtension () {
1770 if (!isset($GLOBALS[__FUNCTION__])) {
1772 $GLOBALS[__FUNCTION__] = getConfig('CACHE_EXTENSION');
1776 return $GLOBALS[__FUNCTION__];
1779 // "Getter" for WRITE_FOOTER
1780 function getWriteFooter () {
1782 if (!isset($GLOBALS[__FUNCTION__])) {
1784 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1788 return $GLOBALS[__FUNCTION__];
1791 // "Getter" for secret_key
1792 function getSecretKey () {
1794 if (!isset($GLOBALS[__FUNCTION__])) {
1796 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1800 return $GLOBALS[__FUNCTION__];
1803 // "Getter" for SITE_KEY
1804 function getSiteKey () {
1806 if (!isset($GLOBALS[__FUNCTION__])) {
1808 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1812 return $GLOBALS[__FUNCTION__];
1815 // "Getter" for DATE_KEY
1816 function getDateKey () {
1818 if (!isset($GLOBALS[__FUNCTION__])) {
1820 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1824 return $GLOBALS[__FUNCTION__];
1827 // "Getter" for master_salt
1828 function getMasterSalt () {
1830 if (!isset($GLOBALS[__FUNCTION__])) {
1832 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1836 return $GLOBALS[__FUNCTION__];
1839 // "Getter" for prime
1840 function getPrime () {
1842 if (!isset($GLOBALS[__FUNCTION__])) {
1844 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1848 return $GLOBALS[__FUNCTION__];
1851 // "Getter" for encrypt_separator
1852 function getEncryptSeparator () {
1854 if (!isset($GLOBALS[__FUNCTION__])) {
1856 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1860 return $GLOBALS[__FUNCTION__];
1863 // "Getter" for mysql_prefix
1864 function getMysqlPrefix () {
1866 if (!isset($GLOBALS[__FUNCTION__])) {
1868 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1872 return $GLOBALS[__FUNCTION__];
1875 // "Getter" for table_type
1876 function getTableType () {
1878 if (!isset($GLOBALS[__FUNCTION__])) {
1880 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1884 return $GLOBALS[__FUNCTION__];
1887 // "Getter" for db_type
1888 function getDbType () {
1890 if (!isset($GLOBALS[__FUNCTION__])) {
1892 $GLOBALS[__FUNCTION__] = getConfig('_DB_TYPE');
1896 return $GLOBALS[__FUNCTION__];
1899 // "Getter" for salt_length
1900 function getSaltLength () {
1902 if (!isset($GLOBALS[__FUNCTION__])) {
1904 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1908 return $GLOBALS[__FUNCTION__];
1911 // "Getter" for output_mode
1912 function getOutputMode () {
1914 if (!isset($GLOBALS[__FUNCTION__])) {
1916 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1920 return $GLOBALS[__FUNCTION__];
1923 // "Getter" for full_version
1924 function getFullVersion () {
1926 if (!isset($GLOBALS[__FUNCTION__])) {
1928 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1932 return $GLOBALS[__FUNCTION__];
1935 // "Getter" for title
1936 function getTitle () {
1938 if (!isset($GLOBALS[__FUNCTION__])) {
1940 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1944 return $GLOBALS[__FUNCTION__];
1947 // "Getter" for server_url
1948 function getServerUrl () {
1950 if (!isset($GLOBALS[__FUNCTION__])) {
1952 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1956 return $GLOBALS[__FUNCTION__];
1959 // "Getter" for mt_word
1960 function getMtWord () {
1962 if (!isset($GLOBALS[__FUNCTION__])) {
1964 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1968 return $GLOBALS[__FUNCTION__];
1971 // "Getter" for mt_word2
1972 function getMtWord2 () {
1974 if (!isset($GLOBALS[__FUNCTION__])) {
1976 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1980 return $GLOBALS[__FUNCTION__];
1983 // "Getter" for mt_word3
1984 function getMtWord3 () {
1986 if (!isset($GLOBALS[__FUNCTION__])) {
1988 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1992 return $GLOBALS[__FUNCTION__];
1995 // "Getter" for START_TDAY
1996 function getStartTday () {
1998 if (!isset($GLOBALS[__FUNCTION__])) {
2000 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
2004 return $GLOBALS[__FUNCTION__];
2007 // "Getter" for START_YDAY
2008 function getStartYday () {
2010 if (!isset($GLOBALS[__FUNCTION__])) {
2012 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
2016 return $GLOBALS[__FUNCTION__];
2019 // "Getter" for main_title
2020 function getMainTitle () {
2022 if (!isset($GLOBALS[__FUNCTION__])) {
2024 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2028 return $GLOBALS[__FUNCTION__];
2031 // "Getter" for file_hash
2032 function getFileHash () {
2034 if (!isset($GLOBALS[__FUNCTION__])) {
2036 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2040 return $GLOBALS[__FUNCTION__];
2043 // "Getter" for pass_scramble
2044 function getPassScramble () {
2046 if (!isset($GLOBALS[__FUNCTION__])) {
2048 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2052 return $GLOBALS[__FUNCTION__];
2055 // "Getter" for ap_inactive_since
2056 function getApInactiveSince () {
2058 if (!isset($GLOBALS[__FUNCTION__])) {
2060 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2064 return $GLOBALS[__FUNCTION__];
2067 // "Getter" for user_min_confirmed
2068 function getUserMinConfirmed () {
2070 if (!isset($GLOBALS[__FUNCTION__])) {
2072 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2076 return $GLOBALS[__FUNCTION__];
2078 // "Getter" for points
2079 function getPoints () {
2081 if (!isset($GLOBALS[__FUNCTION__])) {
2083 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2087 return $GLOBALS[__FUNCTION__];
2090 // "Getter" for slogan
2091 function getSlogan () {
2093 if (!isset($GLOBALS[__FUNCTION__])) {
2095 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2099 return $GLOBALS[__FUNCTION__];
2102 // "Getter" for copy
2103 function getCopy () {
2105 if (!isset($GLOBALS[__FUNCTION__])) {
2107 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2111 return $GLOBALS[__FUNCTION__];
2114 // "Getter" for webmaster
2115 function getWebmaster () {
2117 if (!isset($GLOBALS[__FUNCTION__])) {
2119 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2123 return $GLOBALS[__FUNCTION__];
2126 // "Getter" for sql_count
2127 function getSqlCount () {
2129 if (!isset($GLOBALS[__FUNCTION__])) {
2131 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2135 return $GLOBALS[__FUNCTION__];
2138 // "Getter" for num_templates
2139 function getNumTemplates () {
2141 if (!isset($GLOBALS[__FUNCTION__])) {
2143 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2147 return $GLOBALS[__FUNCTION__];
2150 // "Getter" for dns_cache_timeout
2151 function getDnsCacheTimeout () {
2153 if (!isset($GLOBALS[__FUNCTION__])) {
2155 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2159 return $GLOBALS[__FUNCTION__];
2162 // "Getter" for menu_blur_spacer
2163 function getMenuBlurSpacer () {
2165 if (!isset($GLOBALS[__FUNCTION__])) {
2167 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2171 return $GLOBALS[__FUNCTION__];
2174 // "Getter" for points_register
2175 function getPointsRegister () {
2177 if (!isset($GLOBALS[__FUNCTION__])) {
2179 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2183 return $GLOBALS[__FUNCTION__];
2186 // "Getter" for points_ref
2187 function getPointsRef () {
2189 if (!isset($GLOBALS[__FUNCTION__])) {
2191 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2195 return $GLOBALS[__FUNCTION__];
2198 // "Getter" for ref_payout
2199 function getRefPayout () {
2201 if (!isset($GLOBALS[__FUNCTION__])) {
2203 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2207 return $GLOBALS[__FUNCTION__];
2210 // "Getter" for online_timeout
2211 function getOnlineTimeout () {
2213 if (!isset($GLOBALS[__FUNCTION__])) {
2215 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2219 return $GLOBALS[__FUNCTION__];
2222 // "Getter" for index_home
2223 function getIndexHome () {
2225 if (!isset($GLOBALS[__FUNCTION__])) {
2227 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2231 return $GLOBALS[__FUNCTION__];
2234 // "Getter" for one_day
2235 function getOneDay () {
2237 if (!isset($GLOBALS[__FUNCTION__])) {
2239 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2243 return $GLOBALS[__FUNCTION__];
2246 // "Getter" for img_type
2247 function getImgType () {
2249 if (!isset($GLOBALS[__FUNCTION__])) {
2251 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2255 return $GLOBALS[__FUNCTION__];
2258 // "Getter" for code_length
2259 function getCodeLength () {
2261 if (!isset($GLOBALS[__FUNCTION__])) {
2263 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2267 return $GLOBALS[__FUNCTION__];
2270 // "Getter" for min_password_length
2271 function getMinPasswordLength () {
2273 if (!isset($GLOBALS[__FUNCTION__])) {
2275 $GLOBALS[__FUNCTION__] = getConfig('min_password_length');
2279 return $GLOBALS[__FUNCTION__];
2282 // "Getter" for min_password_score
2283 function getMinPasswordScore () {
2285 if (!isset($GLOBALS[__FUNCTION__])) {
2287 $GLOBALS[__FUNCTION__] = getConfig('min_password_score');
2291 return $GLOBALS[__FUNCTION__];
2294 // "Getter" for admin_menu
2295 function getAdminMenu () {
2297 if (!isset($GLOBALS[__FUNCTION__])) {
2299 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2303 return $GLOBALS[__FUNCTION__];
2306 // "Getter" for last_hourly
2307 function getLastHourly () {
2309 if (!isset($GLOBALS[__FUNCTION__])) {
2311 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2315 return $GLOBALS[__FUNCTION__];
2318 // "Getter" for last_daily
2319 function getLastDaily () {
2321 if (!isset($GLOBALS[__FUNCTION__])) {
2323 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2327 return $GLOBALS[__FUNCTION__];
2330 // "Getter" for last_weekly
2331 function getLastWeekly () {
2333 if (!isset($GLOBALS[__FUNCTION__])) {
2335 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2339 return $GLOBALS[__FUNCTION__];
2342 // "Getter" for last_monthly
2343 function getLastMonthly () {
2345 if (!isset($GLOBALS[__FUNCTION__])) {
2347 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2351 return $GLOBALS[__FUNCTION__];
2354 // "Getter" for last_yearly
2355 function getLastYearly () {
2357 if (!isset($GLOBALS[__FUNCTION__])) {
2359 $GLOBALS[__FUNCTION__] = getConfig('last_yearly');
2363 return $GLOBALS[__FUNCTION__];
2366 // "Getter" for mails_page
2367 function getMailsPage () {
2369 if (!isset($GLOBALS[__FUNCTION__])) {
2371 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2375 return $GLOBALS[__FUNCTION__];
2378 // "Getter" for rand_no
2379 function getRandNo () {
2381 if (!isset($GLOBALS[__FUNCTION__])) {
2383 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2387 return $GLOBALS[__FUNCTION__];
2390 // "Getter" for __DB_NAME
2391 function getDbName () {
2393 if (!isset($GLOBALS[__FUNCTION__])) {
2395 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2399 return $GLOBALS[__FUNCTION__];
2402 // "Getter" for DOMAIN
2403 function getDomain () {
2405 if (!isset($GLOBALS[__FUNCTION__])) {
2407 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2411 return $GLOBALS[__FUNCTION__];
2414 // "Getter" for proxy_username
2415 function getProxyUsername () {
2417 if (!isset($GLOBALS[__FUNCTION__])) {
2419 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2423 return $GLOBALS[__FUNCTION__];
2426 // "Getter" for proxy_password
2427 function getProxyPassword () {
2429 if (!isset($GLOBALS[__FUNCTION__])) {
2431 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2435 return $GLOBALS[__FUNCTION__];
2438 // "Getter" for proxy_host
2439 function getProxyHost () {
2441 if (!isset($GLOBALS[__FUNCTION__])) {
2443 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2447 return $GLOBALS[__FUNCTION__];
2450 // "Getter" for proxy_port
2451 function getProxyPort () {
2453 if (!isset($GLOBALS[__FUNCTION__])) {
2455 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2459 return $GLOBALS[__FUNCTION__];
2462 // "Getter" for SMTP_HOSTNAME
2463 function getSmtpHostname () {
2465 if (!isset($GLOBALS[__FUNCTION__])) {
2467 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2471 return $GLOBALS[__FUNCTION__];
2474 // "Getter" for SMTP_USER
2475 function getSmtpUser () {
2477 if (!isset($GLOBALS[__FUNCTION__])) {
2479 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2483 return $GLOBALS[__FUNCTION__];
2486 // "Getter" for SMTP_PASSWORD
2487 function getSmtpPassword () {
2489 if (!isset($GLOBALS[__FUNCTION__])) {
2491 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2495 return $GLOBALS[__FUNCTION__];
2498 // "Getter" for points_word
2499 function getPointsWord () {
2501 if (!isset($GLOBALS[__FUNCTION__])) {
2503 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2507 return $GLOBALS[__FUNCTION__];
2510 // "Getter" for profile_lock
2511 function getProfileLock () {
2513 if (!isset($GLOBALS[__FUNCTION__])) {
2515 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2519 return $GLOBALS[__FUNCTION__];
2522 // "Getter" for url_tlock
2523 function getUrlTlock () {
2525 if (!isset($GLOBALS[__FUNCTION__])) {
2527 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2531 return $GLOBALS[__FUNCTION__];
2534 // "Getter" for title_left
2535 function getTitleLeft () {
2537 if (!isset($GLOBALS[__FUNCTION__])) {
2539 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2543 return $GLOBALS[__FUNCTION__];
2546 // "Getter" for title_right
2547 function getTitleRight () {
2549 if (!isset($GLOBALS[__FUNCTION__])) {
2551 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2555 return $GLOBALS[__FUNCTION__];
2558 // "Getter" for title_middle
2559 function getTitleMiddle () {
2561 if (!isset($GLOBALS[__FUNCTION__])) {
2563 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2567 return $GLOBALS[__FUNCTION__];
2570 // Getter for 'display_home_in_index'
2571 function getDisplayHomeInIndex () {
2572 // Is the cache entry set?
2573 if (!isset($GLOBALS[__FUNCTION__])) {
2574 // No, so determine it
2575 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2578 // Return cached entry
2579 return $GLOBALS[__FUNCTION__];
2582 // Checks whether 'display_home_in_index' is 'Y'
2583 function isDisplayHomeInIndexEnabled () {
2584 // Is the cache entry set?
2585 if (!isset($GLOBALS[__FUNCTION__])) {
2586 // No, so determine it
2587 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isConfigEntrySet('display_home_in_index')) && (getDisplayHomeInIndex() == 'Y'));
2590 // Return cached entry
2591 return $GLOBALS[__FUNCTION__];
2594 // Getter for 'show_points_unconfirmed'
2595 function getShowPointsUnconfirmed () {
2596 // Is the cache entry set?
2597 if (!isset($GLOBALS[__FUNCTION__])) {
2598 // No, so determine it
2599 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2602 // Return cached entry
2603 return $GLOBALS[__FUNCTION__];
2606 // Checks whether 'show_points_unconfirmed' is 'Y'
2607 function isShowPointsUnconfirmedEnabled () {
2608 // Is the cache entry set?
2609 if (!isset($GLOBALS[__FUNCTION__])) {
2610 // No, so determine it
2611 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.5.5')) && (isConfigEntrySet('show_points_unconfirmed')) && (getShowPointsUnconfirmed() == 'Y'));
2614 // Return cached entry
2615 return $GLOBALS[__FUNCTION__];
2618 // Getter for 'youre_here'
2619 function getYoureHere () {
2620 // Is the cache entry set?
2621 if (!isset($GLOBALS[__FUNCTION__])) {
2622 // No, so determine it
2623 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2626 // Return cached entry
2627 return $GLOBALS[__FUNCTION__];
2630 // Checks whether 'show_timings' is 'Y'
2631 function isYoureHereEnabled () {
2632 // Is the cache entry set?
2633 if (!isset($GLOBALS[__FUNCTION__])) {
2634 // No, so determine it
2635 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (isConfigEntrySet('youre_here')) && (getYoureHere() == 'Y'));
2638 // Return cached entry
2639 return $GLOBALS[__FUNCTION__];
2642 // Getter for 'show_timings'
2643 function getShowTimings () {
2644 // Is the cache entry set?
2645 if (!isset($GLOBALS[__FUNCTION__])) {
2646 // No, so determine it
2647 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2650 // Return cached entry
2651 return $GLOBALS[__FUNCTION__];
2654 // Checks whether 'show_timings' is 'Y'
2655 function isShowTimingsEnabled () {
2656 // Is the cache entry set?
2657 if (!isset($GLOBALS[__FUNCTION__])) {
2658 // No, so determine it
2659 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isConfigEntrySet('show_timings')) && (getShowTimings() == 'Y'));
2662 // Return cached entry
2663 return $GLOBALS[__FUNCTION__];
2666 // Getter for 'ap_server_name_since'
2667 function getApServerNameSince () {
2668 // Is the cache entry set?
2669 if (!isset($GLOBALS[__FUNCTION__])) {
2670 // No, so determine it
2671 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2674 // Return cached entry
2675 return $GLOBALS[__FUNCTION__];
2678 // Getter for 'ap_server_name'
2679 function getApServerName () {
2680 // Is the cache entry set?
2681 if (!isset($GLOBALS[__FUNCTION__])) {
2682 // No, so determine it
2683 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2686 // Return cached entry
2687 return $GLOBALS[__FUNCTION__];
2690 // Getter for 'index_delay'
2691 function getIndexDelay () {
2692 // Is the cache entry set?
2693 if (!isset($GLOBALS[__FUNCTION__])) {
2694 // No, so determine it
2695 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2698 // Return cached entry
2699 return $GLOBALS[__FUNCTION__];
2702 // Checks whether 'ap_server_name' is 'Y'
2703 function isApServerNameEnabled () {
2704 // Is the cache entry set?
2705 if (!isset($GLOBALS[__FUNCTION__])) {
2706 // No, so determine it
2707 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2710 // Return cached entry
2711 return $GLOBALS[__FUNCTION__];
2714 // Getter for 'admin_menu_javascript'
2715 function getAdminMenuJavascript () {
2716 // Is the cache entry set?
2717 if (!isset($GLOBALS[__FUNCTION__])) {
2718 // No, so determine it
2719 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2722 // Return cached entry
2723 return $GLOBALS[__FUNCTION__];
2726 // Getter for 'points_remove_account'
2727 function getPointsRemoveAccount () {
2728 // Is the cache entry set?
2729 if (!isset($GLOBALS[__FUNCTION__])) {
2730 // No, so determine it
2731 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2734 // Return cached entry
2735 return $GLOBALS[__FUNCTION__];
2738 // Getter for 'css_php'
2739 function getCssPhp () {
2740 // Is the cache entry set?
2741 if (!isset($GLOBALS[__FUNCTION__])) {
2742 // No, so determine it
2743 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2746 // Return cached entry
2747 return $GLOBALS[__FUNCTION__];
2750 // Getter for 'guest_menu'
2751 function getGuestMenu () {
2752 // Is the cache entry set?
2753 if (!isset($GLOBALS[__FUNCTION__])) {
2754 // No, so determine it
2755 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2758 // Return cached entry
2759 return $GLOBALS[__FUNCTION__];
2762 // Checks if guest menu is enabled
2763 function isGuestMenuEnabled () {
2764 // Is the cache entry set?
2765 if (!isset($GLOBALS[__FUNCTION__])) {
2766 // No, so determine it
2767 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2770 // Return cached entry
2771 return $GLOBALS[__FUNCTION__];
2774 // Getter for 'member_menu'
2775 function getMemberMenu () {
2776 // Is the cache entry set?
2777 if (!isset($GLOBALS[__FUNCTION__])) {
2778 // No, so determine it
2779 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2782 // Return cached entry
2783 return $GLOBALS[__FUNCTION__];
2786 // Checks if member menu is enabled
2787 function isMemberMenuEnabled () {
2788 // Is the cache entry set?
2789 if (!isset($GLOBALS[__FUNCTION__])) {
2790 // No, so determine it
2791 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2794 // Return cached entry
2795 return $GLOBALS[__FUNCTION__];
2798 // Getter for 'word_wrap'
2799 function getWordWrap () {
2800 // Is the cache entry set?
2801 if (!isset($GLOBALS[__FUNCTION__])) {
2802 // Construct config entry name
2803 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2805 // Is a special config entry found or ext-sql_patches updated?
2806 if (isConfigEntrySet($configEntry)) {
2807 // A special config entry has been found, then use it
2808 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2809 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2810 // No special config entry found, then use it as "fall-back"
2811 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2813 // No, use default (15 characters)
2814 $GLOBALS[__FUNCTION__] = 15;
2818 // Return cached entry
2819 return $GLOBALS[__FUNCTION__];
2822 // Checks whether proxy configuration is used
2823 function isProxyUsed () {
2825 if (!isset($GLOBALS[__FUNCTION__])) {
2827 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (isValidNumber(getConfig('proxy_port'))));
2831 return $GLOBALS[__FUNCTION__];
2834 // Checks whether POST data contains selections
2835 function ifPostContainsSelections ($element = 'sel') {
2837 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2839 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2843 return $GLOBALS[__FUNCTION__][$element];
2846 // Checks whether verbose_sql is Y and returns true/false if so
2847 function isVerboseSqlEnabled () {
2849 if (!isset($GLOBALS[__FUNCTION__])) {
2851 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2855 return $GLOBALS[__FUNCTION__];
2858 // "Getter" for total user points
2859 function getTotalPoints ($userid) {
2861 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2862 // Init array for filter chain
2864 'userid' => $userid,
2868 // Run filter chain for getting more point values
2869 $data = runFilterChain('get_total_points', $data);
2872 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2876 return $GLOBALS[__FUNCTION__][$userid];
2879 // Wrapper to get used points for given userid
2880 function getUserUsedPoints ($userid) {
2882 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2884 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2888 return $GLOBALS[__FUNCTION__][$userid];
2891 // Checks whether direct payment is allowed in configuration
2892 function isDirectPaymentEnabled () {
2894 if (!isset($GLOBALS[__FUNCTION__])) {
2896 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('allow_direct_pay')) && (getConfig('allow_direct_pay') == 'Y'));
2900 return $GLOBALS[__FUNCTION__];
2903 // Checks whether JavaScript-based admin menu is enabled
2904 function isAdminMenuJavascriptEnabled () {
2906 if (!isset($GLOBALS[__FUNCTION__])) {
2908 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (isConfigEntrySet('admin_menu_javascript')) && (getAdminMenuJavaScript() == 'Y'));
2912 return $GLOBALS[__FUNCTION__];
2915 // Wrapper to check if current task is for extension (not update)
2916 function isExtensionTask ($content) {
2918 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2920 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2924 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2927 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2928 function ifTesterAccountsAllowed () {
2929 // Is the cache entry set?
2930 if (!isset($GLOBALS[__FUNCTION__])) {
2931 // No, so determine it
2932 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2935 // Return cached entry
2936 return $GLOBALS[__FUNCTION__];
2939 // Wrapper to check if output mode is CSS
2940 function isCssOutputMode () {
2942 if (!isset($GLOBALS[__FUNCTION__])) {
2944 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2945 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2949 return $GLOBALS[__FUNCTION__];
2952 // Wrapper to check if output mode is HTML
2953 function isHtmlOutputMode () {
2955 if (!isset($GLOBALS[__FUNCTION__])) {
2957 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2958 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2962 return $GLOBALS[__FUNCTION__];
2965 // Wrapper to check if output mode is RAW
2966 function isRawOutputMode () {
2968 if (!isset($GLOBALS[__FUNCTION__])) {
2970 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2971 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2975 return $GLOBALS[__FUNCTION__];
2978 // Wrapper to check if output mode is AJAX
2979 function isAjaxOutputMode () {
2981 if (!isset($GLOBALS[__FUNCTION__])) {
2983 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2984 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2988 return $GLOBALS[__FUNCTION__];
2991 // Wrapper to check if output mode is image
2992 function isImageOutputMode () {
2994 if (!isset($GLOBALS[__FUNCTION__])) {
2996 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2997 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
3001 return $GLOBALS[__FUNCTION__];
3004 // Wrapper to generate a user email link
3005 function generateWrappedUserEmailLink ($email) {
3006 // Just call the inner function
3007 return generateEmailLink($email, 'user_data');
3010 // Wrapper to check if user points are locked
3011 function ifUserPointsLocked ($userid) {
3012 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
3014 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3016 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
3020 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
3021 return $GLOBALS[__FUNCTION__][$userid];
3024 // Appends a line to an existing file or creates it instantly with given content.
3025 // This function does always add a new-line character to every line.
3026 function appendLineToFile ($file, $line) {
3027 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
3028 fwrite($fp, $line . PHP_EOL);
3032 // Wrapper for changeDataInFile() but with full path added
3033 function changeDataInInclude ($inc, $comment, $prefix, $suffix, $inserted, $seek=0) {
3035 $FQFN = getPath() . $inc;
3037 // Call inner function
3038 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
3041 // Wrapper for changing entries in config-local.php
3042 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3043 // Call the inner function
3044 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3047 // Shortens ucfirst(strtolower()) calls
3048 function firstCharUpperCase ($str) {
3049 return ucfirst(strtolower($str));
3052 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3053 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3054 // Get the configuration entry
3055 $configValue = getConfig($configEntry);
3057 // Call inner method
3058 return createTimeSelections($configValue, $configEntry, $stamps, $align);
3061 // Shortens converting of German comma to Computer's version in POST data
3062 function convertCommaToDotInPostData ($postEntry) {
3063 // Read and convert given entry
3064 $postValue = convertCommaToDot(postRequestElement($postEntry));
3067 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3069 // ... and set it again
3070 setPostRequestElement($postEntry, $postValue);
3073 // Converts German commas to Computer's version in all entries
3074 function convertCommaToDotInPostDataArray ($postEntries) {
3075 // Replace german decimal comma with computer decimal dot
3076 foreach ($postEntries as $entry) {
3077 // Is the entry there?
3078 if (isPostRequestElementSet($entry)) {
3080 convertCommaToDotInPostData($entry);
3086 * Parses a string into a US formated float variable, taken from user comments
3087 * from PHP documentation website.
3089 * @param $floatString A string holding a float expression
3090 * @return $float Corresponding float variable
3091 * @author chris<at>georgakopoulos<dot>com
3092 * @link http://de.php.net/manual/en/function.floatval.php#92563
3094 function parseFloat ($floatString){
3096 $LocaleInfo = localeconv();
3098 // Remove thousand separators
3099 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3101 // Convert decimal point
3102 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3104 // Return float value of converted string
3105 return floatval($floatString);
3109 * Searches a multi-dimensional array (as used in many places) for given
3110 * key/value pair as taken from user comments from PHP documentation website.
3112 * @param $array An array with one or more dimensions
3113 * @param $key Key to look for
3114 * @param $value Value to look for
3115 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3116 * @return $results Resulted array or empty array if $array is no array
3117 * @author sunelbe<at>gmail<dot>com
3118 * @link http://de.php.net/manual/en/function.array-search.php#110120
3120 function search_array ($array, $key, $value, $parentIndex = NULL) {
3121 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3122 // Init array result
3125 // Is $array really an array?
3126 if (is_array($array)) {
3127 // Search for whole array
3128 foreach ($array as $idx => $dummy) {
3129 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3130 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3131 // Is dummy an array?
3132 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3133 // Then search again
3134 $subResult = search_array($dummy, $key, $value, $idx);
3135 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3138 $results = merge_array($results, $subResult, TRUE);
3139 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3140 // Is found, so add it
3141 $results[$parentIndex] = $array;
3142 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3147 // Return resulting array
3148 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3152 // Generates a YES/NO option list from given default
3153 function generateYesNoOptions ($defaultValue = '') {
3155 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3158 // "Getter" for total available receivers
3159 function getTotalReceivers ($mode = 'normal') {
3161 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3167 // Wrapper "getter" to get total unconfirmed mails for given userid
3168 function getTotalUnconfirmedMails ($userid) {
3170 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3172 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3176 return $GLOBALS[__FUNCTION__][$userid];
3179 // Checks whether 'mailer_theme' was found in session
3180 function isMailerThemeSet () {
3182 if (!isset($GLOBALS[__FUNCTION__])) {
3184 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3188 return $GLOBALS[__FUNCTION__];
3192 * Setter for theme in session (This setter does return the success of
3193 * setSession() which is required e.g. for destroySponsorSession().
3195 function setMailerTheme ($newTheme) {
3196 // Set it in session
3197 return setSession('mailer_theme', $newTheme);
3201 * Getter for theme from session (This getter does return 'mailer_theme' from
3202 * session data or throws an error if not possible
3204 function getMailerTheme () {
3206 if (!isset($GLOBALS[__FUNCTION__])) {
3207 // Is 'mailer_theme' set?
3208 if (!isMailerThemeSet()) {
3209 // No, then abort here
3210 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3213 // Get it and store it in cache
3214 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3218 return $GLOBALS[__FUNCTION__];
3221 // "Getter" for last_module/last_what depending on ext-user version
3222 function getUserLastWhatName () {
3223 // Default is old one: last_module
3224 $columnName = 'last_module';
3226 // Is ext-user up-to-date?
3227 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3228 // Yes, then use new one
3229 $columnName = 'last_what';
3236 // "Getter" for all columns for given alias and separator
3237 function getAllPointColumns ($alias = NULL, $separator = ',') {
3238 // Prepare the filter array
3239 $filterData = array(
3242 'separator' => $separator
3246 $filterData = runFilterChain('get_all_point_columns', $filterData);
3248 // Return the columns
3249 return $filterData['columns'];
3252 // Checks whether the copyright footer (which breaks framesets) is enabled
3253 function ifCopyrightFooterEnabled () {
3254 // Is not unset and not 'N'?
3255 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3259 * Wrapper to check whether we have a "full page". This means that the actual
3260 * content is not delivered in any frame of a frameset.
3262 function isFullPage () {
3264 * The parameter 'frame' is generic and always indicates that this content
3265 * will be output into a frame. Furthermore, if a frameset is reported or
3266 * the copyright line is explicitly deactivated, this cannot be a "full
3269 // @TODO Find a way to not use direct module comparison
3270 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3276 // Checks whether frameset_mode is set to true
3277 function isFramesetModeEnabled () {
3279 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3282 // Function to determine correct 'what' value
3283 function determineWhat ($module = NULL) {
3284 // Init default 'what'
3288 if (is_null($module)) {
3290 $module = getModule();
3298 // Else try to get it from current module
3299 $what = getWhatFromModule($module);
3301 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3303 // Remove any spaces from variable
3304 $what = trim($what);
3308 // Default action for non-admin menus
3312 $what = secureString($what);
3319 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3320 function prependZeros ($str, $length = 2) {
3321 // Return prepended string
3322 return sprintf('%0' . (int) $length . 's', $str);
3325 // Wraps convertSelectionsToEpocheTime()
3326 function convertSelectionsToEpocheTimeInPostData ($id) {
3331 // Get all POST data
3332 $postData = postRequestArray();
3334 // Convert given selection id
3335 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3337 // Set the POST array back
3338 setPostRequestArray($postData);
3341 // Wraps checking if given points account type matches with given in POST data
3342 function ifPointsAccountTypeMatchesPost ($type) {
3344 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3347 // Gets given user's total referral
3348 function getUsersTotalReferrals ($userid, $level = NULL) {
3350 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3351 // Is the level NULL?
3352 if (is_null($level)) {
3353 // Get total amount (all levels)
3354 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3356 // Get it from user refs
3357 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3362 return $GLOBALS[__FUNCTION__][$userid][$level];
3365 // Gets given user's total referral
3366 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3367 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3369 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3370 // Default is all refs
3373 // Is the not level NULL?
3374 if (!is_null($level)) {
3375 // Then add referral level
3376 $add = ' AND `r`.`level`=' . bigintval($level);
3379 // Check for all referrals
3380 $result = sqlQueryEscaped("SELECT
3381 COUNT(`d`.`userid`) AS `cnt`
3383 `{?_MYSQL_PREFIX?}_user_data` AS `d`
3385 `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3387 `d`.`userid`=`r`.`refid`
3389 `d`.`status` != 'CONFIRMED' AND
3397 ), __FUNCTION__, __LINE__);
3400 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3403 sqlFreeResult($result);
3407 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3408 return $GLOBALS[__FUNCTION__][$userid][$level];
3411 // Converts, if found, dollar data to get element
3412 function convertDollarDataToGetElement ($data) {
3413 // Is first char a dollar?
3414 if (substr($data, 0, 1) == chr(36)) {
3415 // Use last part for getRequestElement()
3416 $data = getRequestElement(substr($data, 1));
3423 // Wrapper function for SQL layer to speed-up things
3424 function isSqlDebugEnabled () {
3426 if (!isset($GLOBALS[__FUNCTION__])) {
3428 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3432 return $GLOBALS[__FUNCTION__];
3435 // Wrapper function to wrap call of wordwrap()
3436 function wrapWords ($text) {
3438 $wrapped = wordwrap($test, getWordWrap());
3444 // Encodes given data into a JSON object
3445 function encodeJson ($data) {
3447 return json_encode($data, JSON_FORCE_OBJECT);
3450 // Get all extension files
3451 function loadAllExtensionsByTemplate () {
3453 $extensions = getArrayFromDirectory(
3454 'templates/' . getLanguage() . '/html/ext/',
3468 // Wrapper function to allow full float values as supported by current database layout
3469 function translateFullComma ($dotted) {
3470 // Call inner function
3471 return translateComma($dotted, TRUE, 5);
3474 // Wrapper to check if the first element to be shifted is set to given value
3475 function shift_array (&$array, $value, $key = '0') {
3476 // Is the element set and value matches?
3477 assert(is_array($array));
3478 assert(isset($array[$key]));
3479 assert($array[$key] === $value);
3482 array_shift($array);
3485 // Wrapper for str_pad() with left padding zeros
3486 function padLeftZero ($str, $amount = 2) {
3487 // Is str_pad() there?
3488 if (!function_exists('str_pad')) {
3489 // Use prependZeros()
3490 return prependZeros($str, $amount);
3493 return str_pad($str, $amount, '0', STR_PAD_LEFT);
3497 // Calculates percentage
3498 function calculatePercentageRate ($current, $total) {
3502 // Is sent larger zero? (Prevents division-by-zero)
3504 // Calculate it (it should be "translated" alter on)
3505 $rate = ($current / $total * 100);
3508 // The should be a .0 at the end?
3509 if (strpos($rate, '.') === FALSE) {
3518 // Checks whether an array is filled with entries
3519 function isFilledArray ($array) {
3521 return ((is_array($array)) && (count($array) > 0));
3524 // Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
3525 function isDeveloperSystem () {
3527 return in_array(detectServerName(), array('localhost', '127.0.0.1'));
3530 // Checks whether given subject line has '_ref' suffix
3531 function ifSubjectHasReferralSuffix ($subject) {
3533 if (!isset($GLOBALS[__FUNCTION__][$subject])) {
3535 $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
3539 return $GLOBALS[__FUNCTION__][$subject];
3542 // Converts an API response to an associative array
3543 function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimiter) {
3544 // Explode for key delimiter
3545 $keys = explode($keyDelimiter, $responseString);
3547 // Init returned array and "walk" through all entries
3548 $returned = array();
3549 foreach ($keys as $keyValue) {
3551 $parts = explode($valueDelimiter, $keyValue);
3554 assert(count($parts) == 2);
3556 // Then add both: 0=key, 1=value
3557 $returned[sqlEscapeString($parts[0])] = sqlEscapeString($parts[1]);
3560 // Return finished array
3564 // Getter for full (generic) hash file name
3565 function getGenericHashFileName () {
3567 return sprintf('%s%s.%s%s', getPath(), getCachePath(), getFileHash(), getCacheExtension());
3570 // "Compiles" the given value and sets it in given key
3571 function setSessionCompiled ($key, $value) {
3572 // "Compile" the value
3573 $value = doFinalCompilation(compileRawCode($value));
3576 return setSession($key, $value);