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 - 2012 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')
92 or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
95 if ($aquireLock === TRUE) {
101 $return = fwrite($fp, $content);
107 // Was something written?
108 if ($return !== FALSE) {
109 // Mark it as readable
110 $GLOBALS['file_readable'][$FQFN] = TRUE;
114 return (($return !== FALSE) && (changeMode($FQFN, 0644)));
117 // Clears the output buffer. This function does *NOT* backup sent content.
118 function clearOutputBuffer () {
119 // Make sure this function is not called twice (no double-cleaning!)
120 if (isset($GLOBALS[__FUNCTION__])) {
121 // This function is called twice
122 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
123 } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
125 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
128 // Mark this function as called
129 $GLOBALS[__FUNCTION__] = TRUE;
133 function encodeString ($str) {
134 $str = urlencode(base64_encode(compileUriCode($str)));
138 // Decode strings encoded with encodeString()
139 function decodeString ($str) {
140 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
144 // Decode entities in a nicer way
145 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
146 // Decode the entities to UTF-8 now
147 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
149 // Return decoded string
150 return $decodedString;
153 // Merges an array together but only if both are arrays
154 function merge_array ($array1, $array2, $keepIndex = FALSE) {
155 // Are both an array?
156 if ((!is_array($array1)) && (!is_array($array2))) {
157 // Both are not arrays
158 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
159 } elseif (!is_array($array1)) {
160 // Left one is not an array
161 reportBug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
162 } elseif (!is_array($array2)) {
163 // Right one is not an array
164 reportBug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
167 // Maintain index of array2?
168 if ($keepIndex === TRUE) {
169 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
170 foreach ($array2 as $key => $value) {
172 $array1[$key] = $value;
178 // Merge both together normally
179 return array_merge($array1, $array2);
183 // Check if given FQFN is a readable file
184 function isFileReadable ($FQFN) {
186 if (!isset($GLOBALS['file_readable'][$FQFN])) {
188 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
192 return $GLOBALS['file_readable'][$FQFN];
195 // Checks whether the given FQFN is a directory and not ., .. or .svn
196 function isDirectory ($FQFN) {
198 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
200 $baseName = basename($FQFN);
203 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
207 return $GLOBALS[__FUNCTION__][$FQFN];
210 // "Getter" for the real remote IP number
211 function detectRealIpAddress ($alwaysReal = FALSE) {
212 // Get remote ip from environment
213 $remoteAddr = determineRealRemoteAddress();
215 // Is removeip installed?
216 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
218 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
225 // "Getter" for remote IP number
226 function detectRemoteAddr ($alwaysReal = FALSE) {
227 // Get remote ip from environment
228 $remoteAddr = determineRealRemoteAddress(TRUE);
230 // Is removeip installed?
231 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
233 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
240 // "Getter" for remote hostname
241 function detectRemoteHostname ($alwaysReal = FALSE) {
242 // Get remote ip from environment
243 $remoteHost = getenv('REMOTE_HOST');
245 // Is removeip installed?
246 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
248 $remoteHost = getAnonymousRemoteHost($remoteHost);
255 // "Getter" for user agent
256 function detectUserAgent ($alwaysReal = FALSE) {
257 // Get remote ip from environment
258 $userAgent = getenv('HTTP_USER_AGENT');
260 // Is removeip installed?
261 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
263 $userAgent = getAnonymousUserAgent($userAgent);
270 // "Getter" for referer
271 function detectReferer ($alwaysReal = FALSE) {
272 // Get remote ip from environment
273 $referer = getenv('HTTP_REFERER');
275 // Is removeip installed?
276 if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
278 $referer = getAnonymousReferer($referer);
285 // "Getter" for request URI
286 function detectRequestUri () {
288 return (getenv('REQUEST_URI'));
291 // "Getter" for query string
292 function detectQueryString () {
293 return str_replace('&', '&', (getenv('QUERY_STRING')));
296 // "Getter" for SERVER_NAME
297 function detectServerName () {
299 return (getenv('SERVER_NAME'));
302 // Removes any existing www. from SERVER_NAME. This is very silly but enough
303 // for our purpose here.
304 function detectDomainName () {
306 if (!isset($GLOBALS[__FUNCTION__])) {
308 $domainName = detectServerName();
310 // Is there any www. ?
311 if (substr($domainName, 0, 4) == 'www.') {
313 $domainName = substr($domainName, 4);
317 $GLOBALS[__FUNCTION__] = $domainName;
321 return $GLOBALS[__FUNCTION__];
324 // Check whether we are installing
325 function isInstalling () {
326 // Determine whether we are installing
327 if (!isset($GLOBALS['__mailer_installing'])) {
328 // Check URL (css.php/js.php need this)
329 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
333 return $GLOBALS['__mailer_installing'];
336 // Check whether this script is installed
337 function isInstalled () {
339 if (!isset($GLOBALS[__FUNCTION__])) {
340 // Determine whether this script is installed
341 $GLOBALS[__FUNCTION__] = (
346 isConfigEntrySet('MAILER_INSTALLED')
348 getConfig('MAILER_INSTALLED') == 'Y'
352 // New config file found and loaded
353 isIncludeReadable(getCachePath() . 'config-local.php')
356 // New config file found, but not yet read
357 isIncludeReadable(getCachePath() . 'config-local.php')
360 // Only new config file is found
361 !isIncludeReadable('inc/config.php')
363 // Is installation mode
370 // Then use the cache
371 return $GLOBALS[__FUNCTION__];
374 // Check whether an admin is registered
375 function isAdminRegistered () {
377 if (!isset($GLOBALS[__FUNCTION__])) {
379 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
383 return $GLOBALS[__FUNCTION__];
386 // Checks whether the hourly reset mode is active
387 function isHourlyResetEnabled () {
388 // Now simply check it
389 return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
392 // Checks whether the reset mode is active
393 function isResetModeEnabled () {
394 // Now simply check it
395 return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === TRUE));
398 // Checks whether the debug mode is enabled
399 function isDebugModeEnabled () {
401 if (!isset($GLOBALS[__FUNCTION__])) {
403 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
407 return $GLOBALS[__FUNCTION__];
410 // Checks whether the debug reset is enabled
411 function isDebugResetEnabled () {
413 if (!isset($GLOBALS[__FUNCTION__])) {
415 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
419 return $GLOBALS[__FUNCTION__];
422 // Checks whether SQL debugging is enabled
423 function isSqlDebuggingEnabled () {
425 if (!isset($GLOBALS[__FUNCTION__])) {
426 // Determine if SQL debugging is enabled
427 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
431 return $GLOBALS[__FUNCTION__];
434 // Checks whether we shall debug regular expressions
435 function isDebugRegularExpressionEnabled () {
437 if (!isset($GLOBALS[__FUNCTION__])) {
439 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
443 return $GLOBALS[__FUNCTION__];
446 // Checks whether debugging of build mails is enabled
447 function isDebugBuildMailsEnabled () {
449 if (!isset($GLOBALS[__FUNCTION__])) {
451 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
455 return $GLOBALS[__FUNCTION__];
458 // Checks whether the cache instance is valid
459 function isCacheInstanceValid () {
461 if (!isset($GLOBALS[__FUNCTION__])) {
463 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
467 return $GLOBALS[__FUNCTION__];
470 // Copies a file from source to destination and verifies if that goes fine.
471 // This function should wrap the copy() command and make a nicer debug backtrace
472 // even if there is no xdebug extension installed.
473 function copyFileVerified ($source, $dest, $chmod = '') {
474 // Failed is the default
477 // Is the source file there?
478 if (!isFileReadable($source)) {
480 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
483 // Is the target directory there?
484 if (!isDirectory(dirname($dest))) {
486 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
489 // Now try to copy it
490 if (!copy($source, $dest)) {
491 // Something went wrong
492 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
495 $GLOBALS['file_readable'][$dest] = TRUE;
498 // All fine by default
501 // If there are chmod rights set, apply them
502 if (!empty($chmod)) {
504 $status = changeMode($dest, $chmod);
511 // Wrapper function for chmod()
512 // @TODO Do some more sanity check here
513 function changeMode ($FQFN, $mode) {
514 // Is the file/directory there?
515 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
516 // Neither, so abort here
517 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
521 return chmod($FQFN, $mode);
524 // Wrapper for unlink()
525 function removeFile ($FQFN) {
526 // Is the file there?
527 if (isFileReadable($FQFN)) {
529 $GLOBALS['file_readable'][$FQFN] = FALSE;
532 return unlink($FQFN);
535 // All fine if no file was removed. If we change this to 'false' or rewrite
536 // above if() block it would be to restrictive.
540 // Wrapper for $_POST['sel']
541 function countPostSelection ($element = 'sel') {
543 if (!isset($GLOBALS[__FUNCTION__][$element])) {
545 $GLOBALS[__FUNCTION__][$element] = '0';
548 if (isPostRequestElementSet($element)) {
549 // Return counted elements
550 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
554 // Return cached value
555 return $GLOBALS[__FUNCTION__][$element];
558 // Checks whether the config-local.php is loaded
559 function isConfigLocalLoaded () {
560 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
563 // Checks whether a nickname or userid was entered and caches the result
564 function isNicknameUsed ($userid) {
565 // Is the cache there
566 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
568 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
572 return $GLOBALS[__FUNCTION__][$userid];
575 // Getter for 'what' value
576 function getWhat ($strict = TRUE) {
581 if (isWhatSet($strict)) {
583 $what = $GLOBALS['__what'];
590 // Setter for 'what' value
591 function setWhat ($newWhat) {
592 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
593 $GLOBALS['__what'] = $newWhat;
596 // Setter for 'what' from configuration
597 function setWhatFromConfig ($configEntry) {
598 // Get 'what' from config
599 $what = getConfig($configEntry);
605 // Checks whether what is set and optionally aborts on miss
606 function isWhatSet ($strict = FALSE) {
608 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
610 // Should we abort here?
611 if (($strict === TRUE) && ($isset === FALSE)) {
613 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
620 // Getter for 'action' value
621 function getAction ($strict = TRUE) {
626 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
628 $action = $GLOBALS['__action'];
635 // Setter for 'action' value
636 function setAction ($newAction) {
637 $GLOBALS['__action'] = $newAction;
640 // Checks whether action is set and optionally aborts on miss
641 function isActionSet ($strict = FALSE) {
643 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
645 // Should we abort here?
646 if (($strict === TRUE) && ($isset === FALSE)) {
648 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
655 // Getter for 'module' value
656 function getModule ($strict = TRUE) {
661 if (isModuleSet($strict)) {
663 $module = $GLOBALS['__module'];
670 // Setter for 'module' value
671 function setModule ($newModule) {
672 // Secure it and make all modules lower-case
673 $GLOBALS['__module'] = strtolower($newModule);
676 // Wrapper to get extra module names
677 function getExtraModule () {
681 // Is 'tab/step' set?
682 if (isPostRequestElementSet('tab')) {
684 $extra = 'tab=' . postRequestElement('tab');
685 } elseif (isPostRequestElementSet('step')) {
687 $extra = 'step=' . postRequestElement('step');
688 } elseif ((isActionSet()) && (isWhatSet())) {
690 $extra = 'action=' . getAction() . ':what=' . getWhat();
697 // Checks whether module is set and optionally aborts on miss
698 function isModuleSet ($strict = FALSE) {
700 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
702 // Should we abort here?
703 if (($strict === TRUE) && ($isset === FALSE)) {
705 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
709 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
712 // Getter for 'output_mode' value
713 function getScriptOutputMode () {
715 if (!isset($GLOBALS[__FUNCTION__])) {
716 // Is the output mode set?
717 if (!isOutputModeSet()) {
718 // No, then abort here
719 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
723 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
727 return $GLOBALS[__FUNCTION__];
730 // Setter for 'output_mode' value
731 function setScriptOutputMode ($newOutputMode) {
732 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
733 $GLOBALS['__output_mode'] = (int) $newOutputMode;
736 // Checks whether output_mode is set and optionally aborts on miss
737 function isOutputModeSet ($strict = FALSE) {
739 $isset = (isset($GLOBALS['__output_mode']));
741 // Should we abort here?
742 if (($strict === TRUE) && ($isset === FALSE)) {
744 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
751 // Enables block-mode
752 function enableBlockMode ($enabled = TRUE) {
753 $GLOBALS['__block_mode'] = $enabled;
756 // Checks whether block-mode is enabled
757 function isBlockModeEnabled () {
759 if (!isset($GLOBALS['__block_mode'])) {
761 reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
765 return $GLOBALS['__block_mode'];
768 // Wrapper for redirectToUrl but URL comes from a configuration entry
769 function redirectToConfiguredUrl ($configEntry) {
771 redirectToUrl(getConfig($configEntry));
774 // Wrapper function to redirect from member-only modules to index
775 function redirectToIndexMemberOnlyModule () {
776 // Do the redirect here
777 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
780 // Wrapper function to redirect to current URL
781 function redirectToRequestUri () {
782 redirectToUrl(basename(detectRequestUri()));
785 // Wrapper function to redirect to de-refered URL
786 function redirectToDereferedUrl ($url) {
788 redirectToUrl(generateDereferrerUrl($url));
791 // Wrapper function for checking if extension is installed and newer or same version
792 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
793 // Is an cache entry found?
794 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
796 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
798 // Cache hits should be incremented twice
799 incrementStatsEntry('cache_hits', 2);
803 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
804 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
807 // Wrapper function for checking if extension is installed and older than given version
808 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
809 // Is an cache entry found?
810 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
812 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
814 // Cache hits should be incremented twice
815 incrementStatsEntry('cache_hits', 2);
819 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
820 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
824 function setUsername ($userName) {
825 $GLOBALS['username'] = (string) $userName;
829 function getUsername () {
831 if (!isset($GLOBALS['username'])) {
832 // No, so it has to be a guest
833 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
837 return $GLOBALS['username'];
840 // Wrapper function for installation phase
841 function isInstallationPhase () {
843 if (!isset($GLOBALS[__FUNCTION__])) {
845 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
849 return $GLOBALS[__FUNCTION__];
852 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
853 function isDemoModeActive () {
855 if (!isset($GLOBALS[__FUNCTION__])) {
857 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
861 return $GLOBALS[__FUNCTION__];
864 // Getter for PHP caching value
865 function getPhpCaching () {
866 return $GLOBALS['php_caching'];
869 // Checks whether the admin hash is set
870 function isAdminHashSet ($adminId) {
871 // Is the array there?
872 if (!isset($GLOBALS['cache_array']['admin'])) {
873 // Missing array should be reported
874 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
877 // Check for admin hash
878 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
881 // Setter for admin hash
882 function setAdminHash ($adminId, $hash) {
883 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
886 // Getter for current admin login
887 function getCurrentAdminLogin () {
889 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
892 if (!isset($GLOBALS[__FUNCTION__])) {
894 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
898 return $GLOBALS[__FUNCTION__];
901 // Setter for admin id (and current)
902 function setAdminId ($adminId) {
904 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
907 $status = setSession('admin_id', bigintval($adminId));
910 setCurrentAdminId($adminId);
916 // Setter for admin_last
917 function setAdminLast ($adminLast) {
919 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
922 $status = setSession('admin_last', $adminLast);
928 // Setter for admin_md5
929 function setAdminMd5 ($adminMd5) {
931 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
934 $status = setSession('admin_md5', $adminMd5);
940 // Getter for admin_md5
941 function getAdminMd5 () {
943 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
946 return getSession('admin_md5');
949 // Init user data array
950 function initUserData () {
951 // User id should not be zero
952 if (!isValidUserId(getCurrentUserId())) {
953 // Should be always valid
954 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
958 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
959 $GLOBALS['user_data'][getCurrentUserId()] = array();
962 // Getter for user data
963 function getUserData ($column) {
964 // User id should not be zero
965 if (!isValidUserId(getCurrentUserId())) {
966 // Should be always valid
967 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
973 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
975 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
982 // Checks whether given user data is set to 'Y'
983 function isUserDataEnabled ($column) {
985 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
987 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
991 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
994 // Geter for whole user data array
995 function getUserDataArray () {
997 $userid = getCurrentUserId();
999 // Is the current userid valid?
1000 if (!isValidUserId($userid)) {
1001 // Should be always valid
1002 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1005 // Get the whole array if found
1006 if (isset($GLOBALS['user_data'][$userid])) {
1007 // Found, so return it
1008 return $GLOBALS['user_data'][$userid];
1010 // Return empty array
1015 // Checks if the user data is valid, this may indicate that the user has logged
1016 // in, but you should use isMember() if you want to find that out.
1017 function isUserDataValid () {
1018 // User id should not be zero so abort here
1019 if (!isCurrentUserIdSet()) {
1020 // Debug message, may be noisy
1021 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1028 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1030 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1033 // Return the result
1034 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1037 // Setter for current userid
1038 function setCurrentUserId ($userid) {
1040 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1042 // Is the cache from below functions different?
1043 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1045 unsetCurrentUserId();
1049 $GLOBALS['current_userid'] = bigintval($userid);
1051 // Unset it to re-determine the actual state
1052 unset($GLOBALS['is_userdata_valid'][$userid]);
1055 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1058 // Getter for current userid
1059 function getCurrentUserId () {
1061 if (!isset($GLOBALS[__FUNCTION__])) {
1062 // Userid must be set before it can be used
1063 if (!isCurrentUserIdSet()) {
1065 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1068 // Set userid in cache
1069 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1073 return $GLOBALS[__FUNCTION__];
1076 // Checks if current userid is set
1077 function isCurrentUserIdSet () {
1079 if (!isset($GLOBALS[__FUNCTION__])) {
1081 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1085 return $GLOBALS[__FUNCTION__];
1088 // Unsets current userid
1089 function unsetCurrentUserId () {
1091 if (isset($GLOBALS['current_userid'])) {
1093 unset($GLOBALS['isValidUserId'][$GLOBALS['current_userid']]);
1096 // Unset all cache entries
1097 unset($GLOBALS['current_userid']);
1098 unset($GLOBALS['getCurrentUserId']);
1099 unset($GLOBALS['isCurrentUserIdSet']);
1102 // Checks whether we are debugging template cache
1103 function isDebugTemplateCacheEnabled () {
1105 if (!isset($GLOBALS[__FUNCTION__])) {
1107 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1111 return $GLOBALS[__FUNCTION__];
1114 // Wrapper for fetchUserData() and getUserData() calls
1115 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1116 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1118 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1122 // Can we fetch the user data?
1123 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1124 // Now get the data back
1125 $data = getUserData($valueColumn);
1129 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1133 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1134 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1137 // Wrapper for strpos() to ease porting from deprecated ereg() function
1138 function isInString ($needle, $haystack) {
1139 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1140 return (strpos($haystack, $needle) !== FALSE);
1143 // Wrapper for strpos() to ease porting from deprecated eregi() function
1144 // This function is case-insensitive
1145 function isInStringIgnoreCase ($needle, $haystack) {
1146 return (isInString(strtolower($needle), strtolower($haystack)));
1149 // Wrapper to check for if fatal errors where detected
1150 function ifFatalErrorsDetected () {
1151 // Just call the inner function
1152 return (getTotalFatalErrors() > 0);
1155 // Checks whether a HTTP status has been set
1156 function isHttpStatusSet () {
1157 // Is it set and not empty?
1158 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1161 // Setter for HTTP status
1162 function setHttpStatus ($status) {
1163 $GLOBALS['http_status'] = (string) $status;
1166 // Getter for HTTP status
1167 function getHttpStatus () {
1168 // Is the status set?
1169 if (!isHttpStatusSet()) {
1171 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1175 return $GLOBALS['http_status'];
1179 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1180 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1182 * ----------------------------------------------------------------------------
1183 * If you want to redirect, please use redirectToUrl(); instead
1184 * ----------------------------------------------------------------------------
1186 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1188 * @link http://support.microsoft.com/kb/q176113/
1189 * @author Andreas Gohr <andi@splitbrain.org>
1192 function sendRawRedirect ($url) {
1193 // Clear output buffer
1194 clearOutputBuffer();
1196 // Clear own output buffer
1197 $GLOBALS['__output'] = '';
1199 // To make redirects working (no content type), output mode must be raw
1200 setScriptOutputMode(-1);
1202 // Send helping header
1203 setHttpStatus('302 Found');
1205 // always close the session
1206 session_write_close();
1208 // Revert entity &
1209 $url = str_replace('&', '&', $url);
1211 // check if running on IIS < 6 with CGI-PHP
1212 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1213 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1214 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1215 ($matches[1] < 6)) {
1216 // Send the IIS header
1217 addHttpHeader('Refresh: 0;url=' . $url);
1219 // Send generic header
1220 addHttpHeader('Location: ' . $url);
1227 // Determines the country of the given user id
1228 function determineCountry ($userid) {
1230 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1231 // Default is 'invalid'
1232 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1234 // Is extension country active?
1235 if (isExtensionActive('country')) {
1236 // Determine the right country code through the country id
1237 $id = getUserData('country_code');
1239 // Then handle it over
1240 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1242 // Get raw code from user data
1243 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1248 return $GLOBALS[__FUNCTION__][$userid];
1251 // "Getter" for total confirmed user accounts
1252 function getTotalConfirmedUser () {
1254 if (!isset($GLOBALS[__FUNCTION__])) {
1256 if (isExtensionActive('user')) {
1257 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1259 $GLOBALS[__FUNCTION__] = 0;
1263 // Return cached value
1264 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1265 return $GLOBALS[__FUNCTION__];
1268 // "Getter" for total unconfirmed user accounts
1269 function getTotalUnconfirmedUser () {
1271 if (!isset($GLOBALS[__FUNCTION__])) {
1273 if (isExtensionActive('user')) {
1274 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1276 $GLOBALS[__FUNCTION__] = 0;
1280 // Return cached value
1281 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1282 return $GLOBALS[__FUNCTION__];
1285 // "Getter" for total locked user accounts
1286 function getTotalLockedUser () {
1288 if (!isset($GLOBALS[__FUNCTION__])) {
1290 if (isExtensionActive('user')) {
1291 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1293 $GLOBALS[__FUNCTION__] = 0;
1297 // Return cached value
1298 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1299 return $GLOBALS[__FUNCTION__];
1302 // "Getter" for total locked user accounts
1303 function getTotalRandomRefidUser () {
1305 if (!isset($GLOBALS[__FUNCTION__])) {
1307 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1308 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1310 $GLOBALS[__FUNCTION__] = 0;
1314 // Return cached value
1315 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1316 return $GLOBALS[__FUNCTION__];
1319 // Is given userid valid?
1320 function isValidUserId ($userid) {
1322 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid);
1325 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1327 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid != 'NULL') && ($userid > 0));
1331 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',result=' . intval($GLOBALS[__FUNCTION__][$userid]));
1332 return $GLOBALS[__FUNCTION__][$userid];
1336 function encodeEntities ($str) {
1338 $str = secureString($str, TRUE, TRUE);
1340 // Encode dollar sign as well
1341 $str = str_replace('$', '$', $str);
1347 // "Getter" for date from patch_ctime
1348 function getDateFromRepository () {
1350 if (!isset($GLOBALS[__FUNCTION__])) {
1352 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1356 return $GLOBALS[__FUNCTION__];
1359 // "Getter" for date/time from patch_ctime
1360 function getDateTimeFromRepository () {
1362 if (!isset($GLOBALS[__FUNCTION__])) {
1364 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1368 return $GLOBALS[__FUNCTION__];
1371 // Getter for current year (default)
1372 function getYear ($timestamp = NULL) {
1374 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1375 // If NULL is set, use time()
1376 if (is_null($timestamp)) {
1377 $timestamp = time();
1381 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1385 return $GLOBALS[__FUNCTION__][$timestamp];
1388 // Getter for current month (default)
1389 function getMonth ($timestamp = NULL) {
1391 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1392 // If NULL is set, use time()
1393 if (is_null($timestamp)) {
1394 // Use time() which is current timestamp
1395 $timestamp = time();
1399 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1403 return $GLOBALS[__FUNCTION__][$timestamp];
1406 // Getter for current hour (default)
1407 function getHour ($timestamp = NULL) {
1409 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1411 if (is_null($timestamp)) {
1412 $timestamp = time();
1416 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1420 return $GLOBALS[__FUNCTION__][$timestamp];
1423 // Getter for current day (default)
1424 function getDay ($timestamp = NULL) {
1426 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1428 if (is_null($timestamp)) {
1429 $timestamp = time();
1433 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1437 return $GLOBALS[__FUNCTION__][$timestamp];
1440 // Getter for current week (default)
1441 function getWeek ($timestamp = NULL) {
1443 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1445 if (is_null($timestamp)) $timestamp = time();
1448 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1452 return $GLOBALS[__FUNCTION__][$timestamp];
1455 // Getter for current short_hour (default)
1456 function getShortHour ($timestamp = NULL) {
1458 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1460 if (is_null($timestamp)) $timestamp = time();
1463 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1467 return $GLOBALS[__FUNCTION__][$timestamp];
1470 // Getter for current long_hour (default)
1471 function getLongHour ($timestamp = NULL) {
1473 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1475 if (is_null($timestamp)) $timestamp = time();
1478 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1482 return $GLOBALS[__FUNCTION__][$timestamp];
1485 // Getter for current second (default)
1486 function getSecond ($timestamp = NULL) {
1488 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1490 if (is_null($timestamp)) $timestamp = time();
1493 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1497 return $GLOBALS[__FUNCTION__][$timestamp];
1500 // Getter for current minute (default)
1501 function getMinute ($timestamp = NULL) {
1503 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1505 if (is_null($timestamp)) $timestamp = time();
1508 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1512 return $GLOBALS[__FUNCTION__][$timestamp];
1515 // Checks whether the title decoration is enabled
1516 function isTitleDecorationEnabled () {
1518 if (!isset($GLOBALS[__FUNCTION__])) {
1520 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1524 return $GLOBALS[__FUNCTION__];
1527 // Checks whether filter usage updates are enabled (expensive queries!)
1528 function isFilterUsageUpdateEnabled () {
1530 if (!isset($GLOBALS[__FUNCTION__])) {
1532 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1536 return $GLOBALS[__FUNCTION__];
1539 // Checks whether debugging of weekly resets is enabled
1540 function isWeeklyResetDebugEnabled () {
1542 if (!isset($GLOBALS[__FUNCTION__])) {
1544 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1548 return $GLOBALS[__FUNCTION__];
1551 // Checks whether debugging of monthly resets is enabled
1552 function isMonthlyResetDebugEnabled () {
1554 if (!isset($GLOBALS[__FUNCTION__])) {
1556 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1560 return $GLOBALS[__FUNCTION__];
1563 // Checks whether displaying of debug SQLs are enabled
1564 function isDisplayDebugSqlEnabled () {
1566 if (!isset($GLOBALS[__FUNCTION__])) {
1568 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1572 return $GLOBALS[__FUNCTION__];
1575 // Checks whether module title is enabled
1576 function isModuleTitleEnabled () {
1578 if (!isset($GLOBALS[__FUNCTION__])) {
1580 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1584 return $GLOBALS[__FUNCTION__];
1587 // Checks whether what title is enabled
1588 function isWhatTitleEnabled () {
1590 if (!isset($GLOBALS[__FUNCTION__])) {
1592 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1596 return $GLOBALS[__FUNCTION__];
1599 // Checks whether stats are enabled
1600 function ifInternalStatsEnabled () {
1602 if (!isset($GLOBALS[__FUNCTION__])) {
1603 // Then determine it
1604 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1607 // Return cached value
1608 return $GLOBALS[__FUNCTION__];
1611 // Checks whether admin-notification of certain user actions is enabled
1612 function isAdminNotificationEnabled () {
1614 if (!isset($GLOBALS[__FUNCTION__])) {
1616 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1620 return $GLOBALS[__FUNCTION__];
1623 // Checks whether random referral id selection is enabled
1624 function isRandomReferralIdEnabled () {
1626 if (!isset($GLOBALS[__FUNCTION__])) {
1628 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y'));
1632 return $GLOBALS[__FUNCTION__];
1635 // "Getter" for default language
1636 function getDefaultLanguage () {
1638 if (!isset($GLOBALS[__FUNCTION__])) {
1640 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1644 return $GLOBALS[__FUNCTION__];
1647 // "Getter" for default referral id
1648 function getDefRefid () {
1650 if (!isset($GLOBALS[__FUNCTION__])) {
1652 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1656 return $GLOBALS[__FUNCTION__];
1659 // "Getter" for path
1660 function getPath () {
1662 if (!isset($GLOBALS[__FUNCTION__])) {
1664 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1668 return $GLOBALS[__FUNCTION__];
1672 function getUrl () {
1674 if (!isset($GLOBALS[__FUNCTION__])) {
1676 $GLOBALS[__FUNCTION__] = getConfig('URL');
1680 return $GLOBALS[__FUNCTION__];
1683 // "Getter" for cache_path
1684 function getCachePath () {
1686 if (!isset($GLOBALS[__FUNCTION__])) {
1688 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1692 return $GLOBALS[__FUNCTION__];
1695 // "Getter" for WRITE_FOOTER
1696 function getWriteFooter () {
1698 if (!isset($GLOBALS[__FUNCTION__])) {
1700 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1704 return $GLOBALS[__FUNCTION__];
1707 // "Getter" for secret_key
1708 function getSecretKey () {
1710 if (!isset($GLOBALS[__FUNCTION__])) {
1712 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1716 return $GLOBALS[__FUNCTION__];
1719 // "Getter" for SITE_KEY
1720 function getSiteKey () {
1722 if (!isset($GLOBALS[__FUNCTION__])) {
1724 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1728 return $GLOBALS[__FUNCTION__];
1731 // "Getter" for DATE_KEY
1732 function getDateKey () {
1734 if (!isset($GLOBALS[__FUNCTION__])) {
1736 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1740 return $GLOBALS[__FUNCTION__];
1743 // "Getter" for master_salt
1744 function getMasterSalt () {
1746 if (!isset($GLOBALS[__FUNCTION__])) {
1748 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1752 return $GLOBALS[__FUNCTION__];
1755 // "Getter" for prime
1756 function getPrime () {
1758 if (!isset($GLOBALS[__FUNCTION__])) {
1760 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1764 return $GLOBALS[__FUNCTION__];
1767 // "Getter" for encrypt_separator
1768 function getEncryptSeparator () {
1770 if (!isset($GLOBALS[__FUNCTION__])) {
1772 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1776 return $GLOBALS[__FUNCTION__];
1779 // "Getter" for mysql_prefix
1780 function getMysqlPrefix () {
1782 if (!isset($GLOBALS[__FUNCTION__])) {
1784 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1788 return $GLOBALS[__FUNCTION__];
1791 // "Getter" for table_type
1792 function getTableType () {
1794 if (!isset($GLOBALS[__FUNCTION__])) {
1796 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1800 return $GLOBALS[__FUNCTION__];
1803 // "Getter" for salt_length
1804 function getSaltLength () {
1806 if (!isset($GLOBALS[__FUNCTION__])) {
1808 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1812 return $GLOBALS[__FUNCTION__];
1815 // "Getter" for output_mode
1816 function getOutputMode () {
1818 if (!isset($GLOBALS[__FUNCTION__])) {
1820 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1824 return $GLOBALS[__FUNCTION__];
1827 // "Getter" for full_version
1828 function getFullVersion () {
1830 if (!isset($GLOBALS[__FUNCTION__])) {
1832 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1836 return $GLOBALS[__FUNCTION__];
1839 // "Getter" for title
1840 function getTitle () {
1842 if (!isset($GLOBALS[__FUNCTION__])) {
1844 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1848 return $GLOBALS[__FUNCTION__];
1851 // "Getter" for curr_svn_revision
1852 function getCurrentRepositoryRevision () {
1854 if (!isset($GLOBALS[__FUNCTION__])) {
1856 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1860 return $GLOBALS[__FUNCTION__];
1863 // "Getter" for server_url
1864 function getServerUrl () {
1866 if (!isset($GLOBALS[__FUNCTION__])) {
1868 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1872 return $GLOBALS[__FUNCTION__];
1875 // "Getter" for mt_word
1876 function getMtWord () {
1878 if (!isset($GLOBALS[__FUNCTION__])) {
1880 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1884 return $GLOBALS[__FUNCTION__];
1887 // "Getter" for mt_word2
1888 function getMtWord2 () {
1890 if (!isset($GLOBALS[__FUNCTION__])) {
1892 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1896 return $GLOBALS[__FUNCTION__];
1899 // "Getter" for mt_word3
1900 function getMtWord3 () {
1902 if (!isset($GLOBALS[__FUNCTION__])) {
1904 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1908 return $GLOBALS[__FUNCTION__];
1911 // "Getter" for START_TDAY
1912 function getStartTday () {
1914 if (!isset($GLOBALS[__FUNCTION__])) {
1916 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
1920 return $GLOBALS[__FUNCTION__];
1923 // "Getter" for START_YDAY
1924 function getStartYday () {
1926 if (!isset($GLOBALS[__FUNCTION__])) {
1928 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
1932 return $GLOBALS[__FUNCTION__];
1935 // "Getter" for main_title
1936 function getMainTitle () {
1938 if (!isset($GLOBALS[__FUNCTION__])) {
1940 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1944 return $GLOBALS[__FUNCTION__];
1947 // "Getter" for file_hash
1948 function getFileHash () {
1950 if (!isset($GLOBALS[__FUNCTION__])) {
1952 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1956 return $GLOBALS[__FUNCTION__];
1959 // "Getter" for pass_scramble
1960 function getPassScramble () {
1962 if (!isset($GLOBALS[__FUNCTION__])) {
1964 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1968 return $GLOBALS[__FUNCTION__];
1971 // "Getter" for ap_inactive_since
1972 function getApInactiveSince () {
1974 if (!isset($GLOBALS[__FUNCTION__])) {
1976 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1980 return $GLOBALS[__FUNCTION__];
1983 // "Getter" for user_min_confirmed
1984 function getUserMinConfirmed () {
1986 if (!isset($GLOBALS[__FUNCTION__])) {
1988 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1992 return $GLOBALS[__FUNCTION__];
1994 // "Getter" for points
1995 function getPoints () {
1997 if (!isset($GLOBALS[__FUNCTION__])) {
1999 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2003 return $GLOBALS[__FUNCTION__];
2006 // "Getter" for slogan
2007 function getSlogan () {
2009 if (!isset($GLOBALS[__FUNCTION__])) {
2011 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2015 return $GLOBALS[__FUNCTION__];
2018 // "Getter" for copy
2019 function getCopy () {
2021 if (!isset($GLOBALS[__FUNCTION__])) {
2023 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2027 return $GLOBALS[__FUNCTION__];
2030 // "Getter" for webmaster
2031 function getWebmaster () {
2033 if (!isset($GLOBALS[__FUNCTION__])) {
2035 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2039 return $GLOBALS[__FUNCTION__];
2042 // "Getter" for sql_count
2043 function getSqlCount () {
2045 if (!isset($GLOBALS[__FUNCTION__])) {
2047 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2051 return $GLOBALS[__FUNCTION__];
2054 // "Getter" for num_templates
2055 function getNumTemplates () {
2057 if (!isset($GLOBALS[__FUNCTION__])) {
2059 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2063 return $GLOBALS[__FUNCTION__];
2066 // "Getter" for dns_cache_timeout
2067 function getDnsCacheTimeout () {
2069 if (!isset($GLOBALS[__FUNCTION__])) {
2071 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2075 return $GLOBALS[__FUNCTION__];
2078 // "Getter" for menu_blur_spacer
2079 function getMenuBlurSpacer () {
2081 if (!isset($GLOBALS[__FUNCTION__])) {
2083 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2087 return $GLOBALS[__FUNCTION__];
2090 // "Getter" for points_register
2091 function getPointsRegister () {
2093 if (!isset($GLOBALS[__FUNCTION__])) {
2095 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2099 return $GLOBALS[__FUNCTION__];
2102 // "Getter" for points_ref
2103 function getPointsRef () {
2105 if (!isset($GLOBALS[__FUNCTION__])) {
2107 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2111 return $GLOBALS[__FUNCTION__];
2114 // "Getter" for ref_payout
2115 function getRefPayout () {
2117 if (!isset($GLOBALS[__FUNCTION__])) {
2119 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2123 return $GLOBALS[__FUNCTION__];
2126 // "Getter" for online_timeout
2127 function getOnlineTimeout () {
2129 if (!isset($GLOBALS[__FUNCTION__])) {
2131 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2135 return $GLOBALS[__FUNCTION__];
2138 // "Getter" for index_home
2139 function getIndexHome () {
2141 if (!isset($GLOBALS[__FUNCTION__])) {
2143 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2147 return $GLOBALS[__FUNCTION__];
2150 // "Getter" for one_day
2151 function getOneDay () {
2153 if (!isset($GLOBALS[__FUNCTION__])) {
2155 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2159 return $GLOBALS[__FUNCTION__];
2162 // "Getter" for activate_xchange
2163 function getActivateXchange () {
2165 if (!isset($GLOBALS[__FUNCTION__])) {
2167 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2171 return $GLOBALS[__FUNCTION__];
2174 // "Getter" for img_type
2175 function getImgType () {
2177 if (!isset($GLOBALS[__FUNCTION__])) {
2179 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2183 return $GLOBALS[__FUNCTION__];
2186 // "Getter" for code_length
2187 function getCodeLength () {
2189 if (!isset($GLOBALS[__FUNCTION__])) {
2191 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2195 return $GLOBALS[__FUNCTION__];
2198 // "Getter" for least_cats
2199 function getLeastCats () {
2201 if (!isset($GLOBALS[__FUNCTION__])) {
2203 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2207 return $GLOBALS[__FUNCTION__];
2210 // "Getter" for pass_len
2211 function getPassLen () {
2213 if (!isset($GLOBALS[__FUNCTION__])) {
2215 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2219 return $GLOBALS[__FUNCTION__];
2222 // "Getter" for admin_menu
2223 function getAdminMenu () {
2225 if (!isset($GLOBALS[__FUNCTION__])) {
2227 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2231 return $GLOBALS[__FUNCTION__];
2234 // "Getter" for last_month
2235 function getLastMonth () {
2237 if (!isset($GLOBALS[__FUNCTION__])) {
2239 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2243 return $GLOBALS[__FUNCTION__];
2246 // "Getter" for max_send
2247 function getMaxSend () {
2249 if (!isset($GLOBALS[__FUNCTION__])) {
2251 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2255 return $GLOBALS[__FUNCTION__];
2258 // "Getter" for mails_page
2259 function getMailsPage () {
2261 if (!isset($GLOBALS[__FUNCTION__])) {
2263 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2267 return $GLOBALS[__FUNCTION__];
2270 // "Getter" for rand_no
2271 function getRandNo () {
2273 if (!isset($GLOBALS[__FUNCTION__])) {
2275 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2279 return $GLOBALS[__FUNCTION__];
2282 // "Getter" for __DB_NAME
2283 function getDbName () {
2285 if (!isset($GLOBALS[__FUNCTION__])) {
2287 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2291 return $GLOBALS[__FUNCTION__];
2294 // "Getter" for DOMAIN
2295 function getDomain () {
2297 if (!isset($GLOBALS[__FUNCTION__])) {
2299 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2303 return $GLOBALS[__FUNCTION__];
2306 // "Getter" for proxy_username
2307 function getProxyUsername () {
2309 if (!isset($GLOBALS[__FUNCTION__])) {
2311 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2315 return $GLOBALS[__FUNCTION__];
2318 // "Getter" for proxy_password
2319 function getProxyPassword () {
2321 if (!isset($GLOBALS[__FUNCTION__])) {
2323 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2327 return $GLOBALS[__FUNCTION__];
2330 // "Getter" for proxy_host
2331 function getProxyHost () {
2333 if (!isset($GLOBALS[__FUNCTION__])) {
2335 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2339 return $GLOBALS[__FUNCTION__];
2342 // "Getter" for proxy_port
2343 function getProxyPort () {
2345 if (!isset($GLOBALS[__FUNCTION__])) {
2347 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2351 return $GLOBALS[__FUNCTION__];
2354 // "Getter" for SMTP_HOSTNAME
2355 function getSmtpHostname () {
2357 if (!isset($GLOBALS[__FUNCTION__])) {
2359 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2363 return $GLOBALS[__FUNCTION__];
2366 // "Getter" for SMTP_USER
2367 function getSmtpUser () {
2369 if (!isset($GLOBALS[__FUNCTION__])) {
2371 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2375 return $GLOBALS[__FUNCTION__];
2378 // "Getter" for SMTP_PASSWORD
2379 function getSmtpPassword () {
2381 if (!isset($GLOBALS[__FUNCTION__])) {
2383 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2387 return $GLOBALS[__FUNCTION__];
2390 // "Getter" for points_word
2391 function getPointsWord () {
2393 if (!isset($GLOBALS[__FUNCTION__])) {
2395 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2399 return $GLOBALS[__FUNCTION__];
2402 // "Getter" for profile_lock
2403 function getProfileLock () {
2405 if (!isset($GLOBALS[__FUNCTION__])) {
2407 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2411 return $GLOBALS[__FUNCTION__];
2414 // "Getter" for url_tlock
2415 function getUrlTlock () {
2417 if (!isset($GLOBALS[__FUNCTION__])) {
2419 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2423 return $GLOBALS[__FUNCTION__];
2426 // "Getter" for title_left
2427 function getTitleLeft () {
2429 if (!isset($GLOBALS[__FUNCTION__])) {
2431 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2435 return $GLOBALS[__FUNCTION__];
2438 // "Getter" for title_right
2439 function getTitleRight () {
2441 if (!isset($GLOBALS[__FUNCTION__])) {
2443 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2447 return $GLOBALS[__FUNCTION__];
2450 // "Getter" for title_middle
2451 function getTitleMiddle () {
2453 if (!isset($GLOBALS[__FUNCTION__])) {
2455 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2459 return $GLOBALS[__FUNCTION__];
2462 // Getter for 'check_double_email'
2463 function getCheckDoubleEmail () {
2464 // Is the cache entry set?
2465 if (!isset($GLOBALS[__FUNCTION__])) {
2466 // No, so determine it
2467 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2470 // Return cached entry
2471 return $GLOBALS[__FUNCTION__];
2474 // Checks whether 'check_double_email' is 'Y'
2475 function isCheckDoubleEmailEnabled () {
2476 // Is the cache entry set?
2477 if (!isset($GLOBALS[__FUNCTION__])) {
2478 // No, so determine it
2479 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2482 // Return cached entry
2483 return $GLOBALS[__FUNCTION__];
2486 // Getter for 'display_home_in_index'
2487 function getDisplayHomeInIndex () {
2488 // Is the cache entry set?
2489 if (!isset($GLOBALS[__FUNCTION__])) {
2490 // No, so determine it
2491 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2494 // Return cached entry
2495 return $GLOBALS[__FUNCTION__];
2498 // Checks whether 'display_home_in_index' is 'Y'
2499 function isDisplayHomeInIndexEnabled () {
2500 // Is the cache entry set?
2501 if (!isset($GLOBALS[__FUNCTION__])) {
2502 // No, so determine it
2503 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2506 // Return cached entry
2507 return $GLOBALS[__FUNCTION__];
2510 // Getter for 'show_points_unconfirmed'
2511 function getShowPointsUnconfirmed () {
2512 // Is the cache entry set?
2513 if (!isset($GLOBALS[__FUNCTION__])) {
2514 // No, so determine it
2515 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2518 // Return cached entry
2519 return $GLOBALS[__FUNCTION__];
2522 // Checks whether 'show_points_unconfirmed' is 'Y'
2523 function isShowPointsUnconfirmedEnabled () {
2524 // Is the cache entry set?
2525 if (!isset($GLOBALS[__FUNCTION__])) {
2526 // No, so determine it
2527 $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y');
2530 // Return cached entry
2531 return $GLOBALS[__FUNCTION__];
2534 // Getter for 'youre_here'
2535 function getYoureHere () {
2536 // Is the cache entry set?
2537 if (!isset($GLOBALS[__FUNCTION__])) {
2538 // No, so determine it
2539 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2542 // Return cached entry
2543 return $GLOBALS[__FUNCTION__];
2546 // Checks whether 'show_timings' is 'Y'
2547 function isYoureHereEnabled () {
2548 // Is the cache entry set?
2549 if (!isset($GLOBALS[__FUNCTION__])) {
2550 // No, so determine it
2551 $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y');
2554 // Return cached entry
2555 return $GLOBALS[__FUNCTION__];
2558 // Getter for 'show_timings'
2559 function getShowTimings () {
2560 // Is the cache entry set?
2561 if (!isset($GLOBALS[__FUNCTION__])) {
2562 // No, so determine it
2563 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2566 // Return cached entry
2567 return $GLOBALS[__FUNCTION__];
2570 // Checks whether 'show_timings' is 'Y'
2571 function isShowTimingsEnabled () {
2572 // Is the cache entry set?
2573 if (!isset($GLOBALS[__FUNCTION__])) {
2574 // No, so determine it
2575 $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y');
2578 // Return cached entry
2579 return $GLOBALS[__FUNCTION__];
2582 // Getter for 'ap_server_name_since'
2583 function getApServerNameSince () {
2584 // Is the cache entry set?
2585 if (!isset($GLOBALS[__FUNCTION__])) {
2586 // No, so determine it
2587 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2590 // Return cached entry
2591 return $GLOBALS[__FUNCTION__];
2594 // Getter for 'ap_server_name'
2595 function getApServerName () {
2596 // Is the cache entry set?
2597 if (!isset($GLOBALS[__FUNCTION__])) {
2598 // No, so determine it
2599 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2602 // Return cached entry
2603 return $GLOBALS[__FUNCTION__];
2606 // Getter for 'index_delay'
2607 function getIndexDelay () {
2608 // Is the cache entry set?
2609 if (!isset($GLOBALS[__FUNCTION__])) {
2610 // No, so determine it
2611 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2614 // Return cached entry
2615 return $GLOBALS[__FUNCTION__];
2618 // Checks whether 'ap_server_name' is 'Y'
2619 function isApServerNameEnabled () {
2620 // Is the cache entry set?
2621 if (!isset($GLOBALS[__FUNCTION__])) {
2622 // No, so determine it
2623 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2626 // Return cached entry
2627 return $GLOBALS[__FUNCTION__];
2630 // Getter for 'admin_menu_javascript'
2631 function getAdminMenuJavascript () {
2632 // Is the cache entry set?
2633 if (!isset($GLOBALS[__FUNCTION__])) {
2634 // No, so determine it
2635 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2638 // Return cached entry
2639 return $GLOBALS[__FUNCTION__];
2642 // Getter for 'points_remove_account'
2643 function getPointsRemoveAccount () {
2644 // Is the cache entry set?
2645 if (!isset($GLOBALS[__FUNCTION__])) {
2646 // No, so determine it
2647 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2650 // Return cached entry
2651 return $GLOBALS[__FUNCTION__];
2654 // Getter for 'css_php'
2655 function getCssPhp () {
2656 // Is the cache entry set?
2657 if (!isset($GLOBALS[__FUNCTION__])) {
2658 // No, so determine it
2659 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2662 // Return cached entry
2663 return $GLOBALS[__FUNCTION__];
2666 // Getter for 'guest_menu'
2667 function getGuestMenu () {
2668 // Is the cache entry set?
2669 if (!isset($GLOBALS[__FUNCTION__])) {
2670 // No, so determine it
2671 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2674 // Return cached entry
2675 return $GLOBALS[__FUNCTION__];
2678 // Checks if guest menu is enabled
2679 function isGuestMenuEnabled () {
2680 // Is the cache entry set?
2681 if (!isset($GLOBALS[__FUNCTION__])) {
2682 // No, so determine it
2683 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2686 // Return cached entry
2687 return $GLOBALS[__FUNCTION__];
2690 // Getter for 'member_menu'
2691 function getMemberMenu () {
2692 // Is the cache entry set?
2693 if (!isset($GLOBALS[__FUNCTION__])) {
2694 // No, so determine it
2695 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2698 // Return cached entry
2699 return $GLOBALS[__FUNCTION__];
2702 // Checks if member menu is enabled
2703 function isMemberMenuEnabled () {
2704 // Is the cache entry set?
2705 if (!isset($GLOBALS[__FUNCTION__])) {
2706 // No, so determine it
2707 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2710 // Return cached entry
2711 return $GLOBALS[__FUNCTION__];
2714 // Getter for 'word_wrap'
2715 function getWordWrap () {
2716 // Is the cache entry set?
2717 if (!isset($GLOBALS[__FUNCTION__])) {
2718 // Construct config entry name
2719 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2721 // Is a special config entry found or ext-sql_patches updated?
2722 if (isConfigEntrySet($configEntry)) {
2723 // A special config entry has been found, then use it
2724 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2725 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2726 // No special config entry found, then use it as "fall-back"
2727 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2729 // No, use default (15 characters)
2730 $GLOBALS[__FUNCTION__] = 15;
2734 // Return cached entry
2735 return $GLOBALS[__FUNCTION__];
2738 // Checks whether proxy configuration is used
2739 function isProxyUsed () {
2741 if (!isset($GLOBALS[__FUNCTION__])) {
2743 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2747 return $GLOBALS[__FUNCTION__];
2750 // Checks whether POST data contains selections
2751 function ifPostContainsSelections ($element = 'sel') {
2753 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2755 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2759 return $GLOBALS[__FUNCTION__][$element];
2762 // Checks whether verbose_sql is Y and returns true/false if so
2763 function isVerboseSqlEnabled () {
2765 if (!isset($GLOBALS[__FUNCTION__])) {
2767 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2771 return $GLOBALS[__FUNCTION__];
2774 // "Getter" for total user points
2775 function getTotalPoints ($userid) {
2777 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2778 // Init array for filter chain
2780 'userid' => $userid,
2784 // Run filter chain for getting more point values
2785 $data = runFilterChain('get_total_points', $data);
2788 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2792 return $GLOBALS[__FUNCTION__][$userid];
2795 // Wrapper to get used points for given userid
2796 function getUserUsedPoints ($userid) {
2798 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2800 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2804 return $GLOBALS[__FUNCTION__][$userid];
2807 // Wrapper to check if url_blacklist is enabled
2808 function isUrlBlacklistEnabled () {
2810 if (!isset($GLOBALS[__FUNCTION__])) {
2812 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2816 return $GLOBALS[__FUNCTION__];
2819 // Checks whether direct payment is allowed in configuration
2820 function isDirectPaymentEnabled () {
2822 if (!isset($GLOBALS[__FUNCTION__])) {
2824 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2828 return $GLOBALS[__FUNCTION__];
2831 // Checks whether JavaScript-based admin menu is enabled
2832 function isAdminMenuJavascriptEnabled () {
2834 if (!isset($GLOBALS[__FUNCTION__])) {
2836 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getAdminMenuJavaScript() == 'Y'));
2840 return $GLOBALS[__FUNCTION__];
2843 // Wrapper to check if current task is for extension (not update)
2844 function isExtensionTask ($content) {
2846 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2848 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2852 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2855 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2856 function ifTesterAccountsAllowed () {
2857 // Is the cache entry set?
2858 if (!isset($GLOBALS[__FUNCTION__])) {
2859 // No, so determine it
2860 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2863 // Return cached entry
2864 return $GLOBALS[__FUNCTION__];
2867 // Wrapper to check if output mode is CSS
2868 function isCssOutputMode () {
2870 if (!isset($GLOBALS[__FUNCTION__])) {
2872 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2873 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2877 return $GLOBALS[__FUNCTION__];
2880 // Wrapper to check if output mode is HTML
2881 function isHtmlOutputMode () {
2883 if (!isset($GLOBALS[__FUNCTION__])) {
2885 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2886 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2890 return $GLOBALS[__FUNCTION__];
2893 // Wrapper to check if output mode is RAW
2894 function isRawOutputMode () {
2896 if (!isset($GLOBALS[__FUNCTION__])) {
2898 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2899 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2903 return $GLOBALS[__FUNCTION__];
2906 // Wrapper to check if output mode is AJAX
2907 function isAjaxOutputMode () {
2909 if (!isset($GLOBALS[__FUNCTION__])) {
2911 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2912 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2916 return $GLOBALS[__FUNCTION__];
2919 // Wrapper to check if output mode is image
2920 function isImageOutputMode () {
2922 if (!isset($GLOBALS[__FUNCTION__])) {
2924 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2925 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
2929 return $GLOBALS[__FUNCTION__];
2932 // Wrapper to generate a user email link
2933 function generateWrappedUserEmailLink ($email) {
2934 // Just call the inner function
2935 return generateEmailLink($email, 'user_data');
2938 // Wrapper to check if user points are locked
2939 function ifUserPointsLocked ($userid) {
2940 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2942 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2944 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2948 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2949 return $GLOBALS[__FUNCTION__][$userid];
2952 // Appends a line to an existing file or creates it instantly with given content.
2953 // This function does always add a new-line character to every line.
2954 function appendLineToFile ($file, $line) {
2955 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2956 fwrite($fp, $line . PHP_EOL);
2960 // Wrapper for changeDataInFile() but with full path added
2961 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2963 $FQFN = getPath() . $FQFN;
2965 // Call inner function
2966 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2969 // Wrapper for changing entries in config-local.php
2970 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2971 // Call the inner function
2972 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2975 // Shortens ucfirst(strtolower()) calls
2976 function firstCharUpperCase ($str) {
2977 return ucfirst(strtolower($str));
2980 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2981 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2982 // Get the configuration entry
2983 $configValue = getConfig($configEntry);
2985 // Call inner method
2986 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2989 // Shortens converting of German comma to Computer's version in POST data
2990 function convertCommaToDotInPostData ($postEntry) {
2991 // Read and convert given entry
2992 $postValue = convertCommaToDot(postRequestElement($postEntry));
2995 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
2997 // ... and set it again
2998 setPostRequestElement($postEntry, $postValue);
3001 // Converts German commas to Computer's version in all entries
3002 function convertCommaToDotInPostDataArray ($postEntries) {
3003 // Replace german decimal comma with computer decimal dot
3004 foreach ($postEntries as $entry) {
3005 // Is the entry there?
3006 if (isPostRequestElementSet($entry)) {
3008 convertCommaToDotInPostData($entry);
3014 * Parses a string into a US formated float variable, taken from user comments
3015 * from PHP documentation website.
3017 * @param $floatString A string holding a float expression
3018 * @return $float Corresponding float variable
3019 * @author chris<at>georgakopoulos<dot>com
3020 * @link http://de.php.net/manual/en/function.floatval.php#92563
3022 function parseFloat ($floatString){
3024 $LocaleInfo = localeconv();
3026 // Remove thousand separators
3027 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3029 // Convert decimal point
3030 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3032 // Return float value of converted string
3033 return floatval($floatString);
3037 * Searches a multi-dimensional array (as used in many places) for given
3038 * key/value pair as taken from user comments from PHP documentation website.
3040 * @param $array An array with one or more dimensions
3041 * @param $key Key to look for
3042 * @param $value Value to look for
3043 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3044 * @return $results Resulted array or empty array if $array is no array
3045 * @author sunelbe<at>gmail<dot>com
3046 * @link http://de.php.net/manual/en/function.array-search.php#110120
3048 function search_array ($array, $key, $value, $parentIndex = NULL) {
3049 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3050 // Init array result
3053 // Is $array really an array?
3054 if (is_array($array)) {
3055 // Search for whole array
3056 foreach ($array as $idx => $dummy) {
3057 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3058 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3059 // Is dummy an array?
3060 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3061 // Then search again
3062 $subResult = search_array($dummy, $key, $value, $idx);
3063 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3066 $results = merge_array($results, $subResult, TRUE);
3067 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3068 // Is found, so add it
3069 $results[$parentIndex] = $array;
3070 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3075 // Return resulting array
3076 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3080 // Generates a YES/NO option list from given default
3081 function generateYesNoOptions ($defaultValue = '') {
3083 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3086 // "Getter" for total available receivers
3087 function getTotalReceivers ($mode = 'normal') {
3089 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3095 // Wrapper "getter" to get total unconfirmed mails for given userid
3096 function getTotalUnconfirmedMails ($userid) {
3098 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3100 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3104 return $GLOBALS[__FUNCTION__][$userid];
3107 // Checks whether 'mailer_theme' was found in session
3108 function isMailerThemeSet () {
3110 if (!isset($GLOBALS[__FUNCTION__])) {
3112 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3116 return $GLOBALS[__FUNCTION__];
3120 * Setter for theme in session (This setter does return the success of
3121 * setSession() which is required e.g. for destroySponsorSession().
3123 function setMailerTheme ($newTheme) {
3124 // Set it in session
3125 return setSession('mailer_theme', $newTheme);
3129 * Getter for theme from session (This getter does return 'mailer_theme' from
3130 * session data or throws an error if not possible
3132 function getMailerTheme () {
3134 if (!isset($GLOBALS[__FUNCTION__])) {
3135 // Is 'mailer_theme' set?
3136 if (!isMailerThemeSet()) {
3137 // No, then abort here
3138 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3141 // Get it and store it in cache
3142 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3146 return $GLOBALS[__FUNCTION__];
3149 // "Getter" for last_module/last_what depending on ext-user version
3150 function getUserLastWhatName () {
3151 // Default is old one: last_module
3152 $columnName = 'last_module';
3154 // Is ext-user up-to-date?
3155 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3156 // Yes, then use new one
3157 $columnName = 'last_what';
3164 // "Getter" for all columns for given alias and separator
3165 function getAllPointColumns ($alias = NULL, $separator = ',') {
3166 // Prepare the filter array
3167 $filterData = array(
3170 'separator' => $separator
3174 $filterData = runFilterChain('get_all_point_columns', $filterData);
3176 // Return the columns
3177 return $filterData['columns'];
3180 // Checks whether the copyright footer (which breaks framesets) is enabled
3181 function ifCopyrightFooterEnabled () {
3182 // Is not unset and not 'N'?
3183 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3187 * Wrapper to check whether we have a "full page". This means that the actual
3188 * content is not delivered in any frame of a frameset.
3190 function isFullPage () {
3192 * The parameter 'frame' is generic and always indicates that this content
3193 * will be output into a frame. Furthermore, if a frameset is reported or
3194 * the copyright line is explicitly deactivated, this cannot be a "full
3197 // @TODO Find a way to not use direct module comparison
3198 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3204 // Checks whether frameset_mode is set to true
3205 function isFramesetModeEnabled () {
3207 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3210 // Function to determine correct 'what' value
3211 function determineWhat ($module = NULL) {
3212 // Init default 'what'
3216 if (is_null($module)) {
3218 $module = getModule();
3226 // Else try to get it from current module
3227 $what = getWhatFromModule($module);
3229 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3231 // Remove any spaces from variable
3232 $what = trim($what);
3236 // Default action for non-admin menus
3240 $what = secureString($what);
3247 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3248 function prependZeros ($mStretch, $length = 2) {
3249 // Return prepended string
3250 return sprintf('%0' . (int) $length . 's', $mStretch);
3253 // Wraps convertSelectionsToEpocheTime()
3254 function convertSelectionsToEpocheTimeInPostData ($id) {
3259 // Get all POST data
3260 $postData = postRequestArray();
3262 // Convert given selection id
3263 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3265 // Set the POST array back
3266 setPostRequestArray($postData);
3269 // Wraps checking if given points account type matches with given in POST data
3270 function ifPointsAccountTypeMatchesPost ($type) {
3272 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3275 // Gets given user's total referral
3276 function getUsersTotalReferrals ($userid, $level = NULL) {
3278 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3279 // Is the level NULL?
3280 if (is_null($level)) {
3281 // Get total amount (all levels)
3282 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3284 // Get it from user refs
3285 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3290 return $GLOBALS[__FUNCTION__][$userid][$level];
3293 // Gets given user's total referral
3294 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3295 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3297 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3298 // Default is all refs
3301 // Is the not level NULL?
3302 if (!is_null($level)) {
3303 // Then add referral level
3304 $add = ' AND r.`level`=' . bigintval($level);
3307 // Check for all referrals
3308 $result = SQL_QUERY_ESC("SELECT
3309 COUNT(d.`userid`) AS `cnt`
3311 `{?_MYSQL_PREFIX?}_user_data` AS d
3313 `{?_MYSQL_PREFIX?}_user_refs` AS r
3315 d.`userid`=r.`refid`
3317 d.`status` != 'CONFIRMED' AND
3325 ), __FUNCTION__, __LINE__);
3328 list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
3331 SQL_FREERESULT($result);
3335 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3336 return $GLOBALS[__FUNCTION__][$userid][$level];
3339 // Converts, if found, dollar data to get element
3340 function convertDollarDataToGetElement ($data) {
3341 // Is first char a dollar?
3342 if (substr($data, 0, 1) == chr(36)) {
3343 // Use last part for getRequestElement()
3344 $data = getRequestElement(substr($data, 1));
3351 // Wrapper function for SQL layer to speed-up things
3352 function SQL_DEBUG_ENABLED () {
3354 if (!isset($GLOBALS[__FUNCTION__])) {
3356 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3360 return $GLOBALS[__FUNCTION__];
3363 // Wrapper function to wrap call of wordwrap()
3364 function wrapWords ($text) {
3366 $wrapped = wordwrap($test, getWordWrap());
3372 // Encodes given data into a JSON object
3373 function encodeJson ($data) {
3375 return json_encode($data, JSON_FORCE_OBJECT);
3378 // Get all extension files
3379 function loadAllExtensionsByTemplate () {
3381 $extensions = getArrayFromDirectory(
3382 'templates/' . getLanguage() . '/html/ext/',
3396 // Wrapper function to allow full float values as supported by current database layout
3397 function translateFullComma ($dotted) {
3398 // Call inner function
3399 return translateComma($dotted, TRUE, 5);