2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/04/2009 *
4 * =================== Last change: 04/04/2009 *
6 * -------------------------------------------------------------------- *
7 * File : wrapper-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Wrapper functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Wrapper-Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 function readFromFile ($FQFN) {
45 // Sanity-check if file is there (should be there, but just to make it sure)
46 if (!isFileReadable($FQFN)) {
47 // This should not happen
48 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
52 if (function_exists('file_get_contents')) {
54 $fileContent = file_get_contents($FQFN);
56 // Fall-back to implode-file chain
57 $fileContent = implode('', file($FQFN));
64 // Writes content to a file
65 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
66 // Is the file writeable?
67 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
69 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable or cannot change CHMOD to 0644.", basename($FQFN)));
75 // By default all is failed...
76 $GLOBALS['file_readable'][$FQFN] = FALSE;
79 // Is the function there?
80 if (function_exists('file_put_contents')) {
82 if ($aquireLock === TRUE) {
83 // Write it directly with lock
84 $return = file_put_contents($FQFN, $content, LOCK_EX);
87 $return = file_put_contents($FQFN, $content);
90 // Write it with fopen
91 $fp = fopen($FQFN, 'w')
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 daily reset mode is active
393 function isDailyResetEnabled () {
394 // Now simply check it
395 return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
398 // Checks whether the weekly reset mode is active
399 function isWeeklyResetEnabled () {
400 // Now simply check it
401 return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
404 // Checks whether the monthly reset mode is active
405 function isMonthlyResetEnabled () {
406 // Now simply check it
407 return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
410 // Checks whether one of the reset modes is enabled
411 function isResetModeEnabled () {
412 // Now simply check it
413 return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()));
416 // Checks whether the debug mode is enabled
417 function isDebugModeEnabled () {
419 if (!isset($GLOBALS[__FUNCTION__])) {
421 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
425 return $GLOBALS[__FUNCTION__];
428 // Checks whether the debug hourly is enabled
429 function isDebugHourlyEnabled () {
431 if (!isset($GLOBALS[__FUNCTION__])) {
433 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
437 return $GLOBALS[__FUNCTION__];
440 // Checks whether the debug daily is enabled
441 function isDebugDailyEnabled () {
443 if (!isset($GLOBALS[__FUNCTION__])) {
445 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
449 return $GLOBALS[__FUNCTION__];
452 // Checks whether the debug weekly is enabled
453 function isDebugWeeklyEnabled () {
455 if (!isset($GLOBALS[__FUNCTION__])) {
457 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
461 return $GLOBALS[__FUNCTION__];
464 // Checks whether the debug monthly is enabled
465 function isDebugMonthlyEnabled () {
467 if (!isset($GLOBALS[__FUNCTION__])) {
469 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
473 return $GLOBALS[__FUNCTION__];
476 // Checks whether SQL debugging is enabled
477 function isSqlDebuggingEnabled () {
479 if (!isset($GLOBALS[__FUNCTION__])) {
480 // Determine if SQL debugging is enabled
481 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
485 return $GLOBALS[__FUNCTION__];
488 // Checks whether we shall debug regular expressions
489 function isDebugRegularExpressionEnabled () {
491 if (!isset($GLOBALS[__FUNCTION__])) {
493 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
497 return $GLOBALS[__FUNCTION__];
500 // Checks whether debugging of build mails is enabled
501 function isDebugBuildMailsEnabled () {
503 if (!isset($GLOBALS[__FUNCTION__])) {
505 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
509 return $GLOBALS[__FUNCTION__];
512 // Checks whether the cache instance is valid
513 function isCacheInstanceValid () {
515 if (!isset($GLOBALS[__FUNCTION__])) {
517 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
521 return $GLOBALS[__FUNCTION__];
524 // Copies a file from source to destination and verifies if that goes fine.
525 // This function should wrap the copy() command and make a nicer debug backtrace
526 // even if there is no xdebug extension installed.
527 function copyFileVerified ($source, $dest, $chmod = '') {
528 // Failed is the default
531 // Is the source file there?
532 if (!isFileReadable($source)) {
534 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
537 // Is the target directory there?
538 if (!isDirectory(dirname($dest))) {
540 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
543 // Now try to copy it
544 if (!copy($source, $dest)) {
545 // Something went wrong
546 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
549 $GLOBALS['file_readable'][$dest] = TRUE;
552 // All fine by default
555 // If there are chmod rights set, apply them
556 if (!empty($chmod)) {
558 $status = changeMode($dest, $chmod);
565 // Wrapper function for chmod()
566 // @TODO Do some more sanity check here
567 function changeMode ($FQFN, $mode) {
568 // Is the file/directory there?
569 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
570 // Neither, so abort here
571 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
575 return chmod($FQFN, $mode);
578 // Wrapper for unlink()
579 function removeFile ($FQFN) {
580 // Is the file there?
581 if (isFileReadable($FQFN)) {
583 $GLOBALS['file_readable'][$FQFN] = FALSE;
586 return unlink($FQFN);
589 // All fine if no file was removed. If we change this to 'false' or rewrite
590 // above if() block it would be to restrictive.
594 // Wrapper for $_POST['sel']
595 function countPostSelection ($element = 'sel') {
597 if (!isset($GLOBALS[__FUNCTION__][$element])) {
599 $GLOBALS[__FUNCTION__][$element] = '0';
602 if (isPostRequestElementSet($element)) {
603 // Return counted elements
604 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
608 // Return cached value
609 return $GLOBALS[__FUNCTION__][$element];
612 // Checks whether the config-local.php is loaded
613 function isConfigLocalLoaded () {
614 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
617 // Checks whether a nickname or userid was entered and caches the result
618 function isNicknameUsed ($userid) {
619 // Is the cache there
620 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
622 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
626 return $GLOBALS[__FUNCTION__][$userid];
629 // Getter for 'what' value
630 function getWhat ($strict = TRUE) {
635 if (isWhatSet($strict)) {
637 $what = $GLOBALS['__what'];
644 // Setter for 'what' value
645 function setWhat ($newWhat) {
646 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
647 $GLOBALS['__what'] = $newWhat;
650 // Setter for 'what' from configuration
651 function setWhatFromConfig ($configEntry) {
652 // Get 'what' from config
653 $what = getConfig($configEntry);
659 // Checks whether what is set and optionally aborts on miss
660 function isWhatSet ($strict = FALSE) {
662 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
664 // Should we abort here?
665 if (($strict === TRUE) && ($isset === FALSE)) {
667 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
674 // Getter for 'action' value
675 function getAction ($strict = TRUE) {
680 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
682 $action = $GLOBALS['__action'];
689 // Setter for 'action' value
690 function setAction ($newAction) {
691 $GLOBALS['__action'] = $newAction;
694 // Checks whether action is set and optionally aborts on miss
695 function isActionSet ($strict = FALSE) {
697 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
699 // Should we abort here?
700 if (($strict === TRUE) && ($isset === FALSE)) {
702 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
709 // Getter for 'module' value
710 function getModule ($strict = TRUE) {
715 if (isModuleSet($strict)) {
717 $module = $GLOBALS['__module'];
724 // Setter for 'module' value
725 function setModule ($newModule) {
726 // Secure it and make all modules lower-case
727 $GLOBALS['__module'] = strtolower($newModule);
730 // Wrapper to get extra module names
731 function getExtraModule () {
735 // Is 'tab/step' set?
736 if (isPostRequestElementSet('tab')) {
738 $extra = 'tab=' . postRequestElement('tab');
739 } elseif (isPostRequestElementSet('step')) {
741 $extra = 'step=' . postRequestElement('step');
742 } elseif ((isActionSet()) && (isWhatSet())) {
744 $extra = 'action=' . getAction() . ':what=' . getWhat();
751 // Checks whether module is set and optionally aborts on miss
752 function isModuleSet ($strict = FALSE) {
754 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
756 // Should we abort here?
757 if (($strict === TRUE) && ($isset === FALSE)) {
759 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
763 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
766 // Getter for 'output_mode' value
767 function getScriptOutputMode () {
769 if (!isset($GLOBALS[__FUNCTION__])) {
770 // Is the output mode set?
771 if (!isOutputModeSet()) {
772 // No, then abort here
773 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
777 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
781 return $GLOBALS[__FUNCTION__];
784 // Setter for 'output_mode' value
785 function setScriptOutputMode ($newOutputMode) {
786 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
787 $GLOBALS['__output_mode'] = (int) $newOutputMode;
790 // Checks whether output_mode is set and optionally aborts on miss
791 function isOutputModeSet ($strict = FALSE) {
793 $isset = (isset($GLOBALS['__output_mode']));
795 // Should we abort here?
796 if (($strict === TRUE) && ($isset === FALSE)) {
798 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
805 // Enables block-mode
806 function enableBlockMode ($enabled = TRUE) {
807 $GLOBALS['__block_mode'] = $enabled;
810 // Checks whether block-mode is enabled
811 function isBlockModeEnabled () {
813 if (!isset($GLOBALS['__block_mode'])) {
815 reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
819 return $GLOBALS['__block_mode'];
822 // Wrapper for redirectToUrl but URL comes from a configuration entry
823 function redirectToConfiguredUrl ($configEntry) {
825 redirectToUrl(getConfig($configEntry));
828 // Wrapper function to redirect from member-only modules to index
829 function redirectToIndexMemberOnlyModule () {
830 // Do the redirect here
831 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
834 // Wrapper function to redirect to current URL
835 function redirectToRequestUri () {
836 redirectToUrl(basename(detectRequestUri()));
839 // Wrapper function to redirect to de-refered URL
840 function redirectToDereferedUrl ($url) {
842 redirectToUrl(generateDereferrerUrl($url));
845 // Wrapper function for checking if extension is installed and newer or same version
846 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
847 // Is an cache entry found?
848 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
850 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
852 // Cache hits should be incremented twice
853 incrementStatsEntry('cache_hits', 2);
857 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
858 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
861 // Wrapper function for checking if extension is installed and older than given version
862 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
863 // Is an cache entry found?
864 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
866 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
868 // Cache hits should be incremented twice
869 incrementStatsEntry('cache_hits', 2);
873 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
874 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
878 function setUsername ($userName) {
879 $GLOBALS['username'] = (string) $userName;
883 function getUsername () {
885 if (!isset($GLOBALS['username'])) {
886 // No, so it has to be a guest
887 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
891 return $GLOBALS['username'];
894 // Wrapper function for installation phase
895 function isInstallationPhase () {
897 if (!isset($GLOBALS[__FUNCTION__])) {
899 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
903 return $GLOBALS[__FUNCTION__];
906 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
907 function isDemoModeActive () {
909 if (!isset($GLOBALS[__FUNCTION__])) {
911 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
915 return $GLOBALS[__FUNCTION__];
918 // Getter for PHP caching value
919 function getPhpCaching () {
920 return $GLOBALS['php_caching'];
923 // Checks whether the admin hash is set
924 function isAdminHashSet ($adminId) {
925 // Is the array there?
926 if (!isset($GLOBALS['cache_array']['admin'])) {
927 // Missing array should be reported
928 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
931 // Check for admin hash
932 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
935 // Setter for admin hash
936 function setAdminHash ($adminId, $hash) {
937 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
940 // Getter for current admin login
941 function getCurrentAdminLogin () {
943 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
946 if (!isset($GLOBALS[__FUNCTION__])) {
948 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
952 return $GLOBALS[__FUNCTION__];
955 // Setter for admin id (and current)
956 function setAdminId ($adminId) {
958 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
961 $status = setSession('admin_id', bigintval($adminId));
964 setCurrentAdminId($adminId);
970 // Setter for admin_last
971 function setAdminLast ($adminLast) {
973 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
976 $status = setSession('admin_last', $adminLast);
982 // Setter for admin_md5
983 function setAdminMd5 ($adminMd5) {
985 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
988 $status = setSession('admin_md5', $adminMd5);
994 // Getter for admin_md5
995 function getAdminMd5 () {
997 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1000 return getSession('admin_md5');
1003 // Init user data array
1004 function initUserData () {
1005 // User id should not be zero
1006 if (!isValidId(getCurrentUserId())) {
1007 // Should be always valid
1008 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1012 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1013 $GLOBALS['user_data'][getCurrentUserId()] = array();
1016 // Getter for user data
1017 function getUserData ($column) {
1018 // User id should not be zero
1019 if (!isValidId(getCurrentUserId())) {
1020 // Should be always valid
1021 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1027 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1029 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1036 // Checks whether given user data is set to 'Y'
1037 function isUserDataEnabled ($column) {
1039 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1041 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1045 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1048 // Geter for whole user data array
1049 function getUserDataArray () {
1051 $userid = getCurrentUserId();
1053 // Is the current userid valid?
1054 if (!isValidId($userid)) {
1055 // Should be always valid
1056 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1059 // Get the whole array if found
1060 if (isset($GLOBALS['user_data'][$userid])) {
1061 // Found, so return it
1062 return $GLOBALS['user_data'][$userid];
1064 // Return empty array
1069 // Checks if the user data is valid, this may indicate that the user has logged
1070 // in, but you should use isMember() if you want to find that out.
1071 function isUserDataValid () {
1072 // User id should not be zero so abort here
1073 if (!isCurrentUserIdSet()) {
1074 // Debug message, may be noisy
1075 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1082 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1084 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1087 // Return the result
1088 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1091 // Setter for current userid
1092 function setCurrentUserId ($userid) {
1094 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1096 // Is the cache from below functions different?
1097 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1099 unsetCurrentUserId();
1103 $GLOBALS['current_userid'] = bigintval($userid);
1105 // Unset it to re-determine the actual state
1106 unset($GLOBALS['is_userdata_valid'][$userid]);
1109 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1112 // Getter for current userid
1113 function getCurrentUserId () {
1115 if (!isset($GLOBALS[__FUNCTION__])) {
1116 // Userid must be set before it can be used
1117 if (!isCurrentUserIdSet()) {
1119 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1122 // Set userid in cache
1123 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1127 return $GLOBALS[__FUNCTION__];
1130 // Checks if current userid is set
1131 function isCurrentUserIdSet () {
1133 if (!isset($GLOBALS[__FUNCTION__])) {
1135 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1139 return $GLOBALS[__FUNCTION__];
1142 // Unsets current userid
1143 function unsetCurrentUserId () {
1145 if (isset($GLOBALS['current_userid'])) {
1147 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1150 // Unset all cache entries
1151 unset($GLOBALS['current_userid']);
1152 unset($GLOBALS['getCurrentUserId']);
1153 unset($GLOBALS['isCurrentUserIdSet']);
1156 // Checks whether we are debugging template cache
1157 function isDebugTemplateCacheEnabled () {
1159 if (!isset($GLOBALS[__FUNCTION__])) {
1161 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1165 return $GLOBALS[__FUNCTION__];
1168 // Wrapper for fetchUserData() and getUserData() calls
1169 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1170 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1172 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1176 // Can we fetch the user data?
1177 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1178 // Now get the data back
1179 $data = getUserData($valueColumn);
1183 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1187 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1188 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1191 // Wrapper for strpos() to ease porting from deprecated ereg() function
1192 function isInString ($needle, $haystack) {
1193 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1194 return (strpos($haystack, $needle) !== FALSE);
1197 // Wrapper for strpos() to ease porting from deprecated eregi() function
1198 // This function is case-insensitive
1199 function isInStringIgnoreCase ($needle, $haystack) {
1200 return (isInString(strtolower($needle), strtolower($haystack)));
1203 // Wrapper to check for if fatal errors where detected
1204 function ifFatalErrorsDetected () {
1205 // Just call the inner function
1206 return (getTotalFatalErrors() > 0);
1209 // Checks whether a HTTP status has been set
1210 function isHttpStatusSet () {
1211 // Is it set and not empty?
1212 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1215 // Setter for HTTP status
1216 function setHttpStatus ($status) {
1217 $GLOBALS['http_status'] = (string) $status;
1220 // Getter for HTTP status
1221 function getHttpStatus () {
1222 // Is the status set?
1223 if (!isHttpStatusSet()) {
1225 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1229 return $GLOBALS['http_status'];
1233 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1234 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1236 * ----------------------------------------------------------------------------
1237 * If you want to redirect, please use redirectToUrl(); instead
1238 * ----------------------------------------------------------------------------
1240 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1242 * @link http://support.microsoft.com/kb/q176113/
1243 * @author Andreas Gohr <andi@splitbrain.org>
1246 function sendRawRedirect ($url) {
1247 // Clear output buffer
1248 clearOutputBuffer();
1250 // Clear own output buffer
1251 $GLOBALS['__output'] = '';
1253 // To make redirects working (no content type), output mode must be raw
1254 setScriptOutputMode(-1);
1256 // Send helping header
1257 setHttpStatus('302 Found');
1259 // always close the session
1260 session_write_close();
1262 // Revert entity &
1263 $url = str_replace('&', '&', $url);
1265 // check if running on IIS < 6 with CGI-PHP
1266 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1267 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1268 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1269 ($matches[1] < 6)) {
1270 // Send the IIS header
1271 addHttpHeader('Refresh: 0;url=' . $url);
1273 // Send generic header
1274 addHttpHeader('Location: ' . $url);
1281 // Determines the country of the given user id
1282 function determineCountry ($userid) {
1284 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1285 // Default is 'invalid'
1286 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1288 // Is extension country active?
1289 if (isExtensionActive('country')) {
1290 // Determine the right country code through the country id
1291 $id = getUserData('country_code');
1293 // Then handle it over
1294 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1296 // Get raw code from user data
1297 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1302 return $GLOBALS[__FUNCTION__][$userid];
1305 // "Getter" for total confirmed user accounts
1306 function getTotalConfirmedUser () {
1308 if (!isset($GLOBALS[__FUNCTION__])) {
1310 if (isExtensionActive('user')) {
1311 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1313 $GLOBALS[__FUNCTION__] = 0;
1317 // Return cached value
1318 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1319 return $GLOBALS[__FUNCTION__];
1322 // "Getter" for total unconfirmed user accounts
1323 function getTotalUnconfirmedUser () {
1325 if (!isset($GLOBALS[__FUNCTION__])) {
1327 if (isExtensionActive('user')) {
1328 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1330 $GLOBALS[__FUNCTION__] = 0;
1334 // Return cached value
1335 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1336 return $GLOBALS[__FUNCTION__];
1339 // "Getter" for total locked user accounts
1340 function getTotalLockedUser () {
1342 if (!isset($GLOBALS[__FUNCTION__])) {
1344 if (isExtensionActive('user')) {
1345 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1347 $GLOBALS[__FUNCTION__] = 0;
1351 // Return cached value
1352 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1353 return $GLOBALS[__FUNCTION__];
1356 // "Getter" for total locked user accounts
1357 function getTotalRandomRefidUser () {
1359 if (!isset($GLOBALS[__FUNCTION__])) {
1361 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1362 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1364 $GLOBALS[__FUNCTION__] = 0;
1368 // Return cached value
1369 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1370 return $GLOBALS[__FUNCTION__];
1373 // Is given id number valid?
1374 function isValidId ($id) {
1376 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1379 if (!isset($GLOBALS[__FUNCTION__][$id])) {
1381 $GLOBALS[__FUNCTION__][$id] = ((!is_null($id)) && (!is_bool($id)) && (!empty($id)) && ($id != 'NULL') && ($id > 0));
1385 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1386 return $GLOBALS[__FUNCTION__][$id];
1390 function encodeEntities ($str) {
1392 $str = secureString($str, TRUE, TRUE);
1394 // Encode dollar sign as well
1395 $str = str_replace('$', '$', $str);
1401 // "Getter" for date from patch_ctime
1402 function getDateFromRepository () {
1404 if (!isset($GLOBALS[__FUNCTION__])) {
1406 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1410 return $GLOBALS[__FUNCTION__];
1413 // "Getter" for date/time from patch_ctime
1414 function getDateTimeFromRepository () {
1416 if (!isset($GLOBALS[__FUNCTION__])) {
1418 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1422 return $GLOBALS[__FUNCTION__];
1425 // Getter for current year (default)
1426 function getYear ($timestamp = NULL) {
1428 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1429 // If NULL is set, use time()
1430 if (is_null($timestamp)) {
1431 $timestamp = time();
1435 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1439 return $GLOBALS[__FUNCTION__][$timestamp];
1442 // Getter for current month (default)
1443 function getMonth ($timestamp = NULL) {
1445 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1446 // If NULL is set, use time()
1447 if (is_null($timestamp)) {
1448 // Use time() which is current timestamp
1449 $timestamp = time();
1453 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1457 return $GLOBALS[__FUNCTION__][$timestamp];
1460 // Getter for current hour (default)
1461 function getHour ($timestamp = NULL) {
1463 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1465 if (is_null($timestamp)) {
1466 $timestamp = time();
1470 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1474 return $GLOBALS[__FUNCTION__][$timestamp];
1477 // Getter for current day (default)
1478 function getDay ($timestamp = NULL) {
1480 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1482 if (is_null($timestamp)) {
1483 $timestamp = time();
1487 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1491 return $GLOBALS[__FUNCTION__][$timestamp];
1494 // Getter for current week (default)
1495 function getWeek ($timestamp = NULL) {
1497 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1499 if (is_null($timestamp)) $timestamp = time();
1502 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1506 return $GLOBALS[__FUNCTION__][$timestamp];
1509 // Getter for current short_hour (default)
1510 function getShortHour ($timestamp = NULL) {
1512 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1514 if (is_null($timestamp)) $timestamp = time();
1517 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1521 return $GLOBALS[__FUNCTION__][$timestamp];
1524 // Getter for current long_hour (default)
1525 function getLongHour ($timestamp = NULL) {
1527 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1529 if (is_null($timestamp)) $timestamp = time();
1532 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1536 return $GLOBALS[__FUNCTION__][$timestamp];
1539 // Getter for current second (default)
1540 function getSecond ($timestamp = NULL) {
1542 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1544 if (is_null($timestamp)) $timestamp = time();
1547 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1551 return $GLOBALS[__FUNCTION__][$timestamp];
1554 // Getter for current minute (default)
1555 function getMinute ($timestamp = NULL) {
1557 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1559 if (is_null($timestamp)) $timestamp = time();
1562 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1566 return $GLOBALS[__FUNCTION__][$timestamp];
1569 // Checks whether the title decoration is enabled
1570 function isTitleDecorationEnabled () {
1572 if (!isset($GLOBALS[__FUNCTION__])) {
1574 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1578 return $GLOBALS[__FUNCTION__];
1581 // Checks whether filter usage updates are enabled (expensive queries!)
1582 function isFilterUsageUpdateEnabled () {
1584 if (!isset($GLOBALS[__FUNCTION__])) {
1586 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1590 return $GLOBALS[__FUNCTION__];
1593 // Checks whether debugging of weekly resets is enabled
1594 function isWeeklyResetDebugEnabled () {
1596 if (!isset($GLOBALS[__FUNCTION__])) {
1598 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1602 return $GLOBALS[__FUNCTION__];
1605 // Checks whether debugging of monthly resets is enabled
1606 function isMonthlyResetDebugEnabled () {
1608 if (!isset($GLOBALS[__FUNCTION__])) {
1610 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1614 return $GLOBALS[__FUNCTION__];
1617 // Checks whether displaying of debug SQLs are enabled
1618 function isDisplayDebugSqlEnabled () {
1620 if (!isset($GLOBALS[__FUNCTION__])) {
1622 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getDisplayDebugSqls() == 'Y'));
1626 return $GLOBALS[__FUNCTION__];
1629 // Checks whether module title is enabled
1630 function isModuleTitleEnabled () {
1632 if (!isset($GLOBALS[__FUNCTION__])) {
1634 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1638 return $GLOBALS[__FUNCTION__];
1641 // Checks whether what title is enabled
1642 function isWhatTitleEnabled () {
1644 if (!isset($GLOBALS[__FUNCTION__])) {
1646 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1650 return $GLOBALS[__FUNCTION__];
1653 // "Getter" for internal_stats
1654 function getInternalStats () {
1656 if (!isset($GLOBALS[__FUNCTION__])) {
1658 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1662 return $GLOBALS[__FUNCTION__];
1665 // Checks whether stats are enabled
1666 function ifInternalStatsEnabled () {
1668 if (!isset($GLOBALS[__FUNCTION__])) {
1669 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1670 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1673 // Return cached value
1674 return $GLOBALS[__FUNCTION__];
1677 // Checks whether admin-notification of certain user actions is enabled
1678 function isAdminNotificationEnabled () {
1680 if (!isset($GLOBALS[__FUNCTION__])) {
1682 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (getAdminNotify() == 'Y'));
1686 return $GLOBALS[__FUNCTION__];
1689 // Checks whether random referral id selection is enabled
1690 function isRandomReferralIdEnabled () {
1692 if (!isset($GLOBALS[__FUNCTION__])) {
1694 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y'));
1698 return $GLOBALS[__FUNCTION__];
1701 // "Getter" for default language
1702 function getDefaultLanguage () {
1704 if (!isset($GLOBALS[__FUNCTION__])) {
1706 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1710 return $GLOBALS[__FUNCTION__];
1713 // "Getter" for default referral id
1714 function getDefRefid () {
1716 if (!isset($GLOBALS[__FUNCTION__])) {
1718 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1722 return $GLOBALS[__FUNCTION__];
1725 // "Getter" for path
1726 function getPath () {
1728 if (!isset($GLOBALS[__FUNCTION__])) {
1730 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1734 return $GLOBALS[__FUNCTION__];
1738 function getUrl () {
1740 if (!isset($GLOBALS[__FUNCTION__])) {
1742 $GLOBALS[__FUNCTION__] = getConfig('URL');
1746 return $GLOBALS[__FUNCTION__];
1749 // "Getter" for cache_path
1750 function getCachePath () {
1752 if (!isset($GLOBALS[__FUNCTION__])) {
1754 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1758 return $GLOBALS[__FUNCTION__];
1761 // "Getter" for WRITE_FOOTER
1762 function getWriteFooter () {
1764 if (!isset($GLOBALS[__FUNCTION__])) {
1766 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1770 return $GLOBALS[__FUNCTION__];
1773 // "Getter" for secret_key
1774 function getSecretKey () {
1776 if (!isset($GLOBALS[__FUNCTION__])) {
1778 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1782 return $GLOBALS[__FUNCTION__];
1785 // "Getter" for SITE_KEY
1786 function getSiteKey () {
1788 if (!isset($GLOBALS[__FUNCTION__])) {
1790 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1794 return $GLOBALS[__FUNCTION__];
1797 // "Getter" for DATE_KEY
1798 function getDateKey () {
1800 if (!isset($GLOBALS[__FUNCTION__])) {
1802 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1806 return $GLOBALS[__FUNCTION__];
1809 // "Getter" for master_salt
1810 function getMasterSalt () {
1812 if (!isset($GLOBALS[__FUNCTION__])) {
1814 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1818 return $GLOBALS[__FUNCTION__];
1821 // "Getter" for prime
1822 function getPrime () {
1824 if (!isset($GLOBALS[__FUNCTION__])) {
1826 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1830 return $GLOBALS[__FUNCTION__];
1833 // "Getter" for encrypt_separator
1834 function getEncryptSeparator () {
1836 if (!isset($GLOBALS[__FUNCTION__])) {
1838 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1842 return $GLOBALS[__FUNCTION__];
1845 // "Getter" for mysql_prefix
1846 function getMysqlPrefix () {
1848 if (!isset($GLOBALS[__FUNCTION__])) {
1850 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1854 return $GLOBALS[__FUNCTION__];
1857 // "Getter" for table_type
1858 function getTableType () {
1860 if (!isset($GLOBALS[__FUNCTION__])) {
1862 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1866 return $GLOBALS[__FUNCTION__];
1869 // "Getter" for salt_length
1870 function getSaltLength () {
1872 if (!isset($GLOBALS[__FUNCTION__])) {
1874 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1878 return $GLOBALS[__FUNCTION__];
1881 // "Getter" for output_mode
1882 function getOutputMode () {
1884 if (!isset($GLOBALS[__FUNCTION__])) {
1886 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1890 return $GLOBALS[__FUNCTION__];
1893 // "Getter" for full_version
1894 function getFullVersion () {
1896 if (!isset($GLOBALS[__FUNCTION__])) {
1898 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1902 return $GLOBALS[__FUNCTION__];
1905 // "Getter" for title
1906 function getTitle () {
1908 if (!isset($GLOBALS[__FUNCTION__])) {
1910 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1914 return $GLOBALS[__FUNCTION__];
1917 // "Getter" for curr_svn_revision
1918 function getCurrentRepositoryRevision () {
1920 if (!isset($GLOBALS[__FUNCTION__])) {
1922 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1926 return $GLOBALS[__FUNCTION__];
1929 // "Getter" for server_url
1930 function getServerUrl () {
1932 if (!isset($GLOBALS[__FUNCTION__])) {
1934 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1938 return $GLOBALS[__FUNCTION__];
1941 // "Getter" for mt_word
1942 function getMtWord () {
1944 if (!isset($GLOBALS[__FUNCTION__])) {
1946 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1950 return $GLOBALS[__FUNCTION__];
1953 // "Getter" for mt_word2
1954 function getMtWord2 () {
1956 if (!isset($GLOBALS[__FUNCTION__])) {
1958 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1962 return $GLOBALS[__FUNCTION__];
1965 // "Getter" for mt_word3
1966 function getMtWord3 () {
1968 if (!isset($GLOBALS[__FUNCTION__])) {
1970 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1974 return $GLOBALS[__FUNCTION__];
1977 // "Getter" for START_TDAY
1978 function getStartTday () {
1980 if (!isset($GLOBALS[__FUNCTION__])) {
1982 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
1986 return $GLOBALS[__FUNCTION__];
1989 // "Getter" for START_YDAY
1990 function getStartYday () {
1992 if (!isset($GLOBALS[__FUNCTION__])) {
1994 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
1998 return $GLOBALS[__FUNCTION__];
2001 // "Getter" for main_title
2002 function getMainTitle () {
2004 if (!isset($GLOBALS[__FUNCTION__])) {
2006 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2010 return $GLOBALS[__FUNCTION__];
2013 // "Getter" for file_hash
2014 function getFileHash () {
2016 if (!isset($GLOBALS[__FUNCTION__])) {
2018 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2022 return $GLOBALS[__FUNCTION__];
2025 // "Getter" for pass_scramble
2026 function getPassScramble () {
2028 if (!isset($GLOBALS[__FUNCTION__])) {
2030 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2034 return $GLOBALS[__FUNCTION__];
2037 // "Getter" for ap_inactive_since
2038 function getApInactiveSince () {
2040 if (!isset($GLOBALS[__FUNCTION__])) {
2042 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2046 return $GLOBALS[__FUNCTION__];
2049 // "Getter" for user_min_confirmed
2050 function getUserMinConfirmed () {
2052 if (!isset($GLOBALS[__FUNCTION__])) {
2054 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2058 return $GLOBALS[__FUNCTION__];
2060 // "Getter" for points
2061 function getPoints () {
2063 if (!isset($GLOBALS[__FUNCTION__])) {
2065 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2069 return $GLOBALS[__FUNCTION__];
2072 // "Getter" for slogan
2073 function getSlogan () {
2075 if (!isset($GLOBALS[__FUNCTION__])) {
2077 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2081 return $GLOBALS[__FUNCTION__];
2084 // "Getter" for copy
2085 function getCopy () {
2087 if (!isset($GLOBALS[__FUNCTION__])) {
2089 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2093 return $GLOBALS[__FUNCTION__];
2096 // "Getter" for webmaster
2097 function getWebmaster () {
2099 if (!isset($GLOBALS[__FUNCTION__])) {
2101 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2105 return $GLOBALS[__FUNCTION__];
2108 // "Getter" for sql_count
2109 function getSqlCount () {
2111 if (!isset($GLOBALS[__FUNCTION__])) {
2113 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2117 return $GLOBALS[__FUNCTION__];
2120 // "Getter" for num_templates
2121 function getNumTemplates () {
2123 if (!isset($GLOBALS[__FUNCTION__])) {
2125 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2129 return $GLOBALS[__FUNCTION__];
2132 // "Getter" for dns_cache_timeout
2133 function getDnsCacheTimeout () {
2135 if (!isset($GLOBALS[__FUNCTION__])) {
2137 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2141 return $GLOBALS[__FUNCTION__];
2144 // "Getter" for menu_blur_spacer
2145 function getMenuBlurSpacer () {
2147 if (!isset($GLOBALS[__FUNCTION__])) {
2149 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2153 return $GLOBALS[__FUNCTION__];
2156 // "Getter" for points_register
2157 function getPointsRegister () {
2159 if (!isset($GLOBALS[__FUNCTION__])) {
2161 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2165 return $GLOBALS[__FUNCTION__];
2168 // "Getter" for points_ref
2169 function getPointsRef () {
2171 if (!isset($GLOBALS[__FUNCTION__])) {
2173 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2177 return $GLOBALS[__FUNCTION__];
2180 // "Getter" for ref_payout
2181 function getRefPayout () {
2183 if (!isset($GLOBALS[__FUNCTION__])) {
2185 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2189 return $GLOBALS[__FUNCTION__];
2192 // "Getter" for online_timeout
2193 function getOnlineTimeout () {
2195 if (!isset($GLOBALS[__FUNCTION__])) {
2197 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2201 return $GLOBALS[__FUNCTION__];
2204 // "Getter" for index_home
2205 function getIndexHome () {
2207 if (!isset($GLOBALS[__FUNCTION__])) {
2209 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2213 return $GLOBALS[__FUNCTION__];
2216 // "Getter" for one_day
2217 function getOneDay () {
2219 if (!isset($GLOBALS[__FUNCTION__])) {
2221 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2225 return $GLOBALS[__FUNCTION__];
2228 // "Getter" for img_type
2229 function getImgType () {
2231 if (!isset($GLOBALS[__FUNCTION__])) {
2233 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2237 return $GLOBALS[__FUNCTION__];
2240 // "Getter" for code_length
2241 function getCodeLength () {
2243 if (!isset($GLOBALS[__FUNCTION__])) {
2245 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2249 return $GLOBALS[__FUNCTION__];
2252 // "Getter" for pass_len
2253 function getPassLen () {
2255 if (!isset($GLOBALS[__FUNCTION__])) {
2257 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2261 return $GLOBALS[__FUNCTION__];
2264 // "Getter" for admin_menu
2265 function getAdminMenu () {
2267 if (!isset($GLOBALS[__FUNCTION__])) {
2269 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2273 return $GLOBALS[__FUNCTION__];
2276 // "Getter" for last_hourly
2277 function getLastHourly () {
2279 if (!isset($GLOBALS[__FUNCTION__])) {
2281 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2285 return $GLOBALS[__FUNCTION__];
2288 // "Getter" for last_daily
2289 function getLastDaily () {
2291 if (!isset($GLOBALS[__FUNCTION__])) {
2293 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2297 return $GLOBALS[__FUNCTION__];
2300 // "Getter" for last_weekly
2301 function getLastWeekly () {
2303 if (!isset($GLOBALS[__FUNCTION__])) {
2305 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2309 return $GLOBALS[__FUNCTION__];
2312 // "Getter" for last_monthly
2313 function getLastMonthly () {
2315 if (!isset($GLOBALS[__FUNCTION__])) {
2317 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2321 return $GLOBALS[__FUNCTION__];
2324 // "Getter" for mails_page
2325 function getMailsPage () {
2327 if (!isset($GLOBALS[__FUNCTION__])) {
2329 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2333 return $GLOBALS[__FUNCTION__];
2336 // "Getter" for rand_no
2337 function getRandNo () {
2339 if (!isset($GLOBALS[__FUNCTION__])) {
2341 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2345 return $GLOBALS[__FUNCTION__];
2348 // "Getter" for __DB_NAME
2349 function getDbName () {
2351 if (!isset($GLOBALS[__FUNCTION__])) {
2353 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2357 return $GLOBALS[__FUNCTION__];
2360 // "Getter" for DOMAIN
2361 function getDomain () {
2363 if (!isset($GLOBALS[__FUNCTION__])) {
2365 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2369 return $GLOBALS[__FUNCTION__];
2372 // "Getter" for proxy_username
2373 function getProxyUsername () {
2375 if (!isset($GLOBALS[__FUNCTION__])) {
2377 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2381 return $GLOBALS[__FUNCTION__];
2384 // "Getter" for proxy_password
2385 function getProxyPassword () {
2387 if (!isset($GLOBALS[__FUNCTION__])) {
2389 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2393 return $GLOBALS[__FUNCTION__];
2396 // "Getter" for proxy_host
2397 function getProxyHost () {
2399 if (!isset($GLOBALS[__FUNCTION__])) {
2401 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2405 return $GLOBALS[__FUNCTION__];
2408 // "Getter" for proxy_port
2409 function getProxyPort () {
2411 if (!isset($GLOBALS[__FUNCTION__])) {
2413 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2417 return $GLOBALS[__FUNCTION__];
2420 // "Getter" for SMTP_HOSTNAME
2421 function getSmtpHostname () {
2423 if (!isset($GLOBALS[__FUNCTION__])) {
2425 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2429 return $GLOBALS[__FUNCTION__];
2432 // "Getter" for SMTP_USER
2433 function getSmtpUser () {
2435 if (!isset($GLOBALS[__FUNCTION__])) {
2437 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2441 return $GLOBALS[__FUNCTION__];
2444 // "Getter" for SMTP_PASSWORD
2445 function getSmtpPassword () {
2447 if (!isset($GLOBALS[__FUNCTION__])) {
2449 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2453 return $GLOBALS[__FUNCTION__];
2456 // "Getter" for points_word
2457 function getPointsWord () {
2459 if (!isset($GLOBALS[__FUNCTION__])) {
2461 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2465 return $GLOBALS[__FUNCTION__];
2468 // "Getter" for profile_lock
2469 function getProfileLock () {
2471 if (!isset($GLOBALS[__FUNCTION__])) {
2473 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2477 return $GLOBALS[__FUNCTION__];
2480 // "Getter" for url_tlock
2481 function getUrlTlock () {
2483 if (!isset($GLOBALS[__FUNCTION__])) {
2485 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2489 return $GLOBALS[__FUNCTION__];
2492 // "Getter" for title_left
2493 function getTitleLeft () {
2495 if (!isset($GLOBALS[__FUNCTION__])) {
2497 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2501 return $GLOBALS[__FUNCTION__];
2504 // "Getter" for title_right
2505 function getTitleRight () {
2507 if (!isset($GLOBALS[__FUNCTION__])) {
2509 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2513 return $GLOBALS[__FUNCTION__];
2516 // "Getter" for title_middle
2517 function getTitleMiddle () {
2519 if (!isset($GLOBALS[__FUNCTION__])) {
2521 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2525 return $GLOBALS[__FUNCTION__];
2528 // Getter for 'display_home_in_index'
2529 function getDisplayHomeInIndex () {
2530 // Is the cache entry set?
2531 if (!isset($GLOBALS[__FUNCTION__])) {
2532 // No, so determine it
2533 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2536 // Return cached entry
2537 return $GLOBALS[__FUNCTION__];
2540 // Checks whether 'display_home_in_index' is 'Y'
2541 function isDisplayHomeInIndexEnabled () {
2542 // Is the cache entry set?
2543 if (!isset($GLOBALS[__FUNCTION__])) {
2544 // No, so determine it
2545 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2548 // Return cached entry
2549 return $GLOBALS[__FUNCTION__];
2552 // Getter for 'show_points_unconfirmed'
2553 function getShowPointsUnconfirmed () {
2554 // Is the cache entry set?
2555 if (!isset($GLOBALS[__FUNCTION__])) {
2556 // No, so determine it
2557 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2560 // Return cached entry
2561 return $GLOBALS[__FUNCTION__];
2564 // Checks whether 'show_points_unconfirmed' is 'Y'
2565 function isShowPointsUnconfirmedEnabled () {
2566 // Is the cache entry set?
2567 if (!isset($GLOBALS[__FUNCTION__])) {
2568 // No, so determine it
2569 $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y');
2572 // Return cached entry
2573 return $GLOBALS[__FUNCTION__];
2576 // Getter for 'youre_here'
2577 function getYoureHere () {
2578 // Is the cache entry set?
2579 if (!isset($GLOBALS[__FUNCTION__])) {
2580 // No, so determine it
2581 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2584 // Return cached entry
2585 return $GLOBALS[__FUNCTION__];
2588 // Checks whether 'show_timings' is 'Y'
2589 function isYoureHereEnabled () {
2590 // Is the cache entry set?
2591 if (!isset($GLOBALS[__FUNCTION__])) {
2592 // No, so determine it
2593 $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y');
2596 // Return cached entry
2597 return $GLOBALS[__FUNCTION__];
2600 // Getter for 'show_timings'
2601 function getShowTimings () {
2602 // Is the cache entry set?
2603 if (!isset($GLOBALS[__FUNCTION__])) {
2604 // No, so determine it
2605 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2608 // Return cached entry
2609 return $GLOBALS[__FUNCTION__];
2612 // Checks whether 'show_timings' is 'Y'
2613 function isShowTimingsEnabled () {
2614 // Is the cache entry set?
2615 if (!isset($GLOBALS[__FUNCTION__])) {
2616 // No, so determine it
2617 $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y');
2620 // Return cached entry
2621 return $GLOBALS[__FUNCTION__];
2624 // Getter for 'ap_server_name_since'
2625 function getApServerNameSince () {
2626 // Is the cache entry set?
2627 if (!isset($GLOBALS[__FUNCTION__])) {
2628 // No, so determine it
2629 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2632 // Return cached entry
2633 return $GLOBALS[__FUNCTION__];
2636 // Getter for 'ap_server_name'
2637 function getApServerName () {
2638 // Is the cache entry set?
2639 if (!isset($GLOBALS[__FUNCTION__])) {
2640 // No, so determine it
2641 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2644 // Return cached entry
2645 return $GLOBALS[__FUNCTION__];
2648 // Getter for 'index_delay'
2649 function getIndexDelay () {
2650 // Is the cache entry set?
2651 if (!isset($GLOBALS[__FUNCTION__])) {
2652 // No, so determine it
2653 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2656 // Return cached entry
2657 return $GLOBALS[__FUNCTION__];
2660 // Checks whether 'ap_server_name' is 'Y'
2661 function isApServerNameEnabled () {
2662 // Is the cache entry set?
2663 if (!isset($GLOBALS[__FUNCTION__])) {
2664 // No, so determine it
2665 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2668 // Return cached entry
2669 return $GLOBALS[__FUNCTION__];
2672 // Getter for 'admin_menu_javascript'
2673 function getAdminMenuJavascript () {
2674 // Is the cache entry set?
2675 if (!isset($GLOBALS[__FUNCTION__])) {
2676 // No, so determine it
2677 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2680 // Return cached entry
2681 return $GLOBALS[__FUNCTION__];
2684 // Getter for 'points_remove_account'
2685 function getPointsRemoveAccount () {
2686 // Is the cache entry set?
2687 if (!isset($GLOBALS[__FUNCTION__])) {
2688 // No, so determine it
2689 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2692 // Return cached entry
2693 return $GLOBALS[__FUNCTION__];
2696 // Getter for 'css_php'
2697 function getCssPhp () {
2698 // Is the cache entry set?
2699 if (!isset($GLOBALS[__FUNCTION__])) {
2700 // No, so determine it
2701 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2704 // Return cached entry
2705 return $GLOBALS[__FUNCTION__];
2708 // Getter for 'guest_menu'
2709 function getGuestMenu () {
2710 // Is the cache entry set?
2711 if (!isset($GLOBALS[__FUNCTION__])) {
2712 // No, so determine it
2713 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2716 // Return cached entry
2717 return $GLOBALS[__FUNCTION__];
2720 // Checks if guest menu is enabled
2721 function isGuestMenuEnabled () {
2722 // Is the cache entry set?
2723 if (!isset($GLOBALS[__FUNCTION__])) {
2724 // No, so determine it
2725 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2728 // Return cached entry
2729 return $GLOBALS[__FUNCTION__];
2732 // Getter for 'member_menu'
2733 function getMemberMenu () {
2734 // Is the cache entry set?
2735 if (!isset($GLOBALS[__FUNCTION__])) {
2736 // No, so determine it
2737 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2740 // Return cached entry
2741 return $GLOBALS[__FUNCTION__];
2744 // Checks if member menu is enabled
2745 function isMemberMenuEnabled () {
2746 // Is the cache entry set?
2747 if (!isset($GLOBALS[__FUNCTION__])) {
2748 // No, so determine it
2749 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2752 // Return cached entry
2753 return $GLOBALS[__FUNCTION__];
2756 // Getter for 'word_wrap'
2757 function getWordWrap () {
2758 // Is the cache entry set?
2759 if (!isset($GLOBALS[__FUNCTION__])) {
2760 // Construct config entry name
2761 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2763 // Is a special config entry found or ext-sql_patches updated?
2764 if (isConfigEntrySet($configEntry)) {
2765 // A special config entry has been found, then use it
2766 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2767 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2768 // No special config entry found, then use it as "fall-back"
2769 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2771 // No, use default (15 characters)
2772 $GLOBALS[__FUNCTION__] = 15;
2776 // Return cached entry
2777 return $GLOBALS[__FUNCTION__];
2780 // Checks whether proxy configuration is used
2781 function isProxyUsed () {
2783 if (!isset($GLOBALS[__FUNCTION__])) {
2785 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2789 return $GLOBALS[__FUNCTION__];
2792 // Checks whether POST data contains selections
2793 function ifPostContainsSelections ($element = 'sel') {
2795 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2797 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2801 return $GLOBALS[__FUNCTION__][$element];
2804 // Checks whether verbose_sql is Y and returns true/false if so
2805 function isVerboseSqlEnabled () {
2807 if (!isset($GLOBALS[__FUNCTION__])) {
2809 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2813 return $GLOBALS[__FUNCTION__];
2816 // "Getter" for total user points
2817 function getTotalPoints ($userid) {
2819 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2820 // Init array for filter chain
2822 'userid' => $userid,
2826 // Run filter chain for getting more point values
2827 $data = runFilterChain('get_total_points', $data);
2830 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2834 return $GLOBALS[__FUNCTION__][$userid];
2837 // Wrapper to get used points for given userid
2838 function getUserUsedPoints ($userid) {
2840 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2842 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2846 return $GLOBALS[__FUNCTION__][$userid];
2849 // Checks whether direct payment is allowed in configuration
2850 function isDirectPaymentEnabled () {
2852 if (!isset($GLOBALS[__FUNCTION__])) {
2854 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2858 return $GLOBALS[__FUNCTION__];
2861 // Checks whether JavaScript-based admin menu is enabled
2862 function isAdminMenuJavascriptEnabled () {
2864 if (!isset($GLOBALS[__FUNCTION__])) {
2866 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getAdminMenuJavaScript() == 'Y'));
2870 return $GLOBALS[__FUNCTION__];
2873 // Wrapper to check if current task is for extension (not update)
2874 function isExtensionTask ($content) {
2876 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2878 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2882 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2885 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2886 function ifTesterAccountsAllowed () {
2887 // Is the cache entry set?
2888 if (!isset($GLOBALS[__FUNCTION__])) {
2889 // No, so determine it
2890 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2893 // Return cached entry
2894 return $GLOBALS[__FUNCTION__];
2897 // Wrapper to check if output mode is CSS
2898 function isCssOutputMode () {
2900 if (!isset($GLOBALS[__FUNCTION__])) {
2902 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2903 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2907 return $GLOBALS[__FUNCTION__];
2910 // Wrapper to check if output mode is HTML
2911 function isHtmlOutputMode () {
2913 if (!isset($GLOBALS[__FUNCTION__])) {
2915 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2916 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2920 return $GLOBALS[__FUNCTION__];
2923 // Wrapper to check if output mode is RAW
2924 function isRawOutputMode () {
2926 if (!isset($GLOBALS[__FUNCTION__])) {
2928 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2929 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2933 return $GLOBALS[__FUNCTION__];
2936 // Wrapper to check if output mode is AJAX
2937 function isAjaxOutputMode () {
2939 if (!isset($GLOBALS[__FUNCTION__])) {
2941 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2942 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2946 return $GLOBALS[__FUNCTION__];
2949 // Wrapper to check if output mode is image
2950 function isImageOutputMode () {
2952 if (!isset($GLOBALS[__FUNCTION__])) {
2954 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2955 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
2959 return $GLOBALS[__FUNCTION__];
2962 // Wrapper to generate a user email link
2963 function generateWrappedUserEmailLink ($email) {
2964 // Just call the inner function
2965 return generateEmailLink($email, 'user_data');
2968 // Wrapper to check if user points are locked
2969 function ifUserPointsLocked ($userid) {
2970 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2972 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2974 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2978 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2979 return $GLOBALS[__FUNCTION__][$userid];
2982 // Appends a line to an existing file or creates it instantly with given content.
2983 // This function does always add a new-line character to every line.
2984 function appendLineToFile ($file, $line) {
2985 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2986 fwrite($fp, $line . PHP_EOL);
2990 // Wrapper for changeDataInFile() but with full path added
2991 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2993 $FQFN = getPath() . $FQFN;
2995 // Call inner function
2996 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2999 // Wrapper for changing entries in config-local.php
3000 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3001 // Call the inner function
3002 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3005 // Shortens ucfirst(strtolower()) calls
3006 function firstCharUpperCase ($str) {
3007 return ucfirst(strtolower($str));
3010 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3011 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3012 // Get the configuration entry
3013 $configValue = getConfig($configEntry);
3015 // Call inner method
3016 return createTimeSelections($configValue, $configEntry, $stamps, $align);
3019 // Shortens converting of German comma to Computer's version in POST data
3020 function convertCommaToDotInPostData ($postEntry) {
3021 // Read and convert given entry
3022 $postValue = convertCommaToDot(postRequestElement($postEntry));
3025 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3027 // ... and set it again
3028 setPostRequestElement($postEntry, $postValue);
3031 // Converts German commas to Computer's version in all entries
3032 function convertCommaToDotInPostDataArray ($postEntries) {
3033 // Replace german decimal comma with computer decimal dot
3034 foreach ($postEntries as $entry) {
3035 // Is the entry there?
3036 if (isPostRequestElementSet($entry)) {
3038 convertCommaToDotInPostData($entry);
3044 * Parses a string into a US formated float variable, taken from user comments
3045 * from PHP documentation website.
3047 * @param $floatString A string holding a float expression
3048 * @return $float Corresponding float variable
3049 * @author chris<at>georgakopoulos<dot>com
3050 * @link http://de.php.net/manual/en/function.floatval.php#92563
3052 function parseFloat ($floatString){
3054 $LocaleInfo = localeconv();
3056 // Remove thousand separators
3057 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3059 // Convert decimal point
3060 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3062 // Return float value of converted string
3063 return floatval($floatString);
3067 * Searches a multi-dimensional array (as used in many places) for given
3068 * key/value pair as taken from user comments from PHP documentation website.
3070 * @param $array An array with one or more dimensions
3071 * @param $key Key to look for
3072 * @param $value Value to look for
3073 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3074 * @return $results Resulted array or empty array if $array is no array
3075 * @author sunelbe<at>gmail<dot>com
3076 * @link http://de.php.net/manual/en/function.array-search.php#110120
3078 function search_array ($array, $key, $value, $parentIndex = NULL) {
3079 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3080 // Init array result
3083 // Is $array really an array?
3084 if (is_array($array)) {
3085 // Search for whole array
3086 foreach ($array as $idx => $dummy) {
3087 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3088 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3089 // Is dummy an array?
3090 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3091 // Then search again
3092 $subResult = search_array($dummy, $key, $value, $idx);
3093 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3096 $results = merge_array($results, $subResult, TRUE);
3097 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3098 // Is found, so add it
3099 $results[$parentIndex] = $array;
3100 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3105 // Return resulting array
3106 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3110 // Generates a YES/NO option list from given default
3111 function generateYesNoOptions ($defaultValue = '') {
3113 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3116 // "Getter" for total available receivers
3117 function getTotalReceivers ($mode = 'normal') {
3119 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3125 // Wrapper "getter" to get total unconfirmed mails for given userid
3126 function getTotalUnconfirmedMails ($userid) {
3128 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3130 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3134 return $GLOBALS[__FUNCTION__][$userid];
3137 // Checks whether 'mailer_theme' was found in session
3138 function isMailerThemeSet () {
3140 if (!isset($GLOBALS[__FUNCTION__])) {
3142 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3146 return $GLOBALS[__FUNCTION__];
3150 * Setter for theme in session (This setter does return the success of
3151 * setSession() which is required e.g. for destroySponsorSession().
3153 function setMailerTheme ($newTheme) {
3154 // Set it in session
3155 return setSession('mailer_theme', $newTheme);
3159 * Getter for theme from session (This getter does return 'mailer_theme' from
3160 * session data or throws an error if not possible
3162 function getMailerTheme () {
3164 if (!isset($GLOBALS[__FUNCTION__])) {
3165 // Is 'mailer_theme' set?
3166 if (!isMailerThemeSet()) {
3167 // No, then abort here
3168 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3171 // Get it and store it in cache
3172 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3176 return $GLOBALS[__FUNCTION__];
3179 // "Getter" for last_module/last_what depending on ext-user version
3180 function getUserLastWhatName () {
3181 // Default is old one: last_module
3182 $columnName = 'last_module';
3184 // Is ext-user up-to-date?
3185 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3186 // Yes, then use new one
3187 $columnName = 'last_what';
3194 // "Getter" for all columns for given alias and separator
3195 function getAllPointColumns ($alias = NULL, $separator = ',') {
3196 // Prepare the filter array
3197 $filterData = array(
3200 'separator' => $separator
3204 $filterData = runFilterChain('get_all_point_columns', $filterData);
3206 // Return the columns
3207 return $filterData['columns'];
3210 // Checks whether the copyright footer (which breaks framesets) is enabled
3211 function ifCopyrightFooterEnabled () {
3212 // Is not unset and not 'N'?
3213 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3217 * Wrapper to check whether we have a "full page". This means that the actual
3218 * content is not delivered in any frame of a frameset.
3220 function isFullPage () {
3222 * The parameter 'frame' is generic and always indicates that this content
3223 * will be output into a frame. Furthermore, if a frameset is reported or
3224 * the copyright line is explicitly deactivated, this cannot be a "full
3227 // @TODO Find a way to not use direct module comparison
3228 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3234 // Checks whether frameset_mode is set to true
3235 function isFramesetModeEnabled () {
3237 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3240 // Function to determine correct 'what' value
3241 function determineWhat ($module = NULL) {
3242 // Init default 'what'
3246 if (is_null($module)) {
3248 $module = getModule();
3256 // Else try to get it from current module
3257 $what = getWhatFromModule($module);
3259 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3261 // Remove any spaces from variable
3262 $what = trim($what);
3266 // Default action for non-admin menus
3270 $what = secureString($what);
3277 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3278 function prependZeros ($str, $length = 2) {
3279 // Return prepended string
3280 return sprintf('%0' . (int) $length . 's', $str);
3283 // Wraps convertSelectionsToEpocheTime()
3284 function convertSelectionsToEpocheTimeInPostData ($id) {
3289 // Get all POST data
3290 $postData = postRequestArray();
3292 // Convert given selection id
3293 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3295 // Set the POST array back
3296 setPostRequestArray($postData);
3299 // Wraps checking if given points account type matches with given in POST data
3300 function ifPointsAccountTypeMatchesPost ($type) {
3302 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3305 // Gets given user's total referral
3306 function getUsersTotalReferrals ($userid, $level = NULL) {
3308 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3309 // Is the level NULL?
3310 if (is_null($level)) {
3311 // Get total amount (all levels)
3312 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3314 // Get it from user refs
3315 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3320 return $GLOBALS[__FUNCTION__][$userid][$level];
3323 // Gets given user's total referral
3324 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3325 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3327 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3328 // Default is all refs
3331 // Is the not level NULL?
3332 if (!is_null($level)) {
3333 // Then add referral level
3334 $add = ' AND `r`.`level`=' . bigintval($level);
3337 // Check for all referrals
3338 $result = SQL_QUERY_ESC("SELECT
3339 COUNT(`d`.`userid`) AS `cnt`
3341 `{?_MYSQL_PREFIX?}_user_data` AS `d`
3343 `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3345 `d`.`userid`=`r`.`refid`
3347 `d`.`status` != 'CONFIRMED' AND
3355 ), __FUNCTION__, __LINE__);
3358 list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
3361 SQL_FREERESULT($result);
3365 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3366 return $GLOBALS[__FUNCTION__][$userid][$level];
3369 // Converts, if found, dollar data to get element
3370 function convertDollarDataToGetElement ($data) {
3371 // Is first char a dollar?
3372 if (substr($data, 0, 1) == chr(36)) {
3373 // Use last part for getRequestElement()
3374 $data = getRequestElement(substr($data, 1));
3381 // Wrapper function for SQL layer to speed-up things
3382 function SQL_DEBUG_ENABLED () {
3384 if (!isset($GLOBALS[__FUNCTION__])) {
3386 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3390 return $GLOBALS[__FUNCTION__];
3393 // Wrapper function to wrap call of wordwrap()
3394 function wrapWords ($text) {
3396 $wrapped = wordwrap($test, getWordWrap());
3402 // Encodes given data into a JSON object
3403 function encodeJson ($data) {
3405 return json_encode($data, JSON_FORCE_OBJECT);
3408 // Get all extension files
3409 function loadAllExtensionsByTemplate () {
3411 $extensions = getArrayFromDirectory(
3412 'templates/' . getLanguage() . '/html/ext/',
3426 // Wrapper function to allow full float values as supported by current database layout
3427 function translateFullComma ($dotted) {
3428 // Call inner function
3429 return translateComma($dotted, TRUE, 5);
3432 // Wrapper to check if the first element to be shifted is set to given value
3433 function shift_array (&$array, $value, $key = '0') {
3434 // Is the element set and value matches?
3435 assert(is_array($array));
3436 assert(isset($array[$key]));
3437 assert($array[$key] === $value);
3440 array_shift($array);
3443 // Wrapper for str_pad() with left padding zeros
3444 function padLeftZero ($str, $amount = 2) {
3445 // Is str_pad() there?
3446 if (function_exists('str_pad')) {
3447 // Use prependZeros()
3448 return prependZeros($str, $amount);
3451 return str_pad($str, $amount, '0', STR_PAD_LEFT);