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