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 hourly is enabled
411 function isDebugHourlyEnabled () {
413 if (!isset($GLOBALS[__FUNCTION__])) {
415 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
419 return $GLOBALS[__FUNCTION__];
422 // Checks whether the debug reset is enabled
423 function isDebugResetEnabled () {
425 if (!isset($GLOBALS[__FUNCTION__])) {
427 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
431 return $GLOBALS[__FUNCTION__];
434 // Checks whether SQL debugging is enabled
435 function isSqlDebuggingEnabled () {
437 if (!isset($GLOBALS[__FUNCTION__])) {
438 // Determine if SQL debugging is enabled
439 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
443 return $GLOBALS[__FUNCTION__];
446 // Checks whether we shall debug regular expressions
447 function isDebugRegularExpressionEnabled () {
449 if (!isset($GLOBALS[__FUNCTION__])) {
451 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
455 return $GLOBALS[__FUNCTION__];
458 // Checks whether debugging of build mails is enabled
459 function isDebugBuildMailsEnabled () {
461 if (!isset($GLOBALS[__FUNCTION__])) {
463 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
467 return $GLOBALS[__FUNCTION__];
470 // Checks whether the cache instance is valid
471 function isCacheInstanceValid () {
473 if (!isset($GLOBALS[__FUNCTION__])) {
475 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
479 return $GLOBALS[__FUNCTION__];
482 // Copies a file from source to destination and verifies if that goes fine.
483 // This function should wrap the copy() command and make a nicer debug backtrace
484 // even if there is no xdebug extension installed.
485 function copyFileVerified ($source, $dest, $chmod = '') {
486 // Failed is the default
489 // Is the source file there?
490 if (!isFileReadable($source)) {
492 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
495 // Is the target directory there?
496 if (!isDirectory(dirname($dest))) {
498 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
501 // Now try to copy it
502 if (!copy($source, $dest)) {
503 // Something went wrong
504 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
507 $GLOBALS['file_readable'][$dest] = TRUE;
510 // All fine by default
513 // If there are chmod rights set, apply them
514 if (!empty($chmod)) {
516 $status = changeMode($dest, $chmod);
523 // Wrapper function for chmod()
524 // @TODO Do some more sanity check here
525 function changeMode ($FQFN, $mode) {
526 // Is the file/directory there?
527 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
528 // Neither, so abort here
529 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
533 return chmod($FQFN, $mode);
536 // Wrapper for unlink()
537 function removeFile ($FQFN) {
538 // Is the file there?
539 if (isFileReadable($FQFN)) {
541 $GLOBALS['file_readable'][$FQFN] = FALSE;
544 return unlink($FQFN);
547 // All fine if no file was removed. If we change this to 'false' or rewrite
548 // above if() block it would be to restrictive.
552 // Wrapper for $_POST['sel']
553 function countPostSelection ($element = 'sel') {
555 if (!isset($GLOBALS[__FUNCTION__][$element])) {
557 $GLOBALS[__FUNCTION__][$element] = '0';
560 if (isPostRequestElementSet($element)) {
561 // Return counted elements
562 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
566 // Return cached value
567 return $GLOBALS[__FUNCTION__][$element];
570 // Checks whether the config-local.php is loaded
571 function isConfigLocalLoaded () {
572 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
575 // Checks whether a nickname or userid was entered and caches the result
576 function isNicknameUsed ($userid) {
577 // Is the cache there
578 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
580 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
584 return $GLOBALS[__FUNCTION__][$userid];
587 // Getter for 'what' value
588 function getWhat ($strict = TRUE) {
593 if (isWhatSet($strict)) {
595 $what = $GLOBALS['__what'];
602 // Setter for 'what' value
603 function setWhat ($newWhat) {
604 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
605 $GLOBALS['__what'] = $newWhat;
608 // Setter for 'what' from configuration
609 function setWhatFromConfig ($configEntry) {
610 // Get 'what' from config
611 $what = getConfig($configEntry);
617 // Checks whether what is set and optionally aborts on miss
618 function isWhatSet ($strict = FALSE) {
620 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
622 // Should we abort here?
623 if (($strict === TRUE) && ($isset === FALSE)) {
625 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
632 // Getter for 'action' value
633 function getAction ($strict = TRUE) {
638 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
640 $action = $GLOBALS['__action'];
647 // Setter for 'action' value
648 function setAction ($newAction) {
649 $GLOBALS['__action'] = $newAction;
652 // Checks whether action is set and optionally aborts on miss
653 function isActionSet ($strict = FALSE) {
655 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
657 // Should we abort here?
658 if (($strict === TRUE) && ($isset === FALSE)) {
660 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
667 // Getter for 'module' value
668 function getModule ($strict = TRUE) {
673 if (isModuleSet($strict)) {
675 $module = $GLOBALS['__module'];
682 // Setter for 'module' value
683 function setModule ($newModule) {
684 // Secure it and make all modules lower-case
685 $GLOBALS['__module'] = strtolower($newModule);
688 // Wrapper to get extra module names
689 function getExtraModule () {
693 // Is 'tab/step' set?
694 if (isPostRequestElementSet('tab')) {
696 $extra = 'tab=' . postRequestElement('tab');
697 } elseif (isPostRequestElementSet('step')) {
699 $extra = 'step=' . postRequestElement('step');
700 } elseif ((isActionSet()) && (isWhatSet())) {
702 $extra = 'action=' . getAction() . ':what=' . getWhat();
709 // Checks whether module is set and optionally aborts on miss
710 function isModuleSet ($strict = FALSE) {
712 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
714 // Should we abort here?
715 if (($strict === TRUE) && ($isset === FALSE)) {
717 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
721 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
724 // Getter for 'output_mode' value
725 function getScriptOutputMode () {
727 if (!isset($GLOBALS[__FUNCTION__])) {
728 // Is the output mode set?
729 if (!isOutputModeSet()) {
730 // No, then abort here
731 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
735 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
739 return $GLOBALS[__FUNCTION__];
742 // Setter for 'output_mode' value
743 function setScriptOutputMode ($newOutputMode) {
744 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
745 $GLOBALS['__output_mode'] = (int) $newOutputMode;
748 // Checks whether output_mode is set and optionally aborts on miss
749 function isOutputModeSet ($strict = FALSE) {
751 $isset = (isset($GLOBALS['__output_mode']));
753 // Should we abort here?
754 if (($strict === TRUE) && ($isset === FALSE)) {
756 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
763 // Enables block-mode
764 function enableBlockMode ($enabled = TRUE) {
765 $GLOBALS['__block_mode'] = $enabled;
768 // Checks whether block-mode is enabled
769 function isBlockModeEnabled () {
771 if (!isset($GLOBALS['__block_mode'])) {
773 reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
777 return $GLOBALS['__block_mode'];
780 // Wrapper for redirectToUrl but URL comes from a configuration entry
781 function redirectToConfiguredUrl ($configEntry) {
783 redirectToUrl(getConfig($configEntry));
786 // Wrapper function to redirect from member-only modules to index
787 function redirectToIndexMemberOnlyModule () {
788 // Do the redirect here
789 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
792 // Wrapper function to redirect to current URL
793 function redirectToRequestUri () {
794 redirectToUrl(basename(detectRequestUri()));
797 // Wrapper function to redirect to de-refered URL
798 function redirectToDereferedUrl ($url) {
800 redirectToUrl(generateDereferrerUrl($url));
803 // Wrapper function for checking if extension is installed and newer or same version
804 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
805 // Is an cache entry found?
806 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
808 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
810 // Cache hits should be incremented twice
811 incrementStatsEntry('cache_hits', 2);
815 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
816 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
819 // Wrapper function for checking if extension is installed and older than given version
820 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
821 // Is an cache entry found?
822 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
824 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
826 // Cache hits should be incremented twice
827 incrementStatsEntry('cache_hits', 2);
831 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
832 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
836 function setUsername ($userName) {
837 $GLOBALS['username'] = (string) $userName;
841 function getUsername () {
843 if (!isset($GLOBALS['username'])) {
844 // No, so it has to be a guest
845 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
849 return $GLOBALS['username'];
852 // Wrapper function for installation phase
853 function isInstallationPhase () {
855 if (!isset($GLOBALS[__FUNCTION__])) {
857 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
861 return $GLOBALS[__FUNCTION__];
864 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
865 function isDemoModeActive () {
867 if (!isset($GLOBALS[__FUNCTION__])) {
869 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
873 return $GLOBALS[__FUNCTION__];
876 // Getter for PHP caching value
877 function getPhpCaching () {
878 return $GLOBALS['php_caching'];
881 // Checks whether the admin hash is set
882 function isAdminHashSet ($adminId) {
883 // Is the array there?
884 if (!isset($GLOBALS['cache_array']['admin'])) {
885 // Missing array should be reported
886 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
889 // Check for admin hash
890 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
893 // Setter for admin hash
894 function setAdminHash ($adminId, $hash) {
895 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
898 // Getter for current admin login
899 function getCurrentAdminLogin () {
901 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
904 if (!isset($GLOBALS[__FUNCTION__])) {
906 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
910 return $GLOBALS[__FUNCTION__];
913 // Setter for admin id (and current)
914 function setAdminId ($adminId) {
916 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
919 $status = setSession('admin_id', bigintval($adminId));
922 setCurrentAdminId($adminId);
928 // Setter for admin_last
929 function setAdminLast ($adminLast) {
931 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
934 $status = setSession('admin_last', $adminLast);
940 // Setter for admin_md5
941 function setAdminMd5 ($adminMd5) {
943 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
946 $status = setSession('admin_md5', $adminMd5);
952 // Getter for admin_md5
953 function getAdminMd5 () {
955 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
958 return getSession('admin_md5');
961 // Init user data array
962 function initUserData () {
963 // User id should not be zero
964 if (!isValidId(getCurrentUserId())) {
965 // Should be always valid
966 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
970 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
971 $GLOBALS['user_data'][getCurrentUserId()] = array();
974 // Getter for user data
975 function getUserData ($column) {
976 // User id should not be zero
977 if (!isValidId(getCurrentUserId())) {
978 // Should be always valid
979 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
985 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
987 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
994 // Checks whether given user data is set to 'Y'
995 function isUserDataEnabled ($column) {
997 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
999 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1003 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1006 // Geter for whole user data array
1007 function getUserDataArray () {
1009 $userid = getCurrentUserId();
1011 // Is the current userid valid?
1012 if (!isValidId($userid)) {
1013 // Should be always valid
1014 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1017 // Get the whole array if found
1018 if (isset($GLOBALS['user_data'][$userid])) {
1019 // Found, so return it
1020 return $GLOBALS['user_data'][$userid];
1022 // Return empty array
1027 // Checks if the user data is valid, this may indicate that the user has logged
1028 // in, but you should use isMember() if you want to find that out.
1029 function isUserDataValid () {
1030 // User id should not be zero so abort here
1031 if (!isCurrentUserIdSet()) {
1032 // Debug message, may be noisy
1033 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1040 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1042 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1045 // Return the result
1046 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1049 // Setter for current userid
1050 function setCurrentUserId ($userid) {
1052 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1054 // Is the cache from below functions different?
1055 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1057 unsetCurrentUserId();
1061 $GLOBALS['current_userid'] = bigintval($userid);
1063 // Unset it to re-determine the actual state
1064 unset($GLOBALS['is_userdata_valid'][$userid]);
1067 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1070 // Getter for current userid
1071 function getCurrentUserId () {
1073 if (!isset($GLOBALS[__FUNCTION__])) {
1074 // Userid must be set before it can be used
1075 if (!isCurrentUserIdSet()) {
1077 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1080 // Set userid in cache
1081 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1085 return $GLOBALS[__FUNCTION__];
1088 // Checks if current userid is set
1089 function isCurrentUserIdSet () {
1091 if (!isset($GLOBALS[__FUNCTION__])) {
1093 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1097 return $GLOBALS[__FUNCTION__];
1100 // Unsets current userid
1101 function unsetCurrentUserId () {
1103 if (isset($GLOBALS['current_userid'])) {
1105 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1108 // Unset all cache entries
1109 unset($GLOBALS['current_userid']);
1110 unset($GLOBALS['getCurrentUserId']);
1111 unset($GLOBALS['isCurrentUserIdSet']);
1114 // Checks whether we are debugging template cache
1115 function isDebugTemplateCacheEnabled () {
1117 if (!isset($GLOBALS[__FUNCTION__])) {
1119 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1123 return $GLOBALS[__FUNCTION__];
1126 // Wrapper for fetchUserData() and getUserData() calls
1127 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1128 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1130 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1134 // Can we fetch the user data?
1135 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1136 // Now get the data back
1137 $data = getUserData($valueColumn);
1141 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1145 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1146 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1149 // Wrapper for strpos() to ease porting from deprecated ereg() function
1150 function isInString ($needle, $haystack) {
1151 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1152 return (strpos($haystack, $needle) !== FALSE);
1155 // Wrapper for strpos() to ease porting from deprecated eregi() function
1156 // This function is case-insensitive
1157 function isInStringIgnoreCase ($needle, $haystack) {
1158 return (isInString(strtolower($needle), strtolower($haystack)));
1161 // Wrapper to check for if fatal errors where detected
1162 function ifFatalErrorsDetected () {
1163 // Just call the inner function
1164 return (getTotalFatalErrors() > 0);
1167 // Checks whether a HTTP status has been set
1168 function isHttpStatusSet () {
1169 // Is it set and not empty?
1170 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1173 // Setter for HTTP status
1174 function setHttpStatus ($status) {
1175 $GLOBALS['http_status'] = (string) $status;
1178 // Getter for HTTP status
1179 function getHttpStatus () {
1180 // Is the status set?
1181 if (!isHttpStatusSet()) {
1183 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1187 return $GLOBALS['http_status'];
1191 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1192 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1194 * ----------------------------------------------------------------------------
1195 * If you want to redirect, please use redirectToUrl(); instead
1196 * ----------------------------------------------------------------------------
1198 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1200 * @link http://support.microsoft.com/kb/q176113/
1201 * @author Andreas Gohr <andi@splitbrain.org>
1204 function sendRawRedirect ($url) {
1205 // Clear output buffer
1206 clearOutputBuffer();
1208 // Clear own output buffer
1209 $GLOBALS['__output'] = '';
1211 // To make redirects working (no content type), output mode must be raw
1212 setScriptOutputMode(-1);
1214 // Send helping header
1215 setHttpStatus('302 Found');
1217 // always close the session
1218 session_write_close();
1220 // Revert entity &
1221 $url = str_replace('&', '&', $url);
1223 // check if running on IIS < 6 with CGI-PHP
1224 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1225 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1226 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1227 ($matches[1] < 6)) {
1228 // Send the IIS header
1229 addHttpHeader('Refresh: 0;url=' . $url);
1231 // Send generic header
1232 addHttpHeader('Location: ' . $url);
1239 // Determines the country of the given user id
1240 function determineCountry ($userid) {
1242 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1243 // Default is 'invalid'
1244 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1246 // Is extension country active?
1247 if (isExtensionActive('country')) {
1248 // Determine the right country code through the country id
1249 $id = getUserData('country_code');
1251 // Then handle it over
1252 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1254 // Get raw code from user data
1255 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1260 return $GLOBALS[__FUNCTION__][$userid];
1263 // "Getter" for total confirmed user accounts
1264 function getTotalConfirmedUser () {
1266 if (!isset($GLOBALS[__FUNCTION__])) {
1268 if (isExtensionActive('user')) {
1269 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1271 $GLOBALS[__FUNCTION__] = 0;
1275 // Return cached value
1276 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1277 return $GLOBALS[__FUNCTION__];
1280 // "Getter" for total unconfirmed user accounts
1281 function getTotalUnconfirmedUser () {
1283 if (!isset($GLOBALS[__FUNCTION__])) {
1285 if (isExtensionActive('user')) {
1286 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1288 $GLOBALS[__FUNCTION__] = 0;
1292 // Return cached value
1293 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1294 return $GLOBALS[__FUNCTION__];
1297 // "Getter" for total locked user accounts
1298 function getTotalLockedUser () {
1300 if (!isset($GLOBALS[__FUNCTION__])) {
1302 if (isExtensionActive('user')) {
1303 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1305 $GLOBALS[__FUNCTION__] = 0;
1309 // Return cached value
1310 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1311 return $GLOBALS[__FUNCTION__];
1314 // "Getter" for total locked user accounts
1315 function getTotalRandomRefidUser () {
1317 if (!isset($GLOBALS[__FUNCTION__])) {
1319 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1320 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1322 $GLOBALS[__FUNCTION__] = 0;
1326 // Return cached value
1327 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1328 return $GLOBALS[__FUNCTION__];
1331 // Is given id number valid?
1332 function isValidId ($id) {
1334 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1337 if (!isset($GLOBALS[__FUNCTION__][$id])) {
1339 $GLOBALS[__FUNCTION__][$id] = ((!is_null($id)) && (!is_bool($id)) && (!empty($id)) && ($id != 'NULL') && ($id > 0));
1343 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1344 return $GLOBALS[__FUNCTION__][$id];
1348 function encodeEntities ($str) {
1350 $str = secureString($str, TRUE, TRUE);
1352 // Encode dollar sign as well
1353 $str = str_replace('$', '$', $str);
1359 // "Getter" for date from patch_ctime
1360 function getDateFromRepository () {
1362 if (!isset($GLOBALS[__FUNCTION__])) {
1364 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1368 return $GLOBALS[__FUNCTION__];
1371 // "Getter" for date/time from patch_ctime
1372 function getDateTimeFromRepository () {
1374 if (!isset($GLOBALS[__FUNCTION__])) {
1376 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1380 return $GLOBALS[__FUNCTION__];
1383 // Getter for current year (default)
1384 function getYear ($timestamp = NULL) {
1386 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1387 // If NULL is set, use time()
1388 if (is_null($timestamp)) {
1389 $timestamp = time();
1393 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1397 return $GLOBALS[__FUNCTION__][$timestamp];
1400 // Getter for current month (default)
1401 function getMonth ($timestamp = NULL) {
1403 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1404 // If NULL is set, use time()
1405 if (is_null($timestamp)) {
1406 // Use time() which is current timestamp
1407 $timestamp = time();
1411 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1415 return $GLOBALS[__FUNCTION__][$timestamp];
1418 // Getter for current hour (default)
1419 function getHour ($timestamp = NULL) {
1421 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1423 if (is_null($timestamp)) {
1424 $timestamp = time();
1428 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1432 return $GLOBALS[__FUNCTION__][$timestamp];
1435 // Getter for current day (default)
1436 function getDay ($timestamp = NULL) {
1438 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1440 if (is_null($timestamp)) {
1441 $timestamp = time();
1445 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1449 return $GLOBALS[__FUNCTION__][$timestamp];
1452 // Getter for current week (default)
1453 function getWeek ($timestamp = NULL) {
1455 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1457 if (is_null($timestamp)) $timestamp = time();
1460 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1464 return $GLOBALS[__FUNCTION__][$timestamp];
1467 // Getter for current short_hour (default)
1468 function getShortHour ($timestamp = NULL) {
1470 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1472 if (is_null($timestamp)) $timestamp = time();
1475 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1479 return $GLOBALS[__FUNCTION__][$timestamp];
1482 // Getter for current long_hour (default)
1483 function getLongHour ($timestamp = NULL) {
1485 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1487 if (is_null($timestamp)) $timestamp = time();
1490 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1494 return $GLOBALS[__FUNCTION__][$timestamp];
1497 // Getter for current second (default)
1498 function getSecond ($timestamp = NULL) {
1500 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1502 if (is_null($timestamp)) $timestamp = time();
1505 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1509 return $GLOBALS[__FUNCTION__][$timestamp];
1512 // Getter for current minute (default)
1513 function getMinute ($timestamp = NULL) {
1515 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1517 if (is_null($timestamp)) $timestamp = time();
1520 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1524 return $GLOBALS[__FUNCTION__][$timestamp];
1527 // Checks whether the title decoration is enabled
1528 function isTitleDecorationEnabled () {
1530 if (!isset($GLOBALS[__FUNCTION__])) {
1532 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1536 return $GLOBALS[__FUNCTION__];
1539 // Checks whether filter usage updates are enabled (expensive queries!)
1540 function isFilterUsageUpdateEnabled () {
1542 if (!isset($GLOBALS[__FUNCTION__])) {
1544 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1548 return $GLOBALS[__FUNCTION__];
1551 // Checks whether debugging of weekly resets is enabled
1552 function isWeeklyResetDebugEnabled () {
1554 if (!isset($GLOBALS[__FUNCTION__])) {
1556 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1560 return $GLOBALS[__FUNCTION__];
1563 // Checks whether debugging of monthly resets is enabled
1564 function isMonthlyResetDebugEnabled () {
1566 if (!isset($GLOBALS[__FUNCTION__])) {
1568 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1572 return $GLOBALS[__FUNCTION__];
1575 // Checks whether displaying of debug SQLs are enabled
1576 function isDisplayDebugSqlEnabled () {
1578 if (!isset($GLOBALS[__FUNCTION__])) {
1580 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1584 return $GLOBALS[__FUNCTION__];
1587 // Checks whether module title is enabled
1588 function isModuleTitleEnabled () {
1590 if (!isset($GLOBALS[__FUNCTION__])) {
1592 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1596 return $GLOBALS[__FUNCTION__];
1599 // Checks whether what title is enabled
1600 function isWhatTitleEnabled () {
1602 if (!isset($GLOBALS[__FUNCTION__])) {
1604 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1608 return $GLOBALS[__FUNCTION__];
1611 // Checks whether stats are enabled
1612 function ifInternalStatsEnabled () {
1614 if (!isset($GLOBALS[__FUNCTION__])) {
1615 // Then determine it
1616 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1619 // Return cached value
1620 return $GLOBALS[__FUNCTION__];
1623 // Checks whether admin-notification of certain user actions is enabled
1624 function isAdminNotificationEnabled () {
1626 if (!isset($GLOBALS[__FUNCTION__])) {
1628 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1632 return $GLOBALS[__FUNCTION__];
1635 // Checks whether random referral id selection is enabled
1636 function isRandomReferralIdEnabled () {
1638 if (!isset($GLOBALS[__FUNCTION__])) {
1640 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y'));
1644 return $GLOBALS[__FUNCTION__];
1647 // "Getter" for default language
1648 function getDefaultLanguage () {
1650 if (!isset($GLOBALS[__FUNCTION__])) {
1652 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1656 return $GLOBALS[__FUNCTION__];
1659 // "Getter" for default referral id
1660 function getDefRefid () {
1662 if (!isset($GLOBALS[__FUNCTION__])) {
1664 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1668 return $GLOBALS[__FUNCTION__];
1671 // "Getter" for path
1672 function getPath () {
1674 if (!isset($GLOBALS[__FUNCTION__])) {
1676 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1680 return $GLOBALS[__FUNCTION__];
1684 function getUrl () {
1686 if (!isset($GLOBALS[__FUNCTION__])) {
1688 $GLOBALS[__FUNCTION__] = getConfig('URL');
1692 return $GLOBALS[__FUNCTION__];
1695 // "Getter" for cache_path
1696 function getCachePath () {
1698 if (!isset($GLOBALS[__FUNCTION__])) {
1700 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1704 return $GLOBALS[__FUNCTION__];
1707 // "Getter" for WRITE_FOOTER
1708 function getWriteFooter () {
1710 if (!isset($GLOBALS[__FUNCTION__])) {
1712 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1716 return $GLOBALS[__FUNCTION__];
1719 // "Getter" for secret_key
1720 function getSecretKey () {
1722 if (!isset($GLOBALS[__FUNCTION__])) {
1724 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1728 return $GLOBALS[__FUNCTION__];
1731 // "Getter" for SITE_KEY
1732 function getSiteKey () {
1734 if (!isset($GLOBALS[__FUNCTION__])) {
1736 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1740 return $GLOBALS[__FUNCTION__];
1743 // "Getter" for DATE_KEY
1744 function getDateKey () {
1746 if (!isset($GLOBALS[__FUNCTION__])) {
1748 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1752 return $GLOBALS[__FUNCTION__];
1755 // "Getter" for master_salt
1756 function getMasterSalt () {
1758 if (!isset($GLOBALS[__FUNCTION__])) {
1760 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1764 return $GLOBALS[__FUNCTION__];
1767 // "Getter" for prime
1768 function getPrime () {
1770 if (!isset($GLOBALS[__FUNCTION__])) {
1772 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1776 return $GLOBALS[__FUNCTION__];
1779 // "Getter" for encrypt_separator
1780 function getEncryptSeparator () {
1782 if (!isset($GLOBALS[__FUNCTION__])) {
1784 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1788 return $GLOBALS[__FUNCTION__];
1791 // "Getter" for mysql_prefix
1792 function getMysqlPrefix () {
1794 if (!isset($GLOBALS[__FUNCTION__])) {
1796 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1800 return $GLOBALS[__FUNCTION__];
1803 // "Getter" for table_type
1804 function getTableType () {
1806 if (!isset($GLOBALS[__FUNCTION__])) {
1808 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1812 return $GLOBALS[__FUNCTION__];
1815 // "Getter" for salt_length
1816 function getSaltLength () {
1818 if (!isset($GLOBALS[__FUNCTION__])) {
1820 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1824 return $GLOBALS[__FUNCTION__];
1827 // "Getter" for output_mode
1828 function getOutputMode () {
1830 if (!isset($GLOBALS[__FUNCTION__])) {
1832 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1836 return $GLOBALS[__FUNCTION__];
1839 // "Getter" for full_version
1840 function getFullVersion () {
1842 if (!isset($GLOBALS[__FUNCTION__])) {
1844 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1848 return $GLOBALS[__FUNCTION__];
1851 // "Getter" for title
1852 function getTitle () {
1854 if (!isset($GLOBALS[__FUNCTION__])) {
1856 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1860 return $GLOBALS[__FUNCTION__];
1863 // "Getter" for curr_svn_revision
1864 function getCurrentRepositoryRevision () {
1866 if (!isset($GLOBALS[__FUNCTION__])) {
1868 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1872 return $GLOBALS[__FUNCTION__];
1875 // "Getter" for server_url
1876 function getServerUrl () {
1878 if (!isset($GLOBALS[__FUNCTION__])) {
1880 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1884 return $GLOBALS[__FUNCTION__];
1887 // "Getter" for mt_word
1888 function getMtWord () {
1890 if (!isset($GLOBALS[__FUNCTION__])) {
1892 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1896 return $GLOBALS[__FUNCTION__];
1899 // "Getter" for mt_word2
1900 function getMtWord2 () {
1902 if (!isset($GLOBALS[__FUNCTION__])) {
1904 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1908 return $GLOBALS[__FUNCTION__];
1911 // "Getter" for mt_word3
1912 function getMtWord3 () {
1914 if (!isset($GLOBALS[__FUNCTION__])) {
1916 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1920 return $GLOBALS[__FUNCTION__];
1923 // "Getter" for START_TDAY
1924 function getStartTday () {
1926 if (!isset($GLOBALS[__FUNCTION__])) {
1928 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
1932 return $GLOBALS[__FUNCTION__];
1935 // "Getter" for START_YDAY
1936 function getStartYday () {
1938 if (!isset($GLOBALS[__FUNCTION__])) {
1940 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
1944 return $GLOBALS[__FUNCTION__];
1947 // "Getter" for main_title
1948 function getMainTitle () {
1950 if (!isset($GLOBALS[__FUNCTION__])) {
1952 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1956 return $GLOBALS[__FUNCTION__];
1959 // "Getter" for file_hash
1960 function getFileHash () {
1962 if (!isset($GLOBALS[__FUNCTION__])) {
1964 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1968 return $GLOBALS[__FUNCTION__];
1971 // "Getter" for pass_scramble
1972 function getPassScramble () {
1974 if (!isset($GLOBALS[__FUNCTION__])) {
1976 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1980 return $GLOBALS[__FUNCTION__];
1983 // "Getter" for ap_inactive_since
1984 function getApInactiveSince () {
1986 if (!isset($GLOBALS[__FUNCTION__])) {
1988 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1992 return $GLOBALS[__FUNCTION__];
1995 // "Getter" for user_min_confirmed
1996 function getUserMinConfirmed () {
1998 if (!isset($GLOBALS[__FUNCTION__])) {
2000 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2004 return $GLOBALS[__FUNCTION__];
2006 // "Getter" for points
2007 function getPoints () {
2009 if (!isset($GLOBALS[__FUNCTION__])) {
2011 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2015 return $GLOBALS[__FUNCTION__];
2018 // "Getter" for slogan
2019 function getSlogan () {
2021 if (!isset($GLOBALS[__FUNCTION__])) {
2023 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2027 return $GLOBALS[__FUNCTION__];
2030 // "Getter" for copy
2031 function getCopy () {
2033 if (!isset($GLOBALS[__FUNCTION__])) {
2035 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2039 return $GLOBALS[__FUNCTION__];
2042 // "Getter" for webmaster
2043 function getWebmaster () {
2045 if (!isset($GLOBALS[__FUNCTION__])) {
2047 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2051 return $GLOBALS[__FUNCTION__];
2054 // "Getter" for sql_count
2055 function getSqlCount () {
2057 if (!isset($GLOBALS[__FUNCTION__])) {
2059 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2063 return $GLOBALS[__FUNCTION__];
2066 // "Getter" for num_templates
2067 function getNumTemplates () {
2069 if (!isset($GLOBALS[__FUNCTION__])) {
2071 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2075 return $GLOBALS[__FUNCTION__];
2078 // "Getter" for dns_cache_timeout
2079 function getDnsCacheTimeout () {
2081 if (!isset($GLOBALS[__FUNCTION__])) {
2083 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2087 return $GLOBALS[__FUNCTION__];
2090 // "Getter" for menu_blur_spacer
2091 function getMenuBlurSpacer () {
2093 if (!isset($GLOBALS[__FUNCTION__])) {
2095 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2099 return $GLOBALS[__FUNCTION__];
2102 // "Getter" for points_register
2103 function getPointsRegister () {
2105 if (!isset($GLOBALS[__FUNCTION__])) {
2107 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2111 return $GLOBALS[__FUNCTION__];
2114 // "Getter" for points_ref
2115 function getPointsRef () {
2117 if (!isset($GLOBALS[__FUNCTION__])) {
2119 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2123 return $GLOBALS[__FUNCTION__];
2126 // "Getter" for ref_payout
2127 function getRefPayout () {
2129 if (!isset($GLOBALS[__FUNCTION__])) {
2131 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2135 return $GLOBALS[__FUNCTION__];
2138 // "Getter" for online_timeout
2139 function getOnlineTimeout () {
2141 if (!isset($GLOBALS[__FUNCTION__])) {
2143 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2147 return $GLOBALS[__FUNCTION__];
2150 // "Getter" for index_home
2151 function getIndexHome () {
2153 if (!isset($GLOBALS[__FUNCTION__])) {
2155 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2159 return $GLOBALS[__FUNCTION__];
2162 // "Getter" for one_day
2163 function getOneDay () {
2165 if (!isset($GLOBALS[__FUNCTION__])) {
2167 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2171 return $GLOBALS[__FUNCTION__];
2174 // "Getter" for activate_xchange
2175 function getActivateXchange () {
2177 if (!isset($GLOBALS[__FUNCTION__])) {
2179 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2183 return $GLOBALS[__FUNCTION__];
2186 // "Getter" for img_type
2187 function getImgType () {
2189 if (!isset($GLOBALS[__FUNCTION__])) {
2191 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2195 return $GLOBALS[__FUNCTION__];
2198 // "Getter" for code_length
2199 function getCodeLength () {
2201 if (!isset($GLOBALS[__FUNCTION__])) {
2203 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2207 return $GLOBALS[__FUNCTION__];
2210 // "Getter" for least_cats
2211 function getLeastCats () {
2213 if (!isset($GLOBALS[__FUNCTION__])) {
2215 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2219 return $GLOBALS[__FUNCTION__];
2222 // "Getter" for pass_len
2223 function getPassLen () {
2225 if (!isset($GLOBALS[__FUNCTION__])) {
2227 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2231 return $GLOBALS[__FUNCTION__];
2234 // "Getter" for admin_menu
2235 function getAdminMenu () {
2237 if (!isset($GLOBALS[__FUNCTION__])) {
2239 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2243 return $GLOBALS[__FUNCTION__];
2246 // "Getter" for last_month
2247 function getLastMonth () {
2249 if (!isset($GLOBALS[__FUNCTION__])) {
2251 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2255 return $GLOBALS[__FUNCTION__];
2258 // "Getter" for max_send
2259 function getMaxSend () {
2261 if (!isset($GLOBALS[__FUNCTION__])) {
2263 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2267 return $GLOBALS[__FUNCTION__];
2270 // "Getter" for mails_page
2271 function getMailsPage () {
2273 if (!isset($GLOBALS[__FUNCTION__])) {
2275 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2279 return $GLOBALS[__FUNCTION__];
2282 // "Getter" for rand_no
2283 function getRandNo () {
2285 if (!isset($GLOBALS[__FUNCTION__])) {
2287 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2291 return $GLOBALS[__FUNCTION__];
2294 // "Getter" for __DB_NAME
2295 function getDbName () {
2297 if (!isset($GLOBALS[__FUNCTION__])) {
2299 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2303 return $GLOBALS[__FUNCTION__];
2306 // "Getter" for DOMAIN
2307 function getDomain () {
2309 if (!isset($GLOBALS[__FUNCTION__])) {
2311 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2315 return $GLOBALS[__FUNCTION__];
2318 // "Getter" for proxy_username
2319 function getProxyUsername () {
2321 if (!isset($GLOBALS[__FUNCTION__])) {
2323 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2327 return $GLOBALS[__FUNCTION__];
2330 // "Getter" for proxy_password
2331 function getProxyPassword () {
2333 if (!isset($GLOBALS[__FUNCTION__])) {
2335 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2339 return $GLOBALS[__FUNCTION__];
2342 // "Getter" for proxy_host
2343 function getProxyHost () {
2345 if (!isset($GLOBALS[__FUNCTION__])) {
2347 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2351 return $GLOBALS[__FUNCTION__];
2354 // "Getter" for proxy_port
2355 function getProxyPort () {
2357 if (!isset($GLOBALS[__FUNCTION__])) {
2359 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2363 return $GLOBALS[__FUNCTION__];
2366 // "Getter" for SMTP_HOSTNAME
2367 function getSmtpHostname () {
2369 if (!isset($GLOBALS[__FUNCTION__])) {
2371 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2375 return $GLOBALS[__FUNCTION__];
2378 // "Getter" for SMTP_USER
2379 function getSmtpUser () {
2381 if (!isset($GLOBALS[__FUNCTION__])) {
2383 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2387 return $GLOBALS[__FUNCTION__];
2390 // "Getter" for SMTP_PASSWORD
2391 function getSmtpPassword () {
2393 if (!isset($GLOBALS[__FUNCTION__])) {
2395 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2399 return $GLOBALS[__FUNCTION__];
2402 // "Getter" for points_word
2403 function getPointsWord () {
2405 if (!isset($GLOBALS[__FUNCTION__])) {
2407 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2411 return $GLOBALS[__FUNCTION__];
2414 // "Getter" for profile_lock
2415 function getProfileLock () {
2417 if (!isset($GLOBALS[__FUNCTION__])) {
2419 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2423 return $GLOBALS[__FUNCTION__];
2426 // "Getter" for url_tlock
2427 function getUrlTlock () {
2429 if (!isset($GLOBALS[__FUNCTION__])) {
2431 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2435 return $GLOBALS[__FUNCTION__];
2438 // "Getter" for title_left
2439 function getTitleLeft () {
2441 if (!isset($GLOBALS[__FUNCTION__])) {
2443 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2447 return $GLOBALS[__FUNCTION__];
2450 // "Getter" for title_right
2451 function getTitleRight () {
2453 if (!isset($GLOBALS[__FUNCTION__])) {
2455 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2459 return $GLOBALS[__FUNCTION__];
2462 // "Getter" for title_middle
2463 function getTitleMiddle () {
2465 if (!isset($GLOBALS[__FUNCTION__])) {
2467 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2471 return $GLOBALS[__FUNCTION__];
2474 // Getter for 'check_double_email'
2475 function getCheckDoubleEmail () {
2476 // Is the cache entry set?
2477 if (!isset($GLOBALS[__FUNCTION__])) {
2478 // No, so determine it
2479 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2482 // Return cached entry
2483 return $GLOBALS[__FUNCTION__];
2486 // Checks whether 'check_double_email' is 'Y'
2487 function isCheckDoubleEmailEnabled () {
2488 // Is the cache entry set?
2489 if (!isset($GLOBALS[__FUNCTION__])) {
2490 // No, so determine it
2491 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2494 // Return cached entry
2495 return $GLOBALS[__FUNCTION__];
2498 // Getter for 'display_home_in_index'
2499 function getDisplayHomeInIndex () {
2500 // Is the cache entry set?
2501 if (!isset($GLOBALS[__FUNCTION__])) {
2502 // No, so determine it
2503 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2506 // Return cached entry
2507 return $GLOBALS[__FUNCTION__];
2510 // Checks whether 'display_home_in_index' is 'Y'
2511 function isDisplayHomeInIndexEnabled () {
2512 // Is the cache entry set?
2513 if (!isset($GLOBALS[__FUNCTION__])) {
2514 // No, so determine it
2515 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2518 // Return cached entry
2519 return $GLOBALS[__FUNCTION__];
2522 // Getter for 'show_points_unconfirmed'
2523 function getShowPointsUnconfirmed () {
2524 // Is the cache entry set?
2525 if (!isset($GLOBALS[__FUNCTION__])) {
2526 // No, so determine it
2527 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2530 // Return cached entry
2531 return $GLOBALS[__FUNCTION__];
2534 // Checks whether 'show_points_unconfirmed' is 'Y'
2535 function isShowPointsUnconfirmedEnabled () {
2536 // Is the cache entry set?
2537 if (!isset($GLOBALS[__FUNCTION__])) {
2538 // No, so determine it
2539 $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y');
2542 // Return cached entry
2543 return $GLOBALS[__FUNCTION__];
2546 // Getter for 'youre_here'
2547 function getYoureHere () {
2548 // Is the cache entry set?
2549 if (!isset($GLOBALS[__FUNCTION__])) {
2550 // No, so determine it
2551 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2554 // Return cached entry
2555 return $GLOBALS[__FUNCTION__];
2558 // Checks whether 'show_timings' is 'Y'
2559 function isYoureHereEnabled () {
2560 // Is the cache entry set?
2561 if (!isset($GLOBALS[__FUNCTION__])) {
2562 // No, so determine it
2563 $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y');
2566 // Return cached entry
2567 return $GLOBALS[__FUNCTION__];
2570 // Getter for 'show_timings'
2571 function getShowTimings () {
2572 // Is the cache entry set?
2573 if (!isset($GLOBALS[__FUNCTION__])) {
2574 // No, so determine it
2575 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2578 // Return cached entry
2579 return $GLOBALS[__FUNCTION__];
2582 // Checks whether 'show_timings' is 'Y'
2583 function isShowTimingsEnabled () {
2584 // Is the cache entry set?
2585 if (!isset($GLOBALS[__FUNCTION__])) {
2586 // No, so determine it
2587 $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y');
2590 // Return cached entry
2591 return $GLOBALS[__FUNCTION__];
2594 // Getter for 'ap_server_name_since'
2595 function getApServerNameSince () {
2596 // Is the cache entry set?
2597 if (!isset($GLOBALS[__FUNCTION__])) {
2598 // No, so determine it
2599 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2602 // Return cached entry
2603 return $GLOBALS[__FUNCTION__];
2606 // Getter for 'ap_server_name'
2607 function getApServerName () {
2608 // Is the cache entry set?
2609 if (!isset($GLOBALS[__FUNCTION__])) {
2610 // No, so determine it
2611 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2614 // Return cached entry
2615 return $GLOBALS[__FUNCTION__];
2618 // Getter for 'index_delay'
2619 function getIndexDelay () {
2620 // Is the cache entry set?
2621 if (!isset($GLOBALS[__FUNCTION__])) {
2622 // No, so determine it
2623 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2626 // Return cached entry
2627 return $GLOBALS[__FUNCTION__];
2630 // Checks whether 'ap_server_name' is 'Y'
2631 function isApServerNameEnabled () {
2632 // Is the cache entry set?
2633 if (!isset($GLOBALS[__FUNCTION__])) {
2634 // No, so determine it
2635 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2638 // Return cached entry
2639 return $GLOBALS[__FUNCTION__];
2642 // Getter for 'admin_menu_javascript'
2643 function getAdminMenuJavascript () {
2644 // Is the cache entry set?
2645 if (!isset($GLOBALS[__FUNCTION__])) {
2646 // No, so determine it
2647 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2650 // Return cached entry
2651 return $GLOBALS[__FUNCTION__];
2654 // Getter for 'points_remove_account'
2655 function getPointsRemoveAccount () {
2656 // Is the cache entry set?
2657 if (!isset($GLOBALS[__FUNCTION__])) {
2658 // No, so determine it
2659 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2662 // Return cached entry
2663 return $GLOBALS[__FUNCTION__];
2666 // Getter for 'css_php'
2667 function getCssPhp () {
2668 // Is the cache entry set?
2669 if (!isset($GLOBALS[__FUNCTION__])) {
2670 // No, so determine it
2671 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2674 // Return cached entry
2675 return $GLOBALS[__FUNCTION__];
2678 // Getter for 'guest_menu'
2679 function getGuestMenu () {
2680 // Is the cache entry set?
2681 if (!isset($GLOBALS[__FUNCTION__])) {
2682 // No, so determine it
2683 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2686 // Return cached entry
2687 return $GLOBALS[__FUNCTION__];
2690 // Checks if guest menu is enabled
2691 function isGuestMenuEnabled () {
2692 // Is the cache entry set?
2693 if (!isset($GLOBALS[__FUNCTION__])) {
2694 // No, so determine it
2695 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2698 // Return cached entry
2699 return $GLOBALS[__FUNCTION__];
2702 // Getter for 'member_menu'
2703 function getMemberMenu () {
2704 // Is the cache entry set?
2705 if (!isset($GLOBALS[__FUNCTION__])) {
2706 // No, so determine it
2707 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2710 // Return cached entry
2711 return $GLOBALS[__FUNCTION__];
2714 // Checks if member menu is enabled
2715 function isMemberMenuEnabled () {
2716 // Is the cache entry set?
2717 if (!isset($GLOBALS[__FUNCTION__])) {
2718 // No, so determine it
2719 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2722 // Return cached entry
2723 return $GLOBALS[__FUNCTION__];
2726 // Getter for 'word_wrap'
2727 function getWordWrap () {
2728 // Is the cache entry set?
2729 if (!isset($GLOBALS[__FUNCTION__])) {
2730 // Construct config entry name
2731 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2733 // Is a special config entry found or ext-sql_patches updated?
2734 if (isConfigEntrySet($configEntry)) {
2735 // A special config entry has been found, then use it
2736 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2737 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2738 // No special config entry found, then use it as "fall-back"
2739 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2741 // No, use default (15 characters)
2742 $GLOBALS[__FUNCTION__] = 15;
2746 // Return cached entry
2747 return $GLOBALS[__FUNCTION__];
2750 // Checks whether proxy configuration is used
2751 function isProxyUsed () {
2753 if (!isset($GLOBALS[__FUNCTION__])) {
2755 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2759 return $GLOBALS[__FUNCTION__];
2762 // Checks whether POST data contains selections
2763 function ifPostContainsSelections ($element = 'sel') {
2765 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2767 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2771 return $GLOBALS[__FUNCTION__][$element];
2774 // Checks whether verbose_sql is Y and returns true/false if so
2775 function isVerboseSqlEnabled () {
2777 if (!isset($GLOBALS[__FUNCTION__])) {
2779 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2783 return $GLOBALS[__FUNCTION__];
2786 // "Getter" for total user points
2787 function getTotalPoints ($userid) {
2789 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2790 // Init array for filter chain
2792 'userid' => $userid,
2796 // Run filter chain for getting more point values
2797 $data = runFilterChain('get_total_points', $data);
2800 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2804 return $GLOBALS[__FUNCTION__][$userid];
2807 // Wrapper to get used points for given userid
2808 function getUserUsedPoints ($userid) {
2810 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2812 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2816 return $GLOBALS[__FUNCTION__][$userid];
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 ($str, $length = 2) {
3249 // Return prepended string
3250 return sprintf('%0' . (int) $length . 's', $str);
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);
3402 // Wrapper to check if the first element to be shifted is set to given value
3403 function shift_array (&$array, $value, $key = '0') {
3404 // Is the element set and value matches?
3405 assert(is_array($array));
3406 assert(isset($array[$key]));
3407 assert($array[$key] === $value);
3410 array_shift($array);
3413 // Wrapper for str_pad() with left padding zeros
3414 function padLeftZero ($str, $amount = 2) {
3415 // Is str_pad() there?
3416 if (function_exists('str_pad')) {
3417 // Use prependZeros()
3418 return prependZeros($str, $amount);
3421 return str_pad($str, $amount, '0', STR_PAD_LEFT);