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