2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/04/2009 *
4 * =================== Last change: 04/04/2009 *
6 * -------------------------------------------------------------------- *
7 * File : wrapper-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Wrapper functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Wrapper-Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 function readFromFile ($FQFN) {
45 // Sanity-check if file is there (should be there, but just to make it sure)
46 if (!isFileReadable($FQFN)) {
47 // This should not happen
48 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
52 if (function_exists('file_get_contents')) {
54 $fileContent = file_get_contents($FQFN);
56 // Fall-back to implode-file chain
57 $fileContent = implode('', file($FQFN));
64 // Writes content to a file
65 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
66 // Is the file writeable?
67 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
69 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable or cannot change CHMOD to 0644.", basename($FQFN)));
75 // By default all is failed...
76 $GLOBALS['file_readable'][$FQFN] = FALSE;
79 // Is the function there?
80 if (function_exists('file_put_contents')) {
82 if ($aquireLock === TRUE) {
83 // Write it directly with lock
84 $return = file_put_contents($FQFN, $content, LOCK_EX);
87 $return = file_put_contents($FQFN, $content);
90 // Write it with fopen
91 $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
94 if ($aquireLock === TRUE) {
100 $return = fwrite($fp, $content);
106 // Was something written?
107 if ($return !== FALSE) {
108 // Mark it as readable
109 $GLOBALS['file_readable'][$FQFN] = TRUE;
113 return (($return !== FALSE) && (changeMode($FQFN, 0644)));
116 // Clears the output buffer. This function does *NOT* backup sent content.
117 function clearOutputBuffer () {
118 // Make sure this function is not called twice (no double-cleaning!)
119 if (isset($GLOBALS[__FUNCTION__])) {
120 // This function is called twice
121 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
122 } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
124 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
127 // Mark this function as called
128 $GLOBALS[__FUNCTION__] = TRUE;
132 function encodeString ($str) {
133 $str = urlencode(base64_encode(compileUriCode($str)));
137 // Decode strings encoded with encodeString()
138 function decodeString ($str) {
139 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
143 // Decode entities in a nicer way
144 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
145 // Decode the entities to UTF-8 now
146 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
148 // Return decoded string
149 return $decodedString;
152 // Merges an array together but only if both are arrays
153 function merge_array ($array1, $array2, $keepIndex = FALSE) {
154 // Are both an array?
155 if ((!is_array($array1)) && (!is_array($array2))) {
156 // Both are not arrays
157 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
158 } elseif (!is_array($array1)) {
159 // Left one is not an array
160 reportBug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
161 } elseif (!is_array($array2)) {
162 // Right one is not an array
163 reportBug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
166 // Maintain index of array2?
167 if ($keepIndex === TRUE) {
168 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
169 foreach ($array2 as $key => $value) {
171 $array1[$key] = $value;
177 // Merge both together normally
178 return array_merge($array1, $array2);
182 // Check if given FQFN is a readable file
183 function isFileReadable ($FQFN) {
185 if (!isset($GLOBALS['file_readable'][$FQFN])) {
187 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
191 return $GLOBALS['file_readable'][$FQFN];
194 // Checks whether the given FQFN is a directory and not ., .. or .svn
195 function isDirectory ($FQFN) {
197 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
199 $baseName = basename($FQFN);
202 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
206 return $GLOBALS[__FUNCTION__][$FQFN];
209 // "Getter" for the real remote IP number
210 function detectRealIpAddress ($alwaysReal = FALSE) {
211 // Get remote ip from environment
212 $remoteAddr = determineRealRemoteAddress();
214 // Is removeip installed?
215 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
217 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
224 // "Getter" for remote IP number
225 function detectRemoteAddr ($alwaysReal = FALSE) {
226 // Get remote ip from environment
227 $remoteAddr = determineRealRemoteAddress(TRUE);
229 // Is removeip installed?
230 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
232 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
239 // "Getter" for remote hostname
240 function detectRemoteHostname ($alwaysReal = FALSE) {
241 // Get remote ip from environment
242 $remoteHost = getenv('REMOTE_HOST');
244 // Is removeip installed?
245 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
247 $remoteHost = getAnonymousRemoteHost($remoteHost);
254 // "Getter" for user agent
255 function detectUserAgent ($alwaysReal = FALSE) {
256 // Get remote ip from environment
257 $userAgent = getenv('HTTP_USER_AGENT');
259 // Is removeip installed?
260 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
262 $userAgent = getAnonymousUserAgent($userAgent);
269 // "Getter" for referer
270 function detectReferer ($alwaysReal = FALSE) {
271 // Get remote ip from environment
272 $referer = getenv('HTTP_REFERER');
274 // Is removeip installed?
275 if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
277 $referer = getAnonymousReferer($referer);
284 // "Getter" for request URI
285 function detectRequestUri () {
287 return (getenv('REQUEST_URI'));
290 // "Getter" for query string
291 function detectQueryString () {
292 return str_replace('&', '&', (getenv('QUERY_STRING')));
295 // "Getter" for SERVER_NAME
296 function detectServerName () {
298 return (getenv('SERVER_NAME'));
301 // Removes any existing www. from SERVER_NAME. This is very silly but enough
302 // for our purpose here.
303 function detectDomainName () {
305 if (!isset($GLOBALS[__FUNCTION__])) {
307 $domainName = detectServerName();
309 // Is there any www. ?
310 if (substr($domainName, 0, 4) == 'www.') {
312 $domainName = substr($domainName, 4);
316 $GLOBALS[__FUNCTION__] = $domainName;
320 return $GLOBALS[__FUNCTION__];
323 // Check whether we are installing
324 function isInstalling () {
325 // Determine whether we are installing
326 if (!isset($GLOBALS['__mailer_installing'])) {
327 // Check URL (css.php/js.php need this)
328 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isAjaxOutputMode()) && (isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
332 return $GLOBALS['__mailer_installing'];
335 // Check whether this script is installed
336 function isInstalled () {
338 if (!isset($GLOBALS[__FUNCTION__])) {
339 // Determine whether this script is installed
340 $GLOBALS[__FUNCTION__] = (
345 isConfigEntrySet('MAILER_INSTALLED')
347 getConfig('MAILER_INSTALLED') == 'Y'
351 // New config file found and loaded
352 isIncludeReadable(getCachePath() . 'config-local.php')
355 // New config file found, but not yet read
356 isIncludeReadable(getCachePath() . 'config-local.php')
359 // Only new config file is found
360 !isIncludeReadable('inc/config.php')
362 // Is installation mode
369 // Then use the cache
370 return $GLOBALS[__FUNCTION__];
373 // Check whether an admin is registered
374 function isAdminRegistered () {
376 if (!isset($GLOBALS[__FUNCTION__])) {
378 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
382 return $GLOBALS[__FUNCTION__];
385 // Checks whether the hourly reset mode is active
386 function isHourlyResetEnabled () {
387 // Now simply check it
388 return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
391 // Checks whether the daily reset mode is active
392 function isDailyResetEnabled () {
393 // Now simply check it
394 return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
397 // Checks whether the weekly reset mode is active
398 function isWeeklyResetEnabled () {
399 // Now simply check it
400 return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
403 // Checks whether the monthly reset mode is active
404 function isMonthlyResetEnabled () {
405 // Now simply check it
406 return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
409 // Checks whether the yearly reset mode is active
410 function isYearlyResetEnabled () {
411 // Now simply check it
412 return ((isset($GLOBALS['yearly_enabled'])) && ($GLOBALS['yearly_enabled'] === TRUE));
415 // Checks whether one of the reset modes is enabled
416 function isResetModeEnabled () {
417 // Now simply check it
418 return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()) || (isYearlyResetEnabled()));
421 // Checks whether the debug mode is enabled
422 function isDebugModeEnabled () {
424 if (!isset($GLOBALS[__FUNCTION__])) {
426 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
430 return $GLOBALS[__FUNCTION__];
433 // Checks whether the debug hourly is enabled
434 function isDebugHourlyEnabled () {
436 if (!isset($GLOBALS[__FUNCTION__])) {
438 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
442 return $GLOBALS[__FUNCTION__];
445 // Checks whether the debug daily is enabled
446 function isDebugDailyEnabled () {
448 if (!isset($GLOBALS[__FUNCTION__])) {
450 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
454 return $GLOBALS[__FUNCTION__];
457 // Checks whether the debug weekly is enabled
458 function isDebugWeeklyEnabled () {
460 if (!isset($GLOBALS[__FUNCTION__])) {
462 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
466 return $GLOBALS[__FUNCTION__];
469 // Checks whether the debug monthly is enabled
470 function isDebugMonthlyEnabled () {
472 if (!isset($GLOBALS[__FUNCTION__])) {
474 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
478 return $GLOBALS[__FUNCTION__];
481 // Checks whether the debug yearly is enabled
482 function isDebugYearlyEnabled () {
484 if (!isset($GLOBALS[__FUNCTION__])) {
486 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
490 return $GLOBALS[__FUNCTION__];
493 // Checks whether SQL debugging is enabled
494 function isSqlDebuggingEnabled () {
496 if (!isset($GLOBALS[__FUNCTION__])) {
497 // Determine if SQL debugging is enabled
498 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
502 return $GLOBALS[__FUNCTION__];
505 // Checks whether we shall debug regular expressions
506 function isDebugRegularExpressionEnabled () {
508 if (!isset($GLOBALS[__FUNCTION__])) {
510 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
514 return $GLOBALS[__FUNCTION__];
517 // Checks whether debugging of build mails is enabled
518 function isDebugBuildMailsEnabled () {
520 if (!isset($GLOBALS[__FUNCTION__])) {
522 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
526 return $GLOBALS[__FUNCTION__];
529 // Checks whether the cache instance is valid
530 function isValidCacheInstance () {
532 if (!isset($GLOBALS[__FUNCTION__])) {
534 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
538 return $GLOBALS[__FUNCTION__];
541 // Copies a file from source to destination and verifies if that goes fine.
542 // This function should wrap the copy() command and make a nicer debug backtrace
543 // even if there is no xdebug extension installed.
544 function copyFileVerified ($source, $dest, $chmod = '') {
545 // Failed is the default
548 // Is the source file there?
549 if (!isFileReadable($source)) {
551 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
554 // Is the target directory there?
555 if (!isDirectory(dirname($dest))) {
557 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
560 // Now try to copy it
561 if (!copy($source, $dest)) {
562 // Something went wrong
563 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
566 $GLOBALS['file_readable'][$dest] = TRUE;
569 // All fine by default
572 // If there are chmod rights set, apply them
573 if (!empty($chmod)) {
575 $status = changeMode($dest, $chmod);
582 // Wrapper function for chmod()
583 // @TODO Do some more sanity check here
584 function changeMode ($FQFN, $mode) {
585 // Is the file/directory there?
586 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
587 // Neither, so abort here
588 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
592 return chmod($FQFN, $mode);
595 // Wrapper for unlink()
596 function removeFile ($FQFN) {
597 // Is the file there?
598 if (isFileReadable($FQFN)) {
600 $GLOBALS['file_readable'][$FQFN] = FALSE;
603 return unlink($FQFN);
606 // All fine if no file was removed. If we change this to 'false' or rewrite
607 // above if() block it would be to restrictive.
611 // Wrapper for $_POST['sel']
612 function countPostSelection ($element = 'sel') {
614 if (!isset($GLOBALS[__FUNCTION__][$element])) {
616 $GLOBALS[__FUNCTION__][$element] = '0';
619 if (isPostRequestElementSet($element)) {
620 // Return counted elements
621 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
625 // Return cached value
626 return $GLOBALS[__FUNCTION__][$element];
629 // Checks whether the config-local.php is loaded
630 function isConfigLocalLoaded () {
631 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
634 // Checks whether a nickname or userid was entered and caches the result
635 function isNicknameUsed ($userid) {
636 // Is the cache there
637 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
639 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
643 return $GLOBALS[__FUNCTION__][$userid];
646 // Getter for 'what' value
647 function getWhat ($strict = TRUE) {
652 if (isWhatSet($strict)) {
654 $what = $GLOBALS['__what'];
661 // Setter for 'what' value
662 function setWhat ($newWhat) {
663 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
664 $GLOBALS['__what'] = $newWhat;
667 // Setter for 'what' from configuration
668 function setWhatFromConfig ($configEntry) {
669 // Get 'what' from config
670 $what = getConfig($configEntry);
676 // Checks whether what is set and optionally aborts on miss
677 function isWhatSet ($strict = FALSE) {
679 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
681 // Should we abort here?
682 if (($strict === TRUE) && ($isset === FALSE)) {
684 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
691 // Getter for 'action' value
692 function getAction ($strict = TRUE) {
697 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
699 $action = $GLOBALS['__action'];
706 // Setter for 'action' value
707 function setAction ($newAction) {
708 $GLOBALS['__action'] = $newAction;
711 // Checks whether action is set and optionally aborts on miss
712 function isActionSet ($strict = FALSE) {
714 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
716 // Should we abort here?
717 if (($strict === TRUE) && ($isset === FALSE)) {
719 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
726 // Getter for 'module' value
727 function getModule ($strict = TRUE) {
732 if (isModuleSet($strict)) {
734 $module = $GLOBALS['__module'];
741 // Setter for 'module' value
742 function setModule ($newModule) {
743 // Secure it and make all modules lower-case
744 $GLOBALS['__module'] = strtolower($newModule);
747 // Wrapper to get extra module names
748 function getExtraModule () {
752 // Is 'tab/step' set?
753 if (isPostRequestElementSet('tab')) {
755 $extra = 'tab=' . postRequestElement('tab');
756 } elseif (isPostRequestElementSet('step')) {
758 $extra = 'step=' . postRequestElement('step');
759 } elseif ((isActionSet()) && (isWhatSet())) {
761 $extra = 'action=' . getAction() . ':what=' . getWhat();
768 // Checks whether module is set and optionally aborts on miss
769 function isModuleSet ($strict = FALSE) {
771 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
773 // Should we abort here?
774 if (($strict === TRUE) && ($isset === FALSE)) {
776 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
780 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
783 // Getter for 'output_mode' value
784 function getScriptOutputMode () {
786 if (!isset($GLOBALS[__FUNCTION__])) {
787 // Is the output mode set?
788 if (!isOutputModeSet()) {
789 // No, then abort here
790 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
794 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
798 return $GLOBALS[__FUNCTION__];
801 // Setter for 'output_mode' value
802 function setScriptOutputMode ($newOutputMode) {
803 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
804 $GLOBALS['__output_mode'] = (int) $newOutputMode;
807 // Checks whether output_mode is set and optionally aborts on miss
808 function isOutputModeSet ($strict = FALSE) {
810 $isset = (isset($GLOBALS['__output_mode']));
812 // Should we abort here?
813 if (($strict === TRUE) && ($isset === FALSE)) {
815 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
822 // Enables block-mode
823 function enableBlockMode ($enabled = TRUE) {
824 $GLOBALS['__block_mode'] = $enabled;
827 // Checks whether block-mode is enabled
828 function isBlockModeEnabled () {
830 if (!isset($GLOBALS['__block_mode'])) {
832 reportBug(__FUNCTION__, __LINE__, '__block_mode is not set.');
836 return $GLOBALS['__block_mode'];
839 // Wrapper for redirectToUrl but URL comes from a configuration entry
840 function redirectToConfiguredUrl ($configEntry) {
842 redirectToUrl(getConfig($configEntry));
845 // Wrapper function to redirect from member-only modules to index
846 function redirectToIndexMemberOnlyModule () {
847 // Do the redirect here
848 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
851 // Wrapper function to redirect to current URL
852 function redirectToRequestUri () {
853 redirectToUrl(basename(detectRequestUri()));
856 // Wrapper function to redirect to de-refered URL
857 function redirectToDereferedUrl ($url) {
859 redirectToUrl(generateDereferrerUrl($url));
862 // Wrapper function for checking if extension is installed and newer or same version
863 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
864 // Is an cache entry found?
865 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
867 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
869 // Cache hits should be incremented twice
870 incrementStatsEntry('cache_hits', 2);
874 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
875 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
878 // Wrapper function for checking if extension is installed and older than given version
879 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
880 // Is an cache entry found?
881 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
883 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
885 // Cache hits should be incremented twice
886 incrementStatsEntry('cache_hits', 2);
890 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
891 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
895 function setUsername ($userName) {
896 $GLOBALS['username'] = (string) $userName;
900 function getUsername () {
902 if (!isset($GLOBALS['username'])) {
903 // No, so it has to be a guest
904 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
908 return $GLOBALS['username'];
911 // Wrapper function for installation phase
912 function isInstaller () {
914 if (!isset($GLOBALS[__FUNCTION__])) {
916 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
920 return $GLOBALS[__FUNCTION__];
923 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
924 function isDemoModeActive () {
926 if (!isset($GLOBALS[__FUNCTION__])) {
928 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
932 return $GLOBALS[__FUNCTION__];
935 // Getter for PHP caching value
936 function getPhpCaching () {
937 return $GLOBALS['php_caching'];
940 // Checks whether the admin hash is set
941 function isAdminHashSet ($adminId) {
942 // Is the array there?
943 if (!isset($GLOBALS['cache_array']['admin'])) {
944 // Missing array should be reported
945 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
948 // Check for admin hash
949 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
952 // Setter for admin hash
953 function setAdminHash ($adminId, $hash) {
954 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
957 // Getter for current admin login
958 function getCurrentAdminLogin () {
960 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
963 if (!isset($GLOBALS[__FUNCTION__])) {
965 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
969 return $GLOBALS[__FUNCTION__];
972 // Setter for admin id (and current)
973 function setAdminId ($adminId) {
975 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
978 $status = setSession('admin_id', bigintval($adminId));
981 setCurrentAdminId($adminId);
987 // Setter for admin_last
988 function setAdminLast ($adminLast) {
990 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
993 $status = setSession('admin_last', $adminLast);
999 // Setter for admin_md5
1000 function setAdminMd5 ($adminMd5) {
1001 // Log debug message
1002 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
1005 $status = setSession('admin_md5', $adminMd5);
1011 // Getter for admin_md5
1012 function getAdminMd5 () {
1013 // Log debug message
1014 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1017 return getSession('admin_md5');
1020 // Init user data array
1021 function initUserData () {
1022 // User id should not be zero
1023 if (!isValidId(getCurrentUserId())) {
1024 // Should be always valid
1025 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1029 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1030 $GLOBALS['user_data'][getCurrentUserId()] = array();
1033 // Getter for user data
1034 function getUserData ($column) {
1035 // User id should not be zero
1036 if (!isValidId(getCurrentUserId())) {
1037 // Should be always valid
1038 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1044 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1046 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1053 // Checks whether given user data is set to 'Y'
1054 function isUserDataEnabled ($column) {
1056 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1058 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1062 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1065 // Geter for whole user data array
1066 function getUserDataArray () {
1068 $userid = getCurrentUserId();
1070 // Is the current userid valid?
1071 if (!isValidId($userid)) {
1072 // Should be always valid
1073 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1076 // Get the whole array if found
1077 if (isset($GLOBALS['user_data'][$userid])) {
1078 // Found, so return it
1079 return $GLOBALS['user_data'][$userid];
1081 // Return empty array
1086 // Checks if the user data is valid, this may indicate that the user has logged
1087 // in, but you should use isMember() if you want to find that out.
1088 function isValidUserData () {
1089 // User id should not be zero so abort here
1090 if (!isCurrentUserIdSet()) {
1091 // Debug message, may be noisy
1092 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1099 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1101 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1104 // Return the result
1105 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1108 // Setter for current userid
1109 function setCurrentUserId ($userid) {
1111 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1113 // Is the cache from below functions different?
1114 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1116 unsetCurrentUserId();
1120 $GLOBALS['current_userid'] = bigintval($userid);
1122 // Unset it to re-determine the actual state
1123 unset($GLOBALS['is_userdata_valid'][$userid]);
1126 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1129 // Getter for current userid
1130 function getCurrentUserId () {
1132 if (!isset($GLOBALS[__FUNCTION__])) {
1133 // Userid must be set before it can be used
1134 if (!isCurrentUserIdSet()) {
1136 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1139 // Set userid in cache
1140 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1144 return $GLOBALS[__FUNCTION__];
1147 // Checks if current userid is set
1148 function isCurrentUserIdSet () {
1150 if (!isset($GLOBALS[__FUNCTION__])) {
1152 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1156 return $GLOBALS[__FUNCTION__];
1159 // Unsets current userid
1160 function unsetCurrentUserId () {
1162 if (isset($GLOBALS['current_userid'])) {
1164 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1167 // Unset all cache entries
1168 unset($GLOBALS['current_userid']);
1169 unset($GLOBALS['getCurrentUserId']);
1170 unset($GLOBALS['isCurrentUserIdSet']);
1173 // Checks whether we are debugging template cache
1174 function isDebugTemplateCacheEnabled () {
1176 if (!isset($GLOBALS[__FUNCTION__])) {
1178 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_TEMPLATE_CACHE')) && (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'));
1182 return $GLOBALS[__FUNCTION__];
1185 // Wrapper for fetchUserData() and getUserData() calls
1186 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1187 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1189 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1193 // Can we fetch the user data?
1194 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1195 // Now get the data back
1196 $data = getUserData($valueColumn);
1200 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1204 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1205 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1208 // Wrapper for strpos() to ease porting from deprecated ereg() function
1209 function isInString ($needle, $haystack) {
1210 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1211 return (strpos($haystack, $needle) !== FALSE);
1214 // Wrapper for strpos() to ease porting from deprecated eregi() function
1215 // This function is case-insensitive
1216 function isInStringIgnoreCase ($needle, $haystack) {
1217 return (isInString(strtolower($needle), strtolower($haystack)));
1220 // Wrapper to check for if fatal errors where detected
1221 function ifFatalErrorsDetected () {
1222 // Just call the inner function
1223 return (getTotalFatalErrors() > 0);
1226 // Checks whether a HTTP status has been set
1227 function isHttpStatusSet () {
1228 // Is it set and not empty?
1229 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1232 // Setter for HTTP status
1233 function setHttpStatus ($status) {
1234 $GLOBALS['http_status'] = (string) $status;
1237 // Getter for HTTP status
1238 function getHttpStatus () {
1239 // Is the status set?
1240 if (!isHttpStatusSet()) {
1242 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1246 return $GLOBALS['http_status'];
1250 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1251 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1253 * ----------------------------------------------------------------------------
1254 * If you want to redirect, please use redirectToUrl(); instead
1255 * ----------------------------------------------------------------------------
1257 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1259 * @link http://support.microsoft.com/kb/q176113/
1260 * @author Andreas Gohr <andi@splitbrain.org>
1263 function sendRawRedirect ($url) {
1264 // Clear output buffer
1265 clearOutputBuffer();
1267 // Clear own output buffer
1268 $GLOBALS['__output'] = '';
1270 // To make redirects working (no content type), output mode must be raw
1271 setScriptOutputMode(-1);
1273 // Send helping header
1274 setHttpStatus('302 Found');
1276 // always close the session
1277 session_write_close();
1279 // Revert entity &
1280 $url = str_replace('&', '&', $url);
1282 // check if running on IIS < 6 with CGI-PHP
1283 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1284 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1285 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1286 ($matches[1] < 6)) {
1287 // Send the IIS header
1288 addHttpHeader('Refresh: 0;url=' . $url);
1290 // Send generic header
1291 addHttpHeader('Location: ' . $url);
1298 // Determines the country of the given user id
1299 function determineCountry ($userid) {
1301 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1302 // Default is 'invalid'
1303 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1305 // Is extension country active?
1306 if (isExtensionActive('country')) {
1307 // Determine the right country code through the country id
1308 $id = getUserData('country_code');
1310 // Then handle it over
1311 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1313 // Get raw code from user data
1314 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1319 return $GLOBALS[__FUNCTION__][$userid];
1322 // "Getter" for total confirmed user accounts
1323 function getTotalConfirmedUser () {
1325 if (!isset($GLOBALS[__FUNCTION__])) {
1327 if (isExtensionActive('user')) {
1328 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1330 $GLOBALS[__FUNCTION__] = 0;
1334 // Return cached value
1335 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1336 return $GLOBALS[__FUNCTION__];
1339 // "Getter" for total unconfirmed user accounts
1340 function getTotalUnconfirmedUser () {
1342 if (!isset($GLOBALS[__FUNCTION__])) {
1344 if (isExtensionActive('user')) {
1345 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1347 $GLOBALS[__FUNCTION__] = 0;
1351 // Return cached value
1352 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1353 return $GLOBALS[__FUNCTION__];
1356 // "Getter" for total locked user accounts
1357 function getTotalLockedUser () {
1359 if (!isset($GLOBALS[__FUNCTION__])) {
1361 if (isExtensionActive('user')) {
1362 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1364 $GLOBALS[__FUNCTION__] = 0;
1368 // Return cached value
1369 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1370 return $GLOBALS[__FUNCTION__];
1373 // "Getter" for total locked user accounts
1374 function getTotalRandomRefidUser () {
1376 if (!isset($GLOBALS[__FUNCTION__])) {
1378 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1379 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1381 $GLOBALS[__FUNCTION__] = 0;
1385 // Return cached value
1386 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1387 return $GLOBALS[__FUNCTION__];
1390 // Is given id number valid?
1391 function isValidId ($id) {
1393 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1396 if (!isset($GLOBALS[__FUNCTION__][$id])) {
1398 $GLOBALS[__FUNCTION__][$id] = ((isValidNumber($id)) && (!is_bool($id)) && ($id != '00000') && ($id > 0));
1402 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1403 return $GLOBALS[__FUNCTION__][$id];
1406 // Checks whether a valid number is given
1407 function isValidNumber ($num) {
1409 return ((!is_null($num)) && (!empty($num)) && ('*' . bigintval($num, TRUE, FALSE) . '*' == '*' . $num . '*'));
1413 function encodeEntities ($str) {
1415 $str = secureString($str, TRUE, TRUE);
1417 // Encode dollar sign as well
1418 $str = str_replace('$', '$', $str);
1424 // "Getter" for date from patch_ctime
1425 function getDateFromRepository () {
1427 if (!isset($GLOBALS[__FUNCTION__])) {
1429 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1433 return $GLOBALS[__FUNCTION__];
1436 // "Getter" for date/time from patch_ctime
1437 function getDateTimeFromRepository () {
1439 if (!isset($GLOBALS[__FUNCTION__])) {
1441 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1445 return $GLOBALS[__FUNCTION__];
1448 // Getter for current year (default)
1449 function getYear ($timestamp = NULL) {
1451 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1452 // If NULL is set, use time()
1453 if (is_null($timestamp)) {
1454 $timestamp = time();
1458 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1462 return $GLOBALS[__FUNCTION__][$timestamp];
1465 // Getter for current month (default)
1466 function getMonth ($timestamp = NULL) {
1468 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1469 // If NULL is set, use time()
1470 if (is_null($timestamp)) {
1471 // Use time() which is current timestamp
1472 $timestamp = time();
1476 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1480 return $GLOBALS[__FUNCTION__][$timestamp];
1483 // Getter for current hour (default)
1484 function getHour ($timestamp = NULL) {
1486 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1488 if (is_null($timestamp)) {
1489 $timestamp = time();
1493 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1497 return $GLOBALS[__FUNCTION__][$timestamp];
1500 // Getter for current day (default)
1501 function getDay ($timestamp = NULL) {
1503 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1505 if (is_null($timestamp)) {
1506 $timestamp = time();
1510 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1514 return $GLOBALS[__FUNCTION__][$timestamp];
1517 // Getter for current week (default)
1518 function getWeek ($timestamp = NULL) {
1520 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1522 if (is_null($timestamp)) $timestamp = time();
1525 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1529 return $GLOBALS[__FUNCTION__][$timestamp];
1532 // Getter for current short_hour (default)
1533 function getShortHour ($timestamp = NULL) {
1535 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1537 if (is_null($timestamp)) $timestamp = time();
1540 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1544 return $GLOBALS[__FUNCTION__][$timestamp];
1547 // Getter for current long_hour (default)
1548 function getLongHour ($timestamp = NULL) {
1550 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1552 if (is_null($timestamp)) $timestamp = time();
1555 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1559 return $GLOBALS[__FUNCTION__][$timestamp];
1562 // Getter for current second (default)
1563 function getSecond ($timestamp = NULL) {
1565 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1567 if (is_null($timestamp)) $timestamp = time();
1570 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1574 return $GLOBALS[__FUNCTION__][$timestamp];
1577 // Getter for current minute (default)
1578 function getMinute ($timestamp = NULL) {
1580 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1582 if (is_null($timestamp)) $timestamp = time();
1585 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1589 return $GLOBALS[__FUNCTION__][$timestamp];
1592 // Checks whether the title decoration is enabled
1593 function isTitleDecorationEnabled () {
1595 if (!isset($GLOBALS[__FUNCTION__])) {
1597 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_title_deco')) && (getConfig('enable_title_deco') == 'Y'));
1601 return $GLOBALS[__FUNCTION__];
1604 // Checks whether filter usage updates are enabled (expensive queries!)
1605 function isFilterUsageUpdateEnabled () {
1607 if (!isset($GLOBALS[__FUNCTION__])) {
1609 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1613 return $GLOBALS[__FUNCTION__];
1616 // Checks whether debugging of weekly resets is enabled
1617 function isWeeklyResetDebugEnabled () {
1619 if (!isset($GLOBALS[__FUNCTION__])) {
1621 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1625 return $GLOBALS[__FUNCTION__];
1628 // Checks whether debugging of monthly resets is enabled
1629 function isMonthlyResetDebugEnabled () {
1631 if (!isset($GLOBALS[__FUNCTION__])) {
1633 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1637 return $GLOBALS[__FUNCTION__];
1640 // Checks whether debugging of yearly resets is enabled
1641 function isYearlyResetDebugEnabled () {
1643 if (!isset($GLOBALS[__FUNCTION__])) {
1645 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
1649 return $GLOBALS[__FUNCTION__];
1652 // Checks whether displaying of debug SQLs are enabled
1653 function isDisplayDebugSqlEnabled () {
1655 if (!isset($GLOBALS[__FUNCTION__])) {
1657 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (isConfigEntrySet('display_debug_sql')) && (getDisplayDebugSqls() == 'Y'));
1661 return $GLOBALS[__FUNCTION__];
1664 // Checks whether module title is enabled
1665 function isModuleTitleEnabled () {
1667 if (!isset($GLOBALS[__FUNCTION__])) {
1669 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_mod_title')) && (getConfig('enable_mod_title') == 'Y'));
1673 return $GLOBALS[__FUNCTION__];
1676 // Checks whether what title is enabled
1677 function isWhatTitleEnabled () {
1679 if (!isset($GLOBALS[__FUNCTION__])) {
1681 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_what_title')) && (getConfig('enable_what_title') == 'Y'));
1685 return $GLOBALS[__FUNCTION__];
1688 // "Getter" for internal_stats
1689 function getInternalStats () {
1691 if (!isset($GLOBALS[__FUNCTION__])) {
1693 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1697 return $GLOBALS[__FUNCTION__];
1700 // Checks whether stats are enabled
1701 function ifInternalStatsEnabled () {
1703 if (!isset($GLOBALS[__FUNCTION__])) {
1704 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1705 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1708 // Return cached value
1709 return $GLOBALS[__FUNCTION__];
1712 // Checks whether admin-notification of certain user actions is enabled
1713 function isAdminNotificationEnabled () {
1715 if (!isset($GLOBALS[__FUNCTION__])) {
1717 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isConfigEntrySet('admin_notify')) && (getAdminNotify() == 'Y'));
1721 return $GLOBALS[__FUNCTION__];
1724 // Checks whether random referral id selection is enabled
1725 function isRandomReferralIdEnabled () {
1727 if (!isset($GLOBALS[__FUNCTION__])) {
1729 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isConfigEntrySet('select_user_zero_refid')) && (getSelectUserZeroRefid() == 'Y'));
1733 return $GLOBALS[__FUNCTION__];
1736 // "Getter" for default language
1737 function getDefaultLanguage () {
1739 if (!isset($GLOBALS[__FUNCTION__])) {
1741 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1745 return $GLOBALS[__FUNCTION__];
1748 // "Getter" for default referral id
1749 function getDefRefid () {
1751 if (!isset($GLOBALS[__FUNCTION__])) {
1753 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1757 return $GLOBALS[__FUNCTION__];
1760 // "Getter" for path
1761 function getPath () {
1763 if (!isset($GLOBALS[__FUNCTION__])) {
1765 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1769 return $GLOBALS[__FUNCTION__];
1773 function getUrl () {
1775 if (!isset($GLOBALS[__FUNCTION__])) {
1777 $GLOBALS[__FUNCTION__] = getConfig('URL');
1781 return $GLOBALS[__FUNCTION__];
1784 // "Getter" for cache_path
1785 function getCachePath () {
1787 if (!isset($GLOBALS[__FUNCTION__])) {
1789 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1793 return $GLOBALS[__FUNCTION__];
1796 // "Getter" for WRITE_FOOTER
1797 function getWriteFooter () {
1799 if (!isset($GLOBALS[__FUNCTION__])) {
1801 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1805 return $GLOBALS[__FUNCTION__];
1808 // "Getter" for secret_key
1809 function getSecretKey () {
1811 if (!isset($GLOBALS[__FUNCTION__])) {
1813 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1817 return $GLOBALS[__FUNCTION__];
1820 // "Getter" for SITE_KEY
1821 function getSiteKey () {
1823 if (!isset($GLOBALS[__FUNCTION__])) {
1825 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1829 return $GLOBALS[__FUNCTION__];
1832 // "Getter" for DATE_KEY
1833 function getDateKey () {
1835 if (!isset($GLOBALS[__FUNCTION__])) {
1837 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1841 return $GLOBALS[__FUNCTION__];
1844 // "Getter" for master_salt
1845 function getMasterSalt () {
1847 if (!isset($GLOBALS[__FUNCTION__])) {
1849 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1853 return $GLOBALS[__FUNCTION__];
1856 // "Getter" for prime
1857 function getPrime () {
1859 if (!isset($GLOBALS[__FUNCTION__])) {
1861 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1865 return $GLOBALS[__FUNCTION__];
1868 // "Getter" for encrypt_separator
1869 function getEncryptSeparator () {
1871 if (!isset($GLOBALS[__FUNCTION__])) {
1873 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1877 return $GLOBALS[__FUNCTION__];
1880 // "Getter" for mysql_prefix
1881 function getMysqlPrefix () {
1883 if (!isset($GLOBALS[__FUNCTION__])) {
1885 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1889 return $GLOBALS[__FUNCTION__];
1892 // "Getter" for table_type
1893 function getTableType () {
1895 if (!isset($GLOBALS[__FUNCTION__])) {
1897 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1901 return $GLOBALS[__FUNCTION__];
1904 // "Getter" for salt_length
1905 function getSaltLength () {
1907 if (!isset($GLOBALS[__FUNCTION__])) {
1909 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1913 return $GLOBALS[__FUNCTION__];
1916 // "Getter" for output_mode
1917 function getOutputMode () {
1919 if (!isset($GLOBALS[__FUNCTION__])) {
1921 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1925 return $GLOBALS[__FUNCTION__];
1928 // "Getter" for full_version
1929 function getFullVersion () {
1931 if (!isset($GLOBALS[__FUNCTION__])) {
1933 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1937 return $GLOBALS[__FUNCTION__];
1940 // "Getter" for title
1941 function getTitle () {
1943 if (!isset($GLOBALS[__FUNCTION__])) {
1945 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1949 return $GLOBALS[__FUNCTION__];
1952 // "Getter" for curr_svn_revision
1953 function getCurrentRepositoryRevision () {
1955 if (!isset($GLOBALS[__FUNCTION__])) {
1957 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1961 return $GLOBALS[__FUNCTION__];
1964 // "Getter" for server_url
1965 function getServerUrl () {
1967 if (!isset($GLOBALS[__FUNCTION__])) {
1969 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1973 return $GLOBALS[__FUNCTION__];
1976 // "Getter" for mt_word
1977 function getMtWord () {
1979 if (!isset($GLOBALS[__FUNCTION__])) {
1981 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1985 return $GLOBALS[__FUNCTION__];
1988 // "Getter" for mt_word2
1989 function getMtWord2 () {
1991 if (!isset($GLOBALS[__FUNCTION__])) {
1993 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1997 return $GLOBALS[__FUNCTION__];
2000 // "Getter" for mt_word3
2001 function getMtWord3 () {
2003 if (!isset($GLOBALS[__FUNCTION__])) {
2005 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
2009 return $GLOBALS[__FUNCTION__];
2012 // "Getter" for START_TDAY
2013 function getStartTday () {
2015 if (!isset($GLOBALS[__FUNCTION__])) {
2017 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
2021 return $GLOBALS[__FUNCTION__];
2024 // "Getter" for START_YDAY
2025 function getStartYday () {
2027 if (!isset($GLOBALS[__FUNCTION__])) {
2029 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
2033 return $GLOBALS[__FUNCTION__];
2036 // "Getter" for main_title
2037 function getMainTitle () {
2039 if (!isset($GLOBALS[__FUNCTION__])) {
2041 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2045 return $GLOBALS[__FUNCTION__];
2048 // "Getter" for file_hash
2049 function getFileHash () {
2051 if (!isset($GLOBALS[__FUNCTION__])) {
2053 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2057 return $GLOBALS[__FUNCTION__];
2060 // "Getter" for pass_scramble
2061 function getPassScramble () {
2063 if (!isset($GLOBALS[__FUNCTION__])) {
2065 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2069 return $GLOBALS[__FUNCTION__];
2072 // "Getter" for ap_inactive_since
2073 function getApInactiveSince () {
2075 if (!isset($GLOBALS[__FUNCTION__])) {
2077 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2081 return $GLOBALS[__FUNCTION__];
2084 // "Getter" for user_min_confirmed
2085 function getUserMinConfirmed () {
2087 if (!isset($GLOBALS[__FUNCTION__])) {
2089 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2093 return $GLOBALS[__FUNCTION__];
2095 // "Getter" for points
2096 function getPoints () {
2098 if (!isset($GLOBALS[__FUNCTION__])) {
2100 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2104 return $GLOBALS[__FUNCTION__];
2107 // "Getter" for slogan
2108 function getSlogan () {
2110 if (!isset($GLOBALS[__FUNCTION__])) {
2112 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2116 return $GLOBALS[__FUNCTION__];
2119 // "Getter" for copy
2120 function getCopy () {
2122 if (!isset($GLOBALS[__FUNCTION__])) {
2124 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2128 return $GLOBALS[__FUNCTION__];
2131 // "Getter" for webmaster
2132 function getWebmaster () {
2134 if (!isset($GLOBALS[__FUNCTION__])) {
2136 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2140 return $GLOBALS[__FUNCTION__];
2143 // "Getter" for sql_count
2144 function getSqlCount () {
2146 if (!isset($GLOBALS[__FUNCTION__])) {
2148 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2152 return $GLOBALS[__FUNCTION__];
2155 // "Getter" for num_templates
2156 function getNumTemplates () {
2158 if (!isset($GLOBALS[__FUNCTION__])) {
2160 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2164 return $GLOBALS[__FUNCTION__];
2167 // "Getter" for dns_cache_timeout
2168 function getDnsCacheTimeout () {
2170 if (!isset($GLOBALS[__FUNCTION__])) {
2172 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2176 return $GLOBALS[__FUNCTION__];
2179 // "Getter" for menu_blur_spacer
2180 function getMenuBlurSpacer () {
2182 if (!isset($GLOBALS[__FUNCTION__])) {
2184 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2188 return $GLOBALS[__FUNCTION__];
2191 // "Getter" for points_register
2192 function getPointsRegister () {
2194 if (!isset($GLOBALS[__FUNCTION__])) {
2196 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2200 return $GLOBALS[__FUNCTION__];
2203 // "Getter" for points_ref
2204 function getPointsRef () {
2206 if (!isset($GLOBALS[__FUNCTION__])) {
2208 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2212 return $GLOBALS[__FUNCTION__];
2215 // "Getter" for ref_payout
2216 function getRefPayout () {
2218 if (!isset($GLOBALS[__FUNCTION__])) {
2220 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2224 return $GLOBALS[__FUNCTION__];
2227 // "Getter" for online_timeout
2228 function getOnlineTimeout () {
2230 if (!isset($GLOBALS[__FUNCTION__])) {
2232 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2236 return $GLOBALS[__FUNCTION__];
2239 // "Getter" for index_home
2240 function getIndexHome () {
2242 if (!isset($GLOBALS[__FUNCTION__])) {
2244 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2248 return $GLOBALS[__FUNCTION__];
2251 // "Getter" for one_day
2252 function getOneDay () {
2254 if (!isset($GLOBALS[__FUNCTION__])) {
2256 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2260 return $GLOBALS[__FUNCTION__];
2263 // "Getter" for img_type
2264 function getImgType () {
2266 if (!isset($GLOBALS[__FUNCTION__])) {
2268 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2272 return $GLOBALS[__FUNCTION__];
2275 // "Getter" for code_length
2276 function getCodeLength () {
2278 if (!isset($GLOBALS[__FUNCTION__])) {
2280 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2284 return $GLOBALS[__FUNCTION__];
2287 // "Getter" for min_password_length
2288 function getMinPasswordLength () {
2290 if (!isset($GLOBALS[__FUNCTION__])) {
2292 $GLOBALS[__FUNCTION__] = getConfig('min_password_length');
2296 return $GLOBALS[__FUNCTION__];
2299 // "Getter" for min_password_score
2300 function getMinPasswordScore () {
2302 if (!isset($GLOBALS[__FUNCTION__])) {
2304 $GLOBALS[__FUNCTION__] = getConfig('min_password_score');
2308 return $GLOBALS[__FUNCTION__];
2311 // "Getter" for admin_menu
2312 function getAdminMenu () {
2314 if (!isset($GLOBALS[__FUNCTION__])) {
2316 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2320 return $GLOBALS[__FUNCTION__];
2323 // "Getter" for last_hourly
2324 function getLastHourly () {
2326 if (!isset($GLOBALS[__FUNCTION__])) {
2328 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2332 return $GLOBALS[__FUNCTION__];
2335 // "Getter" for last_daily
2336 function getLastDaily () {
2338 if (!isset($GLOBALS[__FUNCTION__])) {
2340 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2344 return $GLOBALS[__FUNCTION__];
2347 // "Getter" for last_weekly
2348 function getLastWeekly () {
2350 if (!isset($GLOBALS[__FUNCTION__])) {
2352 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2356 return $GLOBALS[__FUNCTION__];
2359 // "Getter" for last_monthly
2360 function getLastMonthly () {
2362 if (!isset($GLOBALS[__FUNCTION__])) {
2364 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2368 return $GLOBALS[__FUNCTION__];
2371 // "Getter" for last_yearly
2372 function getLastYearly () {
2374 if (!isset($GLOBALS[__FUNCTION__])) {
2376 $GLOBALS[__FUNCTION__] = getConfig('last_yearly');
2380 return $GLOBALS[__FUNCTION__];
2383 // "Getter" for mails_page
2384 function getMailsPage () {
2386 if (!isset($GLOBALS[__FUNCTION__])) {
2388 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2392 return $GLOBALS[__FUNCTION__];
2395 // "Getter" for rand_no
2396 function getRandNo () {
2398 if (!isset($GLOBALS[__FUNCTION__])) {
2400 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2404 return $GLOBALS[__FUNCTION__];
2407 // "Getter" for __DB_NAME
2408 function getDbName () {
2410 if (!isset($GLOBALS[__FUNCTION__])) {
2412 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2416 return $GLOBALS[__FUNCTION__];
2419 // "Getter" for DOMAIN
2420 function getDomain () {
2422 if (!isset($GLOBALS[__FUNCTION__])) {
2424 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2428 return $GLOBALS[__FUNCTION__];
2431 // "Getter" for proxy_username
2432 function getProxyUsername () {
2434 if (!isset($GLOBALS[__FUNCTION__])) {
2436 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2440 return $GLOBALS[__FUNCTION__];
2443 // "Getter" for proxy_password
2444 function getProxyPassword () {
2446 if (!isset($GLOBALS[__FUNCTION__])) {
2448 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2452 return $GLOBALS[__FUNCTION__];
2455 // "Getter" for proxy_host
2456 function getProxyHost () {
2458 if (!isset($GLOBALS[__FUNCTION__])) {
2460 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2464 return $GLOBALS[__FUNCTION__];
2467 // "Getter" for proxy_port
2468 function getProxyPort () {
2470 if (!isset($GLOBALS[__FUNCTION__])) {
2472 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2476 return $GLOBALS[__FUNCTION__];
2479 // "Getter" for SMTP_HOSTNAME
2480 function getSmtpHostname () {
2482 if (!isset($GLOBALS[__FUNCTION__])) {
2484 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2488 return $GLOBALS[__FUNCTION__];
2491 // "Getter" for SMTP_USER
2492 function getSmtpUser () {
2494 if (!isset($GLOBALS[__FUNCTION__])) {
2496 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2500 return $GLOBALS[__FUNCTION__];
2503 // "Getter" for SMTP_PASSWORD
2504 function getSmtpPassword () {
2506 if (!isset($GLOBALS[__FUNCTION__])) {
2508 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2512 return $GLOBALS[__FUNCTION__];
2515 // "Getter" for points_word
2516 function getPointsWord () {
2518 if (!isset($GLOBALS[__FUNCTION__])) {
2520 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2524 return $GLOBALS[__FUNCTION__];
2527 // "Getter" for profile_lock
2528 function getProfileLock () {
2530 if (!isset($GLOBALS[__FUNCTION__])) {
2532 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2536 return $GLOBALS[__FUNCTION__];
2539 // "Getter" for url_tlock
2540 function getUrlTlock () {
2542 if (!isset($GLOBALS[__FUNCTION__])) {
2544 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2548 return $GLOBALS[__FUNCTION__];
2551 // "Getter" for title_left
2552 function getTitleLeft () {
2554 if (!isset($GLOBALS[__FUNCTION__])) {
2556 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2560 return $GLOBALS[__FUNCTION__];
2563 // "Getter" for title_right
2564 function getTitleRight () {
2566 if (!isset($GLOBALS[__FUNCTION__])) {
2568 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2572 return $GLOBALS[__FUNCTION__];
2575 // "Getter" for title_middle
2576 function getTitleMiddle () {
2578 if (!isset($GLOBALS[__FUNCTION__])) {
2580 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2584 return $GLOBALS[__FUNCTION__];
2587 // Getter for 'display_home_in_index'
2588 function getDisplayHomeInIndex () {
2589 // Is the cache entry set?
2590 if (!isset($GLOBALS[__FUNCTION__])) {
2591 // No, so determine it
2592 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2595 // Return cached entry
2596 return $GLOBALS[__FUNCTION__];
2599 // Checks whether 'display_home_in_index' is 'Y'
2600 function isDisplayHomeInIndexEnabled () {
2601 // Is the cache entry set?
2602 if (!isset($GLOBALS[__FUNCTION__])) {
2603 // No, so determine it
2604 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isConfigEntrySet('display_home_in_index')) && (getDisplayHomeInIndex() == 'Y'));
2607 // Return cached entry
2608 return $GLOBALS[__FUNCTION__];
2611 // Getter for 'show_points_unconfirmed'
2612 function getShowPointsUnconfirmed () {
2613 // Is the cache entry set?
2614 if (!isset($GLOBALS[__FUNCTION__])) {
2615 // No, so determine it
2616 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2619 // Return cached entry
2620 return $GLOBALS[__FUNCTION__];
2623 // Checks whether 'show_points_unconfirmed' is 'Y'
2624 function isShowPointsUnconfirmedEnabled () {
2625 // Is the cache entry set?
2626 if (!isset($GLOBALS[__FUNCTION__])) {
2627 // No, so determine it
2628 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.5.5')) && (isConfigEntrySet('show_points_unconfirmed')) && (getShowPointsUnconfirmed() == 'Y'));
2631 // Return cached entry
2632 return $GLOBALS[__FUNCTION__];
2635 // Getter for 'youre_here'
2636 function getYoureHere () {
2637 // Is the cache entry set?
2638 if (!isset($GLOBALS[__FUNCTION__])) {
2639 // No, so determine it
2640 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2643 // Return cached entry
2644 return $GLOBALS[__FUNCTION__];
2647 // Checks whether 'show_timings' is 'Y'
2648 function isYoureHereEnabled () {
2649 // Is the cache entry set?
2650 if (!isset($GLOBALS[__FUNCTION__])) {
2651 // No, so determine it
2652 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (isConfigEntrySet('youre_here')) && (getYoureHere() == 'Y'));
2655 // Return cached entry
2656 return $GLOBALS[__FUNCTION__];
2659 // Getter for 'show_timings'
2660 function getShowTimings () {
2661 // Is the cache entry set?
2662 if (!isset($GLOBALS[__FUNCTION__])) {
2663 // No, so determine it
2664 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2667 // Return cached entry
2668 return $GLOBALS[__FUNCTION__];
2671 // Checks whether 'show_timings' is 'Y'
2672 function isShowTimingsEnabled () {
2673 // Is the cache entry set?
2674 if (!isset($GLOBALS[__FUNCTION__])) {
2675 // No, so determine it
2676 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isConfigEntrySet('show_timings')) && (getShowTimings() == 'Y'));
2679 // Return cached entry
2680 return $GLOBALS[__FUNCTION__];
2683 // Getter for 'ap_server_name_since'
2684 function getApServerNameSince () {
2685 // Is the cache entry set?
2686 if (!isset($GLOBALS[__FUNCTION__])) {
2687 // No, so determine it
2688 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2691 // Return cached entry
2692 return $GLOBALS[__FUNCTION__];
2695 // Getter for 'ap_server_name'
2696 function getApServerName () {
2697 // Is the cache entry set?
2698 if (!isset($GLOBALS[__FUNCTION__])) {
2699 // No, so determine it
2700 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2703 // Return cached entry
2704 return $GLOBALS[__FUNCTION__];
2707 // Getter for 'index_delay'
2708 function getIndexDelay () {
2709 // Is the cache entry set?
2710 if (!isset($GLOBALS[__FUNCTION__])) {
2711 // No, so determine it
2712 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2715 // Return cached entry
2716 return $GLOBALS[__FUNCTION__];
2719 // Checks whether 'ap_server_name' is 'Y'
2720 function isApServerNameEnabled () {
2721 // Is the cache entry set?
2722 if (!isset($GLOBALS[__FUNCTION__])) {
2723 // No, so determine it
2724 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2727 // Return cached entry
2728 return $GLOBALS[__FUNCTION__];
2731 // Getter for 'admin_menu_javascript'
2732 function getAdminMenuJavascript () {
2733 // Is the cache entry set?
2734 if (!isset($GLOBALS[__FUNCTION__])) {
2735 // No, so determine it
2736 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2739 // Return cached entry
2740 return $GLOBALS[__FUNCTION__];
2743 // Getter for 'points_remove_account'
2744 function getPointsRemoveAccount () {
2745 // Is the cache entry set?
2746 if (!isset($GLOBALS[__FUNCTION__])) {
2747 // No, so determine it
2748 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2751 // Return cached entry
2752 return $GLOBALS[__FUNCTION__];
2755 // Getter for 'css_php'
2756 function getCssPhp () {
2757 // Is the cache entry set?
2758 if (!isset($GLOBALS[__FUNCTION__])) {
2759 // No, so determine it
2760 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2763 // Return cached entry
2764 return $GLOBALS[__FUNCTION__];
2767 // Getter for 'guest_menu'
2768 function getGuestMenu () {
2769 // Is the cache entry set?
2770 if (!isset($GLOBALS[__FUNCTION__])) {
2771 // No, so determine it
2772 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2775 // Return cached entry
2776 return $GLOBALS[__FUNCTION__];
2779 // Checks if guest menu is enabled
2780 function isGuestMenuEnabled () {
2781 // Is the cache entry set?
2782 if (!isset($GLOBALS[__FUNCTION__])) {
2783 // No, so determine it
2784 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2787 // Return cached entry
2788 return $GLOBALS[__FUNCTION__];
2791 // Getter for 'member_menu'
2792 function getMemberMenu () {
2793 // Is the cache entry set?
2794 if (!isset($GLOBALS[__FUNCTION__])) {
2795 // No, so determine it
2796 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2799 // Return cached entry
2800 return $GLOBALS[__FUNCTION__];
2803 // Checks if member menu is enabled
2804 function isMemberMenuEnabled () {
2805 // Is the cache entry set?
2806 if (!isset($GLOBALS[__FUNCTION__])) {
2807 // No, so determine it
2808 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2811 // Return cached entry
2812 return $GLOBALS[__FUNCTION__];
2815 // Getter for 'word_wrap'
2816 function getWordWrap () {
2817 // Is the cache entry set?
2818 if (!isset($GLOBALS[__FUNCTION__])) {
2819 // Construct config entry name
2820 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2822 // Is a special config entry found or ext-sql_patches updated?
2823 if (isConfigEntrySet($configEntry)) {
2824 // A special config entry has been found, then use it
2825 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2826 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2827 // No special config entry found, then use it as "fall-back"
2828 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2830 // No, use default (15 characters)
2831 $GLOBALS[__FUNCTION__] = 15;
2835 // Return cached entry
2836 return $GLOBALS[__FUNCTION__];
2839 // Checks whether proxy configuration is used
2840 function isProxyUsed () {
2842 if (!isset($GLOBALS[__FUNCTION__])) {
2844 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (isValidNumber(getConfig('proxy_port'))));
2848 return $GLOBALS[__FUNCTION__];
2851 // Checks whether POST data contains selections
2852 function ifPostContainsSelections ($element = 'sel') {
2854 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2856 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2860 return $GLOBALS[__FUNCTION__][$element];
2863 // Checks whether verbose_sql is Y and returns true/false if so
2864 function isVerboseSqlEnabled () {
2866 if (!isset($GLOBALS[__FUNCTION__])) {
2868 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2872 return $GLOBALS[__FUNCTION__];
2875 // "Getter" for total user points
2876 function getTotalPoints ($userid) {
2878 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2879 // Init array for filter chain
2881 'userid' => $userid,
2885 // Run filter chain for getting more point values
2886 $data = runFilterChain('get_total_points', $data);
2889 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2893 return $GLOBALS[__FUNCTION__][$userid];
2896 // Wrapper to get used points for given userid
2897 function getUserUsedPoints ($userid) {
2899 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2901 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2905 return $GLOBALS[__FUNCTION__][$userid];
2908 // Checks whether direct payment is allowed in configuration
2909 function isDirectPaymentEnabled () {
2911 if (!isset($GLOBALS[__FUNCTION__])) {
2913 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('allow_direct_pay')) && (getConfig('allow_direct_pay') == 'Y'));
2917 return $GLOBALS[__FUNCTION__];
2920 // Checks whether JavaScript-based admin menu is enabled
2921 function isAdminMenuJavascriptEnabled () {
2923 if (!isset($GLOBALS[__FUNCTION__])) {
2925 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (isConfigEntrySet('admin_menu_javascript')) && (getAdminMenuJavaScript() == 'Y'));
2929 return $GLOBALS[__FUNCTION__];
2932 // Wrapper to check if current task is for extension (not update)
2933 function isExtensionTask ($content) {
2935 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2937 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2941 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2944 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2945 function ifTesterAccountsAllowed () {
2946 // Is the cache entry set?
2947 if (!isset($GLOBALS[__FUNCTION__])) {
2948 // No, so determine it
2949 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2952 // Return cached entry
2953 return $GLOBALS[__FUNCTION__];
2956 // Wrapper to check if output mode is CSS
2957 function isCssOutputMode () {
2959 if (!isset($GLOBALS[__FUNCTION__])) {
2961 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2962 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2966 return $GLOBALS[__FUNCTION__];
2969 // Wrapper to check if output mode is HTML
2970 function isHtmlOutputMode () {
2972 if (!isset($GLOBALS[__FUNCTION__])) {
2974 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2975 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2979 return $GLOBALS[__FUNCTION__];
2982 // Wrapper to check if output mode is RAW
2983 function isRawOutputMode () {
2985 if (!isset($GLOBALS[__FUNCTION__])) {
2987 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2988 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2992 return $GLOBALS[__FUNCTION__];
2995 // Wrapper to check if output mode is AJAX
2996 function isAjaxOutputMode () {
2998 if (!isset($GLOBALS[__FUNCTION__])) {
3000 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
3001 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
3005 return $GLOBALS[__FUNCTION__];
3008 // Wrapper to check if output mode is image
3009 function isImageOutputMode () {
3011 if (!isset($GLOBALS[__FUNCTION__])) {
3013 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
3014 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
3018 return $GLOBALS[__FUNCTION__];
3021 // Wrapper to generate a user email link
3022 function generateWrappedUserEmailLink ($email) {
3023 // Just call the inner function
3024 return generateEmailLink($email, 'user_data');
3027 // Wrapper to check if user points are locked
3028 function ifUserPointsLocked ($userid) {
3029 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
3031 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3033 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
3037 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
3038 return $GLOBALS[__FUNCTION__][$userid];
3041 // Appends a line to an existing file or creates it instantly with given content.
3042 // This function does always add a new-line character to every line.
3043 function appendLineToFile ($file, $line) {
3044 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
3045 fwrite($fp, $line . PHP_EOL);
3049 // Wrapper for changeDataInFile() but with full path added
3050 function changeDataInInclude ($inc, $comment, $prefix, $suffix, $inserted, $seek=0) {
3052 $FQFN = getPath() . $inc;
3054 // Call inner function
3055 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
3058 // Wrapper for changing entries in config-local.php
3059 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3060 // Call the inner function
3061 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3064 // Shortens ucfirst(strtolower()) calls
3065 function firstCharUpperCase ($str) {
3066 return ucfirst(strtolower($str));
3069 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3070 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3071 // Get the configuration entry
3072 $configValue = getConfig($configEntry);
3074 // Call inner method
3075 return createTimeSelections($configValue, $configEntry, $stamps, $align);
3078 // Shortens converting of German comma to Computer's version in POST data
3079 function convertCommaToDotInPostData ($postEntry) {
3080 // Read and convert given entry
3081 $postValue = convertCommaToDot(postRequestElement($postEntry));
3084 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3086 // ... and set it again
3087 setPostRequestElement($postEntry, $postValue);
3090 // Converts German commas to Computer's version in all entries
3091 function convertCommaToDotInPostDataArray ($postEntries) {
3092 // Replace german decimal comma with computer decimal dot
3093 foreach ($postEntries as $entry) {
3094 // Is the entry there?
3095 if (isPostRequestElementSet($entry)) {
3097 convertCommaToDotInPostData($entry);
3103 * Parses a string into a US formated float variable, taken from user comments
3104 * from PHP documentation website.
3106 * @param $floatString A string holding a float expression
3107 * @return $float Corresponding float variable
3108 * @author chris<at>georgakopoulos<dot>com
3109 * @link http://de.php.net/manual/en/function.floatval.php#92563
3111 function parseFloat ($floatString){
3113 $LocaleInfo = localeconv();
3115 // Remove thousand separators
3116 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3118 // Convert decimal point
3119 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3121 // Return float value of converted string
3122 return floatval($floatString);
3126 * Searches a multi-dimensional array (as used in many places) for given
3127 * key/value pair as taken from user comments from PHP documentation website.
3129 * @param $array An array with one or more dimensions
3130 * @param $key Key to look for
3131 * @param $value Value to look for
3132 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3133 * @return $results Resulted array or empty array if $array is no array
3134 * @author sunelbe<at>gmail<dot>com
3135 * @link http://de.php.net/manual/en/function.array-search.php#110120
3137 function search_array ($array, $key, $value, $parentIndex = NULL) {
3138 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3139 // Init array result
3142 // Is $array really an array?
3143 if (is_array($array)) {
3144 // Search for whole array
3145 foreach ($array as $idx => $dummy) {
3146 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3147 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3148 // Is dummy an array?
3149 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3150 // Then search again
3151 $subResult = search_array($dummy, $key, $value, $idx);
3152 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3155 $results = merge_array($results, $subResult, TRUE);
3156 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3157 // Is found, so add it
3158 $results[$parentIndex] = $array;
3159 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3164 // Return resulting array
3165 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3169 // Generates a YES/NO option list from given default
3170 function generateYesNoOptions ($defaultValue = '') {
3172 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3175 // "Getter" for total available receivers
3176 function getTotalReceivers ($mode = 'normal') {
3178 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3184 // Wrapper "getter" to get total unconfirmed mails for given userid
3185 function getTotalUnconfirmedMails ($userid) {
3187 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3189 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3193 return $GLOBALS[__FUNCTION__][$userid];
3196 // Checks whether 'mailer_theme' was found in session
3197 function isMailerThemeSet () {
3199 if (!isset($GLOBALS[__FUNCTION__])) {
3201 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3205 return $GLOBALS[__FUNCTION__];
3209 * Setter for theme in session (This setter does return the success of
3210 * setSession() which is required e.g. for destroySponsorSession().
3212 function setMailerTheme ($newTheme) {
3213 // Set it in session
3214 return setSession('mailer_theme', $newTheme);
3218 * Getter for theme from session (This getter does return 'mailer_theme' from
3219 * session data or throws an error if not possible
3221 function getMailerTheme () {
3223 if (!isset($GLOBALS[__FUNCTION__])) {
3224 // Is 'mailer_theme' set?
3225 if (!isMailerThemeSet()) {
3226 // No, then abort here
3227 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3230 // Get it and store it in cache
3231 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3235 return $GLOBALS[__FUNCTION__];
3238 // "Getter" for last_module/last_what depending on ext-user version
3239 function getUserLastWhatName () {
3240 // Default is old one: last_module
3241 $columnName = 'last_module';
3243 // Is ext-user up-to-date?
3244 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3245 // Yes, then use new one
3246 $columnName = 'last_what';
3253 // "Getter" for all columns for given alias and separator
3254 function getAllPointColumns ($alias = NULL, $separator = ',') {
3255 // Prepare the filter array
3256 $filterData = array(
3259 'separator' => $separator
3263 $filterData = runFilterChain('get_all_point_columns', $filterData);
3265 // Return the columns
3266 return $filterData['columns'];
3269 // Checks whether the copyright footer (which breaks framesets) is enabled
3270 function ifCopyrightFooterEnabled () {
3271 // Is not unset and not 'N'?
3272 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3276 * Wrapper to check whether we have a "full page". This means that the actual
3277 * content is not delivered in any frame of a frameset.
3279 function isFullPage () {
3281 * The parameter 'frame' is generic and always indicates that this content
3282 * will be output into a frame. Furthermore, if a frameset is reported or
3283 * the copyright line is explicitly deactivated, this cannot be a "full
3286 // @TODO Find a way to not use direct module comparison
3287 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3293 // Checks whether frameset_mode is set to true
3294 function isFramesetModeEnabled () {
3296 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3299 // Function to determine correct 'what' value
3300 function determineWhat ($module = NULL) {
3301 // Init default 'what'
3305 if (is_null($module)) {
3307 $module = getModule();
3315 // Else try to get it from current module
3316 $what = getWhatFromModule($module);
3318 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3320 // Remove any spaces from variable
3321 $what = trim($what);
3325 // Default action for non-admin menus
3329 $what = secureString($what);
3336 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3337 function prependZeros ($str, $length = 2) {
3338 // Return prepended string
3339 return sprintf('%0' . (int) $length . 's', $str);
3342 // Wraps convertSelectionsToEpocheTime()
3343 function convertSelectionsToEpocheTimeInPostData ($id) {
3348 // Get all POST data
3349 $postData = postRequestArray();
3351 // Convert given selection id
3352 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3354 // Set the POST array back
3355 setPostRequestArray($postData);
3358 // Wraps checking if given points account type matches with given in POST data
3359 function ifPointsAccountTypeMatchesPost ($type) {
3361 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3364 // Gets given user's total referral
3365 function getUsersTotalReferrals ($userid, $level = NULL) {
3367 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3368 // Is the level NULL?
3369 if (is_null($level)) {
3370 // Get total amount (all levels)
3371 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3373 // Get it from user refs
3374 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3379 return $GLOBALS[__FUNCTION__][$userid][$level];
3382 // Gets given user's total referral
3383 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3384 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3386 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3387 // Default is all refs
3390 // Is the not level NULL?
3391 if (!is_null($level)) {
3392 // Then add referral level
3393 $add = ' AND `r`.`level`=' . bigintval($level);
3396 // Check for all referrals
3397 $result = sqlQueryEscaped("SELECT
3398 COUNT(`d`.`userid`) AS `cnt`
3400 `{?_MYSQL_PREFIX?}_user_data` AS `d`
3402 `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3404 `d`.`userid`=`r`.`refid`
3406 `d`.`status` != 'CONFIRMED' AND
3414 ), __FUNCTION__, __LINE__);
3417 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3420 sqlFreeResult($result);
3424 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3425 return $GLOBALS[__FUNCTION__][$userid][$level];
3428 // Converts, if found, dollar data to get element
3429 function convertDollarDataToGetElement ($data) {
3430 // Is first char a dollar?
3431 if (substr($data, 0, 1) == chr(36)) {
3432 // Use last part for getRequestElement()
3433 $data = getRequestElement(substr($data, 1));
3440 // Wrapper function for SQL layer to speed-up things
3441 function isSqlDebugEnabled () {
3443 if (!isset($GLOBALS[__FUNCTION__])) {
3445 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3449 return $GLOBALS[__FUNCTION__];
3452 // Wrapper function to wrap call of wordwrap()
3453 function wrapWords ($text) {
3455 $wrapped = wordwrap($test, getWordWrap());
3461 // Encodes given data into a JSON object
3462 function encodeJson ($data) {
3464 return json_encode($data, JSON_FORCE_OBJECT);
3467 // Get all extension files
3468 function loadAllExtensionsByTemplate () {
3470 $extensions = getArrayFromDirectory(
3471 'templates/' . getLanguage() . '/html/ext/',
3485 // Wrapper function to allow full float values as supported by current database layout
3486 function translateFullComma ($dotted) {
3487 // Call inner function
3488 return translateComma($dotted, TRUE, 5);
3491 // Wrapper to check if the first element to be shifted is set to given value
3492 function shift_array (&$array, $value, $key = '0') {
3493 // Is the element set and value matches?
3494 assert(is_array($array));
3495 assert(isset($array[$key]));
3496 assert($array[$key] === $value);
3499 array_shift($array);
3502 // Wrapper for str_pad() with left padding zeros
3503 function padLeftZero ($str, $amount = 2) {
3504 // Is str_pad() there?
3505 if (function_exists('str_pad')) {
3506 // Use prependZeros()
3507 return prependZeros($str, $amount);
3510 return str_pad($str, $amount, '0', STR_PAD_LEFT);
3514 // Calculates percentage
3515 function calculatePercentageRate ($current, $total) {
3519 // Is sent larger zero? (Prevents division-by-zero)
3521 // Calculate it (it should be "translated" alter on)
3522 $rate = ($current / $total * 100);
3525 // The should be a .0 at the end?
3526 if (strpos($rate, '.') === FALSE) {
3535 // Checks whether an array is filled with entries
3536 function isFilledArray ($array) {
3538 return ((is_array($array)) && (count($array) > 0));
3541 // Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
3542 function isDeveloperSystem () {
3544 return in_array(detectServerName(), array('localhost', '127.0.0.1'));
3547 // Checks whether given subject line has '_ref' suffix
3548 function ifSubjectHasReferralSuffix ($subject) {
3550 if (!isset($GLOBALS[__FUNCTION__][$subject])) {
3552 $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
3556 return $GLOBALS[__FUNCTION__][$subject];