]> git.mxchange.org Git - mailer.git/blob - inc/wrapper-functions.php
9cc88986eb5139d470d09d8fa3e447a8d0f05b9f
[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         // Return status
1003         return $status;
1004 }
1005
1006 // Getter for admin_md5
1007 function getAdminMd5 () {
1008         // Log debug message
1009         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1010
1011         // Get session
1012         return getSession('admin_md5');
1013 }
1014
1015 // Init user data array
1016 function initUserData () {
1017         // User id should not be zero
1018         if (!isValidId(getCurrentUserId())) {
1019                 // Should be always valid
1020                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1021         } // END - if
1022
1023         // Init the user
1024         unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1025         $GLOBALS['user_data'][getCurrentUserId()] = array();
1026 }
1027
1028 // Getter for user data
1029 function getUserData ($column) {
1030         // User id should not be zero
1031         if (!isValidId(getCurrentUserId())) {
1032                 // Should be always valid
1033                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1034         } // END - if
1035
1036         // Default is empty
1037         $data = NULL;
1038
1039         if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1040                 // Return the value
1041                 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1042         } // END - if
1043
1044         // Return it
1045         return $data;
1046 }
1047
1048 // Checks whether given user data is set to 'Y'
1049 function isUserDataEnabled ($column) {
1050         // Is there cache?
1051         if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1052                 // Determine it
1053                 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1054         } // END - if
1055
1056         // Return cache
1057         return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1058 }
1059
1060 // Geter for whole user data array
1061 function getUserDataArray () {
1062         // Get user id
1063         $userid = getCurrentUserId();
1064
1065         // Is the current userid valid?
1066         if (!isValidId($userid)) {
1067                 // Should be always valid
1068                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1069         } // END - if
1070
1071         // Get the whole array if found
1072         if (isset($GLOBALS['user_data'][$userid])) {
1073                 // Found, so return it
1074                 return $GLOBALS['user_data'][$userid];
1075         } else {
1076                 // Return empty array
1077                 return array();
1078         }
1079 }
1080
1081 // Checks if the user data is valid, this may indicate that the user has logged
1082 // in, but you should use isMember() if you want to find that out.
1083 function isValidUserData () {
1084         // User id should not be zero so abort here
1085         if (!isCurrentUserIdSet()) {
1086                 // Debug message, may be noisy
1087                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1088
1089                 // Abort here
1090                 return FALSE;
1091         } // END - if
1092
1093         // Is it cached?
1094         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1095                 // Determine it
1096                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1097         } // END - if
1098
1099         // Return the result
1100         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1101 }
1102
1103 // Setter for current userid
1104 function setCurrentUserId ($userid) {
1105         // Debug message
1106         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1107
1108         // Is the cache from below functions different?
1109         if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1110                 // Then unset both
1111                 unsetCurrentUserId();
1112         } // END - if
1113
1114         // Set userid
1115         $GLOBALS['current_userid'] = bigintval($userid);
1116
1117         // Unset it to re-determine the actual state
1118         unset($GLOBALS['is_userdata_valid'][$userid]);
1119
1120         // Debug message
1121         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1122 }
1123
1124 // Getter for current userid
1125 function getCurrentUserId () {
1126         // Is cache set?
1127         if (!isset($GLOBALS[__FUNCTION__])) {
1128                 // Userid must be set before it can be used
1129                 if (!isCurrentUserIdSet()) {
1130                         // Not set
1131                         reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1132                 } // END - if
1133
1134                 // Set userid in cache
1135                 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1136         } // END - if
1137
1138         // Return cache
1139         return $GLOBALS[__FUNCTION__];
1140 }
1141
1142 // Checks if current userid is set
1143 function isCurrentUserIdSet () {
1144         // Is there cache?
1145         if (!isset($GLOBALS[__FUNCTION__])) {
1146                 // Determine it
1147                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1148         } // END - if
1149
1150         // Return cache
1151         return $GLOBALS[__FUNCTION__];
1152 }
1153
1154 // Unsets current userid
1155 function unsetCurrentUserId () {
1156         // Is it set?
1157         if (isset($GLOBALS['current_userid'])) {
1158                 // Unset this, too
1159                 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1160         } // END - if
1161
1162         // Unset all cache entries
1163         unset($GLOBALS['current_userid']);
1164         unset($GLOBALS['getCurrentUserId']);
1165         unset($GLOBALS['isCurrentUserIdSet']);
1166 }
1167
1168 // Checks whether we are debugging template cache
1169 function isDebugTemplateCacheEnabled () {
1170         // Is there cache?
1171         if (!isset($GLOBALS[__FUNCTION__])) {
1172                 // Determine it
1173                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_TEMPLATE_CACHE')) && (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'));
1174         } // END - if
1175
1176         // Return cache
1177         return $GLOBALS[__FUNCTION__];
1178 }
1179
1180 // Wrapper for fetchUserData() and getUserData() calls
1181 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1182         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1183         // Is it cached?
1184         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1185                 // Default is NULL
1186                 $data = NULL;
1187
1188                 // Can we fetch the user data?
1189                 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1190                         // Now get the data back
1191                         $data = getUserData($valueColumn);
1192                 } // END - if
1193
1194                 // Cache it
1195                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1196         } // END - if
1197
1198         // Return it
1199         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1200         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1201 }
1202
1203 // Wrapper for strpos() to ease porting from deprecated ereg() function
1204 function isInString ($needle, $haystack) {
1205         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1206         return (strpos($haystack, $needle) !== FALSE);
1207 }
1208
1209 // Wrapper for strpos() to ease porting from deprecated eregi() function
1210 // This function is case-insensitive
1211 function isInStringIgnoreCase ($needle, $haystack) {
1212         return (isInString(strtolower($needle), strtolower($haystack)));
1213 }
1214
1215 // Wrapper to check for if fatal errors where detected
1216 function ifFatalErrorsDetected () {
1217         // Just call the inner function
1218         return (getTotalFatalErrors() > 0);
1219 }
1220
1221 // Checks whether a HTTP status has been set
1222 function isHttpStatusSet () {
1223         // Is it set and not empty?
1224         return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1225 }
1226
1227 // Setter for HTTP status
1228 function setHttpStatus ($status) {
1229         $GLOBALS['http_status'] = (string) $status;
1230 }
1231
1232 // Getter for HTTP status
1233 function getHttpStatus () {
1234         // Is the status set?
1235         if (!isHttpStatusSet()) {
1236                 // Abort here
1237                 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1238         } // END - if
1239
1240         // Return it
1241         return $GLOBALS['http_status'];
1242 }
1243
1244 /**
1245  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1246  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1247  *
1248  * ----------------------------------------------------------------------------
1249  * If you want to redirect, please use redirectToUrl(); instead
1250  * ----------------------------------------------------------------------------
1251  *
1252  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1253  *
1254  * @link    http://support.microsoft.com/kb/q176113/
1255  * @author  Andreas Gohr <andi@splitbrain.org>
1256  * @access  private
1257  */
1258 function sendRawRedirect ($url) {
1259         // Clear output buffer
1260         clearOutputBuffer();
1261
1262         // Clear own output buffer
1263         $GLOBALS['__output'] = '';
1264
1265         // To make redirects working (no content type), output mode must be raw
1266         setScriptOutputMode(-1);
1267
1268         // Send helping header
1269         setHttpStatus('302 Found');
1270
1271         // always close the session
1272         session_write_close();
1273
1274         // Revert entity &amp;
1275         $url = str_replace('&amp;', '&', $url);
1276
1277         // check if running on IIS < 6 with CGI-PHP
1278         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1279                 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1280                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1281                 ($matches[1] < 6)) {
1282                 // Send the IIS header
1283                 addHttpHeader('Refresh: 0;url=' . $url);
1284         } else {
1285                 // Send generic header
1286                 addHttpHeader('Location: ' . $url);
1287         }
1288
1289         // Shutdown here
1290         doShutdown();
1291 }
1292
1293 // Determines the country of the given user id
1294 function determineCountry ($userid) {
1295         // Is there cache?
1296         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1297                 // Default is 'invalid'
1298                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1299
1300                 // Is extension country active?
1301                 if (isExtensionActive('country')) {
1302                         // Determine the right country code through the country id
1303                         $id = getUserData('country_code');
1304
1305                         // Then handle it over
1306                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1307                 } else {
1308                         // Get raw code from user data
1309                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1310                 }
1311         } // END - if
1312
1313         // Return cache
1314         return $GLOBALS[__FUNCTION__][$userid];
1315 }
1316
1317 // "Getter" for total confirmed user accounts
1318 function getTotalConfirmedUser () {
1319         // Is it cached?
1320         if (!isset($GLOBALS[__FUNCTION__])) {
1321                 // Then do it
1322                 if (isExtensionActive('user')) {
1323                         $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1324                 } else {
1325                         $GLOBALS[__FUNCTION__] = 0;
1326                 }
1327         } // END - if
1328
1329         // Return cached value
1330         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1331         return $GLOBALS[__FUNCTION__];
1332 }
1333
1334 // "Getter" for total unconfirmed user accounts
1335 function getTotalUnconfirmedUser () {
1336         // Is it cached?
1337         if (!isset($GLOBALS[__FUNCTION__])) {
1338                 // Then do it
1339                 if (isExtensionActive('user')) {
1340                         $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1341                 } else {
1342                         $GLOBALS[__FUNCTION__] = 0;
1343                 }
1344         } // END - if
1345
1346         // Return cached value
1347         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1348         return $GLOBALS[__FUNCTION__];
1349 }
1350
1351 // "Getter" for total locked user accounts
1352 function getTotalLockedUser () {
1353         // Is it cached?
1354         if (!isset($GLOBALS[__FUNCTION__])) {
1355                 // Then do it
1356                 if (isExtensionActive('user')) {
1357                         $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1358                 } else {
1359                         $GLOBALS[__FUNCTION__] = 0;
1360                 }
1361         } // END - if
1362
1363         // Return cached value
1364         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1365         return $GLOBALS[__FUNCTION__];
1366 }
1367
1368 // "Getter" for total locked user accounts
1369 function getTotalRandomRefidUser () {
1370         // Is it cached?
1371         if (!isset($GLOBALS[__FUNCTION__])) {
1372                 // Then do it
1373                 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1374                         $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1375                 } else {
1376                         $GLOBALS[__FUNCTION__] = 0;
1377                 }
1378         } // END - if
1379
1380         // Return cached value
1381         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1382         return $GLOBALS[__FUNCTION__];
1383 }
1384
1385 // Is given id number valid?
1386 function isValidId ($id) {
1387         // Debug message
1388         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1389
1390         // Is there cache?
1391         if (!isset($GLOBALS[__FUNCTION__][$id])) {
1392                 // Check it out
1393                 $GLOBALS[__FUNCTION__][$id] = ((isValidNumber($id)) && (!is_bool($id)) && ($id != '00000') && ($id > 0));
1394         } // END - if
1395
1396         // Return cache
1397         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1398         return $GLOBALS[__FUNCTION__][$id];
1399 }
1400
1401 // Checks whether a valid number is given
1402 function isValidNumber ($num) {
1403         // Determine it
1404         return ((!is_null($num)) && (!empty($num)) && ('*' . bigintval($num, TRUE, FALSE) . '*' == '*' . $num . '*'));
1405 }
1406
1407 // Encodes entities
1408 function encodeEntities ($str) {
1409         // Secure it first
1410         $str = secureString($str, TRUE, TRUE);
1411
1412         // Encode dollar sign as well
1413         $str = str_replace('$', '&#36;', $str);
1414
1415         // Return it
1416         return $str;
1417 }
1418
1419 // Getter for current year (default)
1420 function getYear ($timestamp = NULL) {
1421         // Is it cached?
1422         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1423                 // If NULL is set, use time()
1424                 if (is_null($timestamp)) {
1425                         $timestamp = time();
1426                 } // END - if
1427
1428                 // Then create it
1429                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1430         } // END - if
1431
1432         // Return cache
1433         return $GLOBALS[__FUNCTION__][$timestamp];
1434 }
1435
1436 // Getter for current month (default)
1437 function getMonth ($timestamp = NULL) {
1438         // Is it cached?
1439         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1440                 // If NULL is set, use time()
1441                 if (is_null($timestamp)) {
1442                         // Use time() which is current timestamp
1443                         $timestamp = time();
1444                 } // END - if
1445
1446                 // Then create it
1447                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1448         } // END - if
1449
1450         // Return cache
1451         return $GLOBALS[__FUNCTION__][$timestamp];
1452 }
1453
1454 // Getter for current hour (default)
1455 function getHour ($timestamp = NULL) {
1456         // Is it cached?
1457         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1458                 // null is time()
1459                 if (is_null($timestamp)) {
1460                         $timestamp = time();
1461                 } // END - if
1462
1463                 // Then create it
1464                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1465         } // END - if
1466
1467         // Return cache
1468         return $GLOBALS[__FUNCTION__][$timestamp];
1469 }
1470
1471 // Getter for current day (default)
1472 function getDay ($timestamp = NULL) {
1473         // Is it cached?
1474         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1475                 // null is time()
1476                 if (is_null($timestamp)) {
1477                         $timestamp = time();
1478                 } // END - if
1479
1480                 // Then create it
1481                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1482         } // END - if
1483
1484         // Return cache
1485         return $GLOBALS[__FUNCTION__][$timestamp];
1486 }
1487
1488 // Getter for current week (default)
1489 function getWeek ($timestamp = NULL) {
1490         // Is it cached?
1491         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1492                 // null is time()
1493                 if (is_null($timestamp)) $timestamp = time();
1494
1495                 // Then create it
1496                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1497         } // END - if
1498
1499         // Return cache
1500         return $GLOBALS[__FUNCTION__][$timestamp];
1501 }
1502
1503 // Getter for current short_hour (default)
1504 function getShortHour ($timestamp = NULL) {
1505         // Is it cached?
1506         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1507                 // null is time()
1508                 if (is_null($timestamp)) $timestamp = time();
1509
1510                 // Then create it
1511                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1512         } // END - if
1513
1514         // Return cache
1515         return $GLOBALS[__FUNCTION__][$timestamp];
1516 }
1517
1518 // Getter for current long_hour (default)
1519 function getLongHour ($timestamp = NULL) {
1520         // Is it cached?
1521         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1522                 // null is time()
1523                 if (is_null($timestamp)) $timestamp = time();
1524
1525                 // Then create it
1526                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1527         } // END - if
1528
1529         // Return cache
1530         return $GLOBALS[__FUNCTION__][$timestamp];
1531 }
1532
1533 // Getter for current second (default)
1534 function getSecond ($timestamp = NULL) {
1535         // Is it cached?
1536         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1537                 // null is time()
1538                 if (is_null($timestamp)) $timestamp = time();
1539
1540                 // Then create it
1541                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1542         } // END - if
1543
1544         // Return cache
1545         return $GLOBALS[__FUNCTION__][$timestamp];
1546 }
1547
1548 // Getter for current minute (default)
1549 function getMinute ($timestamp = NULL) {
1550         // Is it cached?
1551         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1552                 // null is time()
1553                 if (is_null($timestamp)) $timestamp = time();
1554
1555                 // Then create it
1556                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1557         } // END - if
1558
1559         // Return cache
1560         return $GLOBALS[__FUNCTION__][$timestamp];
1561 }
1562
1563 // Checks whether the title decoration is enabled
1564 function isTitleDecorationEnabled () {
1565         // Is there cache?
1566         if (!isset($GLOBALS[__FUNCTION__])) {
1567                 // Just check it
1568                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_title_deco')) && (getConfig('enable_title_deco') == 'Y'));
1569         } // END - if
1570
1571         // Return cache
1572         return $GLOBALS[__FUNCTION__];
1573 }
1574
1575 // Checks whether filter usage updates are enabled (expensive queries!)
1576 function isFilterUsageUpdateEnabled () {
1577         // Is there cache?
1578         if (!isset($GLOBALS[__FUNCTION__])) {
1579                 // Determine it
1580                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1581         } // END - if
1582
1583         // Return cache
1584         return $GLOBALS[__FUNCTION__];
1585 }
1586
1587 // Checks whether debugging of weekly resets is enabled
1588 function isWeeklyResetDebugEnabled () {
1589         // Is there cache?
1590         if (!isset($GLOBALS[__FUNCTION__])) {
1591                 // Determine it
1592                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1593         } // END - if
1594
1595         // Return cache
1596         return $GLOBALS[__FUNCTION__];
1597 }
1598
1599 // Checks whether debugging of monthly resets is enabled
1600 function isMonthlyResetDebugEnabled () {
1601         // Is there cache?
1602         if (!isset($GLOBALS[__FUNCTION__])) {
1603                 // Determine it
1604                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1605         } // END - if
1606
1607         // Return cache
1608         return $GLOBALS[__FUNCTION__];
1609 }
1610
1611 // Checks whether debugging of yearly resets is enabled
1612 function isYearlyResetDebugEnabled () {
1613         // Is there cache?
1614         if (!isset($GLOBALS[__FUNCTION__])) {
1615                 // Determine it
1616                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
1617         } // END - if
1618
1619         // Return cache
1620         return $GLOBALS[__FUNCTION__];
1621 }
1622
1623 // Checks whether displaying of debug SQLs are enabled
1624 function isDisplayDebugSqlEnabled () {
1625         // Is there cache?
1626         if (!isset($GLOBALS[__FUNCTION__])) {
1627                 // Determine it
1628                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (isConfigEntrySet('display_debug_sql')) && (getDisplayDebugSqls() == 'Y'));
1629         } // END - if
1630
1631         // Return cache
1632         return $GLOBALS[__FUNCTION__];
1633 }
1634
1635 // Checks whether module title is enabled
1636 function isModuleTitleEnabled () {
1637         // Is there cache?
1638         if (!isset($GLOBALS[__FUNCTION__])) {
1639                 // Determine it
1640                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_mod_title')) && (getConfig('enable_mod_title') == 'Y'));
1641         } // END - if
1642
1643         // Return cache
1644         return $GLOBALS[__FUNCTION__];
1645 }
1646
1647 // Checks whether what title is enabled
1648 function isWhatTitleEnabled () {
1649         // Is there cache?
1650         if (!isset($GLOBALS[__FUNCTION__])) {
1651                 // Determine it
1652                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_what_title')) && (getConfig('enable_what_title') == 'Y'));
1653         } // END - if
1654
1655         // Return cache
1656         return $GLOBALS[__FUNCTION__];
1657 }
1658
1659 // "Getter" for internal_stats
1660 function getInternalStats () {
1661         // Is there cache?
1662         if (!isset($GLOBALS[__FUNCTION__])) {
1663                 // Determine it
1664                 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1665         } // END - if
1666
1667         // Return cache
1668         return $GLOBALS[__FUNCTION__];
1669 }
1670
1671 // Checks whether stats are enabled
1672 function ifInternalStatsEnabled () {
1673         // Is there cache?
1674         if (!isset($GLOBALS[__FUNCTION__])) {
1675                 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1676                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1677         } // END - if
1678
1679         // Return cached value
1680         return $GLOBALS[__FUNCTION__];
1681 }
1682
1683 // Checks whether admin-notification of certain user actions is enabled
1684 function isAdminNotificationEnabled () {
1685         // Is there cache?
1686         if (!isset($GLOBALS[__FUNCTION__])) {
1687                 // Determine it
1688                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isConfigEntrySet('admin_notify')) && (getAdminNotify() == 'Y'));
1689         } // END - if
1690
1691         // Return cache
1692         return $GLOBALS[__FUNCTION__];
1693 }
1694
1695 // Checks whether random referral id selection is enabled
1696 function isRandomReferralIdEnabled () {
1697         // Is there cache?
1698         if (!isset($GLOBALS[__FUNCTION__])) {
1699                 // Determine it
1700                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isConfigEntrySet('select_user_zero_refid')) && (getSelectUserZeroRefid() == 'Y'));
1701         } // END - if
1702
1703         // Return cache
1704         return $GLOBALS[__FUNCTION__];
1705 }
1706
1707 // "Getter" for default language
1708 function getDefaultLanguage () {
1709         // Is there cache?
1710         if (!isset($GLOBALS[__FUNCTION__])) {
1711                 // Determine it
1712                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1713         } // END - if
1714
1715         // Return cache
1716         return $GLOBALS[__FUNCTION__];
1717 }
1718
1719 // "Getter" for default referral id
1720 function getDefRefid () {
1721         // Is there cache?
1722         if (!isset($GLOBALS[__FUNCTION__])) {
1723                 // Determine it
1724                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1725         } // END - if
1726
1727         // Return cache
1728         return $GLOBALS[__FUNCTION__];
1729 }
1730
1731 // "Getter" for path
1732 function getPath () {
1733         // Is there cache?
1734         if (!isset($GLOBALS[__FUNCTION__])) {
1735                 // Determine it
1736                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1737         } // END - if
1738
1739         // Return cache
1740         return $GLOBALS[__FUNCTION__];
1741 }
1742
1743 // "Getter" for url
1744 function getUrl () {
1745         // Is there cache?
1746         if (!isset($GLOBALS[__FUNCTION__])) {
1747                 // Determine it
1748                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1749         } // END - if
1750
1751         // Return cache
1752         return $GLOBALS[__FUNCTION__];
1753 }
1754
1755 // "Getter" for cache_path
1756 function getCachePath () {
1757         // Is there cache?
1758         if (!isset($GLOBALS[__FUNCTION__])) {
1759                 // Determine it
1760                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1761         } // END - if
1762
1763         // Return cache
1764         return $GLOBALS[__FUNCTION__];
1765 }
1766
1767 // "Getter" for cache_extension
1768 function getCacheExtension () {
1769         // Is there cache?
1770         if (!isset($GLOBALS[__FUNCTION__])) {
1771                 // Determine it
1772                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_EXTENSION');
1773         } // END - if
1774
1775         // Return cache
1776         return $GLOBALS[__FUNCTION__];
1777 }
1778
1779 // "Getter" for WRITE_FOOTER
1780 function getWriteFooter () {
1781         // Is there cache?
1782         if (!isset($GLOBALS[__FUNCTION__])) {
1783                 // Determine it
1784                 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1785         } // END - if
1786
1787         // Return cache
1788         return $GLOBALS[__FUNCTION__];
1789 }
1790
1791 // "Getter" for secret_key
1792 function getSecretKey () {
1793         // Is there cache?
1794         if (!isset($GLOBALS[__FUNCTION__])) {
1795                 // Determine it
1796                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1797         } // END - if
1798
1799         // Return cache
1800         return $GLOBALS[__FUNCTION__];
1801 }
1802
1803 // "Getter" for SITE_KEY
1804 function getSiteKey () {
1805         // Is there cache?
1806         if (!isset($GLOBALS[__FUNCTION__])) {
1807                 // Determine it
1808                 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1809         } // END - if
1810
1811         // Return cache
1812         return $GLOBALS[__FUNCTION__];
1813 }
1814
1815 // "Getter" for DATE_KEY
1816 function getDateKey () {
1817         // Is there cache?
1818         if (!isset($GLOBALS[__FUNCTION__])) {
1819                 // Determine it
1820                 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1821         } // END - if
1822
1823         // Return cache
1824         return $GLOBALS[__FUNCTION__];
1825 }
1826
1827 // "Getter" for master_salt
1828 function getMasterSalt () {
1829         // Is there cache?
1830         if (!isset($GLOBALS[__FUNCTION__])) {
1831                 // Determine it
1832                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1833         } // END - if
1834
1835         // Return cache
1836         return $GLOBALS[__FUNCTION__];
1837 }
1838
1839 // "Getter" for prime
1840 function getPrime () {
1841         // Is there cache?
1842         if (!isset($GLOBALS[__FUNCTION__])) {
1843                 // Determine it
1844                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1845         } // END - if
1846
1847         // Return cache
1848         return $GLOBALS[__FUNCTION__];
1849 }
1850
1851 // "Getter" for encrypt_separator
1852 function getEncryptSeparator () {
1853         // Is there cache?
1854         if (!isset($GLOBALS[__FUNCTION__])) {
1855                 // Determine it
1856                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1857         } // END - if
1858
1859         // Return cache
1860         return $GLOBALS[__FUNCTION__];
1861 }
1862
1863 // "Getter" for mysql_prefix
1864 function getMysqlPrefix () {
1865         // Is there cache?
1866         if (!isset($GLOBALS[__FUNCTION__])) {
1867                 // Determine it
1868                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1869         } // END - if
1870
1871         // Return cache
1872         return $GLOBALS[__FUNCTION__];
1873 }
1874
1875 // "Getter" for table_type
1876 function getTableType () {
1877         // Is there cache?
1878         if (!isset($GLOBALS[__FUNCTION__])) {
1879                 // Determine it
1880                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1881         } // END - if
1882
1883         // Return cache
1884         return $GLOBALS[__FUNCTION__];
1885 }
1886
1887 // "Getter" for db_type
1888 function getDbType () {
1889         // Is there cache?
1890         if (!isset($GLOBALS[__FUNCTION__])) {
1891                 // Determine it
1892                 $GLOBALS[__FUNCTION__] = getConfig('_DB_TYPE');
1893         } // END - if
1894
1895         // Return cache
1896         return $GLOBALS[__FUNCTION__];
1897 }
1898
1899 // "Getter" for salt_length
1900 function getSaltLength () {
1901         // Is there cache?
1902         if (!isset($GLOBALS[__FUNCTION__])) {
1903                 // Determine it
1904                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1905         } // END - if
1906
1907         // Return cache
1908         return $GLOBALS[__FUNCTION__];
1909 }
1910
1911 // "Getter" for output_mode
1912 function getOutputMode () {
1913         // Is there cache?
1914         if (!isset($GLOBALS[__FUNCTION__])) {
1915                 // Determine it
1916                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1917         } // END - if
1918
1919         // Return cache
1920         return $GLOBALS[__FUNCTION__];
1921 }
1922
1923 // "Getter" for full_version
1924 function getFullVersion () {
1925         // Is there cache?
1926         if (!isset($GLOBALS[__FUNCTION__])) {
1927                 // Determine it
1928                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1929         } // END - if
1930
1931         // Return cache
1932         return $GLOBALS[__FUNCTION__];
1933 }
1934
1935 // "Getter" for title
1936 function getTitle () {
1937         // Is there cache?
1938         if (!isset($GLOBALS[__FUNCTION__])) {
1939                 // Determine it
1940                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1941         } // END - if
1942
1943         // Return cache
1944         return $GLOBALS[__FUNCTION__];
1945 }
1946
1947 // "Getter" for server_url
1948 function getServerUrl () {
1949         // Is there cache?
1950         if (!isset($GLOBALS[__FUNCTION__])) {
1951                 // Determine it
1952                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1953         } // END - if
1954
1955         // Return cache
1956         return $GLOBALS[__FUNCTION__];
1957 }
1958
1959 // "Getter" for mt_word
1960 function getMtWord () {
1961         // Is there cache?
1962         if (!isset($GLOBALS[__FUNCTION__])) {
1963                 // Determine it
1964                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1965         } // END - if
1966
1967         // Return cache
1968         return $GLOBALS[__FUNCTION__];
1969 }
1970
1971 // "Getter" for mt_word2
1972 function getMtWord2 () {
1973         // Is there cache?
1974         if (!isset($GLOBALS[__FUNCTION__])) {
1975                 // Determine it
1976                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1977         } // END - if
1978
1979         // Return cache
1980         return $GLOBALS[__FUNCTION__];
1981 }
1982
1983 // "Getter" for mt_word3
1984 function getMtWord3 () {
1985         // Is there cache?
1986         if (!isset($GLOBALS[__FUNCTION__])) {
1987                 // Determine it
1988                 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
1989         } // END - if
1990
1991         // Return cache
1992         return $GLOBALS[__FUNCTION__];
1993 }
1994
1995 // "Getter" for START_TDAY
1996 function getStartTday () {
1997         // Is there cache?
1998         if (!isset($GLOBALS[__FUNCTION__])) {
1999                 // Determine it
2000                 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
2001         } // END - if
2002
2003         // Return cache
2004         return $GLOBALS[__FUNCTION__];
2005 }
2006
2007 // "Getter" for START_YDAY
2008 function getStartYday () {
2009         // Is there cache?
2010         if (!isset($GLOBALS[__FUNCTION__])) {
2011                 // Determine it
2012                 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
2013         } // END - if
2014
2015         // Return cache
2016         return $GLOBALS[__FUNCTION__];
2017 }
2018
2019 // "Getter" for main_title
2020 function getMainTitle () {
2021         // Is there cache?
2022         if (!isset($GLOBALS[__FUNCTION__])) {
2023                 // Determine it
2024                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2025         } // END - if
2026
2027         // Return cache
2028         return $GLOBALS[__FUNCTION__];
2029 }
2030
2031 // "Getter" for file_hash
2032 function getFileHash () {
2033         // Is there cache?
2034         if (!isset($GLOBALS[__FUNCTION__])) {
2035                 // Determine it
2036                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2037         } // END - if
2038
2039         // Return cache
2040         return $GLOBALS[__FUNCTION__];
2041 }
2042
2043 // "Getter" for pass_scramble
2044 function getPassScramble () {
2045         // Is there cache?
2046         if (!isset($GLOBALS[__FUNCTION__])) {
2047                 // Determine it
2048                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2049         } // END - if
2050
2051         // Return cache
2052         return $GLOBALS[__FUNCTION__];
2053 }
2054
2055 // "Getter" for ap_inactive_since
2056 function getApInactiveSince () {
2057         // Is there cache?
2058         if (!isset($GLOBALS[__FUNCTION__])) {
2059                 // Determine it
2060                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2061         } // END - if
2062
2063         // Return cache
2064         return $GLOBALS[__FUNCTION__];
2065 }
2066
2067 // "Getter" for user_min_confirmed
2068 function getUserMinConfirmed () {
2069         // Is there cache?
2070         if (!isset($GLOBALS[__FUNCTION__])) {
2071                 // Determine it
2072                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2073         } // END - if
2074
2075         // Return cache
2076         return $GLOBALS[__FUNCTION__];
2077 }
2078 // "Getter" for points
2079 function getPoints () {
2080         // Is there cache?
2081         if (!isset($GLOBALS[__FUNCTION__])) {
2082                 // Determine it
2083                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2084         } // END - if
2085
2086         // Return cache
2087         return $GLOBALS[__FUNCTION__];
2088 }
2089
2090 // "Getter" for slogan
2091 function getSlogan () {
2092         // Is there cache?
2093         if (!isset($GLOBALS[__FUNCTION__])) {
2094                 // Determine it
2095                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2096         } // END - if
2097
2098         // Return cache
2099         return $GLOBALS[__FUNCTION__];
2100 }
2101
2102 // "Getter" for copy
2103 function getCopy () {
2104         // Is there cache?
2105         if (!isset($GLOBALS[__FUNCTION__])) {
2106                 // Determine it
2107                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2108         } // END - if
2109
2110         // Return cache
2111         return $GLOBALS[__FUNCTION__];
2112 }
2113
2114 // "Getter" for webmaster
2115 function getWebmaster () {
2116         // Is there cache?
2117         if (!isset($GLOBALS[__FUNCTION__])) {
2118                 // Determine it
2119                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2120         } // END - if
2121
2122         // Return cache
2123         return $GLOBALS[__FUNCTION__];
2124 }
2125
2126 // "Getter" for sql_count
2127 function getSqlCount () {
2128         // Is there cache?
2129         if (!isset($GLOBALS[__FUNCTION__])) {
2130                 // Determine it
2131                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2132         } // END - if
2133
2134         // Return cache
2135         return $GLOBALS[__FUNCTION__];
2136 }
2137
2138 // "Getter" for num_templates
2139 function getNumTemplates () {
2140         // Is there cache?
2141         if (!isset($GLOBALS[__FUNCTION__])) {
2142                 // Determine it
2143                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2144         } // END - if
2145
2146         // Return cache
2147         return $GLOBALS[__FUNCTION__];
2148 }
2149
2150 // "Getter" for dns_cache_timeout
2151 function getDnsCacheTimeout () {
2152         // Is there cache?
2153         if (!isset($GLOBALS[__FUNCTION__])) {
2154                 // Determine it
2155                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2156         } // END - if
2157
2158         // Return cache
2159         return $GLOBALS[__FUNCTION__];
2160 }
2161
2162 // "Getter" for menu_blur_spacer
2163 function getMenuBlurSpacer () {
2164         // Is there cache?
2165         if (!isset($GLOBALS[__FUNCTION__])) {
2166                 // Determine it
2167                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2168         } // END - if
2169
2170         // Return cache
2171         return $GLOBALS[__FUNCTION__];
2172 }
2173
2174 // "Getter" for points_register
2175 function getPointsRegister () {
2176         // Is there cache?
2177         if (!isset($GLOBALS[__FUNCTION__])) {
2178                 // Determine it
2179                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2180         } // END - if
2181
2182         // Return cache
2183         return $GLOBALS[__FUNCTION__];
2184 }
2185
2186 // "Getter" for points_ref
2187 function getPointsRef () {
2188         // Is there cache?
2189         if (!isset($GLOBALS[__FUNCTION__])) {
2190                 // Determine it
2191                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2192         } // END - if
2193
2194         // Return cache
2195         return $GLOBALS[__FUNCTION__];
2196 }
2197
2198 // "Getter" for ref_payout
2199 function getRefPayout () {
2200         // Is there cache?
2201         if (!isset($GLOBALS[__FUNCTION__])) {
2202                 // Determine it
2203                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2204         } // END - if
2205
2206         // Return cache
2207         return $GLOBALS[__FUNCTION__];
2208 }
2209
2210 // "Getter" for online_timeout
2211 function getOnlineTimeout () {
2212         // Is there cache?
2213         if (!isset($GLOBALS[__FUNCTION__])) {
2214                 // Determine it
2215                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2216         } // END - if
2217
2218         // Return cache
2219         return $GLOBALS[__FUNCTION__];
2220 }
2221
2222 // "Getter" for index_home
2223 function getIndexHome () {
2224         // Is there cache?
2225         if (!isset($GLOBALS[__FUNCTION__])) {
2226                 // Determine it
2227                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2228         } // END - if
2229
2230         // Return cache
2231         return $GLOBALS[__FUNCTION__];
2232 }
2233
2234 // "Getter" for one_day
2235 function getOneDay () {
2236         // Is there cache?
2237         if (!isset($GLOBALS[__FUNCTION__])) {
2238                 // Determine it
2239                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2240         } // END - if
2241
2242         // Return cache
2243         return $GLOBALS[__FUNCTION__];
2244 }
2245
2246 // "Getter" for img_type
2247 function getImgType () {
2248         // Is there cache?
2249         if (!isset($GLOBALS[__FUNCTION__])) {
2250                 // Determine it
2251                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2252         } // END - if
2253
2254         // Return cache
2255         return $GLOBALS[__FUNCTION__];
2256 }
2257
2258 // "Getter" for code_length
2259 function getCodeLength () {
2260         // Is there cache?
2261         if (!isset($GLOBALS[__FUNCTION__])) {
2262                 // Determine it
2263                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2264         } // END - if
2265
2266         // Return cache
2267         return $GLOBALS[__FUNCTION__];
2268 }
2269
2270 // "Getter" for min_password_length
2271 function getMinPasswordLength () {
2272         // Is there cache?
2273         if (!isset($GLOBALS[__FUNCTION__])) {
2274                 // Determine it
2275                 $GLOBALS[__FUNCTION__] = getConfig('min_password_length');
2276         } // END - if
2277
2278         // Return cache
2279         return $GLOBALS[__FUNCTION__];
2280 }
2281
2282 // "Getter" for min_password_score
2283 function getMinPasswordScore () {
2284         // Is there cache?
2285         if (!isset($GLOBALS[__FUNCTION__])) {
2286                 // Determine it
2287                 $GLOBALS[__FUNCTION__] = getConfig('min_password_score');
2288         } // END - if
2289
2290         // Return cache
2291         return $GLOBALS[__FUNCTION__];
2292 }
2293
2294 // "Getter" for admin_menu
2295 function getAdminMenu () {
2296         // Is there cache?
2297         if (!isset($GLOBALS[__FUNCTION__])) {
2298                 // Determine it
2299                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2300         } // END - if
2301
2302         // Return cache
2303         return $GLOBALS[__FUNCTION__];
2304 }
2305
2306 // "Getter" for last_hourly
2307 function getLastHourly () {
2308         // Is there cache?
2309         if (!isset($GLOBALS[__FUNCTION__])) {
2310                 // Determine it
2311                 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2312         } // END - if
2313
2314         // Return cache
2315         return $GLOBALS[__FUNCTION__];
2316 }
2317
2318 // "Getter" for last_daily
2319 function getLastDaily () {
2320         // Is there cache?
2321         if (!isset($GLOBALS[__FUNCTION__])) {
2322                 // Determine it
2323                 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2324         } // END - if
2325
2326         // Return cache
2327         return $GLOBALS[__FUNCTION__];
2328 }
2329
2330 // "Getter" for last_weekly
2331 function getLastWeekly () {
2332         // Is there cache?
2333         if (!isset($GLOBALS[__FUNCTION__])) {
2334                 // Determine it
2335                 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2336         } // END - if
2337
2338         // Return cache
2339         return $GLOBALS[__FUNCTION__];
2340 }
2341
2342 // "Getter" for last_monthly
2343 function getLastMonthly () {
2344         // Is there cache?
2345         if (!isset($GLOBALS[__FUNCTION__])) {
2346                 // Determine it
2347                 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2348         } // END - if
2349
2350         // Return cache
2351         return $GLOBALS[__FUNCTION__];
2352 }
2353
2354 // "Getter" for last_yearly
2355 function getLastYearly () {
2356         // Is there cache?
2357         if (!isset($GLOBALS[__FUNCTION__])) {
2358                 // Determine it
2359                 $GLOBALS[__FUNCTION__] = getConfig('last_yearly');
2360         } // END - if
2361
2362         // Return cache
2363         return $GLOBALS[__FUNCTION__];
2364 }
2365
2366 // "Getter" for mails_page
2367 function getMailsPage () {
2368         // Is there cache?
2369         if (!isset($GLOBALS[__FUNCTION__])) {
2370                 // Determine it
2371                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2372         } // END - if
2373
2374         // Return cache
2375         return $GLOBALS[__FUNCTION__];
2376 }
2377
2378 // "Getter" for rand_no
2379 function getRandNo () {
2380         // Is there cache?
2381         if (!isset($GLOBALS[__FUNCTION__])) {
2382                 // Determine it
2383                 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2384         } // END - if
2385
2386         // Return cache
2387         return $GLOBALS[__FUNCTION__];
2388 }
2389
2390 // "Getter" for __DB_NAME
2391 function getDbName () {
2392         // Is there cache?
2393         if (!isset($GLOBALS[__FUNCTION__])) {
2394                 // Determine it
2395                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2396         } // END - if
2397
2398         // Return cache
2399         return $GLOBALS[__FUNCTION__];
2400 }
2401
2402 // "Getter" for DOMAIN
2403 function getDomain () {
2404         // Is there cache?
2405         if (!isset($GLOBALS[__FUNCTION__])) {
2406                 // Determine it
2407                 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2408         } // END - if
2409
2410         // Return cache
2411         return $GLOBALS[__FUNCTION__];
2412 }
2413
2414 // "Getter" for proxy_username
2415 function getProxyUsername () {
2416         // Is there cache?
2417         if (!isset($GLOBALS[__FUNCTION__])) {
2418                 // Determine it
2419                 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2420         } // END - if
2421
2422         // Return cache
2423         return $GLOBALS[__FUNCTION__];
2424 }
2425
2426 // "Getter" for proxy_password
2427 function getProxyPassword () {
2428         // Is there cache?
2429         if (!isset($GLOBALS[__FUNCTION__])) {
2430                 // Determine it
2431                 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2432         } // END - if
2433
2434         // Return cache
2435         return $GLOBALS[__FUNCTION__];
2436 }
2437
2438 // "Getter" for proxy_host
2439 function getProxyHost () {
2440         // Is there cache?
2441         if (!isset($GLOBALS[__FUNCTION__])) {
2442                 // Determine it
2443                 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2444         } // END - if
2445
2446         // Return cache
2447         return $GLOBALS[__FUNCTION__];
2448 }
2449
2450 // "Getter" for proxy_port
2451 function getProxyPort () {
2452         // Is there cache?
2453         if (!isset($GLOBALS[__FUNCTION__])) {
2454                 // Determine it
2455                 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2456         } // END - if
2457
2458         // Return cache
2459         return $GLOBALS[__FUNCTION__];
2460 }
2461
2462 // "Getter" for SMTP_HOSTNAME
2463 function getSmtpHostname () {
2464         // Is there cache?
2465         if (!isset($GLOBALS[__FUNCTION__])) {
2466                 // Determine it
2467                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2468         } // END - if
2469
2470         // Return cache
2471         return $GLOBALS[__FUNCTION__];
2472 }
2473
2474 // "Getter" for SMTP_USER
2475 function getSmtpUser () {
2476         // Is there cache?
2477         if (!isset($GLOBALS[__FUNCTION__])) {
2478                 // Determine it
2479                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2480         } // END - if
2481
2482         // Return cache
2483         return $GLOBALS[__FUNCTION__];
2484 }
2485
2486 // "Getter" for SMTP_PASSWORD
2487 function getSmtpPassword () {
2488         // Is there cache?
2489         if (!isset($GLOBALS[__FUNCTION__])) {
2490                 // Determine it
2491                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2492         } // END - if
2493
2494         // Return cache
2495         return $GLOBALS[__FUNCTION__];
2496 }
2497
2498 // "Getter" for points_word
2499 function getPointsWord () {
2500         // Is there cache?
2501         if (!isset($GLOBALS[__FUNCTION__])) {
2502                 // Determine it
2503                 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2504         } // END - if
2505
2506         // Return cache
2507         return $GLOBALS[__FUNCTION__];
2508 }
2509
2510 // "Getter" for profile_lock
2511 function getProfileLock () {
2512         // Is there cache?
2513         if (!isset($GLOBALS[__FUNCTION__])) {
2514                 // Determine it
2515                 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2516         } // END - if
2517
2518         // Return cache
2519         return $GLOBALS[__FUNCTION__];
2520 }
2521
2522 // "Getter" for url_tlock
2523 function getUrlTlock () {
2524         // Is there cache?
2525         if (!isset($GLOBALS[__FUNCTION__])) {
2526                 // Determine it
2527                 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2528         } // END - if
2529
2530         // Return cache
2531         return $GLOBALS[__FUNCTION__];
2532 }
2533
2534 // "Getter" for title_left
2535 function getTitleLeft () {
2536         // Is there cache?
2537         if (!isset($GLOBALS[__FUNCTION__])) {
2538                 // Determine it
2539                 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2540         } // END - if
2541
2542         // Return cache
2543         return $GLOBALS[__FUNCTION__];
2544 }
2545
2546 // "Getter" for title_right
2547 function getTitleRight () {
2548         // Is there cache?
2549         if (!isset($GLOBALS[__FUNCTION__])) {
2550                 // Determine it
2551                 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2552         } // END - if
2553
2554         // Return cache
2555         return $GLOBALS[__FUNCTION__];
2556 }
2557
2558 // "Getter" for title_middle
2559 function getTitleMiddle () {
2560         // Is there cache?
2561         if (!isset($GLOBALS[__FUNCTION__])) {
2562                 // Determine it
2563                 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2564         } // END - if
2565
2566         // Return cache
2567         return $GLOBALS[__FUNCTION__];
2568 }
2569
2570 // Getter for 'display_home_in_index'
2571 function getDisplayHomeInIndex () {
2572         // Is the cache entry set?
2573         if (!isset($GLOBALS[__FUNCTION__])) {
2574                 // No, so determine it
2575                 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2576         } // END - if
2577
2578         // Return cached entry
2579         return $GLOBALS[__FUNCTION__];
2580 }
2581
2582 // Checks whether 'display_home_in_index' is 'Y'
2583 function isDisplayHomeInIndexEnabled () {
2584         // Is the cache entry set?
2585         if (!isset($GLOBALS[__FUNCTION__])) {
2586                 // No, so determine it
2587                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isConfigEntrySet('display_home_in_index')) && (getDisplayHomeInIndex() == 'Y'));
2588         } // END - if
2589
2590         // Return cached entry
2591         return $GLOBALS[__FUNCTION__];
2592 }
2593
2594 // Getter for 'show_points_unconfirmed'
2595 function getShowPointsUnconfirmed () {
2596         // Is the cache entry set?
2597         if (!isset($GLOBALS[__FUNCTION__])) {
2598                 // No, so determine it
2599                 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2600         } // END - if
2601
2602         // Return cached entry
2603         return $GLOBALS[__FUNCTION__];
2604 }
2605
2606 // Checks whether 'show_points_unconfirmed' is 'Y'
2607 function isShowPointsUnconfirmedEnabled () {
2608         // Is the cache entry set?
2609         if (!isset($GLOBALS[__FUNCTION__])) {
2610                 // No, so determine it
2611                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.5.5')) && (isConfigEntrySet('show_points_unconfirmed')) && (getShowPointsUnconfirmed() == 'Y'));
2612         } // END - if
2613
2614         // Return cached entry
2615         return $GLOBALS[__FUNCTION__];
2616 }
2617
2618 // Getter for 'youre_here'
2619 function getYoureHere () {
2620         // Is the cache entry set?
2621         if (!isset($GLOBALS[__FUNCTION__])) {
2622                 // No, so determine it
2623                 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2624         } // END - if
2625
2626         // Return cached entry
2627         return $GLOBALS[__FUNCTION__];
2628 }
2629
2630 // Checks whether 'show_timings' is 'Y'
2631 function isYoureHereEnabled () {
2632         // Is the cache entry set?
2633         if (!isset($GLOBALS[__FUNCTION__])) {
2634                 // No, so determine it
2635                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (isConfigEntrySet('youre_here')) && (getYoureHere() == 'Y'));
2636         } // END - if
2637
2638         // Return cached entry
2639         return $GLOBALS[__FUNCTION__];
2640 }
2641
2642 // Getter for 'show_timings'
2643 function getShowTimings () {
2644         // Is the cache entry set?
2645         if (!isset($GLOBALS[__FUNCTION__])) {
2646                 // No, so determine it
2647                 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2648         } // END - if
2649
2650         // Return cached entry
2651         return $GLOBALS[__FUNCTION__];
2652 }
2653
2654 // Checks whether 'show_timings' is 'Y'
2655 function isShowTimingsEnabled () {
2656         // Is the cache entry set?
2657         if (!isset($GLOBALS[__FUNCTION__])) {
2658                 // No, so determine it
2659                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isConfigEntrySet('show_timings')) && (getShowTimings() == 'Y'));
2660         } // END - if
2661
2662         // Return cached entry
2663         return $GLOBALS[__FUNCTION__];
2664 }
2665
2666 // Getter for 'ap_server_name_since'
2667 function getApServerNameSince () {
2668         // Is the cache entry set?
2669         if (!isset($GLOBALS[__FUNCTION__])) {
2670                 // No, so determine it
2671                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2672         } // END - if
2673
2674         // Return cached entry
2675         return $GLOBALS[__FUNCTION__];
2676 }
2677
2678 // Getter for 'ap_server_name'
2679 function getApServerName () {
2680         // Is the cache entry set?
2681         if (!isset($GLOBALS[__FUNCTION__])) {
2682                 // No, so determine it
2683                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2684         } // END - if
2685
2686         // Return cached entry
2687         return $GLOBALS[__FUNCTION__];
2688 }
2689
2690 // Getter for 'index_delay'
2691 function getIndexDelay () {
2692         // Is the cache entry set?
2693         if (!isset($GLOBALS[__FUNCTION__])) {
2694                 // No, so determine it
2695                 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2696         } // END - if
2697
2698         // Return cached entry
2699         return $GLOBALS[__FUNCTION__];
2700 }
2701
2702 // Checks whether 'ap_server_name' is 'Y'
2703 function isApServerNameEnabled () {
2704         // Is the cache entry set?
2705         if (!isset($GLOBALS[__FUNCTION__])) {
2706                 // No, so determine it
2707                 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2708         } // END - if
2709
2710         // Return cached entry
2711         return $GLOBALS[__FUNCTION__];
2712 }
2713
2714 // Getter for 'admin_menu_javascript'
2715 function getAdminMenuJavascript () {
2716         // Is the cache entry set?
2717         if (!isset($GLOBALS[__FUNCTION__])) {
2718                 // No, so determine it
2719                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2720         } // END - if
2721
2722         // Return cached entry
2723         return $GLOBALS[__FUNCTION__];
2724 }
2725
2726 // Getter for 'points_remove_account'
2727 function getPointsRemoveAccount () {
2728         // Is the cache entry set?
2729         if (!isset($GLOBALS[__FUNCTION__])) {
2730                 // No, so determine it
2731                 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2732         } // END - if
2733
2734         // Return cached entry
2735         return $GLOBALS[__FUNCTION__];
2736 }
2737
2738 // Getter for 'css_php'
2739 function getCssPhp () {
2740         // Is the cache entry set?
2741         if (!isset($GLOBALS[__FUNCTION__])) {
2742                 // No, so determine it
2743                 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2744         } // END - if
2745
2746         // Return cached entry
2747         return $GLOBALS[__FUNCTION__];
2748 }
2749
2750 // Getter for 'guest_menu'
2751 function getGuestMenu () {
2752         // Is the cache entry set?
2753         if (!isset($GLOBALS[__FUNCTION__])) {
2754                 // No, so determine it
2755                 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2756         } // END - if
2757
2758         // Return cached entry
2759         return $GLOBALS[__FUNCTION__];
2760 }
2761
2762 // Checks if guest menu is enabled
2763 function isGuestMenuEnabled () {
2764         // Is the cache entry set?
2765         if (!isset($GLOBALS[__FUNCTION__])) {
2766                 // No, so determine it
2767                 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2768         } // END - if
2769
2770         // Return cached entry
2771         return $GLOBALS[__FUNCTION__];
2772 }
2773
2774 // Getter for 'member_menu'
2775 function getMemberMenu () {
2776         // Is the cache entry set?
2777         if (!isset($GLOBALS[__FUNCTION__])) {
2778                 // No, so determine it
2779                 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2780         } // END - if
2781
2782         // Return cached entry
2783         return $GLOBALS[__FUNCTION__];
2784 }
2785
2786 // Checks if member menu is enabled
2787 function isMemberMenuEnabled () {
2788         // Is the cache entry set?
2789         if (!isset($GLOBALS[__FUNCTION__])) {
2790                 // No, so determine it
2791                 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2792         } // END - if
2793
2794         // Return cached entry
2795         return $GLOBALS[__FUNCTION__];
2796 }
2797
2798 // Getter for 'word_wrap'
2799 function getWordWrap () {
2800         // Is the cache entry set?
2801         if (!isset($GLOBALS[__FUNCTION__])) {
2802                 // Construct config entry name
2803                 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2804
2805                 // Is a special config entry found or ext-sql_patches updated?
2806                 if (isConfigEntrySet($configEntry)) {
2807                         // A special config entry has been found, then use it
2808                         $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2809                 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2810                         // No special config entry found, then use it as "fall-back"
2811                         $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2812                 } else {
2813                         // No, use default (15 characters)
2814                         $GLOBALS[__FUNCTION__] = 15;
2815                 }
2816         } // END - if
2817
2818         // Return cached entry
2819         return $GLOBALS[__FUNCTION__];
2820 }
2821
2822 // Checks whether proxy configuration is used
2823 function isProxyUsed () {
2824         // Is there cache?
2825         if (!isset($GLOBALS[__FUNCTION__])) {
2826                 // Determine it
2827                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (isValidNumber(getConfig('proxy_port'))));
2828         } // END - if
2829
2830         // Return cache
2831         return $GLOBALS[__FUNCTION__];
2832 }
2833
2834 // Checks whether POST data contains selections
2835 function ifPostContainsSelections ($element = 'sel') {
2836         // Is there cache?
2837         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2838                 // Determine it
2839                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2840         } // END - if
2841
2842         // Return cache
2843         return $GLOBALS[__FUNCTION__][$element];
2844 }
2845
2846 // Checks whether verbose_sql is Y and returns true/false if so
2847 function isVerboseSqlEnabled () {
2848         // Is there cache?
2849         if (!isset($GLOBALS[__FUNCTION__])) {
2850                 // Determine it
2851                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2852         } // END - if
2853
2854         // Return cache
2855         return $GLOBALS[__FUNCTION__];
2856 }
2857
2858 // "Getter" for total user points
2859 function getTotalPoints ($userid) {
2860         // Is there cache?
2861         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2862                 // Init array for filter chain
2863                 $data = array(
2864                         'userid' => $userid,
2865                         'points' => 0
2866                 );
2867
2868                 // Run filter chain for getting more point values
2869                 $data = runFilterChain('get_total_points', $data);
2870
2871                 // Determine it
2872                 $GLOBALS[__FUNCTION__][$userid] = $data['points']  - getUserUsedPoints($userid);
2873         } // END - if
2874
2875         // Return cache
2876         return $GLOBALS[__FUNCTION__][$userid];
2877 }
2878
2879 // Wrapper to get used points for given userid
2880 function getUserUsedPoints ($userid) {
2881         // Is there cache?
2882         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2883                 // Determine it
2884                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2885         } // END - if
2886
2887         // Return cache
2888         return $GLOBALS[__FUNCTION__][$userid];
2889 }
2890
2891 // Checks whether direct payment is allowed in configuration
2892 function isDirectPaymentEnabled () {
2893         // Is there cache?
2894         if (!isset($GLOBALS[__FUNCTION__])) {
2895                 // Determine it
2896                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('allow_direct_pay')) && (getConfig('allow_direct_pay') == 'Y'));
2897         } // END - if
2898
2899         // Return cache
2900         return $GLOBALS[__FUNCTION__];
2901 }
2902
2903 // Checks whether JavaScript-based admin menu is enabled
2904 function isAdminMenuJavascriptEnabled () {
2905         // Is there cache?
2906         if (!isset($GLOBALS[__FUNCTION__])) {
2907                 // Determine it
2908                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (isConfigEntrySet('admin_menu_javascript')) && (getAdminMenuJavaScript() == 'Y'));
2909         } // END - if
2910
2911         // Return cache
2912         return $GLOBALS[__FUNCTION__];
2913 }
2914
2915 // Wrapper to check if current task is for extension (not update)
2916 function isExtensionTask ($content) {
2917         // Is there cache?
2918         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2919                 // Determine it
2920                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2921         } // END - if
2922
2923         // Return cache
2924         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2925 }
2926
2927 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2928 function ifTesterAccountsAllowed () {
2929         // Is the cache entry set?
2930         if (!isset($GLOBALS[__FUNCTION__])) {
2931                 // No, so determine it
2932                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2933         } // END - if
2934
2935         // Return cached entry
2936         return $GLOBALS[__FUNCTION__];
2937 }
2938
2939 // Wrapper to check if output mode is CSS
2940 function isCssOutputMode () {
2941         // Is cache set?
2942         if (!isset($GLOBALS[__FUNCTION__])) {
2943                 // Determine it
2944                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2945                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2946         } // END - if
2947
2948         // Return cache
2949         return $GLOBALS[__FUNCTION__];
2950 }
2951
2952 // Wrapper to check if output mode is HTML
2953 function isHtmlOutputMode () {
2954         // Is cache set?
2955         if (!isset($GLOBALS[__FUNCTION__])) {
2956                 // Determine it
2957                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2958                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2959         } // END - if
2960
2961         // Return cache
2962         return $GLOBALS[__FUNCTION__];
2963 }
2964
2965 // Wrapper to check if output mode is RAW
2966 function isRawOutputMode () {
2967         // Is cache set?
2968         if (!isset($GLOBALS[__FUNCTION__])) {
2969                 // Determine it
2970                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2971                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2972         } // END - if
2973
2974         // Return cache
2975         return $GLOBALS[__FUNCTION__];
2976 }
2977
2978 // Wrapper to check if output mode is AJAX
2979 function isAjaxOutputMode () {
2980         // Is cache set?
2981         if (!isset($GLOBALS[__FUNCTION__])) {
2982                 // Determine it
2983                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2984                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
2985         } // END - if
2986
2987         // Return cache
2988         return $GLOBALS[__FUNCTION__];
2989 }
2990
2991 // Wrapper to check if output mode is image
2992 function isImageOutputMode () {
2993         // Is cache set?
2994         if (!isset($GLOBALS[__FUNCTION__])) {
2995                 // Determine it
2996                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2997                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
2998         } // END - if
2999
3000         // Return cache
3001         return $GLOBALS[__FUNCTION__];
3002 }
3003
3004 // Wrapper to generate a user email link
3005 function generateWrappedUserEmailLink ($email) {
3006         // Just call the inner function
3007         return generateEmailLink($email, 'user_data');
3008 }
3009
3010 // Wrapper to check if user points are locked
3011 function ifUserPointsLocked ($userid) {
3012         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
3013         // Is there cache?
3014         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3015                 // Determine it
3016                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
3017         } // END - if
3018
3019         // Return cache
3020         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
3021         return $GLOBALS[__FUNCTION__][$userid];
3022 }
3023
3024 // Appends a line to an existing file or creates it instantly with given content.
3025 // This function does always add a new-line character to every line.
3026 function appendLineToFile ($file, $line) {
3027         $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
3028         fwrite($fp, $line . PHP_EOL);
3029         fclose($fp);
3030 }
3031
3032 // Wrapper for changeDataInFile() but with full path added
3033 function changeDataInInclude ($inc, $comment, $prefix, $suffix, $inserted, $seek=0) {
3034         // Add full path
3035         $FQFN = getPath() . $inc;
3036
3037         // Call inner function
3038         return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
3039 }
3040
3041 // Wrapper for changing entries in config-local.php
3042 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3043         // Call the inner function
3044         return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3045 }
3046
3047 // Shortens ucfirst(strtolower()) calls
3048 function firstCharUpperCase ($str) {
3049         return ucfirst(strtolower($str));
3050 }
3051
3052 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3053 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3054         // Get the configuration entry
3055         $configValue = getConfig($configEntry);
3056
3057         // Call inner method
3058         return createTimeSelections($configValue, $configEntry, $stamps, $align);
3059 }
3060
3061 // Shortens converting of German comma to Computer's version in POST data
3062 function convertCommaToDotInPostData ($postEntry) {
3063         // Read and convert given entry
3064         $postValue = convertCommaToDot(postRequestElement($postEntry));
3065
3066         // Log message
3067         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3068
3069         // ... and set it again
3070         setPostRequestElement($postEntry, $postValue);
3071 }
3072
3073 // Converts German commas to Computer's version in all entries
3074 function convertCommaToDotInPostDataArray ($postEntries) {
3075         // Replace german decimal comma with computer decimal dot
3076         foreach ($postEntries as $entry) {
3077                 // Is the entry there?
3078                 if (isPostRequestElementSet($entry)) {
3079                         // Then convert it
3080                         convertCommaToDotInPostData($entry);
3081                 } // END - if
3082         } // END - foreach
3083 }
3084
3085 /**
3086  * Parses a string into a US formated float variable, taken from user comments
3087  * from PHP documentation website.
3088  *
3089  * @param       $floatString    A string holding a float expression
3090  * @return      $float                  Corresponding float variable
3091  * @author      chris<at>georgakopoulos<dot>com
3092  * @link        http://de.php.net/manual/en/function.floatval.php#92563
3093  */
3094 function parseFloat ($floatString){
3095         // Load locale info
3096         $LocaleInfo = localeconv();
3097
3098         // Remove thousand separators
3099         $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3100
3101         // Convert decimal point
3102         $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3103
3104         // Return float value of converted string
3105         return floatval($floatString);
3106 }
3107
3108 /**
3109  * Searches a multi-dimensional array (as used in many places) for given
3110  * key/value pair as taken from user comments from PHP documentation website.
3111  *
3112  * @param       $array                  An array with one or more dimensions
3113  * @param       $key                    Key to look for
3114  * @param       $value                  Value to look for
3115  * @param       $parentIndex    Parent index (ONLY INTERNAL USE!)
3116  * @return      $results                Resulted array or empty array if $array is no array
3117  * @author      sunelbe<at>gmail<dot>com
3118  * @link        http://de.php.net/manual/en/function.array-search.php#110120
3119  */
3120 function search_array ($array, $key, $value, $parentIndex = NULL) {
3121         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3122         // Init array result
3123         $results = array();
3124
3125         // Is $array really an array?
3126         if (is_array($array)) {
3127                 // Search for whole array
3128                 foreach ($array as $idx => $dummy) {
3129                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3130                         //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3131                         // Is dummy an array?
3132                         if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3133                                 // Then search again
3134                                 $subResult = search_array($dummy, $key, $value, $idx);
3135                                 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3136
3137                                 // And merge both
3138                                 $results = merge_array($results, $subResult, TRUE);
3139                         } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3140                                 // Is found, so add it
3141                                 $results[$parentIndex] = $array;
3142                                 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3143                         }
3144                 } // END - foreach
3145         } // END - if
3146
3147         // Return resulting array
3148         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3149         return $results;
3150 }
3151
3152 // Generates a YES/NO option list from given default
3153 function generateYesNoOptions ($defaultValue = '') {
3154         // Generate it
3155         return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3156 }
3157
3158 // "Getter" for total available receivers
3159 function getTotalReceivers ($mode = 'normal') {
3160         // Get num rows
3161         $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3162
3163         // Return value
3164         return $numRows;
3165 }
3166
3167 // Wrapper "getter" to get total unconfirmed mails for given userid
3168 function getTotalUnconfirmedMails ($userid) {
3169         // Is there cache?
3170         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3171                 // Determine it
3172                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3173         } // END - if
3174
3175         // Return cache
3176         return $GLOBALS[__FUNCTION__][$userid];
3177 }
3178
3179 // Checks whether 'mailer_theme' was found in session
3180 function isMailerThemeSet () {
3181         // Is cache set?
3182         if (!isset($GLOBALS[__FUNCTION__])) {
3183                 // Determine it
3184                 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3185         } // END - if
3186
3187         // Return cache
3188         return $GLOBALS[__FUNCTION__];
3189 }
3190
3191 /**
3192  * Setter for theme in session (This setter does return the success of
3193  * setSession() which is required e.g. for destroySponsorSession().
3194  */
3195 function setMailerTheme ($newTheme) {
3196         // Set it in session
3197         return setSession('mailer_theme', $newTheme);
3198 }
3199
3200 /**
3201  * Getter for theme from session (This getter does return 'mailer_theme' from
3202  * session data or throws an error if not possible
3203  */
3204 function getMailerTheme () {
3205         // Is cache set?
3206         if (!isset($GLOBALS[__FUNCTION__])) {
3207                 // Is 'mailer_theme' set?
3208                 if (!isMailerThemeSet()) {
3209                         // No, then abort here
3210                         reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3211                 } // END - if
3212
3213                 // Get it and store it in cache
3214                 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3215         } // END - if
3216
3217         // Return cache
3218         return $GLOBALS[__FUNCTION__];
3219 }
3220
3221 // "Getter" for last_module/last_what depending on ext-user version
3222 function getUserLastWhatName () {
3223         // Default is old one: last_module
3224         $columnName = 'last_module';
3225
3226         // Is ext-user up-to-date?
3227         if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3228                 // Yes, then use new one
3229                 $columnName = 'last_what';
3230         } // END - if
3231
3232         // Return it
3233         return $columnName;
3234 }
3235
3236 // "Getter" for all columns for given alias and separator
3237 function getAllPointColumns ($alias = NULL, $separator = ',') {
3238         // Prepare the filter array
3239         $filterData = array(
3240                 'columns'   => '',
3241                 'alias'     => $alias,
3242                 'separator' => $separator
3243         );
3244
3245         // Run the filter
3246         $filterData = runFilterChain('get_all_point_columns', $filterData);
3247
3248         // Return the columns
3249         return $filterData['columns'];
3250 }
3251
3252 // Checks whether the copyright footer (which breaks framesets) is enabled
3253 function ifCopyrightFooterEnabled () {
3254         // Is not unset and not 'N'?
3255         return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3256 }
3257
3258 /**
3259  * Wrapper to check whether we have a "full page". This means that the actual
3260  * content is not delivered in any frame of a frameset.
3261  */
3262 function isFullPage () {
3263         /*
3264          * The parameter 'frame' is generic and always indicates that this content
3265          * will be output into a frame. Furthermore, if a frameset is reported or
3266          * the copyright line is explicitly deactivated, this cannot be a "full
3267          * page" again.
3268          */
3269         // @TODO Find a way to not use direct module comparison
3270         $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3271
3272         // Return it
3273         return $isFullPage;
3274 }
3275
3276 // Checks whether frameset_mode is set to true
3277 function isFramesetModeEnabled () {
3278         // Check it
3279         return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3280 }
3281
3282 // Function to determine correct 'what' value
3283 function determineWhat ($module = NULL) {
3284         // Init default 'what'
3285         $what = 'welcome';
3286
3287         // Is module NULL?
3288         if (is_null($module)) {
3289                 // Then use default
3290                 $module = getModule();
3291         } // END - if
3292
3293         // Is what set?
3294         if (isWhatSet()) {
3295                 // Then use it
3296                 $what = getWhat();
3297         } else {
3298                 // Else try to get it from current module
3299                 $what = getWhatFromModule($module);
3300         }
3301         //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3302
3303         // Remove any spaces from variable
3304         $what = trim($what);
3305
3306         // Is it empty?
3307         if (empty($what)) {
3308                 // Default action for non-admin menus
3309                 $what = 'welcome';
3310         } else {
3311                 // Secure it
3312                 $what = secureString($what);
3313         }
3314
3315         // Return what
3316         return $what;
3317 }
3318
3319 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3320 function prependZeros ($str, $length = 2) {
3321         // Return prepended string
3322         return sprintf('%0' . (int) $length . 's', $str);
3323 }
3324
3325 // Wraps convertSelectionsToEpocheTime()
3326 function convertSelectionsToEpocheTimeInPostData ($id) {
3327         // Init variables
3328         $content = array();
3329         $skip = FALSE;
3330
3331         // Get all POST data
3332         $postData = postRequestArray();
3333
3334         // Convert given selection id
3335         convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3336
3337         // Set the POST array back
3338         setPostRequestArray($postData);
3339 }
3340
3341 // Wraps checking if given points account type matches with given in POST data
3342 function ifPointsAccountTypeMatchesPost ($type) {
3343         // Check condition
3344         exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3345 }
3346
3347 // Gets given user's total referral
3348 function getUsersTotalReferrals ($userid, $level = NULL) {
3349         // Is there cache?
3350         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3351                 // Is the level NULL?
3352                 if (is_null($level)) {
3353                         // Get total amount (all levels)
3354                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3355                 } else {
3356                         // Get it from user refs
3357                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3358                 }
3359         } // END - if
3360
3361         // Return it
3362         return $GLOBALS[__FUNCTION__][$userid][$level];
3363 }
3364
3365 // Gets given user's total referral
3366 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3367         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3368         // Is there cache?
3369         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3370                 // Default is all refs
3371                 $add = '';
3372
3373                 // Is the not level NULL?
3374                 if (!is_null($level)) {
3375                         // Then add referral level
3376                         $add = ' AND `r`.`level`=' . bigintval($level);
3377                 } // END - if
3378
3379                 // Check for all referrals
3380                 $result = sqlQueryEscaped("SELECT
3381         COUNT(`d`.`userid`) AS `cnt`
3382 FROM
3383         `{?_MYSQL_PREFIX?}_user_data` AS `d`
3384 INNER JOIN
3385         `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3386 ON
3387         `d`.`userid`=`r`.`refid`
3388 WHERE
3389         `d`.`status` != 'CONFIRMED' AND
3390         `r`.`userid`=%s
3391         " . $add . "
3392 ORDER BY
3393         `d`.`userid` ASC
3394 LIMIT 1",
3395                         array(
3396                                 $userid
3397                         ), __FUNCTION__, __LINE__);
3398
3399                 // Load count
3400                 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3401
3402                 // Free result
3403                 sqlFreeResult($result);
3404         } // END - if
3405
3406         // Return it
3407         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3408         return $GLOBALS[__FUNCTION__][$userid][$level];
3409 }
3410
3411 // Converts, if found, dollar data to get element
3412 function convertDollarDataToGetElement ($data) {
3413         // Is first char a dollar?
3414         if (substr($data, 0, 1) == chr(36)) {
3415                 // Use last part for getRequestElement()
3416                 $data = getRequestElement(substr($data, 1));
3417         } // END - if
3418
3419         // Return it
3420         return $data;
3421 }
3422
3423 // Wrapper function for SQL layer to speed-up things
3424 function isSqlDebugEnabled () {
3425         // Is there cache?
3426         if (!isset($GLOBALS[__FUNCTION__])) {
3427                 // Determine it
3428                 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3429         } // END - if
3430
3431         // Return cache
3432         return $GLOBALS[__FUNCTION__];
3433 }
3434
3435 // Wrapper function to wrap call of wordwrap()
3436 function wrapWords ($text) {
3437         // Wrap words
3438         $wrapped = wordwrap($test, getWordWrap());
3439
3440         // Return it
3441         return $wrapped;
3442 }
3443
3444 // Encodes given data into a JSON object
3445 function encodeJson ($data) {
3446         // Encode it
3447         return json_encode($data, JSON_FORCE_OBJECT);
3448 }
3449
3450 // Get all extension files
3451 function loadAllExtensionsByTemplate () {
3452         // Get all
3453         $extensions = getArrayFromDirectory(
3454                 'templates/' . getLanguage() . '/html/ext/',
3455                 'ext_',
3456                 false,
3457                 false,
3458                 array(),
3459                 '.tpl',
3460                 '@(\.|\.\.)$@',
3461                 false
3462         );
3463
3464         // Return them
3465         return $extensions;
3466 }
3467
3468 // Wrapper function to allow full float values as supported by current database layout
3469 function translateFullComma ($dotted) {
3470         // Call inner function
3471         return translateComma($dotted, TRUE, 5);
3472 }
3473
3474 // Wrapper to check if the first element to be shifted is set to given value
3475 function shift_array (&$array, $value, $key = '0') {
3476         // Is the element set and value matches?
3477         assert(is_array($array));
3478         assert(isset($array[$key]));
3479         assert($array[$key] === $value);
3480
3481         // Shift it
3482         array_shift($array);
3483 }
3484
3485 // Wrapper for str_pad() with left padding zeros
3486 function padLeftZero ($str, $amount = 2) {
3487         // Is str_pad() there?
3488         if (!function_exists('str_pad')) {
3489                 // Use prependZeros()
3490                 return prependZeros($str, $amount);
3491         } else {
3492                 // Pad it
3493                 return str_pad($str, $amount, '0', STR_PAD_LEFT);
3494         }
3495 }
3496
3497 // Calculates percentage
3498 function calculatePercentageRate ($current, $total) {
3499         // Default is zero
3500         $rate = '0.0';
3501
3502         // Is sent larger zero? (Prevents division-by-zero)
3503         if ($total > 0) {
3504                 // Calculate it (it should be "translated" alter on)
3505                 $rate = ($current / $total * 100);
3506         } // END - if
3507
3508         // The should be a .0 at the end?
3509         if (strpos($rate, '.') === FALSE) {
3510                 // No, then add it
3511                 $rate .= '.0';
3512         } // END - if
3513
3514         // Return it
3515         return $rate;
3516 }
3517
3518 // Checks whether an array is filled with entries
3519 function isFilledArray ($array) {
3520         // Determine it
3521         return ((is_array($array)) && (count($array) > 0));
3522 }
3523
3524 // Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
3525 function isDeveloperSystem () {
3526         // Determine it
3527         return in_array(detectServerName(), array('localhost', '127.0.0.1'));
3528 }
3529
3530 // Checks whether given subject line has '_ref' suffix
3531 function ifSubjectHasReferralSuffix ($subject) {
3532         // Is there cache?
3533         if (!isset($GLOBALS[__FUNCTION__][$subject])) {
3534                 // Determine it
3535                 $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
3536         } // END - if
3537
3538         // Return cache
3539         return $GLOBALS[__FUNCTION__][$subject];
3540 }
3541
3542 // Converts an API response to an associative array
3543 function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimiter) {
3544         // Explode for key delimiter
3545         $keys = explode($keyDelimiter, $responseString);
3546
3547         // Init returned array and "walk" through all entries
3548         $returned = array();
3549         foreach ($keys as $keyValue) {
3550                 // Explode it
3551                 $parts = explode($valueDelimiter, $keyValue);
3552
3553                 // Count must be 2
3554                 assert(count($parts) == 2);
3555
3556                 // Then add both: 0=key, 1=value
3557                 $returned[sqlEscapeString($parts[0])] = sqlEscapeString($parts[1]);
3558         } // END - if
3559
3560         // Return finished array
3561         return $returned;
3562 }
3563
3564 // Getter for full (generic) hash file name
3565 function getGenericHashFileName () {
3566         // Return result
3567         return sprintf('%s%s.%s%s', getPath(), getCachePath(), getFileHash(), getCacheExtension());
3568 }
3569
3570 // "Compiles" the given value and sets it in given key
3571 function setSessionCompiled ($key, $value) {
3572         // "Compile" the value
3573         $value = doFinalCompilation(compileRawCode($value));
3574
3575         // And set it
3576         return setSession($key, $value);
3577 }
3578
3579 // [EOF]
3580 ?>