Sometimes a whole array needs to be set in session (installer).
[mailer.git] / inc / wrapper-functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/04/2009 *
4  * ===================                          Last change: 04/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : wrapper-functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Wrapper functions                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Wrapper-Funktionen                               *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         exit();
36 } // END - if
37
38 // Read a given file
39 function readFromFile ($FQFN) {
40         // Sanity-check if file is there (should be there, but just to make it sure)
41         if (!isFileReadable($FQFN)) {
42                 // This should not happen
43                 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
44         } // END - if
45
46         // Load the file
47         if (function_exists('file_get_contents')) {
48                 // Use new function
49                 $fileContent = file_get_contents($FQFN);
50         } else {
51                 // Fall-back to implode-file chain
52                 $fileContent = implode('', file($FQFN));
53         }
54
55         // Return the content
56         return $fileContent;
57 }
58
59 // Writes content to a file
60 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
61         // Is the file writeable?
62         if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
63                 // Not writeable!
64                 logDebugMessage(__FUNCTION__, __LINE__, sprintf('File %s not writeable or cannot change CHMOD to 0644.', basename($FQFN)));
65
66                 // Failed! :(
67                 return FALSE;
68         } // END - if
69
70         // By default all is failed...
71         $GLOBALS['file_readable'][$FQFN] = FALSE;
72         $return = FALSE;
73
74         // Is the function there?
75         if (function_exists('file_put_contents')) {
76                 // With lock?
77                 if ($aquireLock === TRUE) {
78                         // Write it directly with lock
79                         $return = file_put_contents($FQFN, $content, LOCK_EX);
80                 } else {
81                         // Write it directly
82                         $return = file_put_contents($FQFN, $content);
83                 }
84         } else {
85                 // Write it with fopen
86                 $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
87
88                 // Aquire a lock?
89                 if ($aquireLock === TRUE) {
90                         // Aquire a lock.
91                         flock($fp, LOCK_EX);
92                 } // END - if
93
94                 // Write content
95                 $return = fwrite($fp, $content);
96
97                 // Close stream
98                 fclose($fp);
99         }
100
101         // Was something written?
102         if ($return !== FALSE) {
103                 // Mark it as readable
104                 $GLOBALS['file_readable'][$FQFN] = TRUE;
105         } // END - if
106
107         // Return status
108         return (($return !== FALSE) && (changeMode($FQFN, 0644)));
109 }
110
111 // Clears the output buffer. This function does *NOT* backup sent content.
112 function clearOutputBuffer () {
113         // Make sure this function is not called twice (no double-cleaning!)
114         if (isset($GLOBALS[__FUNCTION__])) {
115                 // This function is called twice
116                 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
117         } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
118                 // Failed!
119                 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
120         } // END - if
121
122         // Mark this function as called
123         $GLOBALS[__FUNCTION__] = TRUE;
124 }
125
126 // Encode strings
127 function encodeString ($str) {
128         $str = urlencode(base64_encode(compileUriCode($str)));
129         return $str;
130 }
131
132 // Decode strings encoded with encodeString()
133 function decodeString ($str) {
134         $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
135         return $str;
136 }
137
138 // Decode entities in a nicer way
139 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
140         // Decode the entities to UTF-8 now
141         $decodedString = html_entity_decode($str, $quote, 'UTF-8');
142
143         // Return decoded string
144         return $decodedString;
145 }
146
147 // Merges an array together but only if both are arrays
148 function merge_array ($array1, $array2, $keepIndex = FALSE) {
149         // Are both an array?
150         if ((!is_array($array1)) && (!is_array($array2))) {
151                 // Both are not arrays
152                 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
153         } elseif (!is_array($array1)) {
154                 // Left one is not an array
155                 reportBug(__FUNCTION__, __LINE__, sprintf('array1 is not an array. array != %s', gettype($array1)));
156         } elseif (!is_array($array2)) {
157                 // Right one is not an array
158                 reportBug(__FUNCTION__, __LINE__, sprintf('array2 is not an array. array != %s', gettype($array2)));
159         }
160
161         // Maintain index of array2?
162         if ($keepIndex === TRUE) {
163                 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
164                 foreach ($array2 as $key => $value) {
165                         // Add it
166                         $array1[$key] = $value;
167                 } // END - foreach
168
169                 // Return it
170                 return $array1;
171         } else {
172                 // Merge both together normally
173                 return array_merge($array1, $array2);
174         }
175 }
176
177 // Check if given FQFN is a readable file
178 function isFileReadable ($FQFN) {
179         // Is there cache?
180         if (!isset($GLOBALS['file_readable'][$FQFN])) {
181                 // Check all...
182                 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
183         } // END - if
184
185         // Return result
186         return $GLOBALS['file_readable'][$FQFN];
187 }
188
189 // Checks whether the given FQFN is a directory and not ., .. or .svn
190 function isDirectory ($FQFN) {
191         // Is there cache?
192         if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
193                 // Generate baseName
194                 $baseName = basename($FQFN);
195
196                 // Check it
197                 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
198         } // END - if
199
200         // Return the result
201         return $GLOBALS[__FUNCTION__][$FQFN];
202 }
203
204 // "Getter" for the real remote IP number
205 function detectRealIpAddress ($alwaysReal = FALSE) {
206         // Get remote ip from environment
207         $remoteAddr = determineRealRemoteAddress();
208
209         // Is removeip installed?
210         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
211                 // Then anonymize it
212                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
213         } // END - if
214
215         // Return it
216         return $remoteAddr;
217 }
218
219 // "Getter" for remote IP number
220 function detectRemoteAddr ($alwaysReal = FALSE) {
221         // Get remote ip from environment
222         $remoteAddr = determineRealRemoteAddress(TRUE);
223
224         // Is removeip installed?
225         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
226                 // Then anonymize it
227                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
228         } // END - if
229
230         // Return it
231         return $remoteAddr;
232 }
233
234 // "Getter" for remote hostname
235 function detectRemoteHostname ($alwaysReal = FALSE) {
236         // Get remote ip from environment
237         $remoteHost = getenv('REMOTE_HOST');
238
239         // Is removeip installed?
240         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
241                 // Then anonymize it
242                 $remoteHost = getAnonymousRemoteHost($remoteHost);
243         } // END - if
244
245         // Return it
246         return $remoteHost;
247 }
248
249 // "Getter" for user agent
250 function detectUserAgent ($alwaysReal = FALSE) {
251         // Get remote ip from environment
252         $userAgent = getenv('HTTP_USER_AGENT');
253
254         // Is removeip installed?
255         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
256                 // Then anonymize it
257                 $userAgent = getAnonymousUserAgent($userAgent);
258         } // END - if
259
260         // Return it
261         return $userAgent;
262 }
263
264 // "Getter" for referer
265 function detectReferer ($alwaysReal = FALSE) {
266         // Get remote ip from environment
267         $referer = getenv('HTTP_REFERER');
268
269         // Is removeip installed?
270         if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
271                 // Then anonymize it
272                 $referer = getAnonymousReferer($referer);
273         } // END - if
274
275         // Return it
276         return $referer;
277 }
278
279 // "Getter" for request URI
280 function detectRequestUri () {
281         // Return it
282         return (getenv('REQUEST_URI'));
283 }
284
285 // "Getter" for query string
286 function detectQueryString () {
287         return str_replace('&', '&amp;', (getenv('QUERY_STRING')));
288 }
289
290 // "Getter" for SERVER_NAME
291 function detectServerName () {
292         // Return it
293         return (getenv('SERVER_NAME'));
294 }
295
296 // Removes any  existing www. from SERVER_NAME. This is very silly but enough
297 // for our purpose here.
298 function detectDomainName () {
299         // Is there cache?
300         if (!isset($GLOBALS[__FUNCTION__])) {
301                 // Get server name
302                 $domainName = detectServerName();
303
304                 // Is there any www. ?
305                 if (substr($domainName, 0, 4) == 'www.') {
306                         // Remove it
307                         $domainName = substr($domainName, 4);
308                 } // END - if
309
310                 // Set cache
311                 $GLOBALS[__FUNCTION__] = $domainName;
312         } // END - if
313
314         // Return cache
315         return $GLOBALS[__FUNCTION__];
316 }
317
318 // Check whether we are installing
319 function isInstalling () {
320         // Determine whether we are installing
321         if (!isset($GLOBALS['__mailer_installing'])) {
322                 // Check URL (css.php/js.php need this)
323                 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isAjaxOutputMode()) && (isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
324         } // END - if
325
326         // Return result
327         return $GLOBALS['__mailer_installing'];
328 }
329
330 // Check whether this script is installed
331 function isInstalled () {
332         // Is there cache?
333         if (!isset($GLOBALS[__FUNCTION__])) {
334                 // Determine whether this script is installed
335                 $GLOBALS[__FUNCTION__] = (
336                 (
337                         // First is config
338                         (
339                                 (
340                                         isConfigEntrySet('MAILER_INSTALLED')
341                                 ) && (
342                                         getConfig('MAILER_INSTALLED') == 'Y'
343                                 )
344                         )
345                 ) || (
346                         // New config file found and loaded
347                         isIncludeReadable(getCachePath() . 'config-local.php')
348                 ) || (
349                         (
350                                 // New config file found, but not yet read
351                                 isIncludeReadable(getCachePath() . 'config-local.php')
352                         ) && (
353                                 (
354                                         // Only new config file is found
355                                         !isIncludeReadable('inc/config.php')
356                                 ) || (
357                                         // Is installation mode
358                                         !isInstalling()
359                                 )
360                         )
361                 ));
362         } // END - if
363
364         // Then use the cache
365         return $GLOBALS[__FUNCTION__];
366 }
367
368 // Check whether an admin is registered
369 function isAdminRegistered () {
370         // Is cache set?
371         if (!isset($GLOBALS[__FUNCTION__])) {
372                 // Simply check it
373                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
374         } // END - if
375
376         // Return it
377         return $GLOBALS[__FUNCTION__];
378 }
379
380 // Checks whether the hourly reset mode is active
381 function isHourlyResetEnabled () {
382         // Now simply check it
383         return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
384 }
385
386 // Checks whether the daily reset mode is active
387 function isDailyResetEnabled () {
388         // Now simply check it
389         return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
390 }
391
392 // Checks whether the weekly reset mode is active
393 function isWeeklyResetEnabled () {
394         // Now simply check it
395         return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
396 }
397
398 // Checks whether the monthly reset mode is active
399 function isMonthlyResetEnabled () {
400         // Now simply check it
401         return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
402 }
403
404 // Checks whether the yearly reset mode is active
405 function isYearlyResetEnabled () {
406         // Now simply check it
407         return ((isset($GLOBALS['yearly_enabled'])) && ($GLOBALS['yearly_enabled'] === TRUE));
408 }
409
410 // Checks whether one of the reset modes is enabled
411 function isResetModeEnabled () {
412         // Now simply check it
413         return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()) || (isYearlyResetEnabled()));
414 }
415
416 // Checks whether the debug mode is enabled
417 function isDebugModeEnabled () {
418         // Is cache set?
419         if (!isset($GLOBALS[__FUNCTION__])) {
420                 // Simply check it
421                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
422         } // END - if
423
424         // Return it
425         return $GLOBALS[__FUNCTION__];
426 }
427
428 // Checks whether the debug hourly is enabled
429 function isDebugHourlyEnabled () {
430         // Is cache set?
431         if (!isset($GLOBALS[__FUNCTION__])) {
432                 // Simply check it
433                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
434         } // END - if
435
436         // Return it
437         return $GLOBALS[__FUNCTION__];
438 }
439
440 // Checks whether the debug daily is enabled
441 function isDebugDailyEnabled () {
442         // Is cache set?
443         if (!isset($GLOBALS[__FUNCTION__])) {
444                 // Simply check it
445                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
446         } // END - if
447
448         // Return it
449         return $GLOBALS[__FUNCTION__];
450 }
451
452 // Checks whether the debug weekly is enabled
453 function isDebugWeeklyEnabled () {
454         // Is cache set?
455         if (!isset($GLOBALS[__FUNCTION__])) {
456                 // Simply check it
457                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
458         } // END - if
459
460         // Return it
461         return $GLOBALS[__FUNCTION__];
462 }
463
464 // Checks whether the debug monthly is enabled
465 function isDebugMonthlyEnabled () {
466         // Is cache set?
467         if (!isset($GLOBALS[__FUNCTION__])) {
468                 // Simply check it
469                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
470         } // END - if
471
472         // Return it
473         return $GLOBALS[__FUNCTION__];
474 }
475
476 // Checks whether the debug yearly is enabled
477 function isDebugYearlyEnabled () {
478         // Is cache set?
479         if (!isset($GLOBALS[__FUNCTION__])) {
480                 // Simply check it
481                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
482         } // END - if
483
484         // Return it
485         return $GLOBALS[__FUNCTION__];
486 }
487
488 // Checks whether SQL debugging is enabled
489 function isSqlDebuggingEnabled () {
490         // Is cache set?
491         if (!isset($GLOBALS[__FUNCTION__])) {
492                 // Determine if SQL debugging is enabled
493                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
494         } // END - if
495
496         // Return it
497         return $GLOBALS[__FUNCTION__];
498 }
499
500 // Checks whether we shall debug regular expressions
501 function isDebugRegularExpressionEnabled () {
502         // Is cache set?
503         if (!isset($GLOBALS[__FUNCTION__])) {
504                 // Simply check it
505                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
506         } // END - if
507
508         // Return it
509         return $GLOBALS[__FUNCTION__];
510 }
511
512 // Checks whether debugging of build mails is enabled
513 function isDebugBuildMailsEnabled () {
514         // Is cache set?
515         if (!isset($GLOBALS[__FUNCTION__])) {
516                 // Simply check it
517                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
518         } // END - if
519
520         // Return it
521         return $GLOBALS[__FUNCTION__];
522 }
523
524 // Checks whether the cache instance is valid
525 function isValidCacheInstance () {
526         // Is there cache?
527         if (!isset($GLOBALS[__FUNCTION__])) {
528                 // Determine it
529                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
530         } // END - if
531
532         // Return cache
533         return $GLOBALS[__FUNCTION__];
534 }
535
536 // Copies a file from source to destination and verifies if that goes fine.
537 // This function should wrap the copy() command and make a nicer debug backtrace
538 // even if there is no xdebug extension installed.
539 function copyFileVerified ($source, $dest, $chmod = '') {
540         // Failed is the default
541         $status = FALSE;
542
543         // Is the source file there?
544         if (!isFileReadable($source)) {
545                 // Then abort here
546                 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
547         } // END - if
548
549         // Is the target directory there?
550         if (!isDirectory(dirname($dest))) {
551                 // Then abort here
552                 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
553         } // END - if
554
555         // Now try to copy it
556         if (!copy($source, $dest)) {
557                 // Something went wrong
558                 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
559         } else {
560                 // Reset cache
561                 $GLOBALS['file_readable'][$dest] = TRUE;
562         }
563
564         // All fine by default
565         $status = TRUE;
566
567         // If there are chmod rights set, apply them
568         if (!empty($chmod)) {
569                 // Try to apply them
570                 $status = changeMode($dest, $chmod);
571         } // END - if
572
573         // All fine
574         return $status;
575 }
576
577 // Wrapper function for chmod()
578 // @TODO Do some more sanity check here
579 function changeMode ($FQFN, $mode) {
580         // Is the file/directory there?
581         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
582                 // Neither, so abort here
583                 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
584         } // END - if
585
586         // Try to set them
587         return chmod($FQFN, $mode);
588 }
589
590 // Wrapper for unlink()
591 function removeFile ($FQFN) {
592         // Is the file there?
593         if (isFileReadable($FQFN)) {
594                 // Reset cache first
595                 $GLOBALS['file_readable'][$FQFN] = FALSE;
596
597                 // Yes, so remove it
598                 return unlink($FQFN);
599         } // END - if
600
601         // All fine if no file was removed. If we change this to 'false' or rewrite
602         // above if() block it would be to restrictive.
603         return TRUE;
604 }
605
606 // Wrapper for $_POST['sel']
607 function countPostSelection ($element = 'sel') {
608         // Is there cache?
609         if (!isset($GLOBALS[__FUNCTION__][$element])) {
610                 // Default is zero
611                 $GLOBALS[__FUNCTION__][$element] = '0';
612
613                 // Is it set?
614                 if (isPostRequestElementSet($element)) {
615                         // Return counted elements
616                         $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
617                 } // END - if
618         } // END - if
619
620         // Return cached value
621         return $GLOBALS[__FUNCTION__][$element];
622 }
623
624 // Checks whether the config-local.php is loaded
625 function isConfigLocalLoaded () {
626         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
627 }
628
629 // Checks whether a nickname or userid was entered and caches the result
630 function isNicknameUsed ($userid) {
631         // Is the cache there
632         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
633                 // Determine it
634                 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
635         } // END - if
636
637         // Return the result
638         return $GLOBALS[__FUNCTION__][$userid];
639 }
640
641 // Getter for 'what' value
642 function getWhat ($strict = TRUE) {
643         // Default is null
644         $what = NULL;
645
646         // Is the value set?
647         if (isWhatSet($strict)) {
648                 // Then use it
649                 $what = $GLOBALS['__what'];
650         } // END - if
651
652         // Return it
653         return $what;
654 }
655
656 // Setter for 'what' value
657 function setWhat ($newWhat) {
658         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
659         $GLOBALS['__what'] = $newWhat;
660 }
661
662 // Setter for 'what' from configuration
663 function setWhatFromConfig ($configEntry) {
664         // Get 'what' from config
665         $what = getConfig($configEntry);
666
667         // Set it
668         setWhat($what);
669 }
670
671 // Checks whether what is set and optionally aborts on miss
672 function isWhatSet ($strict = FALSE) {
673         // Check for it
674         $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
675
676         // Should we abort here?
677         if (($strict === TRUE) && ($isset === FALSE)) {
678                 // Output backtrace
679                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
680         } // END - if
681
682         // Return it
683         return $isset;
684 }
685
686 // Getter for 'action' value
687 function getAction ($strict = TRUE) {
688         // Default is null
689         $action = NULL;
690
691         // Is the value set?
692         if (isActionSet(($strict) && (isHtmlOutputMode()))) {
693                 // Then use it
694                 $action = $GLOBALS['__action'];
695         } // END - if
696
697         // Return it
698         return $action;
699 }
700
701 // Setter for 'action' value
702 function setAction ($newAction) {
703         $GLOBALS['__action'] = $newAction;
704 }
705
706 // Checks whether action is set and optionally aborts on miss
707 function isActionSet ($strict = FALSE) {
708         // Check for it
709         $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
710
711         // Should we abort here?
712         if (($strict === TRUE) && ($isset === FALSE)) {
713                 // Output backtrace
714                 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
715         } // END - if
716
717         // Return it
718         return $isset;
719 }
720
721 // Getter for 'module' value
722 function getModule ($strict = TRUE) {
723         // Default is null
724         $module = NULL;
725
726         // Is the value set?
727         if (isModuleSet($strict)) {
728                 // Then use it
729                 $module = $GLOBALS['__module'];
730         } // END - if
731
732         // Return it
733         return $module;
734 }
735
736 // Setter for 'module' value
737 function setModule ($newModule) {
738         // Secure it and make all modules lower-case
739         $GLOBALS['__module'] = strtolower($newModule);
740 }
741
742 // Wrapper to get extra module names
743 function getExtraModule () {
744         // Default is 'NULL'
745         $extra = 'NULL';
746
747         // Is 'tab/step' set?
748         if (isPostRequestElementSet('tab')) {
749                 // Use this
750                 $extra = 'tab=' . postRequestElement('tab');
751         } elseif (isPostRequestElementSet('step')) {
752                 // Use this
753                 $extra = 'step=' . postRequestElement('step');
754         } elseif ((isActionSet()) && (isWhatSet())) {
755                 // Use 'action/what'
756                 $extra = 'action=' . getAction() . ':what=' . getWhat();
757         }
758
759         // Return it
760         return $extra;
761 }
762
763 // Checks whether module is set and optionally aborts on miss
764 function isModuleSet ($strict = FALSE) {
765         // Check for it
766         $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
767
768         // Should we abort here?
769         if (($strict === TRUE) && ($isset === FALSE)) {
770                 // Output backtrace
771                 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
772         } // END - if
773
774         // Return it
775         return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
776 }
777
778 // Getter for 'output_mode' value
779 function getScriptOutputMode () {
780         // Is cache set?
781         if (!isset($GLOBALS[__FUNCTION__])) {
782                 // Is the output mode set?
783                 if (!isOutputModeSet()) {
784                         // No, then abort here
785                         reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
786                 } // END - if
787
788                 // Set it in cache
789                 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
790         } // END - if
791
792         // Return cache
793         return $GLOBALS[__FUNCTION__];
794 }
795
796 // Setter for 'output_mode' value
797 function setScriptOutputMode ($newOutputMode) {
798         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
799         $GLOBALS['__output_mode'] = (int) $newOutputMode;
800 }
801
802 // Checks whether output_mode is set and optionally aborts on miss
803 function isOutputModeSet ($strict = FALSE) {
804         // Check for it
805         $isset = (isset($GLOBALS['__output_mode']));
806
807         // Should we abort here?
808         if (($strict === TRUE) && ($isset === FALSE)) {
809                 // Output backtrace
810                 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
811         } // END - if
812
813         // Return it
814         return $isset;
815 }
816
817 // Enables block-mode
818 function enableBlockMode ($enabled = TRUE) {
819         $GLOBALS['__block_mode'] = $enabled;
820 }
821
822 // Checks whether block-mode is enabled
823 function isBlockModeEnabled () {
824         // Abort if not set
825         if (!isset($GLOBALS['__block_mode'])) {
826                 // Needs to be fixed
827                 reportBug(__FUNCTION__, __LINE__, '__block_mode is not set.');
828         } // END - if
829
830         // Return it
831         return $GLOBALS['__block_mode'];
832 }
833
834 // Wrapper for redirectToUrl but URL comes from a configuration entry
835 function redirectToConfiguredUrl ($configEntry) {
836         // Load the URL
837         redirectToUrl(getConfig($configEntry));
838 }
839
840 // Wrapper function to redirect from member-only modules to index
841 function redirectToIndexMemberOnlyModule () {
842         // Do the redirect here
843         redirectToUrl('modules.php?module=index&amp;code=' . getCode('MODULE_MEMBER_ONLY') . '&amp;mod=' . getModule());
844 }
845
846 // Wrapper function to redirect to current URL
847 function redirectToRequestUri () {
848         redirectToUrl(basename(detectRequestUri()));
849 }
850
851 // Wrapper function to redirect to de-refered URL
852 function redirectToDereferedUrl ($url) {
853         // Redirect to to
854         redirectToUrl(generateDereferrerUrl($url));
855 }
856
857 // Wrapper function for checking if extension is installed and newer or same version
858 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
859         // Is an cache entry found?
860         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
861                 // Determine it
862                 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
863         } else {
864                 // Cache hits should be incremented twice
865                 incrementStatsEntry('cache_hits', 2);
866         }
867
868         // Return it
869         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=&gt;' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
870         return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
871 }
872
873 // Wrapper function for checking if extension is installed and older than given version
874 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
875         // Is an cache entry found?
876         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
877                 // Determine it
878                 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
879         } else {
880                 // Cache hits should be incremented twice
881                 incrementStatsEntry('cache_hits', 2);
882         }
883
884         // Return it
885         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '&lt;' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
886         return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
887 }
888
889 // Set username
890 function setUsername ($userName) {
891         $GLOBALS['username'] = (string) $userName;
892 }
893
894 // Get username
895 function getUsername () {
896         // User name set?
897         if (!isset($GLOBALS['username'])) {
898                 // No, so it has to be a guest
899                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
900         } // END - if
901
902         // Return it
903         return $GLOBALS['username'];
904 }
905
906 // Wrapper function for installation phase
907 function isInstaller () {
908         // Is there cache?
909         if (!isset($GLOBALS[__FUNCTION__])) {
910                 // Determine it
911                 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
912         } // END - if
913
914         // Return result
915         return $GLOBALS[__FUNCTION__];
916 }
917
918 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
919 function isDemoModeActive () {
920         // Is cache set?
921         if (!isset($GLOBALS[__FUNCTION__])) {
922                 // Simply check it
923                 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
924         } // END - if
925
926         // Return it
927         return $GLOBALS[__FUNCTION__];
928 }
929
930 // Getter for PHP caching value
931 function getPhpCaching () {
932         return $GLOBALS['php_caching'];
933 }
934
935 // Checks whether the admin hash is set
936 function isAdminHashSet ($adminId) {
937         // Is the array there?
938         if (!isset($GLOBALS['cache_array']['admin'])) {
939                 // Missing array should be reported
940                 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
941         } // END - if
942
943         // Check for admin hash
944         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
945 }
946
947 // Setter for admin hash
948 function setAdminHash ($adminId, $hash) {
949         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
950 }
951
952 // Getter for current admin login
953 function getCurrentAdminLogin () {
954         // Log debug message
955         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
956
957         // Is there cache?
958         if (!isset($GLOBALS[__FUNCTION__])) {
959                 // Determine it
960                 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
961         } // END - if
962
963         // Return it
964         return $GLOBALS[__FUNCTION__];
965 }
966
967 // Setter for admin id (and current)
968 function setAdminId ($adminId) {
969         // Log debug message
970         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
971
972         // Set session
973         $status = setSession('admin_id', bigintval($adminId));
974
975         // Set current id
976         setCurrentAdminId($adminId);
977
978         // Return status
979         return $status;
980 }
981
982 // Setter for admin_last
983 function setAdminLast ($adminLast) {
984         // Log debug message
985         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
986
987         // Set session
988         $status = setSession('admin_last', $adminLast);
989
990         // Return status
991         return $status;
992 }
993
994 // Setter for admin_md5
995 function setAdminMd5 ($adminMd5) {
996         // Log debug message
997         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
998
999         // Set session
1000         $status = setSession('admin_md5', $adminMd5);
1001
1002         // Remove cache to get correct results
1003         unset($GLOBALS['isAdmin']);
1004
1005         // Return status
1006         return $status;
1007 }
1008
1009 // Getter for admin_md5
1010 function getAdminMd5 () {
1011         // Log debug message
1012         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1013
1014         // Get session
1015         return getSession('admin_md5');
1016 }
1017
1018 // Init user data array
1019 function initUserData () {
1020         // User id should not be zero
1021         if (!isValidId(getCurrentUserId())) {
1022                 // Should be always valid
1023                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1024         } // END - if
1025
1026         // Init the user
1027         unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1028         $GLOBALS['user_data'][getCurrentUserId()] = array();
1029 }
1030
1031 // Getter for user data
1032 function getUserData ($column) {
1033         // User id should not be zero
1034         if (!isValidId(getCurrentUserId())) {
1035                 // Should be always valid
1036                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1037         } // END - if
1038
1039         // Default is empty
1040         $data = NULL;
1041
1042         if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1043                 // Return the value
1044                 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1045         } // END - if
1046
1047         // Return it
1048         return $data;
1049 }
1050
1051 // Checks whether given user data is set to 'Y'
1052 function isUserDataEnabled ($column) {
1053         // Is there cache?
1054         if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1055                 // Determine it
1056                 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1057         } // END - if
1058
1059         // Return cache
1060         return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1061 }
1062
1063 // Geter for whole user data array
1064 function getUserDataArray () {
1065         // Get user id
1066         $userid = getCurrentUserId();
1067
1068         // Is the current userid valid?
1069         if (!isValidId($userid)) {
1070                 // Should be always valid
1071                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1072         } // END - if
1073
1074         // Get the whole array if found
1075         if (isset($GLOBALS['user_data'][$userid])) {
1076                 // Found, so return it
1077                 return $GLOBALS['user_data'][$userid];
1078         } else {
1079                 // Return empty array
1080                 return array();
1081         }
1082 }
1083
1084 // Checks if the user data is valid, this may indicate that the user has logged
1085 // in, but you should use isMember() if you want to find that out.
1086 function isValidUserData () {
1087         // User id should not be zero so abort here
1088         if (!isCurrentUserIdSet()) {
1089                 // Debug message, may be noisy
1090                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1091
1092                 // Abort here
1093                 return FALSE;
1094         } // END - if
1095
1096         // Is it cached?
1097         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1098                 // Determine it
1099                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1100         } // END - if
1101
1102         // Return the result
1103         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1104 }
1105
1106 // Setter for current userid
1107 function setCurrentUserId ($userid) {
1108         // Debug message
1109         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1110
1111         // Is the cache from below functions different?
1112         if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1113                 // Then unset both
1114                 unsetCurrentUserId();
1115         } // END - if
1116
1117         // Set userid
1118         $GLOBALS['current_userid'] = bigintval($userid);
1119
1120         // Unset it to re-determine the actual state
1121         unset($GLOBALS['is_userdata_valid'][$userid]);
1122
1123         // Debug message
1124         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1125 }
1126
1127 // Getter for current userid
1128 function getCurrentUserId () {
1129         // Is cache set?
1130         if (!isset($GLOBALS[__FUNCTION__])) {
1131                 // Userid must be set before it can be used
1132                 if (!isCurrentUserIdSet()) {
1133                         // Not set
1134                         reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1135                 } // END - if
1136
1137                 // Set userid in cache
1138                 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1139         } // END - if
1140
1141         // Return cache
1142         return $GLOBALS[__FUNCTION__];
1143 }
1144
1145 // Checks if current userid is set
1146 function isCurrentUserIdSet () {
1147         // Is there cache?
1148         if (!isset($GLOBALS[__FUNCTION__])) {
1149                 // Determine it
1150                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1151         } // END - if
1152
1153         // Return cache
1154         return $GLOBALS[__FUNCTION__];
1155 }
1156
1157 // Unsets current userid
1158 function unsetCurrentUserId () {
1159         // Is it set?
1160         if (isset($GLOBALS['current_userid'])) {
1161                 // Unset this, too
1162                 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1163         } // END - if
1164
1165         // Unset all cache entries
1166         unset($GLOBALS['current_userid']);
1167         unset($GLOBALS['getCurrentUserId']);
1168         unset($GLOBALS['isCurrentUserIdSet']);
1169 }
1170
1171 // Checks whether we are debugging template cache
1172 function isDebugTemplateCacheEnabled () {
1173         // Is there cache?
1174         if (!isset($GLOBALS[__FUNCTION__])) {
1175                 // Determine it
1176                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_TEMPLATE_CACHE')) && (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'));
1177         } // END - if
1178
1179         // Return cache
1180         return $GLOBALS[__FUNCTION__];
1181 }
1182
1183 // Wrapper for fetchUserData() and getUserData() calls
1184 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1185         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1186         // Is it cached?
1187         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1188                 // Default is NULL
1189                 $data = NULL;
1190
1191                 // Can we fetch the user data?
1192                 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1193                         // Now get the data back
1194                         $data = getUserData($valueColumn);
1195                 } // END - if
1196
1197                 // Cache it
1198                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1199         } // END - if
1200
1201         // Return it
1202         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1203         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1204 }
1205
1206 // Wrapper for strpos() to ease porting from deprecated ereg() function
1207 function isInString ($needle, $haystack) {
1208         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1209         return (strpos($haystack, $needle) !== FALSE);
1210 }
1211
1212 // Wrapper for strpos() to ease porting from deprecated eregi() function
1213 // This function is case-insensitive
1214 function isInStringIgnoreCase ($needle, $haystack) {
1215         return (isInString(strtolower($needle), strtolower($haystack)));
1216 }
1217
1218 // Wrapper to check for if fatal errors where detected
1219 function ifFatalErrorsDetected () {
1220         // Just call the inner function
1221         return (getTotalFatalErrors() > 0);
1222 }
1223
1224 // Checks whether a HTTP status has been set
1225 function isHttpStatusSet () {
1226         // Is it set and not empty?
1227         return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1228 }
1229
1230 // Setter for HTTP status
1231 function setHttpStatus ($status) {
1232         $GLOBALS['http_status'] = (string) $status;
1233 }
1234
1235 // Getter for HTTP status
1236 function getHttpStatus () {
1237         // Is the status set?
1238         if (!isHttpStatusSet()) {
1239                 // Abort here
1240                 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1241         } // END - if
1242
1243         // Return it
1244         return $GLOBALS['http_status'];
1245 }
1246
1247 /**
1248  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1249  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1250  *
1251  * ----------------------------------------------------------------------------
1252  * If you want to redirect, please use redirectToUrl(); instead
1253  * ----------------------------------------------------------------------------
1254  *
1255  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1256  *
1257  * @link    http://support.microsoft.com/kb/q176113/
1258  * @author  Andreas Gohr <andi@splitbrain.org>
1259  * @access  private
1260  */
1261 function sendRawRedirect ($url) {
1262         // Clear output buffer
1263         clearOutputBuffer();
1264
1265         // Clear own output buffer
1266         $GLOBALS['__output'] = '';
1267
1268         // To make redirects working (no content type), output mode must be raw
1269         setScriptOutputMode(-1);
1270
1271         // Send helping header
1272         setHttpStatus('302 Found');
1273
1274         // always close the session
1275         session_write_close();
1276
1277         // Revert entity &amp;
1278         $url = str_replace('&amp;', '&', $url);
1279
1280         // check if running on IIS < 6 with CGI-PHP
1281         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1282                 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1283                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1284                 ($matches[1] < 6)) {
1285                 // Send the IIS header
1286                 addHttpHeader('Refresh: 0;url=' . $url);
1287         } else {
1288                 // Send generic header
1289                 addHttpHeader('Location: ' . $url);
1290         }
1291
1292         // Shutdown here
1293         doShutdown();
1294 }
1295
1296 // Determines the country of the given user id
1297 function determineCountry ($userid) {
1298         // Is there cache?
1299         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1300                 // Default is 'invalid'
1301                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1302
1303                 // Is extension country active?
1304                 if (isExtensionActive('country')) {
1305                         // Determine the right country code through the country id
1306                         $id = getUserData('country_code');
1307
1308                         // Then handle it over
1309                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1310                 } else {
1311                         // Get raw code from user data
1312                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1313                 }
1314         } // END - if
1315
1316         // Return cache
1317         return $GLOBALS[__FUNCTION__][$userid];
1318 }
1319
1320 // "Getter" for total confirmed user accounts
1321 function getTotalConfirmedUser () {
1322         // Is it cached?
1323         if (!isset($GLOBALS[__FUNCTION__])) {
1324                 // Then do it
1325                 if (isExtensionActive('user')) {
1326                         $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1327                 } else {
1328                         $GLOBALS[__FUNCTION__] = 0;
1329                 }
1330         } // END - if
1331
1332         // Return cached value
1333         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1334         return $GLOBALS[__FUNCTION__];
1335 }
1336
1337 // "Getter" for total unconfirmed user accounts
1338 function getTotalUnconfirmedUser () {
1339         // Is it cached?
1340         if (!isset($GLOBALS[__FUNCTION__])) {
1341                 // Then do it
1342                 if (isExtensionActive('user')) {
1343                         $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1344                 } else {
1345                         $GLOBALS[__FUNCTION__] = 0;
1346                 }
1347         } // END - if
1348
1349         // Return cached value
1350         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1351         return $GLOBALS[__FUNCTION__];
1352 }
1353
1354 // "Getter" for total locked user accounts
1355 function getTotalLockedUser () {
1356         // Is it cached?
1357         if (!isset($GLOBALS[__FUNCTION__])) {
1358                 // Then do it
1359                 if (isExtensionActive('user')) {
1360                         $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1361                 } else {
1362                         $GLOBALS[__FUNCTION__] = 0;
1363                 }
1364         } // END - if
1365
1366         // Return cached value
1367         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1368         return $GLOBALS[__FUNCTION__];
1369 }
1370
1371 // "Getter" for total locked user accounts
1372 function getTotalRandomRefidUser () {
1373         // Is it cached?
1374         if (!isset($GLOBALS[__FUNCTION__])) {
1375                 // Then do it
1376                 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1377                         $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1378                 } else {
1379                         $GLOBALS[__FUNCTION__] = 0;
1380                 }
1381         } // END - if
1382
1383         // Return cached value
1384         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1385         return $GLOBALS[__FUNCTION__];
1386 }
1387
1388 // Is given id number valid?
1389 function isValidId ($id) {
1390         // Debug message
1391         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1392
1393         // Is there cache?
1394         if (!isset($GLOBALS[__FUNCTION__][$id])) {
1395                 // Check it out
1396                 $GLOBALS[__FUNCTION__][$id] = ((isValidNumber($id)) && (!is_bool($id)) && ($id != '00000') && ($id > 0));
1397         } // END - if
1398
1399         // Return cache
1400         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1401         return $GLOBALS[__FUNCTION__][$id];
1402 }
1403
1404 // Checks whether a valid number is given
1405 function isValidNumber ($num) {
1406         // Determine it
1407         return ((!is_null($num)) && (!empty($num)) && ('*' . bigintval($num, TRUE, FALSE) . '*' == '*' . $num . '*'));
1408 }
1409
1410 // Encodes entities
1411 function encodeEntities ($str) {
1412         // Secure it first
1413         $str = secureString($str, TRUE, TRUE);
1414
1415         // Encode dollar sign as well
1416         $str = str_replace('$', '&#36;', $str);
1417
1418         // Return it
1419         return $str;
1420 }
1421
1422 // Getter for current year (default)
1423 function getYear ($timestamp = NULL) {
1424         // Is it cached?
1425         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1426                 // If NULL is set, use time()
1427                 if (is_null($timestamp)) {
1428                         $timestamp = time();
1429                 } // END - if
1430
1431                 // Then create it
1432                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1433         } // END - if
1434
1435         // Return cache
1436         return $GLOBALS[__FUNCTION__][$timestamp];
1437 }
1438
1439 // Getter for current month (default)
1440 function getMonth ($timestamp = NULL) {
1441         // Is it cached?
1442         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1443                 // If NULL is set, use time()
1444                 if (is_null($timestamp)) {
1445                         // Use time() which is current timestamp
1446                         $timestamp = time();
1447                 } // END - if
1448
1449                 // Then create it
1450                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1451         } // END - if
1452
1453         // Return cache
1454         return $GLOBALS[__FUNCTION__][$timestamp];
1455 }
1456
1457 // Getter for current hour (default)
1458 function getHour ($timestamp = NULL) {
1459         // Is it cached?
1460         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1461                 // null is time()
1462                 if (is_null($timestamp)) {
1463                         $timestamp = time();
1464                 } // END - if
1465
1466                 // Then create it
1467                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1468         } // END - if
1469
1470         // Return cache
1471         return $GLOBALS[__FUNCTION__][$timestamp];
1472 }
1473
1474 // Getter for current day (default)
1475 function getDay ($timestamp = NULL) {
1476         // Is it cached?
1477         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1478                 // null is time()
1479                 if (is_null($timestamp)) {
1480                         $timestamp = time();
1481                 } // END - if
1482
1483                 // Then create it
1484                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1485         } // END - if
1486
1487         // Return cache
1488         return $GLOBALS[__FUNCTION__][$timestamp];
1489 }
1490
1491 // Getter for current week (default)
1492 function getWeek ($timestamp = NULL) {
1493         // Is it cached?
1494         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1495                 // null is time()
1496                 if (is_null($timestamp)) $timestamp = time();
1497
1498                 // Then create it
1499                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1500         } // END - if
1501
1502         // Return cache
1503         return $GLOBALS[__FUNCTION__][$timestamp];
1504 }
1505
1506 // Getter for current short_hour (default)
1507 function getShortHour ($timestamp = NULL) {
1508         // Is it cached?
1509         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1510                 // null is time()
1511                 if (is_null($timestamp)) $timestamp = time();
1512
1513                 // Then create it
1514                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1515         } // END - if
1516
1517         // Return cache
1518         return $GLOBALS[__FUNCTION__][$timestamp];
1519 }
1520
1521 // Getter for current long_hour (default)
1522 function getLongHour ($timestamp = NULL) {
1523         // Is it cached?
1524         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1525                 // null is time()
1526                 if (is_null($timestamp)) $timestamp = time();
1527
1528                 // Then create it
1529                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1530         } // END - if
1531
1532         // Return cache
1533         return $GLOBALS[__FUNCTION__][$timestamp];
1534 }
1535
1536 // Getter for current second (default)
1537 function getSecond ($timestamp = NULL) {
1538         // Is it cached?
1539         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1540                 // null is time()
1541                 if (is_null($timestamp)) $timestamp = time();
1542
1543                 // Then create it
1544                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1545         } // END - if
1546
1547         // Return cache
1548         return $GLOBALS[__FUNCTION__][$timestamp];
1549 }
1550
1551 // Getter for current minute (default)
1552 function getMinute ($timestamp = NULL) {
1553         // Is it cached?
1554         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1555                 // null is time()
1556                 if (is_null($timestamp)) $timestamp = time();
1557
1558                 // Then create it
1559                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1560         } // END - if
1561
1562         // Return cache
1563         return $GLOBALS[__FUNCTION__][$timestamp];
1564 }
1565
1566 // Checks whether the title decoration is enabled
1567 function isTitleDecorationEnabled () {
1568         // Is there cache?
1569         if (!isset($GLOBALS[__FUNCTION__])) {
1570                 // Just check it
1571                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_title_deco')) && (getConfig('enable_title_deco') == 'Y'));
1572         } // END - if
1573
1574         // Return cache
1575         return $GLOBALS[__FUNCTION__];
1576 }
1577
1578 // Checks whether filter usage updates are enabled (expensive queries!)
1579 function isFilterUsageUpdateEnabled () {
1580         // Is there cache?
1581         if (!isset($GLOBALS[__FUNCTION__])) {
1582                 // Determine it
1583                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1584         } // END - if
1585
1586         // Return cache
1587         return $GLOBALS[__FUNCTION__];
1588 }
1589
1590 // Checks whether debugging of weekly resets is enabled
1591 function isWeeklyResetDebugEnabled () {
1592         // Is there cache?
1593         if (!isset($GLOBALS[__FUNCTION__])) {
1594                 // Determine it
1595                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1596         } // END - if
1597
1598         // Return cache
1599         return $GLOBALS[__FUNCTION__];
1600 }
1601
1602 // Checks whether debugging of monthly resets is enabled
1603 function isMonthlyResetDebugEnabled () {
1604         // Is there cache?
1605         if (!isset($GLOBALS[__FUNCTION__])) {
1606                 // Determine it
1607                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1608         } // END - if
1609
1610         // Return cache
1611         return $GLOBALS[__FUNCTION__];
1612 }
1613
1614 // Checks whether debugging of yearly resets is enabled
1615 function isYearlyResetDebugEnabled () {
1616         // Is there cache?
1617         if (!isset($GLOBALS[__FUNCTION__])) {
1618                 // Determine it
1619                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
1620         } // END - if
1621
1622         // Return cache
1623         return $GLOBALS[__FUNCTION__];
1624 }
1625
1626 // Checks whether displaying of debug SQLs are enabled
1627 function isDisplayDebugSqlEnabled () {
1628         // Is there cache?
1629         if (!isset($GLOBALS[__FUNCTION__])) {
1630                 // Determine it
1631                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (isConfigEntrySet('display_debug_sql')) && (getDisplayDebugSqls() == 'Y'));
1632         } // END - if
1633
1634         // Return cache
1635         return $GLOBALS[__FUNCTION__];
1636 }
1637
1638 // Checks whether module title is enabled
1639 function isModuleTitleEnabled () {
1640         // Is there cache?
1641         if (!isset($GLOBALS[__FUNCTION__])) {
1642                 // Determine it
1643                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_mod_title')) && (getConfig('enable_mod_title') == 'Y'));
1644         } // END - if
1645
1646         // Return cache
1647         return $GLOBALS[__FUNCTION__];
1648 }
1649
1650 // Checks whether what title is enabled
1651 function isWhatTitleEnabled () {
1652         // Is there cache?
1653         if (!isset($GLOBALS[__FUNCTION__])) {
1654                 // Determine it
1655                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_what_title')) && (getConfig('enable_what_title') == 'Y'));
1656         } // END - if
1657
1658         // Return cache
1659         return $GLOBALS[__FUNCTION__];
1660 }
1661
1662 // "Getter" for internal_stats
1663 function getInternalStats () {
1664         // Is there cache?
1665         if (!isset($GLOBALS[__FUNCTION__])) {
1666                 // Determine it
1667                 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1668         } // END - if
1669
1670         // Return cache
1671         return $GLOBALS[__FUNCTION__];
1672 }
1673
1674 // Checks whether stats are enabled
1675 function ifInternalStatsEnabled () {
1676         // Is there cache?
1677         if (!isset($GLOBALS[__FUNCTION__])) {
1678                 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1679                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1680         } // END - if
1681
1682         // Return cached value
1683         return $GLOBALS[__FUNCTION__];
1684 }
1685
1686 // Checks whether admin-notification of certain user actions is enabled
1687 function isAdminNotificationEnabled () {
1688         // Is there cache?
1689         if (!isset($GLOBALS[__FUNCTION__])) {
1690                 // Determine it
1691                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isConfigEntrySet('admin_notify')) && (getAdminNotify() == 'Y'));
1692         } // END - if
1693
1694         // Return cache
1695         return $GLOBALS[__FUNCTION__];
1696 }
1697
1698 // Checks whether random referral id selection is enabled
1699 function isRandomReferralIdEnabled () {
1700         // Is there cache?
1701         if (!isset($GLOBALS[__FUNCTION__])) {
1702                 // Determine it
1703                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isConfigEntrySet('select_user_zero_refid')) && (getSelectUserZeroRefid() == 'Y'));
1704         } // END - if
1705
1706         // Return cache
1707         return $GLOBALS[__FUNCTION__];
1708 }
1709
1710 // "Getter" for default language
1711 function getDefaultLanguage () {
1712         // Is there cache?
1713         if (!isset($GLOBALS[__FUNCTION__])) {
1714                 // Determine it
1715                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1716         } // END - if
1717
1718         // Return cache
1719         return $GLOBALS[__FUNCTION__];
1720 }
1721
1722 // "Getter" for default referral id
1723 function getDefRefid () {
1724         // Is there cache?
1725         if (!isset($GLOBALS[__FUNCTION__])) {
1726                 // Determine it
1727                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1728         } // END - if
1729
1730         // Return cache
1731         return $GLOBALS[__FUNCTION__];
1732 }
1733
1734 // "Getter" for path
1735 function getPath () {
1736         // Is there cache?
1737         if (!isset($GLOBALS[__FUNCTION__])) {
1738                 // Determine it
1739                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1740         } // END - if
1741
1742         // Return cache
1743         return $GLOBALS[__FUNCTION__];
1744 }
1745
1746 // "Getter" for url
1747 function getUrl () {
1748         // Is there cache?
1749         if (!isset($GLOBALS[__FUNCTION__])) {
1750                 // Determine it
1751                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1752         } // END - if
1753
1754         // Return cache
1755         return $GLOBALS[__FUNCTION__];
1756 }
1757
1758 // "Getter" for cache_path
1759 function getCachePath () {
1760         // Is there cache?
1761         if (!isset($GLOBALS[__FUNCTION__])) {
1762                 // Determine it
1763                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1764         } // END - if
1765
1766         // Return cache
1767         return $GLOBALS[__FUNCTION__];
1768 }
1769
1770 // "Getter" for cache_extension
1771 function getCacheExtension () {
1772         // Is there cache?
1773         if (!isset($GLOBALS[__FUNCTION__])) {
1774                 // Determine it
1775                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_EXTENSION');
1776         } // END - if
1777
1778         // Return cache
1779         return $GLOBALS[__FUNCTION__];
1780 }
1781
1782 // "Getter" for WRITE_FOOTER
1783 function getWriteFooter () {
1784         // Is there cache?
1785         if (!isset($GLOBALS[__FUNCTION__])) {
1786                 // Determine it
1787                 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1788         } // END - if
1789
1790         // Return cache
1791         return $GLOBALS[__FUNCTION__];
1792 }
1793
1794 // "Getter" for secret_key
1795 function getSecretKey () {
1796         // Is there cache?
1797         if (!isset($GLOBALS[__FUNCTION__])) {
1798                 // Determine it
1799                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1800         } // END - if
1801
1802         // Return cache
1803         return $GLOBALS[__FUNCTION__];
1804 }
1805
1806 // "Getter" for SITE_KEY
1807 function getSiteKey () {
1808         // Is there cache?
1809         if (!isset($GLOBALS[__FUNCTION__])) {
1810                 // Determine it
1811                 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1812         } // END - if
1813
1814         // Return cache
1815         return $GLOBALS[__FUNCTION__];
1816 }
1817
1818 // "Getter" for DATE_KEY
1819 function getDateKey () {
1820         // Is there cache?
1821         if (!isset($GLOBALS[__FUNCTION__])) {
1822                 // Determine it
1823                 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1824         } // END - if
1825
1826         // Return cache
1827         return $GLOBALS[__FUNCTION__];
1828 }
1829
1830 // "Getter" for master_salt
1831 function getMasterSalt () {
1832         // Is there cache?
1833         if (!isset($GLOBALS[__FUNCTION__])) {
1834                 // Determine it
1835                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1836         } // END - if
1837
1838         // Return cache
1839         return $GLOBALS[__FUNCTION__];
1840 }
1841
1842 // "Getter" for prime
1843 function getPrime () {
1844         // Is there cache?
1845         if (!isset($GLOBALS[__FUNCTION__])) {
1846                 // Determine it
1847                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1848         } // END - if
1849
1850         // Return cache
1851         return $GLOBALS[__FUNCTION__];
1852 }
1853
1854 // "Getter" for encrypt_separator
1855 function getEncryptSeparator () {
1856         // Is there cache?
1857         if (!isset($GLOBALS[__FUNCTION__])) {
1858                 // Determine it
1859                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1860         } // END - if
1861
1862         // Return cache
1863         return $GLOBALS[__FUNCTION__];
1864 }
1865
1866 // "Getter" for mysql_prefix
1867 function getMysqlPrefix () {
1868         // Is there cache?
1869         if (!isset($GLOBALS[__FUNCTION__])) {
1870                 // Determine it
1871                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1872         } // END - if
1873
1874         // Return cache
1875         return $GLOBALS[__FUNCTION__];
1876 }
1877
1878 // "Getter" for table_type
1879 function getTableType () {
1880         // Is there cache?
1881         if (!isset($GLOBALS[__FUNCTION__])) {
1882                 // Determine it
1883                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1884         } // END - if
1885
1886         // Return cache
1887         return $GLOBALS[__FUNCTION__];
1888 }
1889
1890 // "Getter" for db_type
1891 function getDbType () {
1892         // Is there cache?
1893         if (!isset($GLOBALS[__FUNCTION__])) {
1894                 // Determine it
1895                 $GLOBALS[__FUNCTION__] = getConfig('_DB_TYPE');
1896         } // END - if
1897
1898         // Return cache
1899         return $GLOBALS[__FUNCTION__];
1900 }
1901
1902 // "Getter" for salt_length
1903 function getSaltLength () {
1904         // Is there cache?
1905         if (!isset($GLOBALS[__FUNCTION__])) {
1906                 // Determine it
1907                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1908         } // END - if
1909
1910         // Return cache
1911         return $GLOBALS[__FUNCTION__];
1912 }
1913
1914 // "Getter" for output_mode
1915 function getOutputMode () {
1916         // Is there cache?
1917         if (!isset($GLOBALS[__FUNCTION__])) {
1918                 // Determine it
1919                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1920         } // END - if
1921
1922         // Return cache
1923         return $GLOBALS[__FUNCTION__];
1924 }
1925
1926 // "Getter" for full_version
1927 function getFullVersion () {
1928         // Is there cache?
1929         if (!isset($GLOBALS[__FUNCTION__])) {
1930                 // Determine it
1931                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1932         } // END - if
1933
1934         // Return cache
1935         return $GLOBALS[__FUNCTION__];
1936 }
1937
1938 // "Getter" for title
1939 function getTitle () {
1940         // Is there cache?
1941         if (!isset($GLOBALS[__FUNCTION__])) {
1942                 // Determine it
1943                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1944         } // END - if
1945
1946         // Return cache
1947         return $GLOBALS[__FUNCTION__];
1948 }
1949
1950 // "Getter" for server_url
1951 function getServerUrl () {
1952         // Is there cache?
1953         if (!isset($GLOBALS[__FUNCTION__])) {
1954                 // Determine it
1955                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1956         } // END - if
1957
1958         // Return cache
1959         return $GLOBALS[__FUNCTION__];
1960 }
1961
1962 // "Getter" for mt_word
1963 function getMtWord () {
1964         // Is there cache?
1965         if (!isset($GLOBALS[__FUNCTION__])) {
1966                 // Determine it
1967                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1968         } // END - if
1969
1970         // Return cache
1971         return $GLOBALS[__FUNCTION__];
1972 }
1973
1974 // "Getter" for mt_word2
1975 function getMtWord2 () {
1976         // Is there cache?
1977         if (!isset($GLOBALS[__FUNCTION__])) {
1978                 // Determine it
1979                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1980         } // END - if
1981
1982         // Return cache
1983         return $GLOBALS[__FUNCTION__];
1984 }
1985
1986 // "Getter" for mt_word3
1987 function getMtWord3 () {
1988         // Is there cache?
1989         if (!isset($GLOBALS[__FUNCTION__])) {
1990                 // Determine it
1991                 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1992         } // END - if
1993
1994         // Return cache
1995         return $GLOBALS[__FUNCTION__];
1996 }
1997
1998 // "Getter" for START_TDAY
1999 function getStartTday () {
2000         // Is there cache?
2001         if (!isset($GLOBALS[__FUNCTION__])) {
2002                 // Determine it
2003                 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
2004         } // END - if
2005
2006         // Return cache
2007         return $GLOBALS[__FUNCTION__];
2008 }
2009
2010 // "Getter" for START_YDAY
2011 function getStartYday () {
2012         // Is there cache?
2013         if (!isset($GLOBALS[__FUNCTION__])) {
2014                 // Determine it
2015                 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
2016         } // END - if
2017
2018         // Return cache
2019         return $GLOBALS[__FUNCTION__];
2020 }
2021
2022 // "Getter" for main_title
2023 function getMainTitle () {
2024         // Is there cache?
2025         if (!isset($GLOBALS[__FUNCTION__])) {
2026                 // Determine it
2027                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2028         } // END - if
2029
2030         // Return cache
2031         return $GLOBALS[__FUNCTION__];
2032 }
2033
2034 // "Getter" for file_hash
2035 function getFileHash () {
2036         // Is there cache?
2037         if (!isset($GLOBALS[__FUNCTION__])) {
2038                 // Determine it
2039                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2040         } // END - if
2041
2042         // Return cache
2043         return $GLOBALS[__FUNCTION__];
2044 }
2045
2046 // "Getter" for pass_scramble
2047 function getPassScramble () {
2048         // Is there cache?
2049         if (!isset($GLOBALS[__FUNCTION__])) {
2050                 // Determine it
2051                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2052         } // END - if
2053
2054         // Return cache
2055         return $GLOBALS[__FUNCTION__];
2056 }
2057
2058 // "Getter" for ap_inactive_since
2059 function getApInactiveSince () {
2060         // Is there cache?
2061         if (!isset($GLOBALS[__FUNCTION__])) {
2062                 // Determine it
2063                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2064         } // END - if
2065
2066         // Return cache
2067         return $GLOBALS[__FUNCTION__];
2068 }
2069
2070 // "Getter" for user_min_confirmed
2071 function getUserMinConfirmed () {
2072         // Is there cache?
2073         if (!isset($GLOBALS[__FUNCTION__])) {
2074                 // Determine it
2075                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2076         } // END - if
2077
2078         // Return cache
2079         return $GLOBALS[__FUNCTION__];
2080 }
2081 // "Getter" for points
2082 function getPoints () {
2083         // Is there cache?
2084         if (!isset($GLOBALS[__FUNCTION__])) {
2085                 // Determine it
2086                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2087         } // END - if
2088
2089         // Return cache
2090         return $GLOBALS[__FUNCTION__];
2091 }
2092
2093 // "Getter" for slogan
2094 function getSlogan () {
2095         // Is there cache?
2096         if (!isset($GLOBALS[__FUNCTION__])) {
2097                 // Determine it
2098                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2099         } // END - if
2100
2101         // Return cache
2102         return $GLOBALS[__FUNCTION__];
2103 }
2104
2105 // "Getter" for copy
2106 function getCopy () {
2107         // Is there cache?
2108         if (!isset($GLOBALS[__FUNCTION__])) {
2109                 // Determine it
2110                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2111         } // END - if
2112
2113         // Return cache
2114         return $GLOBALS[__FUNCTION__];
2115 }
2116
2117 // "Getter" for webmaster
2118 function getWebmaster () {
2119         // Is there cache?
2120         if (!isset($GLOBALS[__FUNCTION__])) {
2121                 // Determine it
2122                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2123         } // END - if
2124
2125         // Return cache
2126         return $GLOBALS[__FUNCTION__];
2127 }
2128
2129 // "Getter" for sql_count
2130 function getSqlCount () {
2131         // Is there cache?
2132         if (!isset($GLOBALS[__FUNCTION__])) {
2133                 // Determine it
2134                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2135         } // END - if
2136
2137         // Return cache
2138         return $GLOBALS[__FUNCTION__];
2139 }
2140
2141 // "Getter" for num_templates
2142 function getNumTemplates () {
2143         // Is there cache?
2144         if (!isset($GLOBALS[__FUNCTION__])) {
2145                 // Determine it
2146                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2147         } // END - if
2148
2149         // Return cache
2150         return $GLOBALS[__FUNCTION__];
2151 }
2152
2153 // "Getter" for dns_cache_timeout
2154 function getDnsCacheTimeout () {
2155         // Is there cache?
2156         if (!isset($GLOBALS[__FUNCTION__])) {
2157                 // Determine it
2158                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2159         } // END - if
2160
2161         // Return cache
2162         return $GLOBALS[__FUNCTION__];
2163 }
2164
2165 // "Getter" for menu_blur_spacer
2166 function getMenuBlurSpacer () {
2167         // Is there cache?
2168         if (!isset($GLOBALS[__FUNCTION__])) {
2169                 // Determine it
2170                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2171         } // END - if
2172
2173         // Return cache
2174         return $GLOBALS[__FUNCTION__];
2175 }
2176
2177 // "Getter" for points_register
2178 function getPointsRegister () {
2179         // Is there cache?
2180         if (!isset($GLOBALS[__FUNCTION__])) {
2181                 // Determine it
2182                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2183         } // END - if
2184
2185         // Return cache
2186         return $GLOBALS[__FUNCTION__];
2187 }
2188
2189 // "Getter" for points_ref
2190 function getPointsRef () {
2191         // Is there cache?
2192         if (!isset($GLOBALS[__FUNCTION__])) {
2193                 // Determine it
2194                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2195         } // END - if
2196
2197         // Return cache
2198         return $GLOBALS[__FUNCTION__];
2199 }
2200
2201 // "Getter" for ref_payout
2202 function getRefPayout () {
2203         // Is there cache?
2204         if (!isset($GLOBALS[__FUNCTION__])) {
2205                 // Determine it
2206                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2207         } // END - if
2208
2209         // Return cache
2210         return $GLOBALS[__FUNCTION__];
2211 }
2212
2213 // "Getter" for online_timeout
2214 function getOnlineTimeout () {
2215         // Is there cache?
2216         if (!isset($GLOBALS[__FUNCTION__])) {
2217                 // Determine it
2218                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2219         } // END - if
2220
2221         // Return cache
2222         return $GLOBALS[__FUNCTION__];
2223 }
2224
2225 // "Getter" for index_home
2226 function getIndexHome () {
2227         // Is there cache?
2228         if (!isset($GLOBALS[__FUNCTION__])) {
2229                 // Determine it
2230                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2231         } // END - if
2232
2233         // Return cache
2234         return $GLOBALS[__FUNCTION__];
2235 }
2236
2237 // "Getter" for one_day
2238 function getOneDay () {
2239         // Is there cache?
2240         if (!isset($GLOBALS[__FUNCTION__])) {
2241                 // Determine it
2242                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2243         } // END - if
2244
2245         // Return cache
2246         return $GLOBALS[__FUNCTION__];
2247 }
2248
2249 // "Getter" for img_type
2250 function getImgType () {
2251         // Is there cache?
2252         if (!isset($GLOBALS[__FUNCTION__])) {
2253                 // Determine it
2254                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2255         } // END - if
2256
2257         // Return cache
2258         return $GLOBALS[__FUNCTION__];
2259 }
2260
2261 // "Getter" for code_length
2262 function getCodeLength () {
2263         // Is there cache?
2264         if (!isset($GLOBALS[__FUNCTION__])) {
2265                 // Determine it
2266                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2267         } // END - if
2268
2269         // Return cache
2270         return $GLOBALS[__FUNCTION__];
2271 }
2272
2273 // "Getter" for min_password_length
2274 function getMinPasswordLength () {
2275         // Is there cache?
2276         if (!isset($GLOBALS[__FUNCTION__])) {
2277                 // Determine it
2278                 $GLOBALS[__FUNCTION__] = getConfig('min_password_length');
2279         } // END - if
2280
2281         // Return cache
2282         return $GLOBALS[__FUNCTION__];
2283 }
2284
2285 // "Getter" for min_password_score
2286 function getMinPasswordScore () {
2287         // Is there cache?
2288         if (!isset($GLOBALS[__FUNCTION__])) {
2289                 // Determine it
2290                 $GLOBALS[__FUNCTION__] = getConfig('min_password_score');
2291         } // END - if
2292
2293         // Return cache
2294         return $GLOBALS[__FUNCTION__];
2295 }
2296
2297 // "Getter" for admin_menu
2298 function getAdminMenu () {
2299         // Is there cache?
2300         if (!isset($GLOBALS[__FUNCTION__])) {
2301                 // Determine it
2302                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2303         } // END - if
2304
2305         // Return cache
2306         return $GLOBALS[__FUNCTION__];
2307 }
2308
2309 // "Getter" for last_hourly
2310 function getLastHourly () {
2311         // Is there cache?
2312         if (!isset($GLOBALS[__FUNCTION__])) {
2313                 // Determine it
2314                 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2315         } // END - if
2316
2317         // Return cache
2318         return $GLOBALS[__FUNCTION__];
2319 }
2320
2321 // "Getter" for last_daily
2322 function getLastDaily () {
2323         // Is there cache?
2324         if (!isset($GLOBALS[__FUNCTION__])) {
2325                 // Determine it
2326                 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2327         } // END - if
2328
2329         // Return cache
2330         return $GLOBALS[__FUNCTION__];
2331 }
2332
2333 // "Getter" for last_weekly
2334 function getLastWeekly () {
2335         // Is there cache?
2336         if (!isset($GLOBALS[__FUNCTION__])) {
2337                 // Determine it
2338                 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2339         } // END - if
2340
2341         // Return cache
2342         return $GLOBALS[__FUNCTION__];
2343 }
2344
2345 // "Getter" for last_monthly
2346 function getLastMonthly () {
2347         // Is there cache?
2348         if (!isset($GLOBALS[__FUNCTION__])) {
2349                 // Determine it
2350                 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2351         } // END - if
2352
2353         // Return cache
2354         return $GLOBALS[__FUNCTION__];
2355 }
2356
2357 // "Getter" for last_yearly
2358 function getLastYearly () {
2359         // Is there cache?
2360         if (!isset($GLOBALS[__FUNCTION__])) {
2361                 // Determine it
2362                 $GLOBALS[__FUNCTION__] = getConfig('last_yearly');
2363         } // END - if
2364
2365         // Return cache
2366         return $GLOBALS[__FUNCTION__];
2367 }
2368
2369 // "Getter" for mails_page
2370 function getMailsPage () {
2371         // Is there cache?
2372         if (!isset($GLOBALS[__FUNCTION__])) {
2373                 // Determine it
2374                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2375         } // END - if
2376
2377         // Return cache
2378         return $GLOBALS[__FUNCTION__];
2379 }
2380
2381 // "Getter" for rand_no
2382 function getRandNo () {
2383         // Is there cache?
2384         if (!isset($GLOBALS[__FUNCTION__])) {
2385                 // Determine it
2386                 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2387         } // END - if
2388
2389         // Return cache
2390         return $GLOBALS[__FUNCTION__];
2391 }
2392
2393 // "Getter" for __DB_NAME
2394 function getDbName () {
2395         // Is there cache?
2396         if (!isset($GLOBALS[__FUNCTION__])) {
2397                 // Determine it
2398                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2399         } // END - if
2400
2401         // Return cache
2402         return $GLOBALS[__FUNCTION__];
2403 }
2404
2405 // "Getter" for DOMAIN
2406 function getDomain () {
2407         // Is there cache?
2408         if (!isset($GLOBALS[__FUNCTION__])) {
2409                 // Determine it
2410                 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2411         } // END - if
2412
2413         // Return cache
2414         return $GLOBALS[__FUNCTION__];
2415 }
2416
2417 // "Getter" for proxy_username
2418 function getProxyUsername () {
2419         // Is there cache?
2420         if (!isset($GLOBALS[__FUNCTION__])) {
2421                 // Determine it
2422                 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2423         } // END - if
2424
2425         // Return cache
2426         return $GLOBALS[__FUNCTION__];
2427 }
2428
2429 // "Getter" for proxy_password
2430 function getProxyPassword () {
2431         // Is there cache?
2432         if (!isset($GLOBALS[__FUNCTION__])) {
2433                 // Determine it
2434                 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2435         } // END - if
2436
2437         // Return cache
2438         return $GLOBALS[__FUNCTION__];
2439 }
2440
2441 // "Getter" for proxy_host
2442 function getProxyHost () {
2443         // Is there cache?
2444         if (!isset($GLOBALS[__FUNCTION__])) {
2445                 // Determine it
2446                 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2447         } // END - if
2448
2449         // Return cache
2450         return $GLOBALS[__FUNCTION__];
2451 }
2452
2453 // "Getter" for proxy_port
2454 function getProxyPort () {
2455         // Is there cache?
2456         if (!isset($GLOBALS[__FUNCTION__])) {
2457                 // Determine it
2458                 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2459         } // END - if
2460
2461         // Return cache
2462         return $GLOBALS[__FUNCTION__];
2463 }
2464
2465 // "Getter" for SMTP_HOSTNAME
2466 function getSmtpHostname () {
2467         // Is there cache?
2468         if (!isset($GLOBALS[__FUNCTION__])) {
2469                 // Determine it
2470                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2471         } // END - if
2472
2473         // Return cache
2474         return $GLOBALS[__FUNCTION__];
2475 }
2476
2477 // "Getter" for SMTP_USER
2478 function getSmtpUser () {
2479         // Is there cache?
2480         if (!isset($GLOBALS[__FUNCTION__])) {
2481                 // Determine it
2482                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2483         } // END - if
2484
2485         // Return cache
2486         return $GLOBALS[__FUNCTION__];
2487 }
2488
2489 // "Getter" for SMTP_PASSWORD
2490 function getSmtpPassword () {
2491         // Is there cache?
2492         if (!isset($GLOBALS[__FUNCTION__])) {
2493                 // Determine it
2494                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2495         } // END - if
2496
2497         // Return cache
2498         return $GLOBALS[__FUNCTION__];
2499 }
2500
2501 // "Getter" for points_word
2502 function getPointsWord () {
2503         // Is there cache?
2504         if (!isset($GLOBALS[__FUNCTION__])) {
2505                 // Determine it
2506                 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2507         } // END - if
2508
2509         // Return cache
2510         return $GLOBALS[__FUNCTION__];
2511 }
2512
2513 // "Getter" for profile_lock
2514 function getProfileLock () {
2515         // Is there cache?
2516         if (!isset($GLOBALS[__FUNCTION__])) {
2517                 // Determine it
2518                 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2519         } // END - if
2520
2521         // Return cache
2522         return $GLOBALS[__FUNCTION__];
2523 }
2524
2525 // "Getter" for url_tlock
2526 function getUrlTlock () {
2527         // Is there cache?
2528         if (!isset($GLOBALS[__FUNCTION__])) {
2529                 // Determine it
2530                 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2531         } // END - if
2532
2533         // Return cache
2534         return $GLOBALS[__FUNCTION__];
2535 }
2536
2537 // "Getter" for title_left
2538 function getTitleLeft () {
2539         // Is there cache?
2540         if (!isset($GLOBALS[__FUNCTION__])) {
2541                 // Determine it
2542                 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2543         } // END - if
2544
2545         // Return cache
2546         return $GLOBALS[__FUNCTION__];
2547 }
2548
2549 // "Getter" for title_right
2550 function getTitleRight () {
2551         // Is there cache?
2552         if (!isset($GLOBALS[__FUNCTION__])) {
2553                 // Determine it
2554                 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2555         } // END - if
2556
2557         // Return cache
2558         return $GLOBALS[__FUNCTION__];
2559 }
2560
2561 // "Getter" for title_middle
2562 function getTitleMiddle () {
2563         // Is there cache?
2564         if (!isset($GLOBALS[__FUNCTION__])) {
2565                 // Determine it
2566                 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2567         } // END - if
2568
2569         // Return cache
2570         return $GLOBALS[__FUNCTION__];
2571 }
2572
2573 // Getter for 'display_home_in_index'
2574 function getDisplayHomeInIndex () {
2575         // Is the cache entry set?
2576         if (!isset($GLOBALS[__FUNCTION__])) {
2577                 // No, so determine it
2578                 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2579         } // END - if
2580
2581         // Return cached entry
2582         return $GLOBALS[__FUNCTION__];
2583 }
2584
2585 // Checks whether 'display_home_in_index' is 'Y'
2586 function isDisplayHomeInIndexEnabled () {
2587         // Is the cache entry set?
2588         if (!isset($GLOBALS[__FUNCTION__])) {
2589                 // No, so determine it
2590                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isConfigEntrySet('display_home_in_index')) && (getDisplayHomeInIndex() == 'Y'));
2591         } // END - if
2592
2593         // Return cached entry
2594         return $GLOBALS[__FUNCTION__];
2595 }
2596
2597 // Getter for 'show_points_unconfirmed'
2598 function getShowPointsUnconfirmed () {
2599         // Is the cache entry set?
2600         if (!isset($GLOBALS[__FUNCTION__])) {
2601                 // No, so determine it
2602                 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2603         } // END - if
2604
2605         // Return cached entry
2606         return $GLOBALS[__FUNCTION__];
2607 }
2608
2609 // Checks whether 'show_points_unconfirmed' is 'Y'
2610 function isShowPointsUnconfirmedEnabled () {
2611         // Is the cache entry set?
2612         if (!isset($GLOBALS[__FUNCTION__])) {
2613                 // No, so determine it
2614                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.5.5')) && (isConfigEntrySet('show_points_unconfirmed')) && (getShowPointsUnconfirmed() == 'Y'));
2615         } // END - if
2616
2617         // Return cached entry
2618         return $GLOBALS[__FUNCTION__];
2619 }
2620
2621 // Getter for 'youre_here'
2622 function getYoureHere () {
2623         // Is the cache entry set?
2624         if (!isset($GLOBALS[__FUNCTION__])) {
2625                 // No, so determine it
2626                 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2627         } // END - if
2628
2629         // Return cached entry
2630         return $GLOBALS[__FUNCTION__];
2631 }
2632
2633 // Checks whether 'show_timings' is 'Y'
2634 function isYoureHereEnabled () {
2635         // Is the cache entry set?
2636         if (!isset($GLOBALS[__FUNCTION__])) {
2637                 // No, so determine it
2638                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (isConfigEntrySet('youre_here')) && (getYoureHere() == 'Y'));
2639         } // END - if
2640
2641         // Return cached entry
2642         return $GLOBALS[__FUNCTION__];
2643 }
2644
2645 // Getter for 'show_timings'
2646 function getShowTimings () {
2647         // Is the cache entry set?
2648         if (!isset($GLOBALS[__FUNCTION__])) {
2649                 // No, so determine it
2650                 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2651         } // END - if
2652
2653         // Return cached entry
2654         return $GLOBALS[__FUNCTION__];
2655 }
2656
2657 // Checks whether 'show_timings' is 'Y'
2658 function isShowTimingsEnabled () {
2659         // Is the cache entry set?
2660         if (!isset($GLOBALS[__FUNCTION__])) {
2661                 // No, so determine it
2662                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isConfigEntrySet('show_timings')) && (getShowTimings() == 'Y'));
2663         } // END - if
2664
2665         // Return cached entry
2666         return $GLOBALS[__FUNCTION__];
2667 }
2668
2669 // Getter for 'ap_server_name_since'
2670 function getApServerNameSince () {
2671         // Is the cache entry set?
2672         if (!isset($GLOBALS[__FUNCTION__])) {
2673                 // No, so determine it
2674                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2675         } // END - if
2676
2677         // Return cached entry
2678         return $GLOBALS[__FUNCTION__];
2679 }
2680
2681 // Getter for 'ap_server_name'
2682 function getApServerName () {
2683         // Is the cache entry set?
2684         if (!isset($GLOBALS[__FUNCTION__])) {
2685                 // No, so determine it
2686                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2687         } // END - if
2688
2689         // Return cached entry
2690         return $GLOBALS[__FUNCTION__];
2691 }
2692
2693 // Getter for 'index_delay'
2694 function getIndexDelay () {
2695         // Is the cache entry set?
2696         if (!isset($GLOBALS[__FUNCTION__])) {
2697                 // No, so determine it
2698                 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2699         } // END - if
2700
2701         // Return cached entry
2702         return $GLOBALS[__FUNCTION__];
2703 }
2704
2705 // Checks whether 'ap_server_name' is 'Y'
2706 function isApServerNameEnabled () {
2707         // Is the cache entry set?
2708         if (!isset($GLOBALS[__FUNCTION__])) {
2709                 // No, so determine it
2710                 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2711         } // END - if
2712
2713         // Return cached entry
2714         return $GLOBALS[__FUNCTION__];
2715 }
2716
2717 // Getter for 'admin_menu_javascript'
2718 function getAdminMenuJavascript () {
2719         // Is the cache entry set?
2720         if (!isset($GLOBALS[__FUNCTION__])) {
2721                 // No, so determine it
2722                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2723         } // END - if
2724
2725         // Return cached entry
2726         return $GLOBALS[__FUNCTION__];
2727 }
2728
2729 // Getter for 'points_remove_account'
2730 function getPointsRemoveAccount () {
2731         // Is the cache entry set?
2732         if (!isset($GLOBALS[__FUNCTION__])) {
2733                 // No, so determine it
2734                 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2735         } // END - if
2736
2737         // Return cached entry
2738         return $GLOBALS[__FUNCTION__];
2739 }
2740
2741 // Getter for 'css_php'
2742 function getCssPhp () {
2743         // Is the cache entry set?
2744         if (!isset($GLOBALS[__FUNCTION__])) {
2745                 // No, so determine it
2746                 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2747         } // END - if
2748
2749         // Return cached entry
2750         return $GLOBALS[__FUNCTION__];
2751 }
2752
2753 // Getter for 'guest_menu'
2754 function getGuestMenu () {
2755         // Is the cache entry set?
2756         if (!isset($GLOBALS[__FUNCTION__])) {
2757                 // No, so determine it
2758                 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2759         } // END - if
2760
2761         // Return cached entry
2762         return $GLOBALS[__FUNCTION__];
2763 }
2764
2765 // Checks if guest menu is enabled
2766 function isGuestMenuEnabled () {
2767         // Is the cache entry set?
2768         if (!isset($GLOBALS[__FUNCTION__])) {
2769                 // No, so determine it
2770                 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2771         } // END - if
2772
2773         // Return cached entry
2774         return $GLOBALS[__FUNCTION__];
2775 }
2776
2777 // Getter for 'member_menu'
2778 function getMemberMenu () {
2779         // Is the cache entry set?
2780         if (!isset($GLOBALS[__FUNCTION__])) {
2781                 // No, so determine it
2782                 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2783         } // END - if
2784
2785         // Return cached entry
2786         return $GLOBALS[__FUNCTION__];
2787 }
2788
2789 // Checks if member menu is enabled
2790 function isMemberMenuEnabled () {
2791         // Is the cache entry set?
2792         if (!isset($GLOBALS[__FUNCTION__])) {
2793                 // No, so determine it
2794                 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2795         } // END - if
2796
2797         // Return cached entry
2798         return $GLOBALS[__FUNCTION__];
2799 }
2800
2801 // Getter for 'word_wrap'
2802 function getWordWrap () {
2803         // Is the cache entry set?
2804         if (!isset($GLOBALS[__FUNCTION__])) {
2805                 // Construct config entry name
2806                 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2807
2808                 // Is a special config entry found or ext-sql_patches updated?
2809                 if (isConfigEntrySet($configEntry)) {
2810                         // A special config entry has been found, then use it
2811                         $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2812                 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2813                         // No special config entry found, then use it as "fall-back"
2814                         $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2815                 } else {
2816                         // No, use default (15 characters)
2817                         $GLOBALS[__FUNCTION__] = 15;
2818                 }
2819         } // END - if
2820
2821         // Return cached entry
2822         return $GLOBALS[__FUNCTION__];
2823 }
2824
2825 // Checks whether proxy configuration is used
2826 function isProxyUsed () {
2827         // Is there cache?
2828         if (!isset($GLOBALS[__FUNCTION__])) {
2829                 // Determine it
2830                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (isValidNumber(getConfig('proxy_port'))));
2831         } // END - if
2832
2833         // Return cache
2834         return $GLOBALS[__FUNCTION__];
2835 }
2836
2837 // Checks whether POST data contains selections
2838 function ifPostContainsSelections ($element = 'sel') {
2839         // Is there cache?
2840         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2841                 // Determine it
2842                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2843         } // END - if
2844
2845         // Return cache
2846         return $GLOBALS[__FUNCTION__][$element];
2847 }
2848
2849 // Checks whether verbose_sql is Y and returns true/false if so
2850 function isVerboseSqlEnabled () {
2851         // Is there cache?
2852         if (!isset($GLOBALS[__FUNCTION__])) {
2853                 // Determine it
2854                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2855         } // END - if
2856
2857         // Return cache
2858         return $GLOBALS[__FUNCTION__];
2859 }
2860
2861 // "Getter" for total user points
2862 function getTotalPoints ($userid) {
2863         // Is there cache?
2864         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2865                 // Init array for filter chain
2866                 $data = array(
2867                         'userid' => $userid,
2868                         'points' => 0
2869                 );
2870
2871                 // Run filter chain for getting more point values
2872                 $data = runFilterChain('get_total_points', $data);
2873
2874                 // Determine it
2875                 $GLOBALS[__FUNCTION__][$userid] = $data['points']  - getUserUsedPoints($userid);
2876         } // END - if
2877
2878         // Return cache
2879         return $GLOBALS[__FUNCTION__][$userid];
2880 }
2881
2882 // Wrapper to get used points for given userid
2883 function getUserUsedPoints ($userid) {
2884         // Is there cache?
2885         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2886                 // Determine it
2887                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2888         } // END - if
2889
2890         // Return cache
2891         return $GLOBALS[__FUNCTION__][$userid];
2892 }
2893
2894 // Checks whether direct payment is allowed in configuration
2895 function isDirectPaymentEnabled () {
2896         // Is there cache?
2897         if (!isset($GLOBALS[__FUNCTION__])) {
2898                 // Determine it
2899                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('allow_direct_pay')) && (getConfig('allow_direct_pay') == 'Y'));
2900         } // END - if
2901
2902         // Return cache
2903         return $GLOBALS[__FUNCTION__];
2904 }
2905
2906 // Checks whether JavaScript-based admin menu is enabled
2907 function isAdminMenuJavascriptEnabled () {
2908         // Is there cache?
2909         if (!isset($GLOBALS[__FUNCTION__])) {
2910                 // Determine it
2911                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (isConfigEntrySet('admin_menu_javascript')) && (getAdminMenuJavaScript() == 'Y'));
2912         } // END - if
2913
2914         // Return cache
2915         return $GLOBALS[__FUNCTION__];
2916 }
2917
2918 // Wrapper to check if current task is for extension (not update)
2919 function isExtensionTask ($content) {
2920         // Is there cache?
2921         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2922                 // Determine it
2923                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2924         } // END - if
2925
2926         // Return cache
2927         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2928 }
2929
2930 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2931 function ifTesterAccountsAllowed () {
2932         // Is the cache entry set?
2933         if (!isset($GLOBALS[__FUNCTION__])) {
2934                 // No, so determine it
2935                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2936         } // END - if
2937
2938         // Return cached entry
2939         return $GLOBALS[__FUNCTION__];
2940 }
2941
2942 // Wrapper to check if output mode is CSS
2943 function isCssOutputMode () {
2944         // Is cache set?
2945         if (!isset($GLOBALS[__FUNCTION__])) {
2946                 // Determine it
2947                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2948                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2949         } // END - if
2950
2951         // Return cache
2952         return $GLOBALS[__FUNCTION__];
2953 }
2954
2955 // Wrapper to check if output mode is HTML
2956 function isHtmlOutputMode () {
2957         // Is cache set?
2958         if (!isset($GLOBALS[__FUNCTION__])) {
2959                 // Determine it
2960                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2961                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2962         } // END - if
2963
2964         // Return cache
2965         return $GLOBALS[__FUNCTION__];
2966 }
2967
2968 // Wrapper to check if output mode is RAW
2969 function isRawOutputMode () {
2970         // Is cache set?
2971         if (!isset($GLOBALS[__FUNCTION__])) {
2972                 // Determine it
2973                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2974                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2975         } // END - if
2976
2977         // Return cache
2978         return $GLOBALS[__FUNCTION__];
2979 }
2980
2981 // Wrapper to check if output mode is AJAX
2982 function isAjaxOutputMode () {
2983         // Is cache set?
2984         if (!isset($GLOBALS[__FUNCTION__])) {
2985                 // Determine it
2986                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2987                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2988         } // END - if
2989
2990         // Return cache
2991         return $GLOBALS[__FUNCTION__];
2992 }
2993
2994 // Wrapper to check if output mode is image
2995 function isImageOutputMode () {
2996         // Is cache set?
2997         if (!isset($GLOBALS[__FUNCTION__])) {
2998                 // Determine it
2999                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
3000                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
3001         } // END - if
3002
3003         // Return cache
3004         return $GLOBALS[__FUNCTION__];
3005 }
3006
3007 // Wrapper to generate a user email link
3008 function generateWrappedUserEmailLink ($email) {
3009         // Just call the inner function
3010         return generateEmailLink($email, 'user_data');
3011 }
3012
3013 // Wrapper to check if user points are locked
3014 function ifUserPointsLocked ($userid) {
3015         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
3016         // Is there cache?
3017         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3018                 // Determine it
3019                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
3020         } // END - if
3021
3022         // Return cache
3023         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
3024         return $GLOBALS[__FUNCTION__][$userid];
3025 }
3026
3027 // Appends a line to an existing file or creates it instantly with given content.
3028 // This function does always add a new-line character to every line.
3029 function appendLineToFile ($file, $line) {
3030         $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
3031         fwrite($fp, $line . PHP_EOL);
3032         fclose($fp);
3033 }
3034
3035 // Wrapper for changeDataInFile() but with full path added
3036 function changeDataInInclude ($inc, $comment, $prefix, $suffix, $inserted, $seek=0) {
3037         // Add full path
3038         $FQFN = getPath() . $inc;
3039
3040         // Call inner function
3041         return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
3042 }
3043
3044 // Wrapper for changing entries in config-local.php
3045 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3046         // Call the inner function
3047         return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3048 }
3049
3050 // Shortens ucfirst(strtolower()) calls
3051 function firstCharUpperCase ($str) {
3052         return ucfirst(strtolower($str));
3053 }
3054
3055 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3056 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3057         // Get the configuration entry
3058         $configValue = getConfig($configEntry);
3059
3060         // Call inner method
3061         return createTimeSelections($configValue, $configEntry, $stamps, $align);
3062 }
3063
3064 // Shortens converting of German comma to Computer's version in POST data
3065 function convertCommaToDotInPostData ($postEntry) {
3066         // Read and convert given entry
3067         $postValue = convertCommaToDot(postRequestElement($postEntry));
3068
3069         // Log message
3070         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3071
3072         // ... and set it again
3073         setPostRequestElement($postEntry, $postValue);
3074 }
3075
3076 // Converts German commas to Computer's version in all entries
3077 function convertCommaToDotInPostDataArray ($postEntries) {
3078         // Replace german decimal comma with computer decimal dot
3079         foreach ($postEntries as $entry) {
3080                 // Is the entry there?
3081                 if (isPostRequestElementSet($entry)) {
3082                         // Then convert it
3083                         convertCommaToDotInPostData($entry);
3084                 } // END - if
3085         } // END - foreach
3086 }
3087
3088 /**
3089  * Parses a string into a US formated float variable, taken from user comments
3090  * from PHP documentation website.
3091  *
3092  * @param       $floatString    A string holding a float expression
3093  * @return      $float                  Corresponding float variable
3094  * @author      chris<at>georgakopoulos<dot>com
3095  * @link        http://de.php.net/manual/en/function.floatval.php#92563
3096  */
3097 function parseFloat ($floatString){
3098         // Load locale info
3099         $LocaleInfo = localeconv();
3100
3101         // Remove thousand separators
3102         $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3103
3104         // Convert decimal point
3105         $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3106
3107         // Return float value of converted string
3108         return floatval($floatString);
3109 }
3110
3111 /**
3112  * Searches a multi-dimensional array (as used in many places) for given
3113  * key/value pair as taken from user comments from PHP documentation website.
3114  *
3115  * @param       $array                  An array with one or more dimensions
3116  * @param       $key                    Key to look for
3117  * @param       $value                  Value to look for
3118  * @param       $parentIndex    Parent index (ONLY INTERNAL USE!)
3119  * @return      $results                Resulted array or empty array if $array is no array
3120  * @author      sunelbe<at>gmail<dot>com
3121  * @link        http://de.php.net/manual/en/function.array-search.php#110120
3122  */
3123 function search_array ($array, $key, $value, $parentIndex = NULL) {
3124         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3125         // Init array result
3126         $results = array();
3127
3128         // Is $array really an array?
3129         if (is_array($array)) {
3130                 // Search for whole array
3131                 foreach ($array as $idx => $dummy) {
3132                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3133                         //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3134                         // Is dummy an array?
3135                         if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3136                                 // Then search again
3137                                 $subResult = search_array($dummy, $key, $value, $idx);
3138                                 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3139
3140                                 // And merge both
3141                                 $results = merge_array($results, $subResult, TRUE);
3142                         } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3143                                 // Is found, so add it
3144                                 $results[$parentIndex] = $array;
3145                                 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3146                         }
3147                 } // END - foreach
3148         } // END - if
3149
3150         // Return resulting array
3151         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3152         return $results;
3153 }
3154
3155 // Generates a YES/NO option list from given default
3156 function generateYesNoOptions ($defaultValue = '') {
3157         // Generate it
3158         return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3159 }
3160
3161 // "Getter" for total available receivers
3162 function getTotalReceivers ($mode = 'normal') {
3163         // Get num rows
3164         $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3165
3166         // Return value
3167         return $numRows;
3168 }
3169
3170 // Wrapper "getter" to get total unconfirmed mails for given userid
3171 function getTotalUnconfirmedMails ($userid) {
3172         // Is there cache?
3173         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3174                 // Determine it
3175                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3176         } // END - if
3177
3178         // Return cache
3179         return $GLOBALS[__FUNCTION__][$userid];
3180 }
3181
3182 // Checks whether 'mailer_theme' was found in session
3183 function isMailerThemeSet () {
3184         // Is cache set?
3185         if (!isset($GLOBALS[__FUNCTION__])) {
3186                 // Determine it
3187                 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3188         } // END - if
3189
3190         // Return cache
3191         return $GLOBALS[__FUNCTION__];
3192 }
3193
3194 /**
3195  * Setter for theme in session (This setter does return the success of
3196  * setSession() which is required e.g. for destroySponsorSession().
3197  */
3198 function setMailerTheme ($newTheme) {
3199         // Set it in session
3200         return setSession('mailer_theme', $newTheme);
3201 }
3202
3203 /**
3204  * Getter for theme from session (This getter does return 'mailer_theme' from
3205  * session data or throws an error if not possible
3206  */
3207 function getMailerTheme () {
3208         // Is cache set?
3209         if (!isset($GLOBALS[__FUNCTION__])) {
3210                 // Is 'mailer_theme' set?
3211                 if (!isMailerThemeSet()) {
3212                         // No, then abort here
3213                         reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3214                 } // END - if
3215
3216                 // Get it and store it in cache
3217                 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3218         } // END - if
3219
3220         // Return cache
3221         return $GLOBALS[__FUNCTION__];
3222 }
3223
3224 // "Getter" for last_module/last_what depending on ext-user version
3225 function getUserLastWhatName () {
3226         // Default is old one: last_module
3227         $columnName = 'last_module';
3228
3229         // Is ext-user up-to-date?
3230         if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3231                 // Yes, then use new one
3232                 $columnName = 'last_what';
3233         } // END - if
3234
3235         // Return it
3236         return $columnName;
3237 }
3238
3239 // "Getter" for all columns for given alias and separator
3240 function getAllPointColumns ($alias = NULL, $separator = ',') {
3241         // Prepare the filter array
3242         $filterData = array(
3243                 'columns'   => '',
3244                 'alias'     => $alias,
3245                 'separator' => $separator
3246         );
3247
3248         // Run the filter
3249         $filterData = runFilterChain('get_all_point_columns', $filterData);
3250
3251         // Return the columns
3252         return $filterData['columns'];
3253 }
3254
3255 // Checks whether the copyright footer (which breaks framesets) is enabled
3256 function ifCopyrightFooterEnabled () {
3257         // Is not unset and not 'N'?
3258         return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3259 }
3260
3261 /**
3262  * Wrapper to check whether we have a "full page". This means that the actual
3263  * content is not delivered in any frame of a frameset.
3264  */
3265 function isFullPage () {
3266         /*
3267          * The parameter 'frame' is generic and always indicates that this content
3268          * will be output into a frame. Furthermore, if a frameset is reported or
3269          * the copyright line is explicitly deactivated, this cannot be a "full
3270          * page" again.
3271          */
3272         // @TODO Find a way to not use direct module comparison
3273         $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3274
3275         // Return it
3276         return $isFullPage;
3277 }
3278
3279 // Checks whether frameset_mode is set to true
3280 function isFramesetModeEnabled () {
3281         // Check it
3282         return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3283 }
3284
3285 // Function to determine correct 'what' value
3286 function determineWhat ($module = NULL) {
3287         // Init default 'what'
3288         $what = 'welcome';
3289
3290         // Is module NULL?
3291         if (is_null($module)) {
3292                 // Then use default
3293                 $module = getModule();
3294         } // END - if
3295
3296         // Is what set?
3297         if (isWhatSet()) {
3298                 // Then use it
3299                 $what = getWhat();
3300         } else {
3301                 // Else try to get it from current module
3302                 $what = getWhatFromModule($module);
3303         }
3304         //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3305
3306         // Remove any spaces from variable
3307         $what = trim($what);
3308
3309         // Is it empty?
3310         if (empty($what)) {
3311                 // Default action for non-admin menus
3312                 $what = 'welcome';
3313         } else {
3314                 // Secure it
3315                 $what = secureString($what);
3316         }
3317
3318         // Return what
3319         return $what;
3320 }
3321
3322 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3323 function prependZeros ($str, $length = 2) {
3324         // Return prepended string
3325         return sprintf('%0' . (int) $length . 's', $str);
3326 }
3327
3328 // Wraps convertSelectionsToEpocheTime()
3329 function convertSelectionsToEpocheTimeInPostData ($id) {
3330         // Init variables
3331         $content = array();
3332         $skip = FALSE;
3333
3334         // Get all POST data
3335         $postData = postRequestArray();
3336
3337         // Convert given selection id
3338         convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3339
3340         // Set the POST array back
3341         setPostRequestArray($postData);
3342 }
3343
3344 // Wraps checking if given points account type matches with given in POST data
3345 function ifPointsAccountTypeMatchesPost ($type) {
3346         // Check condition
3347         exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3348 }
3349
3350 // Gets given user's total referral
3351 function getUsersTotalReferrals ($userid, $level = NULL) {
3352         // Is there cache?
3353         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3354                 // Is the level NULL?
3355                 if (is_null($level)) {
3356                         // Get total amount (all levels)
3357                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3358                 } else {
3359                         // Get it from user refs
3360                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3361                 }
3362         } // END - if
3363
3364         // Return it
3365         return $GLOBALS[__FUNCTION__][$userid][$level];
3366 }
3367
3368 // Gets given user's total referral
3369 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3370         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3371         // Is there cache?
3372         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3373                 // Default is all refs
3374                 $add = '';
3375
3376                 // Is the not level NULL?
3377                 if (!is_null($level)) {
3378                         // Then add referral level
3379                         $add = ' AND `r`.`level`=' . bigintval($level);
3380                 } // END - if
3381
3382                 // Check for all referrals
3383                 $result = sqlQueryEscaped("SELECT
3384         COUNT(`d`.`userid`) AS `cnt`
3385 FROM
3386         `{?_MYSQL_PREFIX?}_user_data` AS `d`
3387 INNER JOIN
3388         `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3389 ON
3390         `d`.`userid`=`r`.`refid`
3391 WHERE
3392         `d`.`status` != 'CONFIRMED' AND
3393         `r`.`userid`=%s
3394         " . $add . "
3395 ORDER BY
3396         `d`.`userid` ASC
3397 LIMIT 1",
3398                         array(
3399                                 $userid
3400                         ), __FUNCTION__, __LINE__);
3401
3402                 // Load count
3403                 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3404
3405                 // Free result
3406                 sqlFreeResult($result);
3407         } // END - if
3408
3409         // Return it
3410         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3411         return $GLOBALS[__FUNCTION__][$userid][$level];
3412 }
3413
3414 // Converts, if found, dollar data to get element
3415 function convertDollarDataToGetElement ($data) {
3416         // Is first char a dollar?
3417         if (substr($data, 0, 1) == chr(36)) {
3418                 // Use last part for getRequestElement()
3419                 $data = getRequestElement(substr($data, 1));
3420         } // END - if
3421
3422         // Return it
3423         return $data;
3424 }
3425
3426 // Wrapper function for SQL layer to speed-up things
3427 function isSqlDebugEnabled () {
3428         // Is there cache?
3429         if (!isset($GLOBALS[__FUNCTION__])) {
3430                 // Determine it
3431                 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3432         } // END - if
3433
3434         // Return cache
3435         return $GLOBALS[__FUNCTION__];
3436 }
3437
3438 // Wrapper function to wrap call of wordwrap()
3439 function wrapWords ($text) {
3440         // Wrap words
3441         $wrapped = wordwrap($test, getWordWrap());
3442
3443         // Return it
3444         return $wrapped;
3445 }
3446
3447 // Encodes given data into a JSON object
3448 function encodeJson ($data) {
3449         // Encode it
3450         return json_encode($data, JSON_FORCE_OBJECT);
3451 }
3452
3453 // Get all extension files
3454 function loadAllExtensionsByTemplate () {
3455         // Get all
3456         $extensions = getArrayFromDirectory(
3457                 'templates/' . getLanguage() . '/html/ext/',
3458                 'ext_',
3459                 false,
3460                 false,
3461                 array(),
3462                 '.tpl',
3463                 '@(\.|\.\.)$@',
3464                 false
3465         );
3466
3467         // Return them
3468         return $extensions;
3469 }
3470
3471 // Wrapper function to allow full float values as supported by current database layout
3472 function translateFullComma ($dotted) {
3473         // Call inner function
3474         return translateComma($dotted, TRUE, 5);
3475 }
3476
3477 // Wrapper to check if the first element to be shifted is set to given value
3478 function shift_array (&$array, $value, $key = '0') {
3479         // Is the element set and value matches?
3480         assert(is_array($array));
3481         assert(isset($array[$key]));
3482         assert($array[$key] === $value);
3483
3484         // Shift it
3485         array_shift($array);
3486 }
3487
3488 // Wrapper for str_pad() with left padding zeros
3489 function padLeftZero ($str, $amount = 2) {
3490         // Is str_pad() there?
3491         if (!function_exists('str_pad')) {
3492                 // Use prependZeros()
3493                 return prependZeros($str, $amount);
3494         } else {
3495                 // Pad it
3496                 return str_pad($str, $amount, '0', STR_PAD_LEFT);
3497         }
3498 }
3499
3500 // Calculates percentage
3501 function calculatePercentageRate ($current, $total) {
3502         // Default is zero
3503         $rate = '0.0';
3504
3505         // Is sent larger zero? (Prevents division-by-zero)
3506         if ($total > 0) {
3507                 // Calculate it (it should be "translated" alter on)
3508                 $rate = ($current / $total * 100);
3509         } // END - if
3510
3511         // The should be a .0 at the end?
3512         if (strpos($rate, '.') === FALSE) {
3513                 // No, then add it
3514                 $rate .= '.0';
3515         } // END - if
3516
3517         // Return it
3518         return $rate;
3519 }
3520
3521 // Checks whether an array is filled with entries
3522 function isFilledArray ($array) {
3523         // Determine it
3524         return ((is_array($array)) && (count($array) > 0));
3525 }
3526
3527 // Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
3528 function isDeveloperSystem () {
3529         // Determine it
3530         return in_array(detectServerName(), array('localhost', '127.0.0.1'));
3531 }
3532
3533 // Checks whether given subject line has '_ref' suffix
3534 function ifSubjectHasReferralSuffix ($subject) {
3535         // Is there cache?
3536         if (!isset($GLOBALS[__FUNCTION__][$subject])) {
3537                 // Determine it
3538                 $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
3539         } // END - if
3540
3541         // Return cache
3542         return $GLOBALS[__FUNCTION__][$subject];
3543 }
3544
3545 // Converts an API response to an associative array
3546 function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimiter) {
3547         // Explode for key delimiter
3548         $keys = explode($keyDelimiter, $responseString);
3549
3550         // Init returned array and "walk" through all entries
3551         $returned = array();
3552         foreach ($keys as $keyValue) {
3553                 // Explode it
3554                 $parts = explode($valueDelimiter, $keyValue);
3555
3556                 // Count must be 2
3557                 assert(count($parts) == 2);
3558
3559                 // Then add both: 0=key, 1=value
3560                 $returned[sqlEscapeString($parts[0])] = sqlEscapeString($parts[1]);
3561         } // END - if
3562
3563         // Return finished array
3564         return $returned;
3565 }
3566
3567 // Getter for full (generic) hash file name
3568 function getGenericHashFileName () {
3569         // Return result
3570         return sprintf('%s%s.%s%s', getPath(), getCachePath(), getFileHash(), getCacheExtension());
3571 }
3572
3573 // "Compiles" the given value and sets it in given key
3574 function setSessionCompiled ($key, $value) {
3575         // Debug message
3576         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key[]=' . gettype($key) . ',value[]=' . gettype($value));
3577
3578         // Is the value not an array?
3579         if (!is_array($value)) {
3580                 // "Compile" the value
3581                 $value = doFinalCompilation(compileRawCode($value));
3582         } // END - if
3583
3584         // And set it
3585         return setSession($key, $value);
3586 }
3587
3588 // [EOF]
3589 ?>