2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/04/2009 *
4 * =================== Last change: 04/04/2009 *
6 * -------------------------------------------------------------------- *
7 * File : wrapper-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Wrapper functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Wrapper-Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 function readFromFile ($FQFN) {
45 // Sanity-check if file is there (should be there, but just to make it sure)
46 if (!isFileReadable($FQFN)) {
47 // This should not happen
48 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
52 if (function_exists('file_get_contents')) {
54 $fileContent = file_get_contents($FQFN);
56 // Fall-back to implode-file chain
57 $fileContent = implode('', file($FQFN));
64 // Writes content to a file
65 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
66 // Is the file writeable?
67 if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
69 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable or cannot change CHMOD to 0644.", basename($FQFN)));
75 // By default all is failed...
76 $GLOBALS['file_readable'][$FQFN] = FALSE;
79 // Is the function there?
80 if (function_exists('file_put_contents')) {
82 if ($aquireLock === TRUE) {
83 // Write it directly with lock
84 $return = file_put_contents($FQFN, $content, LOCK_EX);
87 $return = file_put_contents($FQFN, $content);
90 // Write it with fopen
91 $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
94 if ($aquireLock === TRUE) {
100 $return = fwrite($fp, $content);
106 // Was something written?
107 if ($return !== FALSE) {
108 // Mark it as readable
109 $GLOBALS['file_readable'][$FQFN] = TRUE;
113 return (($return !== FALSE) && (changeMode($FQFN, 0644)));
116 // Clears the output buffer. This function does *NOT* backup sent content.
117 function clearOutputBuffer () {
118 // Make sure this function is not called twice (no double-cleaning!)
119 if (isset($GLOBALS[__FUNCTION__])) {
120 // This function is called twice
121 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
122 } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
124 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
127 // Mark this function as called
128 $GLOBALS[__FUNCTION__] = TRUE;
132 function encodeString ($str) {
133 $str = urlencode(base64_encode(compileUriCode($str)));
137 // Decode strings encoded with encodeString()
138 function decodeString ($str) {
139 $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
143 // Decode entities in a nicer way
144 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
145 // Decode the entities to UTF-8 now
146 $decodedString = html_entity_decode($str, $quote, 'UTF-8');
148 // Return decoded string
149 return $decodedString;
152 // Merges an array together but only if both are arrays
153 function merge_array ($array1, $array2, $keepIndex = FALSE) {
154 // Are both an array?
155 if ((!is_array($array1)) && (!is_array($array2))) {
156 // Both are not arrays
157 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
158 } elseif (!is_array($array1)) {
159 // Left one is not an array
160 reportBug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
161 } elseif (!is_array($array2)) {
162 // Right one is not an array
163 reportBug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
166 // Maintain index of array2?
167 if ($keepIndex === TRUE) {
168 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
169 foreach ($array2 as $key => $value) {
171 $array1[$key] = $value;
177 // Merge both together normally
178 return array_merge($array1, $array2);
182 // Check if given FQFN is a readable file
183 function isFileReadable ($FQFN) {
185 if (!isset($GLOBALS['file_readable'][$FQFN])) {
187 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
191 return $GLOBALS['file_readable'][$FQFN];
194 // Checks whether the given FQFN is a directory and not ., .. or .svn
195 function isDirectory ($FQFN) {
197 if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
199 $baseName = basename($FQFN);
202 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
206 return $GLOBALS[__FUNCTION__][$FQFN];
209 // "Getter" for the real remote IP number
210 function detectRealIpAddress ($alwaysReal = FALSE) {
211 // Get remote ip from environment
212 $remoteAddr = determineRealRemoteAddress();
214 // Is removeip installed?
215 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
217 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
224 // "Getter" for remote IP number
225 function detectRemoteAddr ($alwaysReal = FALSE) {
226 // Get remote ip from environment
227 $remoteAddr = determineRealRemoteAddress(TRUE);
229 // Is removeip installed?
230 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
232 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
239 // "Getter" for remote hostname
240 function detectRemoteHostname ($alwaysReal = FALSE) {
241 // Get remote ip from environment
242 $remoteHost = getenv('REMOTE_HOST');
244 // Is removeip installed?
245 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
247 $remoteHost = getAnonymousRemoteHost($remoteHost);
254 // "Getter" for user agent
255 function detectUserAgent ($alwaysReal = FALSE) {
256 // Get remote ip from environment
257 $userAgent = getenv('HTTP_USER_AGENT');
259 // Is removeip installed?
260 if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
262 $userAgent = getAnonymousUserAgent($userAgent);
269 // "Getter" for referer
270 function detectReferer ($alwaysReal = FALSE) {
271 // Get remote ip from environment
272 $referer = getenv('HTTP_REFERER');
274 // Is removeip installed?
275 if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
277 $referer = getAnonymousReferer($referer);
284 // "Getter" for request URI
285 function detectRequestUri () {
287 return (getenv('REQUEST_URI'));
290 // "Getter" for query string
291 function detectQueryString () {
292 return str_replace('&', '&', (getenv('QUERY_STRING')));
295 // "Getter" for SERVER_NAME
296 function detectServerName () {
298 return (getenv('SERVER_NAME'));
301 // Removes any existing www. from SERVER_NAME. This is very silly but enough
302 // for our purpose here.
303 function detectDomainName () {
305 if (!isset($GLOBALS[__FUNCTION__])) {
307 $domainName = detectServerName();
309 // Is there any www. ?
310 if (substr($domainName, 0, 4) == 'www.') {
312 $domainName = substr($domainName, 4);
316 $GLOBALS[__FUNCTION__] = $domainName;
320 return $GLOBALS[__FUNCTION__];
323 // Check whether we are installing
324 function isInstalling () {
325 // Determine whether we are installing
326 if (!isset($GLOBALS['__mailer_installing'])) {
327 // Check URL (css.php/js.php need this)
328 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
332 return $GLOBALS['__mailer_installing'];
335 // Check whether this script is installed
336 function isInstalled () {
338 if (!isset($GLOBALS[__FUNCTION__])) {
339 // Determine whether this script is installed
340 $GLOBALS[__FUNCTION__] = (
345 isConfigEntrySet('MAILER_INSTALLED')
347 getConfig('MAILER_INSTALLED') == 'Y'
351 // New config file found and loaded
352 isIncludeReadable(getCachePath() . 'config-local.php')
355 // New config file found, but not yet read
356 isIncludeReadable(getCachePath() . 'config-local.php')
359 // Only new config file is found
360 !isIncludeReadable('inc/config.php')
362 // Is installation mode
369 // Then use the cache
370 return $GLOBALS[__FUNCTION__];
373 // Check whether an admin is registered
374 function isAdminRegistered () {
376 if (!isset($GLOBALS[__FUNCTION__])) {
378 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
382 return $GLOBALS[__FUNCTION__];
385 // Checks whether the hourly reset mode is active
386 function isHourlyResetEnabled () {
387 // Now simply check it
388 return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
391 // Checks whether the daily reset mode is active
392 function isDailyResetEnabled () {
393 // Now simply check it
394 return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
397 // Checks whether the weekly reset mode is active
398 function isWeeklyResetEnabled () {
399 // Now simply check it
400 return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
403 // Checks whether the monthly reset mode is active
404 function isMonthlyResetEnabled () {
405 // Now simply check it
406 return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
409 // Checks whether one of the reset modes is enabled
410 function isResetModeEnabled () {
411 // Now simply check it
412 return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()));
415 // Checks whether the debug mode is enabled
416 function isDebugModeEnabled () {
418 if (!isset($GLOBALS[__FUNCTION__])) {
420 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
424 return $GLOBALS[__FUNCTION__];
427 // Checks whether the debug hourly is enabled
428 function isDebugHourlyEnabled () {
430 if (!isset($GLOBALS[__FUNCTION__])) {
432 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
436 return $GLOBALS[__FUNCTION__];
439 // Checks whether the debug daily is enabled
440 function isDebugDailyEnabled () {
442 if (!isset($GLOBALS[__FUNCTION__])) {
444 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
448 return $GLOBALS[__FUNCTION__];
451 // Checks whether the debug weekly is enabled
452 function isDebugWeeklyEnabled () {
454 if (!isset($GLOBALS[__FUNCTION__])) {
456 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
460 return $GLOBALS[__FUNCTION__];
463 // Checks whether the debug monthly is enabled
464 function isDebugMonthlyEnabled () {
466 if (!isset($GLOBALS[__FUNCTION__])) {
468 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
472 return $GLOBALS[__FUNCTION__];
475 // Checks whether SQL debugging is enabled
476 function isSqlDebuggingEnabled () {
478 if (!isset($GLOBALS[__FUNCTION__])) {
479 // Determine if SQL debugging is enabled
480 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
484 return $GLOBALS[__FUNCTION__];
487 // Checks whether we shall debug regular expressions
488 function isDebugRegularExpressionEnabled () {
490 if (!isset($GLOBALS[__FUNCTION__])) {
492 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
496 return $GLOBALS[__FUNCTION__];
499 // Checks whether debugging of build mails is enabled
500 function isDebugBuildMailsEnabled () {
502 if (!isset($GLOBALS[__FUNCTION__])) {
504 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
508 return $GLOBALS[__FUNCTION__];
511 // Checks whether the cache instance is valid
512 function isCacheInstanceValid () {
514 if (!isset($GLOBALS[__FUNCTION__])) {
516 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
520 return $GLOBALS[__FUNCTION__];
523 // Copies a file from source to destination and verifies if that goes fine.
524 // This function should wrap the copy() command and make a nicer debug backtrace
525 // even if there is no xdebug extension installed.
526 function copyFileVerified ($source, $dest, $chmod = '') {
527 // Failed is the default
530 // Is the source file there?
531 if (!isFileReadable($source)) {
533 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
536 // Is the target directory there?
537 if (!isDirectory(dirname($dest))) {
539 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
542 // Now try to copy it
543 if (!copy($source, $dest)) {
544 // Something went wrong
545 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
548 $GLOBALS['file_readable'][$dest] = TRUE;
551 // All fine by default
554 // If there are chmod rights set, apply them
555 if (!empty($chmod)) {
557 $status = changeMode($dest, $chmod);
564 // Wrapper function for chmod()
565 // @TODO Do some more sanity check here
566 function changeMode ($FQFN, $mode) {
567 // Is the file/directory there?
568 if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
569 // Neither, so abort here
570 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
574 return chmod($FQFN, $mode);
577 // Wrapper for unlink()
578 function removeFile ($FQFN) {
579 // Is the file there?
580 if (isFileReadable($FQFN)) {
582 $GLOBALS['file_readable'][$FQFN] = FALSE;
585 return unlink($FQFN);
588 // All fine if no file was removed. If we change this to 'false' or rewrite
589 // above if() block it would be to restrictive.
593 // Wrapper for $_POST['sel']
594 function countPostSelection ($element = 'sel') {
596 if (!isset($GLOBALS[__FUNCTION__][$element])) {
598 $GLOBALS[__FUNCTION__][$element] = '0';
601 if (isPostRequestElementSet($element)) {
602 // Return counted elements
603 $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
607 // Return cached value
608 return $GLOBALS[__FUNCTION__][$element];
611 // Checks whether the config-local.php is loaded
612 function isConfigLocalLoaded () {
613 return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
616 // Checks whether a nickname or userid was entered and caches the result
617 function isNicknameUsed ($userid) {
618 // Is the cache there
619 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
621 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
625 return $GLOBALS[__FUNCTION__][$userid];
628 // Getter for 'what' value
629 function getWhat ($strict = TRUE) {
634 if (isWhatSet($strict)) {
636 $what = $GLOBALS['__what'];
643 // Setter for 'what' value
644 function setWhat ($newWhat) {
645 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
646 $GLOBALS['__what'] = $newWhat;
649 // Setter for 'what' from configuration
650 function setWhatFromConfig ($configEntry) {
651 // Get 'what' from config
652 $what = getConfig($configEntry);
658 // Checks whether what is set and optionally aborts on miss
659 function isWhatSet ($strict = FALSE) {
661 $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
663 // Should we abort here?
664 if (($strict === TRUE) && ($isset === FALSE)) {
666 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
673 // Getter for 'action' value
674 function getAction ($strict = TRUE) {
679 if (isActionSet(($strict) && (isHtmlOutputMode()))) {
681 $action = $GLOBALS['__action'];
688 // Setter for 'action' value
689 function setAction ($newAction) {
690 $GLOBALS['__action'] = $newAction;
693 // Checks whether action is set and optionally aborts on miss
694 function isActionSet ($strict = FALSE) {
696 $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
698 // Should we abort here?
699 if (($strict === TRUE) && ($isset === FALSE)) {
701 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
708 // Getter for 'module' value
709 function getModule ($strict = TRUE) {
714 if (isModuleSet($strict)) {
716 $module = $GLOBALS['__module'];
723 // Setter for 'module' value
724 function setModule ($newModule) {
725 // Secure it and make all modules lower-case
726 $GLOBALS['__module'] = strtolower($newModule);
729 // Wrapper to get extra module names
730 function getExtraModule () {
734 // Is 'tab/step' set?
735 if (isPostRequestElementSet('tab')) {
737 $extra = 'tab=' . postRequestElement('tab');
738 } elseif (isPostRequestElementSet('step')) {
740 $extra = 'step=' . postRequestElement('step');
741 } elseif ((isActionSet()) && (isWhatSet())) {
743 $extra = 'action=' . getAction() . ':what=' . getWhat();
750 // Checks whether module is set and optionally aborts on miss
751 function isModuleSet ($strict = FALSE) {
753 $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
755 // Should we abort here?
756 if (($strict === TRUE) && ($isset === FALSE)) {
758 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
762 return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
765 // Getter for 'output_mode' value
766 function getScriptOutputMode () {
768 if (!isset($GLOBALS[__FUNCTION__])) {
769 // Is the output mode set?
770 if (!isOutputModeSet()) {
771 // No, then abort here
772 reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
776 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
780 return $GLOBALS[__FUNCTION__];
783 // Setter for 'output_mode' value
784 function setScriptOutputMode ($newOutputMode) {
785 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
786 $GLOBALS['__output_mode'] = (int) $newOutputMode;
789 // Checks whether output_mode is set and optionally aborts on miss
790 function isOutputModeSet ($strict = FALSE) {
792 $isset = (isset($GLOBALS['__output_mode']));
794 // Should we abort here?
795 if (($strict === TRUE) && ($isset === FALSE)) {
797 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
804 // Enables block-mode
805 function enableBlockMode ($enabled = TRUE) {
806 $GLOBALS['__block_mode'] = $enabled;
809 // Checks whether block-mode is enabled
810 function isBlockModeEnabled () {
812 if (!isset($GLOBALS['__block_mode'])) {
814 reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
818 return $GLOBALS['__block_mode'];
821 // Wrapper for redirectToUrl but URL comes from a configuration entry
822 function redirectToConfiguredUrl ($configEntry) {
824 redirectToUrl(getConfig($configEntry));
827 // Wrapper function to redirect from member-only modules to index
828 function redirectToIndexMemberOnlyModule () {
829 // Do the redirect here
830 redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
833 // Wrapper function to redirect to current URL
834 function redirectToRequestUri () {
835 redirectToUrl(basename(detectRequestUri()));
838 // Wrapper function to redirect to de-refered URL
839 function redirectToDereferedUrl ($url) {
841 redirectToUrl(generateDereferrerUrl($url));
844 // Wrapper function for checking if extension is installed and newer or same version
845 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
846 // Is an cache entry found?
847 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
849 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
851 // Cache hits should be incremented twice
852 incrementStatsEntry('cache_hits', 2);
856 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
857 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
860 // Wrapper function for checking if extension is installed and older than given version
861 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
862 // Is an cache entry found?
863 if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
865 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
867 // Cache hits should be incremented twice
868 incrementStatsEntry('cache_hits', 2);
872 //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
873 return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
877 function setUsername ($userName) {
878 $GLOBALS['username'] = (string) $userName;
882 function getUsername () {
884 if (!isset($GLOBALS['username'])) {
885 // No, so it has to be a guest
886 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
890 return $GLOBALS['username'];
893 // Wrapper function for installation phase
894 function isInstallationPhase () {
896 if (!isset($GLOBALS[__FUNCTION__])) {
898 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
902 return $GLOBALS[__FUNCTION__];
905 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
906 function isDemoModeActive () {
908 if (!isset($GLOBALS[__FUNCTION__])) {
910 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
914 return $GLOBALS[__FUNCTION__];
917 // Getter for PHP caching value
918 function getPhpCaching () {
919 return $GLOBALS['php_caching'];
922 // Checks whether the admin hash is set
923 function isAdminHashSet ($adminId) {
924 // Is the array there?
925 if (!isset($GLOBALS['cache_array']['admin'])) {
926 // Missing array should be reported
927 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
930 // Check for admin hash
931 return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
934 // Setter for admin hash
935 function setAdminHash ($adminId, $hash) {
936 $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
939 // Getter for current admin login
940 function getCurrentAdminLogin () {
942 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
945 if (!isset($GLOBALS[__FUNCTION__])) {
947 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
951 return $GLOBALS[__FUNCTION__];
954 // Setter for admin id (and current)
955 function setAdminId ($adminId) {
957 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
960 $status = setSession('admin_id', bigintval($adminId));
963 setCurrentAdminId($adminId);
969 // Setter for admin_last
970 function setAdminLast ($adminLast) {
972 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
975 $status = setSession('admin_last', $adminLast);
981 // Setter for admin_md5
982 function setAdminMd5 ($adminMd5) {
984 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
987 $status = setSession('admin_md5', $adminMd5);
993 // Getter for admin_md5
994 function getAdminMd5 () {
996 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
999 return getSession('admin_md5');
1002 // Init user data array
1003 function initUserData () {
1004 // User id should not be zero
1005 if (!isValidId(getCurrentUserId())) {
1006 // Should be always valid
1007 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1011 unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1012 $GLOBALS['user_data'][getCurrentUserId()] = array();
1015 // Getter for user data
1016 function getUserData ($column) {
1017 // User id should not be zero
1018 if (!isValidId(getCurrentUserId())) {
1019 // Should be always valid
1020 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1026 if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1028 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1035 // Checks whether given user data is set to 'Y'
1036 function isUserDataEnabled ($column) {
1038 if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1040 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1044 return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1047 // Geter for whole user data array
1048 function getUserDataArray () {
1050 $userid = getCurrentUserId();
1052 // Is the current userid valid?
1053 if (!isValidId($userid)) {
1054 // Should be always valid
1055 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1058 // Get the whole array if found
1059 if (isset($GLOBALS['user_data'][$userid])) {
1060 // Found, so return it
1061 return $GLOBALS['user_data'][$userid];
1063 // Return empty array
1068 // Checks if the user data is valid, this may indicate that the user has logged
1069 // in, but you should use isMember() if you want to find that out.
1070 function isUserDataValid () {
1071 // User id should not be zero so abort here
1072 if (!isCurrentUserIdSet()) {
1073 // Debug message, may be noisy
1074 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1081 if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1083 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1086 // Return the result
1087 return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1090 // Setter for current userid
1091 function setCurrentUserId ($userid) {
1093 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1095 // Is the cache from below functions different?
1096 if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1098 unsetCurrentUserId();
1102 $GLOBALS['current_userid'] = bigintval($userid);
1104 // Unset it to re-determine the actual state
1105 unset($GLOBALS['is_userdata_valid'][$userid]);
1108 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1111 // Getter for current userid
1112 function getCurrentUserId () {
1114 if (!isset($GLOBALS[__FUNCTION__])) {
1115 // Userid must be set before it can be used
1116 if (!isCurrentUserIdSet()) {
1118 reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1121 // Set userid in cache
1122 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1126 return $GLOBALS[__FUNCTION__];
1129 // Checks if current userid is set
1130 function isCurrentUserIdSet () {
1132 if (!isset($GLOBALS[__FUNCTION__])) {
1134 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1138 return $GLOBALS[__FUNCTION__];
1141 // Unsets current userid
1142 function unsetCurrentUserId () {
1144 if (isset($GLOBALS['current_userid'])) {
1146 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1149 // Unset all cache entries
1150 unset($GLOBALS['current_userid']);
1151 unset($GLOBALS['getCurrentUserId']);
1152 unset($GLOBALS['isCurrentUserIdSet']);
1155 // Checks whether we are debugging template cache
1156 function isDebugTemplateCacheEnabled () {
1158 if (!isset($GLOBALS[__FUNCTION__])) {
1160 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1164 return $GLOBALS[__FUNCTION__];
1167 // Wrapper for fetchUserData() and getUserData() calls
1168 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1169 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1171 if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1175 // Can we fetch the user data?
1176 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1177 // Now get the data back
1178 $data = getUserData($valueColumn);
1182 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1186 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1187 return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1190 // Wrapper for strpos() to ease porting from deprecated ereg() function
1191 function isInString ($needle, $haystack) {
1192 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1193 return (strpos($haystack, $needle) !== FALSE);
1196 // Wrapper for strpos() to ease porting from deprecated eregi() function
1197 // This function is case-insensitive
1198 function isInStringIgnoreCase ($needle, $haystack) {
1199 return (isInString(strtolower($needle), strtolower($haystack)));
1202 // Wrapper to check for if fatal errors where detected
1203 function ifFatalErrorsDetected () {
1204 // Just call the inner function
1205 return (getTotalFatalErrors() > 0);
1208 // Checks whether a HTTP status has been set
1209 function isHttpStatusSet () {
1210 // Is it set and not empty?
1211 return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1214 // Setter for HTTP status
1215 function setHttpStatus ($status) {
1216 $GLOBALS['http_status'] = (string) $status;
1219 // Getter for HTTP status
1220 function getHttpStatus () {
1221 // Is the status set?
1222 if (!isHttpStatusSet()) {
1224 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1228 return $GLOBALS['http_status'];
1232 * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1233 * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1235 * ----------------------------------------------------------------------------
1236 * If you want to redirect, please use redirectToUrl(); instead
1237 * ----------------------------------------------------------------------------
1239 * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1241 * @link http://support.microsoft.com/kb/q176113/
1242 * @author Andreas Gohr <andi@splitbrain.org>
1245 function sendRawRedirect ($url) {
1246 // Clear output buffer
1247 clearOutputBuffer();
1249 // Clear own output buffer
1250 $GLOBALS['__output'] = '';
1252 // To make redirects working (no content type), output mode must be raw
1253 setScriptOutputMode(-1);
1255 // Send helping header
1256 setHttpStatus('302 Found');
1258 // always close the session
1259 session_write_close();
1261 // Revert entity &
1262 $url = str_replace('&', '&', $url);
1264 // check if running on IIS < 6 with CGI-PHP
1265 if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1266 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1267 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1268 ($matches[1] < 6)) {
1269 // Send the IIS header
1270 addHttpHeader('Refresh: 0;url=' . $url);
1272 // Send generic header
1273 addHttpHeader('Location: ' . $url);
1280 // Determines the country of the given user id
1281 function determineCountry ($userid) {
1283 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1284 // Default is 'invalid'
1285 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1287 // Is extension country active?
1288 if (isExtensionActive('country')) {
1289 // Determine the right country code through the country id
1290 $id = getUserData('country_code');
1292 // Then handle it over
1293 $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1295 // Get raw code from user data
1296 $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1301 return $GLOBALS[__FUNCTION__][$userid];
1304 // "Getter" for total confirmed user accounts
1305 function getTotalConfirmedUser () {
1307 if (!isset($GLOBALS[__FUNCTION__])) {
1309 if (isExtensionActive('user')) {
1310 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1312 $GLOBALS[__FUNCTION__] = 0;
1316 // Return cached value
1317 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1318 return $GLOBALS[__FUNCTION__];
1321 // "Getter" for total unconfirmed user accounts
1322 function getTotalUnconfirmedUser () {
1324 if (!isset($GLOBALS[__FUNCTION__])) {
1326 if (isExtensionActive('user')) {
1327 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1329 $GLOBALS[__FUNCTION__] = 0;
1333 // Return cached value
1334 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1335 return $GLOBALS[__FUNCTION__];
1338 // "Getter" for total locked user accounts
1339 function getTotalLockedUser () {
1341 if (!isset($GLOBALS[__FUNCTION__])) {
1343 if (isExtensionActive('user')) {
1344 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1346 $GLOBALS[__FUNCTION__] = 0;
1350 // Return cached value
1351 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1352 return $GLOBALS[__FUNCTION__];
1355 // "Getter" for total locked user accounts
1356 function getTotalRandomRefidUser () {
1358 if (!isset($GLOBALS[__FUNCTION__])) {
1360 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1361 $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1363 $GLOBALS[__FUNCTION__] = 0;
1367 // Return cached value
1368 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1369 return $GLOBALS[__FUNCTION__];
1372 // Is given id number valid?
1373 function isValidId ($id) {
1375 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1378 if (!isset($GLOBALS[__FUNCTION__][$id])) {
1380 $GLOBALS[__FUNCTION__][$id] = ((!is_null($id)) && (!is_bool($id)) && (!empty($id)) && ($id != 'NULL') && ($id > 0));
1384 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1385 return $GLOBALS[__FUNCTION__][$id];
1389 function encodeEntities ($str) {
1391 $str = secureString($str, TRUE, TRUE);
1393 // Encode dollar sign as well
1394 $str = str_replace('$', '$', $str);
1400 // "Getter" for date from patch_ctime
1401 function getDateFromRepository () {
1403 if (!isset($GLOBALS[__FUNCTION__])) {
1405 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1409 return $GLOBALS[__FUNCTION__];
1412 // "Getter" for date/time from patch_ctime
1413 function getDateTimeFromRepository () {
1415 if (!isset($GLOBALS[__FUNCTION__])) {
1417 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1421 return $GLOBALS[__FUNCTION__];
1424 // Getter for current year (default)
1425 function getYear ($timestamp = NULL) {
1427 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1428 // If NULL is set, use time()
1429 if (is_null($timestamp)) {
1430 $timestamp = time();
1434 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1438 return $GLOBALS[__FUNCTION__][$timestamp];
1441 // Getter for current month (default)
1442 function getMonth ($timestamp = NULL) {
1444 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1445 // If NULL is set, use time()
1446 if (is_null($timestamp)) {
1447 // Use time() which is current timestamp
1448 $timestamp = time();
1452 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1456 return $GLOBALS[__FUNCTION__][$timestamp];
1459 // Getter for current hour (default)
1460 function getHour ($timestamp = NULL) {
1462 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1464 if (is_null($timestamp)) {
1465 $timestamp = time();
1469 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1473 return $GLOBALS[__FUNCTION__][$timestamp];
1476 // Getter for current day (default)
1477 function getDay ($timestamp = NULL) {
1479 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1481 if (is_null($timestamp)) {
1482 $timestamp = time();
1486 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1490 return $GLOBALS[__FUNCTION__][$timestamp];
1493 // Getter for current week (default)
1494 function getWeek ($timestamp = NULL) {
1496 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1498 if (is_null($timestamp)) $timestamp = time();
1501 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1505 return $GLOBALS[__FUNCTION__][$timestamp];
1508 // Getter for current short_hour (default)
1509 function getShortHour ($timestamp = NULL) {
1511 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1513 if (is_null($timestamp)) $timestamp = time();
1516 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1520 return $GLOBALS[__FUNCTION__][$timestamp];
1523 // Getter for current long_hour (default)
1524 function getLongHour ($timestamp = NULL) {
1526 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1528 if (is_null($timestamp)) $timestamp = time();
1531 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1535 return $GLOBALS[__FUNCTION__][$timestamp];
1538 // Getter for current second (default)
1539 function getSecond ($timestamp = NULL) {
1541 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1543 if (is_null($timestamp)) $timestamp = time();
1546 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1550 return $GLOBALS[__FUNCTION__][$timestamp];
1553 // Getter for current minute (default)
1554 function getMinute ($timestamp = NULL) {
1556 if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1558 if (is_null($timestamp)) $timestamp = time();
1561 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1565 return $GLOBALS[__FUNCTION__][$timestamp];
1568 // Checks whether the title decoration is enabled
1569 function isTitleDecorationEnabled () {
1571 if (!isset($GLOBALS[__FUNCTION__])) {
1573 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1577 return $GLOBALS[__FUNCTION__];
1580 // Checks whether filter usage updates are enabled (expensive queries!)
1581 function isFilterUsageUpdateEnabled () {
1583 if (!isset($GLOBALS[__FUNCTION__])) {
1585 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1589 return $GLOBALS[__FUNCTION__];
1592 // Checks whether debugging of weekly resets is enabled
1593 function isWeeklyResetDebugEnabled () {
1595 if (!isset($GLOBALS[__FUNCTION__])) {
1597 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1601 return $GLOBALS[__FUNCTION__];
1604 // Checks whether debugging of monthly resets is enabled
1605 function isMonthlyResetDebugEnabled () {
1607 if (!isset($GLOBALS[__FUNCTION__])) {
1609 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1613 return $GLOBALS[__FUNCTION__];
1616 // Checks whether displaying of debug SQLs are enabled
1617 function isDisplayDebugSqlEnabled () {
1619 if (!isset($GLOBALS[__FUNCTION__])) {
1621 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getDisplayDebugSqls() == 'Y'));
1625 return $GLOBALS[__FUNCTION__];
1628 // Checks whether module title is enabled
1629 function isModuleTitleEnabled () {
1631 if (!isset($GLOBALS[__FUNCTION__])) {
1633 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1637 return $GLOBALS[__FUNCTION__];
1640 // Checks whether what title is enabled
1641 function isWhatTitleEnabled () {
1643 if (!isset($GLOBALS[__FUNCTION__])) {
1645 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1649 return $GLOBALS[__FUNCTION__];
1652 // "Getter" for internal_stats
1653 function getInternalStats () {
1655 if (!isset($GLOBALS[__FUNCTION__])) {
1657 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1661 return $GLOBALS[__FUNCTION__];
1664 // Checks whether stats are enabled
1665 function ifInternalStatsEnabled () {
1667 if (!isset($GLOBALS[__FUNCTION__])) {
1668 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1669 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1672 // Return cached value
1673 return $GLOBALS[__FUNCTION__];
1676 // Checks whether admin-notification of certain user actions is enabled
1677 function isAdminNotificationEnabled () {
1679 if (!isset($GLOBALS[__FUNCTION__])) {
1681 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (getAdminNotify() == 'Y'));
1685 return $GLOBALS[__FUNCTION__];
1688 // Checks whether random referral id selection is enabled
1689 function isRandomReferralIdEnabled () {
1691 if (!isset($GLOBALS[__FUNCTION__])) {
1693 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y'));
1697 return $GLOBALS[__FUNCTION__];
1700 // "Getter" for default language
1701 function getDefaultLanguage () {
1703 if (!isset($GLOBALS[__FUNCTION__])) {
1705 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1709 return $GLOBALS[__FUNCTION__];
1712 // "Getter" for default referral id
1713 function getDefRefid () {
1715 if (!isset($GLOBALS[__FUNCTION__])) {
1717 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1721 return $GLOBALS[__FUNCTION__];
1724 // "Getter" for path
1725 function getPath () {
1727 if (!isset($GLOBALS[__FUNCTION__])) {
1729 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1733 return $GLOBALS[__FUNCTION__];
1737 function getUrl () {
1739 if (!isset($GLOBALS[__FUNCTION__])) {
1741 $GLOBALS[__FUNCTION__] = getConfig('URL');
1745 return $GLOBALS[__FUNCTION__];
1748 // "Getter" for cache_path
1749 function getCachePath () {
1751 if (!isset($GLOBALS[__FUNCTION__])) {
1753 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1757 return $GLOBALS[__FUNCTION__];
1760 // "Getter" for WRITE_FOOTER
1761 function getWriteFooter () {
1763 if (!isset($GLOBALS[__FUNCTION__])) {
1765 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1769 return $GLOBALS[__FUNCTION__];
1772 // "Getter" for secret_key
1773 function getSecretKey () {
1775 if (!isset($GLOBALS[__FUNCTION__])) {
1777 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1781 return $GLOBALS[__FUNCTION__];
1784 // "Getter" for SITE_KEY
1785 function getSiteKey () {
1787 if (!isset($GLOBALS[__FUNCTION__])) {
1789 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1793 return $GLOBALS[__FUNCTION__];
1796 // "Getter" for DATE_KEY
1797 function getDateKey () {
1799 if (!isset($GLOBALS[__FUNCTION__])) {
1801 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1805 return $GLOBALS[__FUNCTION__];
1808 // "Getter" for master_salt
1809 function getMasterSalt () {
1811 if (!isset($GLOBALS[__FUNCTION__])) {
1813 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1817 return $GLOBALS[__FUNCTION__];
1820 // "Getter" for prime
1821 function getPrime () {
1823 if (!isset($GLOBALS[__FUNCTION__])) {
1825 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1829 return $GLOBALS[__FUNCTION__];
1832 // "Getter" for encrypt_separator
1833 function getEncryptSeparator () {
1835 if (!isset($GLOBALS[__FUNCTION__])) {
1837 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1841 return $GLOBALS[__FUNCTION__];
1844 // "Getter" for mysql_prefix
1845 function getMysqlPrefix () {
1847 if (!isset($GLOBALS[__FUNCTION__])) {
1849 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1853 return $GLOBALS[__FUNCTION__];
1856 // "Getter" for table_type
1857 function getTableType () {
1859 if (!isset($GLOBALS[__FUNCTION__])) {
1861 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1865 return $GLOBALS[__FUNCTION__];
1868 // "Getter" for salt_length
1869 function getSaltLength () {
1871 if (!isset($GLOBALS[__FUNCTION__])) {
1873 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1877 return $GLOBALS[__FUNCTION__];
1880 // "Getter" for output_mode
1881 function getOutputMode () {
1883 if (!isset($GLOBALS[__FUNCTION__])) {
1885 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1889 return $GLOBALS[__FUNCTION__];
1892 // "Getter" for full_version
1893 function getFullVersion () {
1895 if (!isset($GLOBALS[__FUNCTION__])) {
1897 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1901 return $GLOBALS[__FUNCTION__];
1904 // "Getter" for title
1905 function getTitle () {
1907 if (!isset($GLOBALS[__FUNCTION__])) {
1909 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1913 return $GLOBALS[__FUNCTION__];
1916 // "Getter" for curr_svn_revision
1917 function getCurrentRepositoryRevision () {
1919 if (!isset($GLOBALS[__FUNCTION__])) {
1921 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1925 return $GLOBALS[__FUNCTION__];
1928 // "Getter" for server_url
1929 function getServerUrl () {
1931 if (!isset($GLOBALS[__FUNCTION__])) {
1933 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1937 return $GLOBALS[__FUNCTION__];
1940 // "Getter" for mt_word
1941 function getMtWord () {
1943 if (!isset($GLOBALS[__FUNCTION__])) {
1945 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1949 return $GLOBALS[__FUNCTION__];
1952 // "Getter" for mt_word2
1953 function getMtWord2 () {
1955 if (!isset($GLOBALS[__FUNCTION__])) {
1957 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1961 return $GLOBALS[__FUNCTION__];
1964 // "Getter" for mt_word3
1965 function getMtWord3 () {
1967 if (!isset($GLOBALS[__FUNCTION__])) {
1969 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1973 return $GLOBALS[__FUNCTION__];
1976 // "Getter" for START_TDAY
1977 function getStartTday () {
1979 if (!isset($GLOBALS[__FUNCTION__])) {
1981 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
1985 return $GLOBALS[__FUNCTION__];
1988 // "Getter" for START_YDAY
1989 function getStartYday () {
1991 if (!isset($GLOBALS[__FUNCTION__])) {
1993 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
1997 return $GLOBALS[__FUNCTION__];
2000 // "Getter" for main_title
2001 function getMainTitle () {
2003 if (!isset($GLOBALS[__FUNCTION__])) {
2005 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2009 return $GLOBALS[__FUNCTION__];
2012 // "Getter" for file_hash
2013 function getFileHash () {
2015 if (!isset($GLOBALS[__FUNCTION__])) {
2017 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2021 return $GLOBALS[__FUNCTION__];
2024 // "Getter" for pass_scramble
2025 function getPassScramble () {
2027 if (!isset($GLOBALS[__FUNCTION__])) {
2029 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2033 return $GLOBALS[__FUNCTION__];
2036 // "Getter" for ap_inactive_since
2037 function getApInactiveSince () {
2039 if (!isset($GLOBALS[__FUNCTION__])) {
2041 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2045 return $GLOBALS[__FUNCTION__];
2048 // "Getter" for user_min_confirmed
2049 function getUserMinConfirmed () {
2051 if (!isset($GLOBALS[__FUNCTION__])) {
2053 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2057 return $GLOBALS[__FUNCTION__];
2059 // "Getter" for points
2060 function getPoints () {
2062 if (!isset($GLOBALS[__FUNCTION__])) {
2064 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2068 return $GLOBALS[__FUNCTION__];
2071 // "Getter" for slogan
2072 function getSlogan () {
2074 if (!isset($GLOBALS[__FUNCTION__])) {
2076 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2080 return $GLOBALS[__FUNCTION__];
2083 // "Getter" for copy
2084 function getCopy () {
2086 if (!isset($GLOBALS[__FUNCTION__])) {
2088 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2092 return $GLOBALS[__FUNCTION__];
2095 // "Getter" for webmaster
2096 function getWebmaster () {
2098 if (!isset($GLOBALS[__FUNCTION__])) {
2100 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2104 return $GLOBALS[__FUNCTION__];
2107 // "Getter" for sql_count
2108 function getSqlCount () {
2110 if (!isset($GLOBALS[__FUNCTION__])) {
2112 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2116 return $GLOBALS[__FUNCTION__];
2119 // "Getter" for num_templates
2120 function getNumTemplates () {
2122 if (!isset($GLOBALS[__FUNCTION__])) {
2124 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2128 return $GLOBALS[__FUNCTION__];
2131 // "Getter" for dns_cache_timeout
2132 function getDnsCacheTimeout () {
2134 if (!isset($GLOBALS[__FUNCTION__])) {
2136 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2140 return $GLOBALS[__FUNCTION__];
2143 // "Getter" for menu_blur_spacer
2144 function getMenuBlurSpacer () {
2146 if (!isset($GLOBALS[__FUNCTION__])) {
2148 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2152 return $GLOBALS[__FUNCTION__];
2155 // "Getter" for points_register
2156 function getPointsRegister () {
2158 if (!isset($GLOBALS[__FUNCTION__])) {
2160 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2164 return $GLOBALS[__FUNCTION__];
2167 // "Getter" for points_ref
2168 function getPointsRef () {
2170 if (!isset($GLOBALS[__FUNCTION__])) {
2172 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2176 return $GLOBALS[__FUNCTION__];
2179 // "Getter" for ref_payout
2180 function getRefPayout () {
2182 if (!isset($GLOBALS[__FUNCTION__])) {
2184 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2188 return $GLOBALS[__FUNCTION__];
2191 // "Getter" for online_timeout
2192 function getOnlineTimeout () {
2194 if (!isset($GLOBALS[__FUNCTION__])) {
2196 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2200 return $GLOBALS[__FUNCTION__];
2203 // "Getter" for index_home
2204 function getIndexHome () {
2206 if (!isset($GLOBALS[__FUNCTION__])) {
2208 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2212 return $GLOBALS[__FUNCTION__];
2215 // "Getter" for one_day
2216 function getOneDay () {
2218 if (!isset($GLOBALS[__FUNCTION__])) {
2220 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2224 return $GLOBALS[__FUNCTION__];
2227 // "Getter" for img_type
2228 function getImgType () {
2230 if (!isset($GLOBALS[__FUNCTION__])) {
2232 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2236 return $GLOBALS[__FUNCTION__];
2239 // "Getter" for code_length
2240 function getCodeLength () {
2242 if (!isset($GLOBALS[__FUNCTION__])) {
2244 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2248 return $GLOBALS[__FUNCTION__];
2251 // "Getter" for pass_len
2252 function getPassLen () {
2254 if (!isset($GLOBALS[__FUNCTION__])) {
2256 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2260 return $GLOBALS[__FUNCTION__];
2263 // "Getter" for admin_menu
2264 function getAdminMenu () {
2266 if (!isset($GLOBALS[__FUNCTION__])) {
2268 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2272 return $GLOBALS[__FUNCTION__];
2275 // "Getter" for last_hourly
2276 function getLastHourly () {
2278 if (!isset($GLOBALS[__FUNCTION__])) {
2280 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2284 return $GLOBALS[__FUNCTION__];
2287 // "Getter" for last_daily
2288 function getLastDaily () {
2290 if (!isset($GLOBALS[__FUNCTION__])) {
2292 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2296 return $GLOBALS[__FUNCTION__];
2299 // "Getter" for last_weekly
2300 function getLastWeekly () {
2302 if (!isset($GLOBALS[__FUNCTION__])) {
2304 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2308 return $GLOBALS[__FUNCTION__];
2311 // "Getter" for last_monthly
2312 function getLastMonthly () {
2314 if (!isset($GLOBALS[__FUNCTION__])) {
2316 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2320 return $GLOBALS[__FUNCTION__];
2323 // "Getter" for mails_page
2324 function getMailsPage () {
2326 if (!isset($GLOBALS[__FUNCTION__])) {
2328 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2332 return $GLOBALS[__FUNCTION__];
2335 // "Getter" for rand_no
2336 function getRandNo () {
2338 if (!isset($GLOBALS[__FUNCTION__])) {
2340 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2344 return $GLOBALS[__FUNCTION__];
2347 // "Getter" for __DB_NAME
2348 function getDbName () {
2350 if (!isset($GLOBALS[__FUNCTION__])) {
2352 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2356 return $GLOBALS[__FUNCTION__];
2359 // "Getter" for DOMAIN
2360 function getDomain () {
2362 if (!isset($GLOBALS[__FUNCTION__])) {
2364 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2368 return $GLOBALS[__FUNCTION__];
2371 // "Getter" for proxy_username
2372 function getProxyUsername () {
2374 if (!isset($GLOBALS[__FUNCTION__])) {
2376 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2380 return $GLOBALS[__FUNCTION__];
2383 // "Getter" for proxy_password
2384 function getProxyPassword () {
2386 if (!isset($GLOBALS[__FUNCTION__])) {
2388 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2392 return $GLOBALS[__FUNCTION__];
2395 // "Getter" for proxy_host
2396 function getProxyHost () {
2398 if (!isset($GLOBALS[__FUNCTION__])) {
2400 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2404 return $GLOBALS[__FUNCTION__];
2407 // "Getter" for proxy_port
2408 function getProxyPort () {
2410 if (!isset($GLOBALS[__FUNCTION__])) {
2412 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2416 return $GLOBALS[__FUNCTION__];
2419 // "Getter" for SMTP_HOSTNAME
2420 function getSmtpHostname () {
2422 if (!isset($GLOBALS[__FUNCTION__])) {
2424 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2428 return $GLOBALS[__FUNCTION__];
2431 // "Getter" for SMTP_USER
2432 function getSmtpUser () {
2434 if (!isset($GLOBALS[__FUNCTION__])) {
2436 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2440 return $GLOBALS[__FUNCTION__];
2443 // "Getter" for SMTP_PASSWORD
2444 function getSmtpPassword () {
2446 if (!isset($GLOBALS[__FUNCTION__])) {
2448 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2452 return $GLOBALS[__FUNCTION__];
2455 // "Getter" for points_word
2456 function getPointsWord () {
2458 if (!isset($GLOBALS[__FUNCTION__])) {
2460 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2464 return $GLOBALS[__FUNCTION__];
2467 // "Getter" for profile_lock
2468 function getProfileLock () {
2470 if (!isset($GLOBALS[__FUNCTION__])) {
2472 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2476 return $GLOBALS[__FUNCTION__];
2479 // "Getter" for url_tlock
2480 function getUrlTlock () {
2482 if (!isset($GLOBALS[__FUNCTION__])) {
2484 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2488 return $GLOBALS[__FUNCTION__];
2491 // "Getter" for title_left
2492 function getTitleLeft () {
2494 if (!isset($GLOBALS[__FUNCTION__])) {
2496 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2500 return $GLOBALS[__FUNCTION__];
2503 // "Getter" for title_right
2504 function getTitleRight () {
2506 if (!isset($GLOBALS[__FUNCTION__])) {
2508 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2512 return $GLOBALS[__FUNCTION__];
2515 // "Getter" for title_middle
2516 function getTitleMiddle () {
2518 if (!isset($GLOBALS[__FUNCTION__])) {
2520 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2524 return $GLOBALS[__FUNCTION__];
2527 // Getter for 'display_home_in_index'
2528 function getDisplayHomeInIndex () {
2529 // Is the cache entry set?
2530 if (!isset($GLOBALS[__FUNCTION__])) {
2531 // No, so determine it
2532 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2535 // Return cached entry
2536 return $GLOBALS[__FUNCTION__];
2539 // Checks whether 'display_home_in_index' is 'Y'
2540 function isDisplayHomeInIndexEnabled () {
2541 // Is the cache entry set?
2542 if (!isset($GLOBALS[__FUNCTION__])) {
2543 // No, so determine it
2544 $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y');
2547 // Return cached entry
2548 return $GLOBALS[__FUNCTION__];
2551 // Getter for 'show_points_unconfirmed'
2552 function getShowPointsUnconfirmed () {
2553 // Is the cache entry set?
2554 if (!isset($GLOBALS[__FUNCTION__])) {
2555 // No, so determine it
2556 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2559 // Return cached entry
2560 return $GLOBALS[__FUNCTION__];
2563 // Checks whether 'show_points_unconfirmed' is 'Y'
2564 function isShowPointsUnconfirmedEnabled () {
2565 // Is the cache entry set?
2566 if (!isset($GLOBALS[__FUNCTION__])) {
2567 // No, so determine it
2568 $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y');
2571 // Return cached entry
2572 return $GLOBALS[__FUNCTION__];
2575 // Getter for 'youre_here'
2576 function getYoureHere () {
2577 // Is the cache entry set?
2578 if (!isset($GLOBALS[__FUNCTION__])) {
2579 // No, so determine it
2580 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2583 // Return cached entry
2584 return $GLOBALS[__FUNCTION__];
2587 // Checks whether 'show_timings' is 'Y'
2588 function isYoureHereEnabled () {
2589 // Is the cache entry set?
2590 if (!isset($GLOBALS[__FUNCTION__])) {
2591 // No, so determine it
2592 $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y');
2595 // Return cached entry
2596 return $GLOBALS[__FUNCTION__];
2599 // Getter for 'show_timings'
2600 function getShowTimings () {
2601 // Is the cache entry set?
2602 if (!isset($GLOBALS[__FUNCTION__])) {
2603 // No, so determine it
2604 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2607 // Return cached entry
2608 return $GLOBALS[__FUNCTION__];
2611 // Checks whether 'show_timings' is 'Y'
2612 function isShowTimingsEnabled () {
2613 // Is the cache entry set?
2614 if (!isset($GLOBALS[__FUNCTION__])) {
2615 // No, so determine it
2616 $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y');
2619 // Return cached entry
2620 return $GLOBALS[__FUNCTION__];
2623 // Getter for 'ap_server_name_since'
2624 function getApServerNameSince () {
2625 // Is the cache entry set?
2626 if (!isset($GLOBALS[__FUNCTION__])) {
2627 // No, so determine it
2628 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2631 // Return cached entry
2632 return $GLOBALS[__FUNCTION__];
2635 // Getter for 'ap_server_name'
2636 function getApServerName () {
2637 // Is the cache entry set?
2638 if (!isset($GLOBALS[__FUNCTION__])) {
2639 // No, so determine it
2640 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2643 // Return cached entry
2644 return $GLOBALS[__FUNCTION__];
2647 // Getter for 'index_delay'
2648 function getIndexDelay () {
2649 // Is the cache entry set?
2650 if (!isset($GLOBALS[__FUNCTION__])) {
2651 // No, so determine it
2652 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2655 // Return cached entry
2656 return $GLOBALS[__FUNCTION__];
2659 // Checks whether 'ap_server_name' is 'Y'
2660 function isApServerNameEnabled () {
2661 // Is the cache entry set?
2662 if (!isset($GLOBALS[__FUNCTION__])) {
2663 // No, so determine it
2664 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2667 // Return cached entry
2668 return $GLOBALS[__FUNCTION__];
2671 // Getter for 'admin_menu_javascript'
2672 function getAdminMenuJavascript () {
2673 // Is the cache entry set?
2674 if (!isset($GLOBALS[__FUNCTION__])) {
2675 // No, so determine it
2676 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2679 // Return cached entry
2680 return $GLOBALS[__FUNCTION__];
2683 // Getter for 'points_remove_account'
2684 function getPointsRemoveAccount () {
2685 // Is the cache entry set?
2686 if (!isset($GLOBALS[__FUNCTION__])) {
2687 // No, so determine it
2688 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2691 // Return cached entry
2692 return $GLOBALS[__FUNCTION__];
2695 // Getter for 'css_php'
2696 function getCssPhp () {
2697 // Is the cache entry set?
2698 if (!isset($GLOBALS[__FUNCTION__])) {
2699 // No, so determine it
2700 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2703 // Return cached entry
2704 return $GLOBALS[__FUNCTION__];
2707 // Getter for 'guest_menu'
2708 function getGuestMenu () {
2709 // Is the cache entry set?
2710 if (!isset($GLOBALS[__FUNCTION__])) {
2711 // No, so determine it
2712 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2715 // Return cached entry
2716 return $GLOBALS[__FUNCTION__];
2719 // Checks if guest menu is enabled
2720 function isGuestMenuEnabled () {
2721 // Is the cache entry set?
2722 if (!isset($GLOBALS[__FUNCTION__])) {
2723 // No, so determine it
2724 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2727 // Return cached entry
2728 return $GLOBALS[__FUNCTION__];
2731 // Getter for 'member_menu'
2732 function getMemberMenu () {
2733 // Is the cache entry set?
2734 if (!isset($GLOBALS[__FUNCTION__])) {
2735 // No, so determine it
2736 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2739 // Return cached entry
2740 return $GLOBALS[__FUNCTION__];
2743 // Checks if member menu is enabled
2744 function isMemberMenuEnabled () {
2745 // Is the cache entry set?
2746 if (!isset($GLOBALS[__FUNCTION__])) {
2747 // No, so determine it
2748 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2751 // Return cached entry
2752 return $GLOBALS[__FUNCTION__];
2755 // Getter for 'word_wrap'
2756 function getWordWrap () {
2757 // Is the cache entry set?
2758 if (!isset($GLOBALS[__FUNCTION__])) {
2759 // Construct config entry name
2760 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2762 // Is a special config entry found or ext-sql_patches updated?
2763 if (isConfigEntrySet($configEntry)) {
2764 // A special config entry has been found, then use it
2765 $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2766 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2767 // No special config entry found, then use it as "fall-back"
2768 $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2770 // No, use default (15 characters)
2771 $GLOBALS[__FUNCTION__] = 15;
2775 // Return cached entry
2776 return $GLOBALS[__FUNCTION__];
2779 // Checks whether proxy configuration is used
2780 function isProxyUsed () {
2782 if (!isset($GLOBALS[__FUNCTION__])) {
2784 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2788 return $GLOBALS[__FUNCTION__];
2791 // Checks whether POST data contains selections
2792 function ifPostContainsSelections ($element = 'sel') {
2794 if (!isset($GLOBALS[__FUNCTION__][$element])) {
2796 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2800 return $GLOBALS[__FUNCTION__][$element];
2803 // Checks whether verbose_sql is Y and returns true/false if so
2804 function isVerboseSqlEnabled () {
2806 if (!isset($GLOBALS[__FUNCTION__])) {
2808 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2812 return $GLOBALS[__FUNCTION__];
2815 // "Getter" for total user points
2816 function getTotalPoints ($userid) {
2818 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2819 // Init array for filter chain
2821 'userid' => $userid,
2825 // Run filter chain for getting more point values
2826 $data = runFilterChain('get_total_points', $data);
2829 $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
2833 return $GLOBALS[__FUNCTION__][$userid];
2836 // Wrapper to get used points for given userid
2837 function getUserUsedPoints ($userid) {
2839 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2841 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2845 return $GLOBALS[__FUNCTION__][$userid];
2848 // Checks whether direct payment is allowed in configuration
2849 function isDirectPaymentEnabled () {
2851 if (!isset($GLOBALS[__FUNCTION__])) {
2853 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2857 return $GLOBALS[__FUNCTION__];
2860 // Checks whether JavaScript-based admin menu is enabled
2861 function isAdminMenuJavascriptEnabled () {
2863 if (!isset($GLOBALS[__FUNCTION__])) {
2865 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getAdminMenuJavaScript() == 'Y'));
2869 return $GLOBALS[__FUNCTION__];
2872 // Wrapper to check if current task is for extension (not update)
2873 function isExtensionTask ($content) {
2875 if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2877 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2881 return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2884 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2885 function ifTesterAccountsAllowed () {
2886 // Is the cache entry set?
2887 if (!isset($GLOBALS[__FUNCTION__])) {
2888 // No, so determine it
2889 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2892 // Return cached entry
2893 return $GLOBALS[__FUNCTION__];
2896 // Wrapper to check if output mode is CSS
2897 function isCssOutputMode () {
2899 if (!isset($GLOBALS[__FUNCTION__])) {
2901 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2902 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2906 return $GLOBALS[__FUNCTION__];
2909 // Wrapper to check if output mode is HTML
2910 function isHtmlOutputMode () {
2912 if (!isset($GLOBALS[__FUNCTION__])) {
2914 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2915 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2919 return $GLOBALS[__FUNCTION__];
2922 // Wrapper to check if output mode is RAW
2923 function isRawOutputMode () {
2925 if (!isset($GLOBALS[__FUNCTION__])) {
2927 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2928 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2932 return $GLOBALS[__FUNCTION__];
2935 // Wrapper to check if output mode is AJAX
2936 function isAjaxOutputMode () {
2938 if (!isset($GLOBALS[__FUNCTION__])) {
2940 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2941 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2945 return $GLOBALS[__FUNCTION__];
2948 // Wrapper to check if output mode is image
2949 function isImageOutputMode () {
2951 if (!isset($GLOBALS[__FUNCTION__])) {
2953 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2954 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
2958 return $GLOBALS[__FUNCTION__];
2961 // Wrapper to generate a user email link
2962 function generateWrappedUserEmailLink ($email) {
2963 // Just call the inner function
2964 return generateEmailLink($email, 'user_data');
2967 // Wrapper to check if user points are locked
2968 function ifUserPointsLocked ($userid) {
2969 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
2971 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2973 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2977 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
2978 return $GLOBALS[__FUNCTION__][$userid];
2981 // Appends a line to an existing file or creates it instantly with given content.
2982 // This function does always add a new-line character to every line.
2983 function appendLineToFile ($file, $line) {
2984 $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2985 fwrite($fp, $line . PHP_EOL);
2989 // Wrapper for changeDataInFile() but with full path added
2990 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
2992 $FQFN = getPath() . $FQFN;
2994 // Call inner function
2995 return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
2998 // Wrapper for changing entries in config-local.php
2999 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3000 // Call the inner function
3001 return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3004 // Shortens ucfirst(strtolower()) calls
3005 function firstCharUpperCase ($str) {
3006 return ucfirst(strtolower($str));
3009 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3010 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3011 // Get the configuration entry
3012 $configValue = getConfig($configEntry);
3014 // Call inner method
3015 return createTimeSelections($configValue, $configEntry, $stamps, $align);
3018 // Shortens converting of German comma to Computer's version in POST data
3019 function convertCommaToDotInPostData ($postEntry) {
3020 // Read and convert given entry
3021 $postValue = convertCommaToDot(postRequestElement($postEntry));
3024 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3026 // ... and set it again
3027 setPostRequestElement($postEntry, $postValue);
3030 // Converts German commas to Computer's version in all entries
3031 function convertCommaToDotInPostDataArray ($postEntries) {
3032 // Replace german decimal comma with computer decimal dot
3033 foreach ($postEntries as $entry) {
3034 // Is the entry there?
3035 if (isPostRequestElementSet($entry)) {
3037 convertCommaToDotInPostData($entry);
3043 * Parses a string into a US formated float variable, taken from user comments
3044 * from PHP documentation website.
3046 * @param $floatString A string holding a float expression
3047 * @return $float Corresponding float variable
3048 * @author chris<at>georgakopoulos<dot>com
3049 * @link http://de.php.net/manual/en/function.floatval.php#92563
3051 function parseFloat ($floatString){
3053 $LocaleInfo = localeconv();
3055 // Remove thousand separators
3056 $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3058 // Convert decimal point
3059 $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3061 // Return float value of converted string
3062 return floatval($floatString);
3066 * Searches a multi-dimensional array (as used in many places) for given
3067 * key/value pair as taken from user comments from PHP documentation website.
3069 * @param $array An array with one or more dimensions
3070 * @param $key Key to look for
3071 * @param $value Value to look for
3072 * @param $parentIndex Parent index (ONLY INTERNAL USE!)
3073 * @return $results Resulted array or empty array if $array is no array
3074 * @author sunelbe<at>gmail<dot>com
3075 * @link http://de.php.net/manual/en/function.array-search.php#110120
3077 function search_array ($array, $key, $value, $parentIndex = NULL) {
3078 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3079 // Init array result
3082 // Is $array really an array?
3083 if (is_array($array)) {
3084 // Search for whole array
3085 foreach ($array as $idx => $dummy) {
3086 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3087 //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3088 // Is dummy an array?
3089 if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3090 // Then search again
3091 $subResult = search_array($dummy, $key, $value, $idx);
3092 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3095 $results = merge_array($results, $subResult, TRUE);
3096 } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3097 // Is found, so add it
3098 $results[$parentIndex] = $array;
3099 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3104 // Return resulting array
3105 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3109 // Generates a YES/NO option list from given default
3110 function generateYesNoOptions ($defaultValue = '') {
3112 return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3115 // "Getter" for total available receivers
3116 function getTotalReceivers ($mode = 'normal') {
3118 $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3124 // Wrapper "getter" to get total unconfirmed mails for given userid
3125 function getTotalUnconfirmedMails ($userid) {
3127 if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3129 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3133 return $GLOBALS[__FUNCTION__][$userid];
3136 // Checks whether 'mailer_theme' was found in session
3137 function isMailerThemeSet () {
3139 if (!isset($GLOBALS[__FUNCTION__])) {
3141 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3145 return $GLOBALS[__FUNCTION__];
3149 * Setter for theme in session (This setter does return the success of
3150 * setSession() which is required e.g. for destroySponsorSession().
3152 function setMailerTheme ($newTheme) {
3153 // Set it in session
3154 return setSession('mailer_theme', $newTheme);
3158 * Getter for theme from session (This getter does return 'mailer_theme' from
3159 * session data or throws an error if not possible
3161 function getMailerTheme () {
3163 if (!isset($GLOBALS[__FUNCTION__])) {
3164 // Is 'mailer_theme' set?
3165 if (!isMailerThemeSet()) {
3166 // No, then abort here
3167 reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3170 // Get it and store it in cache
3171 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3175 return $GLOBALS[__FUNCTION__];
3178 // "Getter" for last_module/last_what depending on ext-user version
3179 function getUserLastWhatName () {
3180 // Default is old one: last_module
3181 $columnName = 'last_module';
3183 // Is ext-user up-to-date?
3184 if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3185 // Yes, then use new one
3186 $columnName = 'last_what';
3193 // "Getter" for all columns for given alias and separator
3194 function getAllPointColumns ($alias = NULL, $separator = ',') {
3195 // Prepare the filter array
3196 $filterData = array(
3199 'separator' => $separator
3203 $filterData = runFilterChain('get_all_point_columns', $filterData);
3205 // Return the columns
3206 return $filterData['columns'];
3209 // Checks whether the copyright footer (which breaks framesets) is enabled
3210 function ifCopyrightFooterEnabled () {
3211 // Is not unset and not 'N'?
3212 return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3216 * Wrapper to check whether we have a "full page". This means that the actual
3217 * content is not delivered in any frame of a frameset.
3219 function isFullPage () {
3221 * The parameter 'frame' is generic and always indicates that this content
3222 * will be output into a frame. Furthermore, if a frameset is reported or
3223 * the copyright line is explicitly deactivated, this cannot be a "full
3226 // @TODO Find a way to not use direct module comparison
3227 $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3233 // Checks whether frameset_mode is set to true
3234 function isFramesetModeEnabled () {
3236 return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3239 // Function to determine correct 'what' value
3240 function determineWhat ($module = NULL) {
3241 // Init default 'what'
3245 if (is_null($module)) {
3247 $module = getModule();
3255 // Else try to get it from current module
3256 $what = getWhatFromModule($module);
3258 //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3260 // Remove any spaces from variable
3261 $what = trim($what);
3265 // Default action for non-admin menus
3269 $what = secureString($what);
3276 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3277 function prependZeros ($str, $length = 2) {
3278 // Return prepended string
3279 return sprintf('%0' . (int) $length . 's', $str);
3282 // Wraps convertSelectionsToEpocheTime()
3283 function convertSelectionsToEpocheTimeInPostData ($id) {
3288 // Get all POST data
3289 $postData = postRequestArray();
3291 // Convert given selection id
3292 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3294 // Set the POST array back
3295 setPostRequestArray($postData);
3298 // Wraps checking if given points account type matches with given in POST data
3299 function ifPointsAccountTypeMatchesPost ($type) {
3301 exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3304 // Gets given user's total referral
3305 function getUsersTotalReferrals ($userid, $level = NULL) {
3307 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3308 // Is the level NULL?
3309 if (is_null($level)) {
3310 // Get total amount (all levels)
3311 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3313 // Get it from user refs
3314 $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3319 return $GLOBALS[__FUNCTION__][$userid][$level];
3322 // Gets given user's total referral
3323 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3324 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3326 if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3327 // Default is all refs
3330 // Is the not level NULL?
3331 if (!is_null($level)) {
3332 // Then add referral level
3333 $add = ' AND `r`.`level`=' . bigintval($level);
3336 // Check for all referrals
3337 $result = sqlQueryEscaped("SELECT
3338 COUNT(`d`.`userid`) AS `cnt`
3340 `{?_MYSQL_PREFIX?}_user_data` AS `d`
3342 `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3344 `d`.`userid`=`r`.`refid`
3346 `d`.`status` != 'CONFIRMED' AND
3354 ), __FUNCTION__, __LINE__);
3357 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3360 sqlFreeResult($result);
3364 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3365 return $GLOBALS[__FUNCTION__][$userid][$level];
3368 // Converts, if found, dollar data to get element
3369 function convertDollarDataToGetElement ($data) {
3370 // Is first char a dollar?
3371 if (substr($data, 0, 1) == chr(36)) {
3372 // Use last part for getRequestElement()
3373 $data = getRequestElement(substr($data, 1));
3380 // Wrapper function for SQL layer to speed-up things
3381 function isSqlDebugEnabled () {
3383 if (!isset($GLOBALS[__FUNCTION__])) {
3385 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3389 return $GLOBALS[__FUNCTION__];
3392 // Wrapper function to wrap call of wordwrap()
3393 function wrapWords ($text) {
3395 $wrapped = wordwrap($test, getWordWrap());
3401 // Encodes given data into a JSON object
3402 function encodeJson ($data) {
3404 return json_encode($data, JSON_FORCE_OBJECT);
3407 // Get all extension files
3408 function loadAllExtensionsByTemplate () {
3410 $extensions = getArrayFromDirectory(
3411 'templates/' . getLanguage() . '/html/ext/',
3425 // Wrapper function to allow full float values as supported by current database layout
3426 function translateFullComma ($dotted) {
3427 // Call inner function
3428 return translateComma($dotted, TRUE, 5);
3431 // Wrapper to check if the first element to be shifted is set to given value
3432 function shift_array (&$array, $value, $key = '0') {
3433 // Is the element set and value matches?
3434 assert(is_array($array));
3435 assert(isset($array[$key]));
3436 assert($array[$key] === $value);
3439 array_shift($array);
3442 // Wrapper for str_pad() with left padding zeros
3443 function padLeftZero ($str, $amount = 2) {
3444 // Is str_pad() there?
3445 if (function_exists('str_pad')) {
3446 // Use prependZeros()
3447 return prependZeros($str, $amount);
3450 return str_pad($str, $amount, '0', STR_PAD_LEFT);