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');
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 // Checks whether module is set and optionally aborts on miss
677 function isModuleSet ($strict = FALSE) {
679 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
681 // Should we abort here?
682 if (($strict === TRUE) && ($isset === FALSE)) {
684 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
688 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
691 // Getter for 'output_mode' value
692 function getScriptOutputMode () {
694 if (!isset($GLOBALS[__FUNCTION__])) {
695 // Is the output mode set?
696 if (!isOutputModeSet()) {
697 // No, then abort here
698 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
702 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
706 return $GLOBALS[__FUNCTION__];
709 // Setter for 'output_mode' value
710 function setScriptOutputMode ($newOutputMode) {
711 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
712 $GLOBALS['__output_mode'] = (int) $newOutputMode;
715 // Checks whether output_mode is set and optionally aborts on miss
716 function isOutputModeSet ($strict = FALSE) {
718 $isset = (isset($GLOBALS['__output_mode']));
720 // Should we abort here?
721 if (($strict === TRUE) && ($isset === FALSE)) {
723 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
730 // Enables block-mode
731 function enableBlockMode ($enabled = TRUE) {
732 $GLOBALS['__block_mode'] = $enabled;
735 // Checks whether block-mode is enabled
736 function isBlockModeEnabled () {
738 if (!isset($GLOBALS['__block_mode'])) {
740 reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
744 return $GLOBALS['__block_mode'];
747 // Wrapper for redirectToUrl but URL comes from a configuration entry
748 function redirectToConfiguredUrl ($configEntry) {
750 redirectToUrl(getConfig($configEntry));
753 // Wrapper function to redirect from member-only modules to index
754 function redirectToIndexMemberOnlyModule () {
755 // Do the redirect here
756 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
759 // Wrapper function to redirect to current URL
760 function redirectToRequestUri () {
761 redirectToUrl(basename(detectRequestUri()));
764 // Wrapper function to redirect to de-refered URL
765 function redirectToDereferedUrl ($url) {
767 redirectToUrl(generateDereferrerUrl($url));
770 // Wrapper function for checking if extension is installed and newer or same version
771 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
772 // Is an cache entry found?
773 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
775 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
777 // Cache hits should be incremented twice
778 incrementStatsEntry('cache_hits', 2);
782 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
783 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
786 // Wrapper function for checking if extension is installed and older than given version
787 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
788 // Is an cache entry found?
789 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
791 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
793 // Cache hits should be incremented twice
794 incrementStatsEntry('cache_hits', 2);
798 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
799 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
803 function setUsername ($userName) {
804 $GLOBALS['username'] = (string) $userName;
808 function getUsername () {
810 if (!isset($GLOBALS['username'])) {
811 // No, so it has to be a guest
812 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
816 return $GLOBALS['username'];
819 // Wrapper function for installation phase
820 function isInstallationPhase () {
822 if (!isset($GLOBALS[__FUNCTION__])) {
824 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
828 return $GLOBALS[__FUNCTION__];
831 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
832 function isDemoModeActive () {
834 if (!isset($GLOBALS[__FUNCTION__])) {
836 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
840 return $GLOBALS[__FUNCTION__];
843 // Getter for PHP caching value
844 function getPhpCaching () {
845 return $GLOBALS['php_caching'];
848 // Checks whether the admin hash is set
849 function isAdminHashSet ($adminId) {
850 // Is the array there?
851 if (!isset($GLOBALS['cache_array']['admin'])) {
852 // Missing array should be reported
853 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
856 // Check for admin hash
857 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
860 // Setter for admin hash
861 function setAdminHash ($adminId, $hash) {
862 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
865 // Getter for current admin login
866 function getCurrentAdminLogin () {
868 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
871 if (!isset($GLOBALS[__FUNCTION__])) {
873 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
877 return $GLOBALS[__FUNCTION__];
880 // Setter for admin id (and current)
881 function setAdminId ($adminId) {
883 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
886 $status = setSession('admin_id', bigintval($adminId));
889 setCurrentAdminId($adminId);
895 // Setter for admin_last
896 function setAdminLast ($adminLast) {
898 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
901 $status = setSession('admin_last', $adminLast);
907 // Setter for admin_md5
908 function setAdminMd5 ($adminMd5) {
910 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
913 $status = setSession('admin_md5', $adminMd5);
919 // Getter for admin_md5
920 function getAdminMd5 () {
922 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
925 return getSession('admin_md5');
928 // Init user data array
929 function initUserData () {
930 // User id should not be zero
931 if (!isValidUserId(getCurrentUserId())) {
932 // Should be always valid
933 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
937 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
938 $GLOBALS['user_data'][getCurrentUserId()] = array();
941 // Getter for user data
942 function getUserData ($column) {
943 // User id should not be zero
944 if (!isValidUserId(getCurrentUserId())) {
945 // Should be always valid
946 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
952 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
954 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
961 // Checks whether given user data is set to 'Y'
962 function isUserDataEnabled ($column) {
964 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
966 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
970 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
973 // Geter for whole user data array
974 function getUserDataArray () {
976 $userid = getCurrentUserId();
978 // Is the current userid valid?
979 if (!isValidUserId($userid)) {
980 // Should be always valid
981 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
984 // Get the whole array if found
985 if (isset($GLOBALS['user_data'][$userid])) {
986 // Found, so return it
987 return $GLOBALS['user_data'][$userid];
989 // Return empty array
994 // Checks if the user data is valid, this may indicate that the user has logged
995 // in, but you should use isMember() if you want to find that out.
996 function isUserDataValid () {
997 // User id should not be zero so abort here
998 if (!isCurrentUserIdSet()) {
999 // Debug message, may be noisy
1000 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1007 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1009 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1012 // Return the result
1013 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1016 // Setter for current userid
1017 function setCurrentUserId ($userid) {
1019 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1021 // Is the cache from below functions different?
1022 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1024 unsetCurrentUserId();
1028 $GLOBALS['current_userid'] = bigintval($userid);
1030 // Unset it to re-determine the actual state
1031 unset($GLOBALS['is_userdata_valid'][$userid]);
1034 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1037 // Getter for current userid
1038 function getCurrentUserId () {
1040 if (!isset($GLOBALS[__FUNCTION__])) {
1041 // Userid must be set before it can be used
1042 if (!isCurrentUserIdSet()) {
1044 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1047 // Set userid in cache
1048 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1052 return $GLOBALS[__FUNCTION__];
1055 // Checks if current userid is set
1056 function isCurrentUserIdSet () {
1058 if (!isset($GLOBALS[__FUNCTION__])) {
1060 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1064 return $GLOBALS[__FUNCTION__];
1067 // Unsets current userid
1068 function unsetCurrentUserId () {
1070 if (isset($GLOBALS['current_userid'])) {
1072 unset($GLOBALS['isValidUserId'][$GLOBALS['current_userid']]);
1075 // Unset all cache entries
1076 unset($GLOBALS['current_userid']);
1077 unset($GLOBALS['getCurrentUserId']);
1078 unset($GLOBALS['isCurrentUserIdSet']);
1081 // Checks whether we are debugging template cache
1082 function isDebuggingTemplateCache () {
1084 if (!isset($GLOBALS[__FUNCTION__])) {
1086 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1090 return $GLOBALS[__FUNCTION__];
1093 // Wrapper for fetchUserData() and getUserData() calls
1094 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1095 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1097 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1101 // Can we fetch the user data?
1102 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1103 // Now get the data back
1104 $data = getUserData($valueColumn);
1108 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1112 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1113 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1116 // Wrapper for strpos() to ease porting from deprecated ereg() function
1117 function isInString ($needle, $haystack) {
1118 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1119 return (strpos($haystack, $needle) !== FALSE);
1122 // Wrapper for strpos() to ease porting from deprecated eregi() function
1123 // This function is case-insensitive
1124 function isInStringIgnoreCase ($needle, $haystack) {
1125 return (isInString(strtolower($needle), strtolower($haystack)));
1128 // Wrapper to check for if fatal errors where detected
1129 function ifFatalErrorsDetected () {
1130 // Just call the inner function
1131 return (getTotalFatalErrors() > 0);
1134 // Checks whether a HTTP status has been set
1135 function isHttpStatusSet () {
1136 // Is it set and not empty?
1137 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1140 // Setter for HTTP status
1141 function setHttpStatus ($status) {
1142 $GLOBALS['http_status'] = (string) $status;
1145 // Getter for HTTP status
1146 function getHttpStatus () {
1147 // Is the status set?
1148 if (!isHttpStatusSet()) {
1150 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1154 return $GLOBALS['http_status'];
1158 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1159 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1161 * ----------------------------------------------------------------------------
1162 * If you want to redirect, please use redirectToUrl(); instead
1163 * ----------------------------------------------------------------------------
1165 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1167 * @link http://support.microsoft.com/kb/q176113/
1168 * @author Andreas Gohr <andi@splitbrain.org>
1171 function sendRawRedirect ($url) {
1172 // Clear output buffer
1173 clearOutputBuffer();
1175 // Clear own output buffer
1176 $GLOBALS['__output'] = '';
1178 // To make redirects working (no content type), output mode must be raw
1179 setScriptOutputMode(-1);
1181 // Send helping header
1182 setHttpStatus('302 Found');
1184 // always close the session
1185 session_write_close();
1187 // Revert entity &
1188 $url = str_replace('&', '&', $url);
1190 // check if running on IIS < 6 with CGI-PHP
1191 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1192 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1193 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1194 ($matches[1] < 6)) {
1195 // Send the IIS header
1196 addHttpHeader('Refresh: 0;url=' . $url);
1198 // Send generic header
1199 addHttpHeader('Location: ' . $url);
1206 // Determines the country of the given user id
1207 function determineCountry ($userid) {
1209 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1210 // Default is 'invalid'
1211 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1213 // Is extension country active?
1214 if (isExtensionActive('country')) {
1215 // Determine the right country code through the country id
1216 $id = getUserData('country_code');
1218 // Then handle it over
1219 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1221 // Get raw code from user data
1222 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1227 return $GLOBALS[__FUNCTION__][$userid];
1230 // "Getter" for total confirmed user accounts
1231 function getTotalConfirmedUser () {
1233 if (!isset($GLOBALS[__FUNCTION__])) {
1235 if (isExtensionActive('user')) {
1236 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1238 $GLOBALS[__FUNCTION__] = 0;
1242 // Return cached value
1243 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1244 return $GLOBALS[__FUNCTION__];
1247 // "Getter" for total unconfirmed user accounts
1248 function getTotalUnconfirmedUser () {
1250 if (!isset($GLOBALS[__FUNCTION__])) {
1252 if (isExtensionActive('user')) {
1253 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1255 $GLOBALS[__FUNCTION__] = 0;
1259 // Return cached value
1260 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1261 return $GLOBALS[__FUNCTION__];
1264 // "Getter" for total locked user accounts
1265 function getTotalLockedUser () {
1267 if (!isset($GLOBALS[__FUNCTION__])) {
1269 if (isExtensionActive('user')) {
1270 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1272 $GLOBALS[__FUNCTION__] = 0;
1276 // Return cached value
1277 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1278 return $GLOBALS[__FUNCTION__];
1281 // "Getter" for total locked user accounts
1282 function getTotalRandomRefidUser () {
1284 if (!isset($GLOBALS[__FUNCTION__])) {
1286 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1287 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1289 $GLOBALS[__FUNCTION__] = 0;
1293 // Return cached value
1294 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1295 return $GLOBALS[__FUNCTION__];
1298 // Is given userid valid?
1299 function isValidUserId ($userid) {
1301 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid);
1304 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1306 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid != 'NULL') && ($userid > 0));
1310 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',result=' . intval($GLOBALS[__FUNCTION__][$userid]));
1311 return $GLOBALS[__FUNCTION__][$userid];
1315 function encodeEntities ($str) {
1317 $str = secureString($str, TRUE, TRUE);
1319 // Encode dollar sign as well
1320 $str = str_replace('$', '$', $str);
1326 // "Getter" for date from patch_ctime
1327 function getDateFromRepository () {
1329 if (!isset($GLOBALS[__FUNCTION__])) {
1331 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1335 return $GLOBALS[__FUNCTION__];
1338 // "Getter" for date/time from patch_ctime
1339 function getDateTimeFromRepository () {
1341 if (!isset($GLOBALS[__FUNCTION__])) {
1343 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1347 return $GLOBALS[__FUNCTION__];
1350 // Getter for current year (default)
1351 function getYear ($timestamp = NULL) {
1353 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1354 // If NULL is set, use time()
1355 if (is_null($timestamp)) {
1356 $timestamp = time();
1360 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1364 return $GLOBALS[__FUNCTION__][$timestamp];
1367 // Getter for current month (default)
1368 function getMonth ($timestamp = NULL) {
1370 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1371 // If NULL is set, use time()
1372 if (is_null($timestamp)) {
1373 // Use time() which is current timestamp
1374 $timestamp = time();
1378 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1382 return $GLOBALS[__FUNCTION__][$timestamp];
1385 // Getter for current hour (default)
1386 function getHour ($timestamp = NULL) {
1388 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1390 if (is_null($timestamp)) {
1391 $timestamp = time();
1395 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1399 return $GLOBALS[__FUNCTION__][$timestamp];
1402 // Getter for current day (default)
1403 function getDay ($timestamp = NULL) {
1405 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1407 if (is_null($timestamp)) {
1408 $timestamp = time();
1412 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1416 return $GLOBALS[__FUNCTION__][$timestamp];
1419 // Getter for current week (default)
1420 function getWeek ($timestamp = NULL) {
1422 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1424 if (is_null($timestamp)) $timestamp = time();
1427 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1431 return $GLOBALS[__FUNCTION__][$timestamp];
1434 // Getter for current short_hour (default)
1435 function getShortHour ($timestamp = NULL) {
1437 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1439 if (is_null($timestamp)) $timestamp = time();
1442 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1446 return $GLOBALS[__FUNCTION__][$timestamp];
1449 // Getter for current long_hour (default)
1450 function getLongHour ($timestamp = NULL) {
1452 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1454 if (is_null($timestamp)) $timestamp = time();
1457 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1461 return $GLOBALS[__FUNCTION__][$timestamp];
1464 // Getter for current second (default)
1465 function getSecond ($timestamp = NULL) {
1467 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1469 if (is_null($timestamp)) $timestamp = time();
1472 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1476 return $GLOBALS[__FUNCTION__][$timestamp];
1479 // Getter for current minute (default)
1480 function getMinute ($timestamp = NULL) {
1482 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1484 if (is_null($timestamp)) $timestamp = time();
1487 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1491 return $GLOBALS[__FUNCTION__][$timestamp];
1494 // Checks whether the title decoration is enabled
1495 function isTitleDecorationEnabled () {
1497 if (!isset($GLOBALS[__FUNCTION__])) {
1499 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1503 return $GLOBALS[__FUNCTION__];
1506 // Checks whether filter usage updates are enabled (expensive queries!)
1507 function isFilterUsageUpdateEnabled () {
1509 if (!isset($GLOBALS[__FUNCTION__])) {
1511 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1515 return $GLOBALS[__FUNCTION__];
1518 // Checks whether debugging of weekly resets is enabled
1519 function isWeeklyResetDebugEnabled () {
1521 if (!isset($GLOBALS[__FUNCTION__])) {
1523 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1527 return $GLOBALS[__FUNCTION__];
1530 // Checks whether debugging of monthly resets is enabled
1531 function isMonthlyResetDebugEnabled () {
1533 if (!isset($GLOBALS[__FUNCTION__])) {
1535 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1539 return $GLOBALS[__FUNCTION__];
1542 // Checks whether displaying of debug SQLs are enabled
1543 function isDisplayDebugSqlEnabled () {
1545 if (!isset($GLOBALS[__FUNCTION__])) {
1547 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1551 return $GLOBALS[__FUNCTION__];
1554 // Checks whether module title is enabled
1555 function isModuleTitleEnabled () {
1557 if (!isset($GLOBALS[__FUNCTION__])) {
1559 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1563 return $GLOBALS[__FUNCTION__];
1566 // Checks whether what title is enabled
1567 function isWhatTitleEnabled () {
1569 if (!isset($GLOBALS[__FUNCTION__])) {
1571 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1575 return $GLOBALS[__FUNCTION__];
1578 // Checks whether stats are enabled
1579 function ifInternalStatsEnabled () {
1581 if (!isset($GLOBALS[__FUNCTION__])) {
1582 // Then determine it
1583 $GLOBALS[__FUNCTION__] = (getConfig('internal_stats') == 'Y');
1586 // Return cached value
1587 return $GLOBALS[__FUNCTION__];
1590 // Checks whether admin-notification of certain user actions is enabled
1591 function isAdminNotificationEnabled () {
1593 if (!isset($GLOBALS[__FUNCTION__])) {
1595 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1599 return $GLOBALS[__FUNCTION__];
1602 // Checks whether random referral id selection is enabled
1603 function isRandomReferralIdEnabled () {
1605 if (!isset($GLOBALS[__FUNCTION__])) {
1607 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y'));
1611 return $GLOBALS[__FUNCTION__];
1614 // "Getter" for default language
1615 function getDefaultLanguage () {
1617 if (!isset($GLOBALS[__FUNCTION__])) {
1619 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1623 return $GLOBALS[__FUNCTION__];
1626 // "Getter" for default referral id
1627 function getDefRefid () {
1629 if (!isset($GLOBALS[__FUNCTION__])) {
1631 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1635 return $GLOBALS[__FUNCTION__];
1638 // "Getter" for path
1639 function getPath () {
1641 if (!isset($GLOBALS[__FUNCTION__])) {
1643 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1647 return $GLOBALS[__FUNCTION__];
1651 function getUrl () {
1653 if (!isset($GLOBALS[__FUNCTION__])) {
1655 $GLOBALS[__FUNCTION__] = getConfig('URL');
1659 return $GLOBALS[__FUNCTION__];
1662 // "Getter" for cache_path
1663 function getCachePath () {
1665 if (!isset($GLOBALS[__FUNCTION__])) {
1667 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1671 return $GLOBALS[__FUNCTION__];
1674 // "Getter" for WRITE_FOOTER
1675 function getWriteFooter () {
1677 if (!isset($GLOBALS[__FUNCTION__])) {
1679 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1683 return $GLOBALS[__FUNCTION__];
1686 // "Getter" for secret_key
1687 function getSecretKey () {
1689 if (!isset($GLOBALS[__FUNCTION__])) {
1691 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1695 return $GLOBALS[__FUNCTION__];
1698 // "Getter" for SITE_KEY
1699 function getSiteKey () {
1701 if (!isset($GLOBALS[__FUNCTION__])) {
1703 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1707 return $GLOBALS[__FUNCTION__];
1710 // "Getter" for DATE_KEY
1711 function getDateKey () {
1713 if (!isset($GLOBALS[__FUNCTION__])) {
1715 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1719 return $GLOBALS[__FUNCTION__];
1722 // "Getter" for master_salt
1723 function getMasterSalt () {
1725 if (!isset($GLOBALS[__FUNCTION__])) {
1727 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1731 return $GLOBALS[__FUNCTION__];
1734 // "Getter" for prime
1735 function getPrime () {
1737 if (!isset($GLOBALS[__FUNCTION__])) {
1739 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1743 return $GLOBALS[__FUNCTION__];
1746 // "Getter" for encrypt_separator
1747 function getEncryptSeparator () {
1749 if (!isset($GLOBALS[__FUNCTION__])) {
1751 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1755 return $GLOBALS[__FUNCTION__];
1758 // "Getter" for mysql_prefix
1759 function getMysqlPrefix () {
1761 if (!isset($GLOBALS[__FUNCTION__])) {
1763 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1767 return $GLOBALS[__FUNCTION__];
1770 // "Getter" for table_type
1771 function getTableType () {
1773 if (!isset($GLOBALS[__FUNCTION__])) {
1775 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1779 return $GLOBALS[__FUNCTION__];
1782 // "Getter" for salt_length
1783 function getSaltLength () {
1785 if (!isset($GLOBALS[__FUNCTION__])) {
1787 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1791 return $GLOBALS[__FUNCTION__];
1794 // "Getter" for output_mode
1795 function getOutputMode () {
1797 if (!isset($GLOBALS[__FUNCTION__])) {
1799 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1803 return $GLOBALS[__FUNCTION__];
1806 // "Getter" for full_version
1807 function getFullVersion () {
1809 if (!isset($GLOBALS[__FUNCTION__])) {
1811 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1815 return $GLOBALS[__FUNCTION__];
1818 // "Getter" for title
1819 function getTitle () {
1821 if (!isset($GLOBALS[__FUNCTION__])) {
1823 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1827 return $GLOBALS[__FUNCTION__];
1830 // "Getter" for curr_svn_revision
1831 function getCurrentRepositoryRevision () {
1833 if (!isset($GLOBALS[__FUNCTION__])) {
1835 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1839 return $GLOBALS[__FUNCTION__];
1842 // "Getter" for server_url
1843 function getServerUrl () {
1845 if (!isset($GLOBALS[__FUNCTION__])) {
1847 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1851 return $GLOBALS[__FUNCTION__];
1854 // "Getter" for mt_word
1855 function getMtWord () {
1857 if (!isset($GLOBALS[__FUNCTION__])) {
1859 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1863 return $GLOBALS[__FUNCTION__];
1866 // "Getter" for mt_word2
1867 function getMtWord2 () {
1869 if (!isset($GLOBALS[__FUNCTION__])) {
1871 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1875 return $GLOBALS[__FUNCTION__];
1878 // "Getter" for mt_word3
1879 function getMtWord3 () {
1881 if (!isset($GLOBALS[__FUNCTION__])) {
1883 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1887 return $GLOBALS[__FUNCTION__];
1890 // "Getter" for START_TDAY
1891 function getStartTday () {
1893 if (!isset($GLOBALS[__FUNCTION__])) {
1895 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
1899 return $GLOBALS[__FUNCTION__];
1902 // "Getter" for START_YDAY
1903 function getStartYday () {
1905 if (!isset($GLOBALS[__FUNCTION__])) {
1907 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
1911 return $GLOBALS[__FUNCTION__];
1914 // "Getter" for main_title
1915 function getMainTitle () {
1917 if (!isset($GLOBALS[__FUNCTION__])) {
1919 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1923 return $GLOBALS[__FUNCTION__];
1926 // "Getter" for file_hash
1927 function getFileHash () {
1929 if (!isset($GLOBALS[__FUNCTION__])) {
1931 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1935 return $GLOBALS[__FUNCTION__];
1938 // "Getter" for pass_scramble
1939 function getPassScramble () {
1941 if (!isset($GLOBALS[__FUNCTION__])) {
1943 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1947 return $GLOBALS[__FUNCTION__];
1950 // "Getter" for ap_inactive_since
1951 function getApInactiveSince () {
1953 if (!isset($GLOBALS[__FUNCTION__])) {
1955 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1959 return $GLOBALS[__FUNCTION__];
1962 // "Getter" for user_min_confirmed
1963 function getUserMinConfirmed () {
1965 if (!isset($GLOBALS[__FUNCTION__])) {
1967 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1971 return $GLOBALS[__FUNCTION__];
1973 // "Getter" for points
1974 function getPoints () {
1976 if (!isset($GLOBALS[__FUNCTION__])) {
1978 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1982 return $GLOBALS[__FUNCTION__];
1985 // "Getter" for slogan
1986 function getSlogan () {
1988 if (!isset($GLOBALS[__FUNCTION__])) {
1990 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1994 return $GLOBALS[__FUNCTION__];
1997 // "Getter" for copy
1998 function getCopy () {
2000 if (!isset($GLOBALS[__FUNCTION__])) {
2002 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2006 return $GLOBALS[__FUNCTION__];
2009 // "Getter" for webmaster
2010 function getWebmaster () {
2012 if (!isset($GLOBALS[__FUNCTION__])) {
2014 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2018 return $GLOBALS[__FUNCTION__];
2021 // "Getter" for sql_count
2022 function getSqlCount () {
2024 if (!isset($GLOBALS[__FUNCTION__])) {
2026 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2030 return $GLOBALS[__FUNCTION__];
2033 // "Getter" for num_templates
2034 function getNumTemplates () {
2036 if (!isset($GLOBALS[__FUNCTION__])) {
2038 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2042 return $GLOBALS[__FUNCTION__];
2045 // "Getter" for dns_cache_timeout
2046 function getDnsCacheTimeout () {
2048 if (!isset($GLOBALS[__FUNCTION__])) {
2050 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2054 return $GLOBALS[__FUNCTION__];
2057 // "Getter" for menu_blur_spacer
2058 function getMenuBlurSpacer () {
2060 if (!isset($GLOBALS[__FUNCTION__])) {
2062 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2066 return $GLOBALS[__FUNCTION__];
2069 // "Getter" for points_register
2070 function getPointsRegister () {
2072 if (!isset($GLOBALS[__FUNCTION__])) {
2074 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2078 return $GLOBALS[__FUNCTION__];
2081 // "Getter" for points_ref
2082 function getPointsRef () {
2084 if (!isset($GLOBALS[__FUNCTION__])) {
2086 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2090 return $GLOBALS[__FUNCTION__];
2093 // "Getter" for ref_payout
2094 function getRefPayout () {
2096 if (!isset($GLOBALS[__FUNCTION__])) {
2098 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2102 return $GLOBALS[__FUNCTION__];
2105 // "Getter" for online_timeout
2106 function getOnlineTimeout () {
2108 if (!isset($GLOBALS[__FUNCTION__])) {
2110 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2114 return $GLOBALS[__FUNCTION__];
2117 // "Getter" for index_home
2118 function getIndexHome () {
2120 if (!isset($GLOBALS[__FUNCTION__])) {
2122 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2126 return $GLOBALS[__FUNCTION__];
2129 // "Getter" for one_day
2130 function getOneDay () {
2132 if (!isset($GLOBALS[__FUNCTION__])) {
2134 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2138 return $GLOBALS[__FUNCTION__];
2141 // "Getter" for activate_xchange
2142 function getActivateXchange () {
2144 if (!isset($GLOBALS[__FUNCTION__])) {
2146 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2150 return $GLOBALS[__FUNCTION__];
2153 // "Getter" for img_type
2154 function getImgType () {
2156 if (!isset($GLOBALS[__FUNCTION__])) {
2158 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2162 return $GLOBALS[__FUNCTION__];
2165 // "Getter" for code_length
2166 function getCodeLength () {
2168 if (!isset($GLOBALS[__FUNCTION__])) {
2170 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2174 return $GLOBALS[__FUNCTION__];
2177 // "Getter" for least_cats
2178 function getLeastCats () {
2180 if (!isset($GLOBALS[__FUNCTION__])) {
2182 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2186 return $GLOBALS[__FUNCTION__];
2189 // "Getter" for pass_len
2190 function getPassLen () {
2192 if (!isset($GLOBALS[__FUNCTION__])) {
2194 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2198 return $GLOBALS[__FUNCTION__];
2201 // "Getter" for admin_menu
2202 function getAdminMenu () {
2204 if (!isset($GLOBALS[__FUNCTION__])) {
2206 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2210 return $GLOBALS[__FUNCTION__];
2213 // "Getter" for last_month
2214 function getLastMonth () {
2216 if (!isset($GLOBALS[__FUNCTION__])) {
2218 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2222 return $GLOBALS[__FUNCTION__];
2225 // "Getter" for max_send
2226 function getMaxSend () {
2228 if (!isset($GLOBALS[__FUNCTION__])) {
2230 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2234 return $GLOBALS[__FUNCTION__];
2237 // "Getter" for mails_page
2238 function getMailsPage () {
2240 if (!isset($GLOBALS[__FUNCTION__])) {
2242 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2246 return $GLOBALS[__FUNCTION__];
2249 // "Getter" for rand_no
2250 function getRandNo () {
2252 if (!isset($GLOBALS[__FUNCTION__])) {
2254 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2258 return $GLOBALS[__FUNCTION__];
2261 // "Getter" for __DB_NAME
2262 function getDbName () {
2264 if (!isset($GLOBALS[__FUNCTION__])) {
2266 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2270 return $GLOBALS[__FUNCTION__];
2273 // "Getter" for DOMAIN
2274 function getDomain () {
2276 if (!isset($GLOBALS[__FUNCTION__])) {
2278 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2282 return $GLOBALS[__FUNCTION__];
2285 // "Getter" for proxy_username
2286 function getProxyUsername () {
2288 if (!isset($GLOBALS[__FUNCTION__])) {
2290 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2294 return $GLOBALS[__FUNCTION__];
2297 // "Getter" for proxy_password
2298 function getProxyPassword () {
2300 if (!isset($GLOBALS[__FUNCTION__])) {
2302 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2306 return $GLOBALS[__FUNCTION__];
2309 // "Getter" for proxy_host
2310 function getProxyHost () {
2312 if (!isset($GLOBALS[__FUNCTION__])) {
2314 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2318 return $GLOBALS[__FUNCTION__];
2321 // "Getter" for proxy_port
2322 function getProxyPort () {
2324 if (!isset($GLOBALS[__FUNCTION__])) {
2326 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2330 return $GLOBALS[__FUNCTION__];
2333 // "Getter" for SMTP_HOSTNAME
2334 function getSmtpHostname () {
2336 if (!isset($GLOBALS[__FUNCTION__])) {
2338 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2342 return $GLOBALS[__FUNCTION__];
2345 // "Getter" for SMTP_USER
2346 function getSmtpUser () {
2348 if (!isset($GLOBALS[__FUNCTION__])) {
2350 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2354 return $GLOBALS[__FUNCTION__];
2357 // "Getter" for SMTP_PASSWORD
2358 function getSmtpPassword () {
2360 if (!isset($GLOBALS[__FUNCTION__])) {
2362 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2366 return $GLOBALS[__FUNCTION__];
2369 // "Getter" for points_word
2370 function getPointsWord () {
2372 if (!isset($GLOBALS[__FUNCTION__])) {
2374 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2378 return $GLOBALS[__FUNCTION__];
2381 // "Getter" for profile_lock
2382 function getProfileLock () {
2384 if (!isset($GLOBALS[__FUNCTION__])) {
2386 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2390 return $GLOBALS[__FUNCTION__];
2393 // "Getter" for url_tlock
2394 function getUrlTlock () {
2396 if (!isset($GLOBALS[__FUNCTION__])) {
2398 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2402 return $GLOBALS[__FUNCTION__];
2405 // "Getter" for title_left
2406 function getTitleLeft () {
2408 if (!isset($GLOBALS[__FUNCTION__])) {
2410 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2414 return $GLOBALS[__FUNCTION__];
2417 // "Getter" for title_right
2418 function getTitleRight () {
2420 if (!isset($GLOBALS[__FUNCTION__])) {
2422 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2426 return $GLOBALS[__FUNCTION__];
2429 // "Getter" for title_middle
2430 function getTitleMiddle () {
2432 if (!isset($GLOBALS[__FUNCTION__])) {
2434 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2438 return $GLOBALS[__FUNCTION__];
2441 // Getter for 'check_double_email'
2442 function getCheckDoubleEmail () {
2443 // Is the cache entry set?
2444 if (!isset($GLOBALS[__FUNCTION__])) {
2445 // No, so determine it
2446 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2449 // Return cached entry
2450 return $GLOBALS[__FUNCTION__];
2453 // Checks whether 'check_double_email' is 'Y'
2454 function isCheckDoubleEmailEnabled () {
2455 // Is the cache entry set?
2456 if (!isset($GLOBALS[__FUNCTION__])) {
2457 // No, so determine it
2458 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2461 // Return cached entry
2462 return $GLOBALS[__FUNCTION__];
2465 // Getter for 'display_home_in_index'
2466 function getDisplayHomeInIndex () {
2467 // Is the cache entry set?
2468 if (!isset($GLOBALS[__FUNCTION__])) {
2469 // No, so determine it
2470 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2473 // Return cached entry
2474 return $GLOBALS[__FUNCTION__];
2477 // Checks whether 'display_home_in_index' is 'Y'
2478 function isDisplayHomeInIndexEnabled () {
2479 // Is the cache entry set?
2480 if (!isset($GLOBALS[__FUNCTION__])) {
2481 // No, so determine it
2482 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2485 // Return cached entry
2486 return $GLOBALS[__FUNCTION__];
2489 // Getter for 'show_points_unconfirmed'
2490 function getShowPointsUnconfirmed () {
2491 // Is the cache entry set?
2492 if (!isset($GLOBALS[__FUNCTION__])) {
2493 // No, so determine it
2494 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2497 // Return cached entry
2498 return $GLOBALS[__FUNCTION__];
2501 // Checks whether 'show_points_unconfirmed' is 'Y'
2502 function isShowPointsUnconfirmedEnabled () {
2503 // Is the cache entry set?
2504 if (!isset($GLOBALS[__FUNCTION__])) {
2505 // No, so determine it
2506 $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y');
2509 // Return cached entry
2510 return $GLOBALS[__FUNCTION__];
2513 // Getter for 'youre_here'
2514 function getYoureHere () {
2515 // Is the cache entry set?
2516 if (!isset($GLOBALS[__FUNCTION__])) {
2517 // No, so determine it
2518 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2521 // Return cached entry
2522 return $GLOBALS[__FUNCTION__];
2525 // Checks whether 'show_timings' is 'Y'
2526 function isYoureHereEnabled () {
2527 // Is the cache entry set?
2528 if (!isset($GLOBALS[__FUNCTION__])) {
2529 // No, so determine it
2530 $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y');
2533 // Return cached entry
2534 return $GLOBALS[__FUNCTION__];
2537 // Getter for 'show_timings'
2538 function getShowTimings () {
2539 // Is the cache entry set?
2540 if (!isset($GLOBALS[__FUNCTION__])) {
2541 // No, so determine it
2542 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2545 // Return cached entry
2546 return $GLOBALS[__FUNCTION__];
2549 // Checks whether 'show_timings' is 'Y'
2550 function isShowTimingsEnabled () {
2551 // Is the cache entry set?
2552 if (!isset($GLOBALS[__FUNCTION__])) {
2553 // No, so determine it
2554 $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y');
2557 // Return cached entry
2558 return $GLOBALS[__FUNCTION__];
2561 // Getter for 'ap_server_name_since'
2562 function getApServerNameSince () {
2563 // Is the cache entry set?
2564 if (!isset($GLOBALS[__FUNCTION__])) {
2565 // No, so determine it
2566 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2569 // Return cached entry
2570 return $GLOBALS[__FUNCTION__];
2573 // Getter for 'ap_server_name'
2574 function getApServerName () {
2575 // Is the cache entry set?
2576 if (!isset($GLOBALS[__FUNCTION__])) {
2577 // No, so determine it
2578 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2581 // Return cached entry
2582 return $GLOBALS[__FUNCTION__];
2585 // Getter for 'index_delay'
2586 function getIndexDelay () {
2587 // Is the cache entry set?
2588 if (!isset($GLOBALS[__FUNCTION__])) {
2589 // No, so determine it
2590 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2593 // Return cached entry
2594 return $GLOBALS[__FUNCTION__];
2597 // Checks whether 'ap_server_name' is 'Y'
2598 function isApServerNameEnabled () {
2599 // Is the cache entry set?
2600 if (!isset($GLOBALS[__FUNCTION__])) {
2601 // No, so determine it
2602 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2605 // Return cached entry
2606 return $GLOBALS[__FUNCTION__];
2609 // Getter for 'admin_menu_javascript'
2610 function getAdminMenuJavascript () {
2611 // Is the cache entry set?
2612 if (!isset($GLOBALS[__FUNCTION__])) {
2613 // No, so determine it
2614 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2617 // Return cached entry
2618 return $GLOBALS[__FUNCTION__];
2621 // Getter for 'points_remove_account'
2622 function getPointsRemoveAccount () {
2623 // Is the cache entry set?
2624 if (!isset($GLOBALS[__FUNCTION__])) {
2625 // No, so determine it
2626 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2629 // Return cached entry
2630 return $GLOBALS[__FUNCTION__];
2633 // Getter for 'css_php'
2634 function getCssPhp () {
2635 // Is the cache entry set?
2636 if (!isset($GLOBALS[__FUNCTION__])) {
2637 // No, so determine it
2638 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2641 // Return cached entry
2642 return $GLOBALS[__FUNCTION__];
2645 // Getter for 'guest_menu'
2646 function getGuestMenu () {
2647 // Is the cache entry set?
2648 if (!isset($GLOBALS[__FUNCTION__])) {
2649 // No, so determine it
2650 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2653 // Return cached entry
2654 return $GLOBALS[__FUNCTION__];
2657 // Checks if guest menu is enabled
2658 function isGuestMenuEnabled () {
2659 // Is the cache entry set?
2660 if (!isset($GLOBALS[__FUNCTION__])) {
2661 // No, so determine it
2662 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2665 // Return cached entry
2666 return $GLOBALS[__FUNCTION__];
2669 // Getter for 'member_menu'
2670 function getMemberMenu () {
2671 // Is the cache entry set?
2672 if (!isset($GLOBALS[__FUNCTION__])) {
2673 // No, so determine it
2674 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2677 // Return cached entry
2678 return $GLOBALS[__FUNCTION__];
2681 // Checks if member menu is enabled
2682 function isMemberMenuEnabled () {
2683 // Is the cache entry set?
2684 if (!isset($GLOBALS[__FUNCTION__])) {
2685 // No, so determine it
2686 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2689 // Return cached entry
2690 return $GLOBALS[__FUNCTION__];
2693 // Getter for 'word_wrap'
2694 function getWordWrap () {
2695 // Is the cache entry set?
2696 if (!isset($GLOBALS[__FUNCTION__])) {
2697 // Construct config entry name
2698 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2700 // Is a special config entry found or ext-sql_patches updated?
2701 if (isConfigEntrySet($configEntry)) {
2702 // A special config entry has been found, then use it
2703 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2704 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2705 // No special config entry found, then use it as "fall-back"
2706 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2708 // No, use default (15 characters)
2709 $GLOBALS[__FUNCTION__] = 15;
2713 // Return cached entry
2714 return $GLOBALS[__FUNCTION__];
2717 // Checks whether proxy configuration is used
2718 function isProxyUsed () {
2720 if (!isset($GLOBALS[__FUNCTION__])) {
2722 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2726 return $GLOBALS[__FUNCTION__];
2729 // Checks whether POST data contains selections
2730 function ifPostContainsSelections ($element = 'sel') {
2732 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2734 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2738 return $GLOBALS[__FUNCTION__][$element];
2741 // Checks whether verbose_sql is Y and returns true/false if so
2742 function isVerboseSqlEnabled () {
2744 if (!isset($GLOBALS[__FUNCTION__])) {
2746 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2750 return $GLOBALS[__FUNCTION__];
2753 // "Getter" for total user points
2754 function getTotalPoints ($userid) {
2756 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2757 // Init array for filter chain
2759 'userid' => $userid,
2763 // Run filter chain for getting more point values
2764 $data = runFilterChain('get_total_points', $data);
2767 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2771 return $GLOBALS[__FUNCTION__][$userid];
2774 // Wrapper to get used points for given userid
2775 function getUserUsedPoints ($userid) {
2777 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2779 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2783 return $GLOBALS[__FUNCTION__][$userid];
2786 // Wrapper to check if url_blacklist is enabled
2787 function isUrlBlacklistEnabled () {
2789 if (!isset($GLOBALS[__FUNCTION__])) {
2791 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2795 return $GLOBALS[__FUNCTION__];
2798 // Checks whether direct payment is allowed in configuration
2799 function isDirectPaymentEnabled () {
2801 if (!isset($GLOBALS[__FUNCTION__])) {
2803 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2807 return $GLOBALS[__FUNCTION__];
2810 // Checks whether JavaScript-based admin menu is enabled
2811 function isAdminMenuJavascriptEnabled () {
2813 if (!isset($GLOBALS[__FUNCTION__])) {
2815 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getAdminMenuJavaScript() == 'Y'));
2819 return $GLOBALS[__FUNCTION__];
2822 // Wrapper to check if current task is for extension (not update)
2823 function isExtensionTask ($content) {
2825 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2827 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2831 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2834 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2835 function ifTesterAccountsAllowed () {
2836 // Is the cache entry set?
2837 if (!isset($GLOBALS[__FUNCTION__])) {
2838 // No, so determine it
2839 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2842 // Return cached entry
2843 return $GLOBALS[__FUNCTION__];
2846 // Wrapper to check if output mode is CSS
2847 function isCssOutputMode () {
2849 if (!isset($GLOBALS[__FUNCTION__])) {
2851 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2852 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2856 return $GLOBALS[__FUNCTION__];
2859 // Wrapper to check if output mode is HTML
2860 function isHtmlOutputMode () {
2862 if (!isset($GLOBALS[__FUNCTION__])) {
2864 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2865 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2869 return $GLOBALS[__FUNCTION__];
2872 // Wrapper to check if output mode is RAW
2873 function isRawOutputMode () {
2875 if (!isset($GLOBALS[__FUNCTION__])) {
2877 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2878 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2882 return $GLOBALS[__FUNCTION__];
2885 // Wrapper to check if output mode is AJAX
2886 function isAjaxOutputMode () {
2888 if (!isset($GLOBALS[__FUNCTION__])) {
2890 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2891 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2895 return $GLOBALS[__FUNCTION__];
2898 // Wrapper to check if output mode is image
2899 function isImageOutputMode () {
2901 if (!isset($GLOBALS[__FUNCTION__])) {
2903 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2904 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
2908 return $GLOBALS[__FUNCTION__];
2911 // Wrapper to generate a user email link
2912 function generateWrappedUserEmailLink ($email) {
2913 // Just call the inner function
2914 return generateEmailLink($email, 'user_data');
2917 // Wrapper to check if user points are locked
2918 function ifUserPointsLocked ($userid) {
2919 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2921 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2923 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2927 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2928 return $GLOBALS[__FUNCTION__][$userid];
2931 // Appends a line to an existing file or creates it instantly with given content.
2932 // This function does always add a new-line character to every line.
2933 function appendLineToFile ($file, $line) {
2934 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2935 fwrite($fp, $line . PHP_EOL);
2939 // Wrapper for changeDataInFile() but with full path added
2940 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2942 $FQFN = getPath() . $FQFN;
2944 // Call inner function
2945 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2948 // Wrapper for changing entries in config-local.php
2949 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
2950 // Call the inner function
2951 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
2954 // Shortens ucfirst(strtolower()) calls
2955 function firstCharUpperCase ($str) {
2956 return ucfirst(strtolower($str));
2959 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2960 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2961 // Get the configuration entry
2962 $configValue = getConfig($configEntry);
2964 // Call inner method
2965 return createTimeSelections($configValue, $configEntry, $stamps, $align);
2968 // Shortens converting of German comma to Computer's version in POST data
2969 function convertCommaToDotInPostData ($postEntry) {
2970 // Read and convert given entry
2971 $postValue = convertCommaToDot(postRequestElement($postEntry));
2974 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
2976 // ... and set it again
2977 setPostRequestElement($postEntry, $postValue);
2980 // Converts German commas to Computer's version in all entries
2981 function convertCommaToDotInPostDataArray ($postEntries) {
2982 // Replace german decimal comma with computer decimal dot
2983 foreach ($postEntries as $entry) {
2984 // Is the entry there?
2985 if (isPostRequestElementSet($entry)) {
2987 convertCommaToDotInPostData($entry);
2993 * Parses a string into a US formated float variable, taken from user comments
2994 * from PHP documentation website.
2996 * @param $floatString A string holding a float expression
2997 * @return $float Corresponding float variable
2998 * @author chris<at>georgakopoulos<dot>com
2999 * @link http://de.php.net/manual/en/function.floatval.php#92563
3001 function parseFloat ($floatString){
3003 $LocaleInfo = localeconv();
3005 // Remove thousand separators
3006 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3008 // Convert decimal point
3009 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3011 // Return float value of converted string
3012 return floatval($floatString);
3016 * Searches a multi-dimensional array (as used in many places) for given
3017 * key/value pair as taken from user comments from PHP documentation website.
3019 * @param $array An array with one or more dimensions
3020 * @param $key Key to look for
3021 * @param $value Value to look for
3022 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3023 * @return $results Resulted array or empty array if $array is no array
3024 * @author sunelbe<at>gmail<dot>com
3025 * @link http://de.php.net/manual/en/function.array-search.php#110120
3027 function search_array ($array, $key, $value, $parentIndex = NULL) {
3028 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3029 // Init array result
3032 // Is $array really an array?
3033 if (is_array($array)) {
3034 // Search for whole array
3035 foreach ($array as $idx => $dummy) {
3036 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3037 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3038 // Is dummy an array?
3039 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3040 // Then search again
3041 $subResult = search_array($dummy, $key, $value, $idx);
3042 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3045 $results = merge_array($results, $subResult, TRUE);
3046 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3047 // Is found, so add it
3048 $results[$parentIndex] = $array;
3049 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3054 // Return resulting array
3055 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3059 // Generates a YES/NO option list from given default
3060 function generateYesNoOptions ($defaultValue = '') {
3062 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3065 // "Getter" for total available receivers
3066 function getTotalReceivers ($mode = 'normal') {
3068 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3074 // Wrapper "getter" to get total unconfirmed mails for given userid
3075 function getTotalUnconfirmedMails ($userid) {
3077 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3079 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3083 return $GLOBALS[__FUNCTION__][$userid];
3086 // Checks whether 'mailer_theme' was found in session
3087 function isMailerThemeSet () {
3089 if (!isset($GLOBALS[__FUNCTION__])) {
3091 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3095 return $GLOBALS[__FUNCTION__];
3099 * Setter for theme in session (This setter does return the success of
3100 * setSession() which is required e.g. for destroySponsorSession().
3102 function setMailerTheme ($newTheme) {
3103 // Set it in session
3104 return setSession('mailer_theme', $newTheme);
3108 * Getter for theme from session (This getter does return 'mailer_theme' from
3109 * session data or throws an error if not possible
3111 function getMailerTheme () {
3113 if (!isset($GLOBALS[__FUNCTION__])) {
3114 // Is 'mailer_theme' set?
3115 if (!isMailerThemeSet()) {
3116 // No, then abort here
3117 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3120 // Get it and store it in cache
3121 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3125 return $GLOBALS[__FUNCTION__];
3128 // "Getter" for last_module/last_what depending on ext-user version
3129 function getUserLastWhatName () {
3130 // Default is old one: last_module
3131 $columnName = 'last_module';
3133 // Is ext-user up-to-date?
3134 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3135 // Yes, then use new one
3136 $columnName = 'last_what';
3143 // "Getter" for all columns for given alias and separator
3144 function getAllPointColumns ($alias = NULL, $separator = ',') {
3145 // Prepare the filter array
3146 $filterData = array(
3149 'separator' => $separator
3153 $filterData = runFilterChain('get_all_point_columns', $filterData);
3155 // Return the columns
3156 return $filterData['columns'];
3159 // Checks whether the copyright footer (which breaks framesets) is enabled
3160 function ifCopyrightFooterEnabled () {
3161 // Is not unset and not 'N'?
3162 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3166 * Wrapper to check whether we have a "full page". This means that the actual
3167 * content is not delivered in any frame of a frameset.
3169 function isFullPage () {
3171 * The parameter 'frame' is generic and always indicates that this content
3172 * will be output into a frame. Furthermore, if a frameset is reported or
3173 * the copyright line is explicitly deactivated, this cannot be a "full
3176 // @TODO Find a way to not use direct module comparison
3177 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3183 // Checks whether frameset_mode is set to true
3184 function isFramesetModeEnabled () {
3186 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3189 // Function to determine correct 'what' value
3190 function determineWhat ($module = NULL) {
3191 // Init default 'what'
3195 if (is_null($module)) {
3197 $module = getModule();
3205 // Else try to get it from current module
3206 $what = getWhatFromModule($module);
3208 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3210 // Remove any spaces from variable
3211 $what = trim($what);
3215 // Default action for non-admin menus
3219 $what = secureString($what);
3226 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3227 function prependZeros ($mStretch, $length = 2) {
3228 // Return prepended string
3229 return sprintf('%0' . (int) $length . 's', $mStretch);
3232 // Wraps convertSelectionsToEpocheTime()
3233 function convertSelectionsToEpocheTimeInPostData ($id) {
3238 // Get all POST data
3239 $postData = postRequestArray();
3241 // Convert given selection id
3242 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3244 // Set the POST array back
3245 setPostRequestArray($postData);
3248 // Wraps checking if given points account type matches with given in POST data
3249 function ifPointsAccountTypeMatchesPost ($type) {
3251 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3254 // Gets given user's total referral
3255 function getUsersTotalReferrals ($userid, $level = NULL) {
3257 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3258 // Is the level NULL?
3259 if (is_null($level)) {
3260 // Get total amount (all levels)
3261 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3263 // Get it from user refs
3264 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3269 return $GLOBALS[__FUNCTION__][$userid][$level];
3272 // Gets given user's total referral
3273 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3274 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3276 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3277 // Default is all refs
3280 // Is the not level NULL?
3281 if (!is_null($level)) {
3282 // Then add referral level
3283 $add = ' AND r.`level`=' . bigintval($level);
3286 // Check for all referrals
3287 $result = SQL_QUERY_ESC("SELECT
3288 COUNT(d.`userid`) AS `cnt`
3290 `{?_MYSQL_PREFIX?}_user_data` AS d
3292 `{?_MYSQL_PREFIX?}_user_refs` AS r
3294 d.`userid`=r.`refid`
3296 d.`status` != 'CONFIRMED' AND
3304 ), __FUNCTION__, __LINE__);
3307 list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
3310 SQL_FREERESULT($result);
3314 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3315 return $GLOBALS[__FUNCTION__][$userid][$level];
3318 // Converts, if found, dollar data to get element
3319 function convertDollarDataToGetElement ($data) {
3320 // Is first char a dollar?
3321 if (substr($data, 0, 1) == chr(36)) {
3322 // Use last part for getRequestElement()
3323 $data = getRequestElement(substr($data, 1));
3330 // Wrapper function for SQL layer to speed-up things
3331 function SQL_DEBUG_ENABLED () {
3333 if (!isset($GLOBALS[__FUNCTION__])) {
3335 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3339 return $GLOBALS[__FUNCTION__];
3342 // Wrapper function to wrap call of wordwrap()
3343 function wrapWords ($text) {
3345 $wrapped = wordwrap($test, getWordWrap());
3351 // Encodes given data into a JSON object
3352 function encodeJson ($data) {
3354 return json_encode($data, JSON_FORCE_OBJECT);