00844537956bacb634ef375ee5479089473325bd
[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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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         die();
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                 debug_report_bug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
49         } elseif (!isset($GLOBALS['file_content'][$FQFN])) {
50                 // Load the file
51                 if (function_exists('file_get_contents')) {
52                         // Use new function
53                         $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
54                 } else {
55                         // Fall-back to implode-file chain
56                         $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
57                 }
58         } // END - if
59
60         // Return the content
61         return $GLOBALS['file_content'][$FQFN];
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.", 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         unset($GLOBALS['file_content'][$FQFN]);
78         $return = false;
79
80         // Is the function there?
81         if (function_exists('file_put_contents')) {
82                 // With lock?
83                 if ($aquireLock === true) {
84                         // Write it directly with lock
85                         $return = file_put_contents($FQFN, $content, LOCK_EX);
86                 } else {
87                         // Write it directly
88                         $return = file_put_contents($FQFN, $content);
89                 }
90         } else {
91                 // Write it with fopen
92                 $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
93
94                 // Do we need to aquire a lock?
95                 if ($aquireLock === true) {
96                         // Aquire 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
112                 // Remember content in cache
113                 $GLOBALS['file_content'][$FQFN] = $content;
114         } // END - if
115
116         // Return status
117         return (($return !== false) && (changeMode($FQFN, 0644)));
118 }
119
120 // Clears the output buffer. This function does *NOT* backup sent content.
121 function clearOutputBuffer () {
122         // Trigger an error on failure
123         if ((ob_get_length() > 0) && (!ob_end_clean())) {
124                 // Failed!
125                 debug_report_bug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
126         } // END - if
127 }
128
129 // Encode strings
130 // @TODO Implement $compress
131 function encodeString ($str, $compress = true) {
132         $str = urlencode(base64_encode(compileUriCode($str)));
133         return $str;
134 }
135
136 // Decode strings encoded with encodeString()
137 // @TODO Implement $decompress
138 function decodeString ($str, $decompress = true) {
139         $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
140         return $str;
141 }
142
143 // Decode entities in a nicer way
144 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
145         // Decode the entities to UTF-8 now
146         $decodedString = html_entity_decode($str, $quote, 'UTF-8');
147
148         // Return decoded string
149         return $decodedString;
150 }
151
152 // Merges an array together but only if both are arrays
153 function merge_array ($array1, $array2) {
154         // Are both an array?
155         if ((!is_array($array1)) && (!is_array($array2))) {
156                 // Both are not arrays
157                 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
158         } elseif (!is_array($array1)) {
159                 // Left one is not an array
160                 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
161         } elseif (!is_array($array2)) {
162                 // Right one is not an array
163                 debug_report_bug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
164         }
165
166         // Merge all together
167         return array_merge($array1, $array2);
168 }
169
170 // Check if given FQFN is a readable file
171 function isFileReadable ($FQFN) {
172         // Do we have cache?
173         if (!isset($GLOBALS['file_readable'][$FQFN])) {
174                 // Check all...
175                 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
176         } // END - if
177
178         // Return result
179         return $GLOBALS['file_readable'][$FQFN];
180 }
181
182 // Checks wether the given FQFN is a directory and not ., .. or .svn
183 function isDirectory ($FQFN) {
184         // Do we have cache?
185         if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
186                 // Generate baseName
187                 $baseName = basename($FQFN);
188
189                 // Check it
190                 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
191         } // END - if
192
193         // Return the result
194         return $GLOBALS[__FUNCTION__][$FQFN];
195 }
196
197 // "Getter" for the real remote IP number
198 function detectRealIpAddress () {
199         // Get remote ip from environment
200         $remoteAddr = determineRealRemoteAddress();
201
202         // Is removeip installed?
203         if (isExtensionActive('removeip')) {
204                 // Then anonymize it
205                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
206         } // END - if
207
208         // Return it
209         return $remoteAddr;
210 }
211
212 // "Getter" for remote IP number
213 function detectRemoteAddr () {
214         // Get remote ip from environment
215         $remoteAddr = determineRealRemoteAddress(true);
216
217         // Is removeip installed?
218         if (isExtensionActive('removeip')) {
219                 // Then anonymize it
220                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
221         } // END - if
222
223         // Return it
224         return $remoteAddr;
225 }
226
227 // "Getter" for remote hostname
228 function detectRemoteHostname () {
229         // Get remote ip from environment
230         $remoteHost = getenv('REMOTE_HOST');
231
232         // Is removeip installed?
233         if (isExtensionActive('removeip')) {
234                 // Then anonymize it
235                 $remoteHost = getAnonymousRemoteHost($remoteHost);
236         } // END - if
237
238         // Return it
239         return $remoteHost;
240 }
241
242 // "Getter" for user agent
243 function detectUserAgent ($alwaysReal = false) {
244         // Get remote ip from environment
245         $userAgent = getenv('HTTP_USER_AGENT');
246
247         // Is removeip installed?
248         if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
249                 // Then anonymize it
250                 $userAgent = getAnonymousUserAgent($userAgent);
251         } // END - if
252
253         // Return it
254         return $userAgent;
255 }
256
257 // "Getter" for referer
258 function detectReferer () {
259         // Get remote ip from environment
260         $referer = getenv('HTTP_REFERER');
261
262         // Is removeip installed?
263         if (isExtensionActive('removeip')) {
264                 // Then anonymize it
265                 $referer = getAnonymousReferer($referer);
266         } // END - if
267
268         // Return it
269         return $referer;
270 }
271
272 // "Getter" for request URI
273 function detectRequestUri () {
274         // Return it
275         return (getenv('REQUEST_URI'));
276 }
277
278 // "Getter" for query string
279 function detectQueryString () {
280         return str_replace('&', '&amp;', (getenv('QUERY_STRING')));
281 }
282
283 // "Getter" for SERVER_NAME
284 function detectServerName () {
285         // Return it
286         return (getenv('SERVER_NAME'));
287 }
288
289 // Removes any  existing www. from SERVER_NAME. This is very silly but enough
290 // for our purpose here.
291 function detectDomainName () {
292         // Do we have cache?
293         if (!isset($GLOBALS[__FUNCTION__])) {
294                 // Get server name
295                 $domainName = detectServerName();
296
297                 // Is there any www. ?
298                 if (substr($domainName, 0, 4) == 'www.') {
299                         // Remove it
300                         $domainName = substr($domainName, 4);
301                 } // END - if
302
303                 // Set cache
304                 $GLOBALS[__FUNCTION__] = $domainName;
305         } // END - if
306
307         // Return cache
308         return $GLOBALS[__FUNCTION__];
309 }
310
311 // Check wether we are installing
312 function isInstalling () {
313         // Determine wether we are installing
314         if (!isset($GLOBALS['mailer_installing'])) {
315                 // Check URL (css.php/js.php need this)
316                 $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
317         } // END - if
318
319         // Return result
320         return $GLOBALS['mailer_installing'];
321 }
322
323 // Check wether this script is installed
324 function isInstalled () {
325         // Do we have cache?
326         if (!isset($GLOBALS[__FUNCTION__])) {
327                 // Determine wether this script is installed
328                 $GLOBALS[__FUNCTION__] = (
329                 (
330                         // First is config
331                         (
332                                 (
333                                         isConfigEntrySet('MXCHANGE_INSTALLED')
334                                 ) && (
335                                         getConfig('MXCHANGE_INSTALLED') == 'Y'
336                                 )
337                         )
338                 ) || (
339                         // New config file found and loaded
340                         isIncludeReadable(getCachePath() . 'config-local.php')
341                 ) || (
342                         (
343                                 // New config file found, but not yet read
344                                 isIncludeReadable(getCachePath() . 'config-local.php')
345                         ) && (
346                                 (
347                                         // Only new config file is found
348                                         !isIncludeReadable('inc/config.php')
349                                 ) || (
350                                         // Is installation mode
351                                         !isInstalling()
352                                 )
353                         )
354                 ));
355         } // END - if
356
357         // Then use the cache
358         return $GLOBALS[__FUNCTION__];
359 }
360
361 // Check wether an admin is registered
362 function isAdminRegistered () {
363         // Is cache set?
364         if (!isset($GLOBALS[__FUNCTION__])) {
365                 // Simply check it
366                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
367         } // END - if
368
369         // Return it
370         return $GLOBALS[__FUNCTION__];
371 }
372
373 // Checks wether the hourly reset mode is active
374 function isHourlyResetEnabled () {
375         // Now simply check it
376         return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === true));
377 }
378
379 // Checks wether the reset mode is active
380 function isResetModeEnabled () {
381         // Now simply check it
382         return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
383 }
384
385 // Checks wether the debug mode is enabled
386 function isDebugModeEnabled () {
387         // Is cache set?
388         if (!isset($GLOBALS[__FUNCTION__])) {
389                 // Simply check it
390                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
391         } // END - if
392
393         // Return it
394         return $GLOBALS[__FUNCTION__];
395 }
396
397 // Checks wether the debug reset is enabled
398 function isDebugResetEnabled () {
399         // Is cache set?
400         if (!isset($GLOBALS[__FUNCTION__])) {
401                 // Simply check it
402                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'));
403         } // END - if
404
405         // Return it
406         return $GLOBALS[__FUNCTION__];
407 }
408
409 // Checks wether SQL debugging is enabled
410 function isSqlDebuggingEnabled () {
411         // Is cache set?
412         if (!isset($GLOBALS[__FUNCTION__])) {
413                 // Determine if SQL debugging is enabled
414                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
415         } // END - if
416
417         // Return it
418         return $GLOBALS[__FUNCTION__];
419 }
420
421 // Checks wether we shall debug regular expressions
422 function isDebugRegularExpressionEnabled () {
423         // Is cache set?
424         if (!isset($GLOBALS[__FUNCTION__])) {
425                 // Simply check it
426                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
427         } // END - if
428
429         // Return it
430         return $GLOBALS[__FUNCTION__];
431 }
432
433 // Checks wether the cache instance is valid
434 function isCacheInstanceValid () {
435         // Do we have cache?
436         if (!isset($GLOBALS[__FUNCTION__])) {
437                 // Determine it
438                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
439         } // END - if
440
441         // Return cache
442         return $GLOBALS[__FUNCTION__];
443 }
444
445 // Copies a file from source to destination and verifies if that goes fine.
446 // This function should wrap the copy() command and make a nicer debug backtrace
447 // even if there is no xdebug extension installed.
448 function copyFileVerified ($source, $dest, $chmod = '') {
449         // Failed is the default
450         $status = false;
451
452         // Is the source file there?
453         if (!isFileReadable($source)) {
454                 // Then abort here
455                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
456         } // END - if
457
458         // Is the target directory there?
459         if (!isDirectory(dirname($dest))) {
460                 // Then abort here
461                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
462         } // END - if
463
464         // Now try to copy it
465         if (!copy($source, $dest)) {
466                 // Something went wrong
467                 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
468         } else {
469                 // Reset cache
470                 $GLOBALS['file_readable'][$dest] = true;
471         }
472
473         // If there are chmod rights set, apply them
474         if (!empty($chmod)) {
475                 // Try to apply them
476                 $status = changeMode($dest, $chmod);
477         } else {
478                 // All fine
479                 $status = true;
480         }
481
482         // All fine
483         return $status;
484 }
485
486 // Wrapper function for header()
487 // Send a header but checks before if we can do so
488 function sendHeader ($header) {
489         // Send the header
490         //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
491         $GLOBALS['header'][] = trim($header);
492 }
493
494 // Flushes all headers
495 function flushHeaders () {
496         // Is the header already sent?
497         if (headers_sent()) {
498                 // Then abort here
499                 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
500         } // END - if
501
502         // Flush all headers if found
503         if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
504                 foreach ($GLOBALS['header'] as $header) {
505                         header($header);
506                 } // END - foreach
507         } // END - if
508
509         // Mark them as flushed
510         $GLOBALS['header'] = array();
511 }
512
513 // Wrapper function for chmod()
514 // @TODO Do some more sanity check here
515 function changeMode ($FQFN, $mode) {
516         // Is the file/directory there?
517         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
518                 // Neither, so abort here
519                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
520         } // END - if
521
522         // Try to set them
523         return chmod($FQFN, $mode);
524 }
525
526 // Wrapper for unlink()
527 function removeFile ($FQFN) {
528         // Is the file there?
529         if (isFileReadable($FQFN)) {
530                 // Reset cache first
531                 $GLOBALS['file_readable'][$FQFN] = false;
532
533                 // Yes, so remove it
534                 return unlink($FQFN);
535         } // END - if
536
537         // All fine if no file was removed. If we change this to 'false' or rewrite
538         // above if() block it would be to restrictive.
539         return true;
540 }
541
542 // Wrapper for $_POST['sel']
543 function countPostSelection ($element = 'sel') {
544         // Is it set?
545         if (isPostRequestParameterSet($element)) {
546                 // Return counted elements
547                 return countSelection(postRequestParameter($element));
548         } else {
549                 // Return zero if not found
550                 return 0;
551         }
552 }
553
554 // Checks wether the config-local.php is loaded
555 function isConfigLocalLoaded () {
556         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
557 }
558
559 // Checks wether a nickname or userid was entered and caches the result
560 function isNicknameUsed ($userid) {
561         // Is the cache there
562         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
563                 // Determine it
564                 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid));
565         } // END - if
566
567         // Return the result
568         return $GLOBALS[__FUNCTION__][$userid];
569 }
570
571 // Getter for 'what' value
572 function getWhat () {
573         // Default is null
574         $what = null;
575
576         // Is the value set?
577         if (isWhatSet(true)) {
578                 // Then use it
579                 $what = $GLOBALS['what'];
580         } // END - if
581
582         // Return it
583         return $what;
584 }
585
586 // Setter for 'what' value
587 function setWhat ($newWhat) {
588         $GLOBALS['what'] = SQL_ESCAPE($newWhat);
589 }
590
591 // Setter for 'what' from configuration
592 function setWhatFromConfig ($configEntry) {
593         // Get 'what' from config
594         $what = getConfig($configEntry);
595
596         // Set it
597         setWhat($what);
598 }
599
600 // Checks wether what is set and optionally aborts on miss
601 function isWhatSet ($strict =  false) {
602         // Check for it
603         $isset = isset($GLOBALS['what']);
604
605         // Should we abort here?
606         if (($strict === true) && ($isset === false)) {
607                 // Output backtrace
608                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
609         } // END - if
610
611         // Return it
612         return $isset;
613 }
614
615 // Getter for 'action' value
616 function getAction ($strict = true) {
617         // Default is null
618         $action = null;
619
620         // Is the value set?
621         if (isActionSet(($strict) && (isHtmlOutputMode()))) {
622                 // Then use it
623                 $action = $GLOBALS['action'];
624         } // END - if
625
626         // Return it
627         return $action;
628 }
629
630 // Setter for 'action' value
631 function setAction ($newAction) {
632         $GLOBALS['action'] = SQL_ESCAPE($newAction);
633 }
634
635 // Checks wether action is set and optionally aborts on miss
636 function isActionSet ($strict =  false) {
637         // Check for it
638         $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
639
640         // Should we abort here?
641         if (($strict === true) && ($isset === false)) {
642                 // Output backtrace
643                 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
644         } // END - if
645
646         // Return it
647         return $isset;
648 }
649
650 // Getter for 'module' value
651 function getModule ($strict = true) {
652         // Default is null
653         $module = null;
654
655         // Is the value set?
656         if (isModuleSet($strict)) {
657                 // Then use it
658                 $module = $GLOBALS['module'];
659         } // END - if
660
661         // Return it
662         return $module;
663 }
664
665 // Setter for 'module' value
666 function setModule ($newModule) {
667         // Secure it and make all modules lower-case
668         $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
669 }
670
671 // Checks wether module is set and optionally aborts on miss
672 function isModuleSet ($strict =  false) {
673         // Check for it
674         $isset = (!empty($GLOBALS['module']));
675
676         // Should we abort here?
677         if (($strict === true) && ($isset === false)) {
678                 // Output backtrace
679                 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
680         } // END - if
681
682         // Return it
683         return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
684 }
685
686 // Getter for 'output_mode' value
687 function getScriptOutputMode () {
688         // Do we have cache?
689         if (!isset($GLOBALS[__FUNCTION__])) {
690                 // Default is null
691                 $output_mode = null;
692
693                 // Is the value set?
694                 if (isOutputModeSet(true)) {
695                         // Then use it
696                         $output_mode = $GLOBALS['output_mode'];
697                 } // END - if
698
699                 // Store it in cache
700                 $GLOBALS[__FUNCTION__] = $output_mode;
701         } // END - if
702
703         // Return cache
704         return $GLOBALS[__FUNCTION__];
705 }
706
707 // Setter for 'output_mode' value
708 function setOutputMode ($newOutputMode) {
709         $GLOBALS['output_mode'] = (int) $newOutputMode;
710 }
711
712 // Checks wether output_mode is set and optionally aborts on miss
713 function isOutputModeSet ($strict =  false) {
714         // Check for it
715         $isset = (isset($GLOBALS['output_mode']));
716
717         // Should we abort here?
718         if (($strict === true) && ($isset === false)) {
719                 // Output backtrace
720                 debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
721         } // END - if
722
723         // Return it
724         return $isset;
725 }
726
727 // Enables block-mode
728 function enableBlockMode ($enabled = true) {
729         $GLOBALS['block_mode'] = $enabled;
730 }
731
732 // Checks wether block-mode is enabled
733 function isBlockModeEnabled () {
734         // Abort if not set
735         if (!isset($GLOBALS['block_mode'])) {
736                 // Needs to be fixed
737                 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
738         } // END - if
739
740         // Return it
741         return $GLOBALS['block_mode'];
742 }
743
744 // Wrapper function for addPointsThroughReferalSystem()
745 function addPointsDirectly ($subject, $userid, $points) {
746         // Reset level here
747         unset($GLOBALS['ref_level']);
748
749         // Call more complicated method (due to more parameters)
750         return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'DIRECT');
751 }
752
753 // Wrapper for redirectToUrl but URL comes from a configuration entry
754 function redirectToConfiguredUrl ($configEntry) {
755         // Load the URL
756         redirectToUrl(getConfig($configEntry));
757 }
758
759 // Wrapper function to redirect from member-only modules to index
760 function redirectToIndexMemberOnlyModule () {
761         // Do the redirect here
762         redirectToUrl('modules.php?module=index&amp;code=' . getCode('MODULE_MEMBER_ONLY') . '&amp;mod=' . getModule());
763 }
764
765 // Wrapper function to redirect to current URL
766 function redirectToRequestUri () {
767         redirectToUrl(basename(detectRequestUri()));
768 }
769
770 // Wrapper function to redirect to de-refered URL
771 function redirectToDereferedUrl ($url) {
772         // Redirect to to
773         redirectToUrl(generateDerefererUrl($url));
774 }
775
776 // Wrapper function for checking if extension is installed and newer or same version
777 function isExtensionInstalledAndNewer ($ext_name, $version) {
778         // Is an cache entry found?
779         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
780                 // Determine it
781                 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
782         } else {
783                 // Cache hits should be incremented twice
784                 incrementStatsEntry('cache_hits', 2);
785         }
786
787         // Return it
788         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=&gt;' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
789         return $GLOBALS[__FUNCTION__][$ext_name][$version];
790 }
791
792 // Wrapper function for checking if extension is installed and older than given version
793 function isExtensionInstalledAndOlder ($ext_name, $version) {
794         // Is an cache entry found?
795         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
796                 // Determine it
797                 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
798         } else {
799                 // Cache hits should be incremented twice
800                 incrementStatsEntry('cache_hits', 2);
801         }
802
803         // Return it
804         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '&lt;' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
805         return $GLOBALS[__FUNCTION__][$ext_name][$version];
806 }
807
808 // Set username
809 function setUsername ($userName) {
810         $GLOBALS['username'] = (string) $userName;
811 }
812
813 // Get username
814 function getUsername () {
815         // User name set?
816         if (!isset($GLOBALS['username'])) {
817                 // No, so it has to be a guest
818                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
819         } // END - if
820
821         // Return it
822         return $GLOBALS['username'];
823 }
824
825 // Wrapper function for installation phase
826 function isInstallationPhase () {
827         // Do we have cache?
828         if (!isset($GLOBALS[__FUNCTION__])) {
829                 // Determine it
830                 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
831         } // END - if
832
833         // Return result
834         return $GLOBALS[__FUNCTION__];
835 }
836
837 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
838 function isDemoModeActive () {
839         // Is cache set?
840         if (!isset($GLOBALS[__FUNCTION__])) {
841                 // Simply check it
842                 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
843         } // END - if
844
845         // Return it
846         return $GLOBALS[__FUNCTION__];
847 }
848
849 // Getter for PHP caching value
850 function getPhpCaching () {
851         return $GLOBALS['php_caching'];
852 }
853
854 // Checks wether the admin hash is set
855 function isAdminHashSet ($adminId) {
856         // Is the array there?
857         if (!isset($GLOBALS['cache_array']['admin'])) {
858                 // Missing array should be reported
859                 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
860         } // END - if
861
862         // Check for admin hash
863         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
864 }
865
866 // Setter for admin hash
867 function setAdminHash ($adminId, $hash) {
868         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
869 }
870
871 // Getter for current admin login
872 function getCurrentAdminLogin () {
873         // Log debug message
874         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
875
876         // Do we have cache?
877         if (!isset($GLOBALS[__FUNCTION__])) {
878                 // Determine it
879                 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
880         } // END - if
881
882         // Return it
883         return $GLOBALS[__FUNCTION__];
884 }
885
886 // Setter for admin id (and current)
887 function setAdminId ($adminId) {
888         // Log debug message
889         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
890
891         // Set session
892         $status = setSession('admin_id', bigintval($adminId));
893
894         // Set current id
895         setCurrentAdminId($adminId);
896
897         // Return status
898         return $status;
899 }
900
901 // Setter for admin_last
902 function setAdminLast ($adminLast) {
903         // Log debug message
904         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
905
906         // Set session
907         $status = setSession('admin_last', $adminLast);
908
909         // Return status
910         return $status;
911 }
912
913 // Setter for admin_md5
914 function setAdminMd5 ($adminMd5) {
915         // Log debug message
916         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
917
918         // Set session
919         $status = setSession('admin_md5', $adminMd5);
920
921         // Return status
922         return $status;
923 }
924
925 // Getter for admin_md5
926 function getAdminMd5 () {
927         // Log debug message
928         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
929
930         // Get session
931         return getSession('admin_md5');
932 }
933
934 // Init user data array
935 function initUserData () {
936         // User id should not be zero
937         if (!isValidUserId(getCurrentUserId())) {
938                 // Should be always valid
939                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
940         } // END - if
941
942         // Init the user
943         $GLOBALS['user_data'][getCurrentUserId()] = array();
944 }
945
946 // Getter for user data
947 function getUserData ($column) {
948         // User id should not be zero
949         if (!isValidUserId(getCurrentUserId())) {
950                 // Should be always valid
951                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
952         } // END - if
953
954         // Default is empty
955         $data = null;
956
957         if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
958                 // Return the value
959                 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
960         } // END - if
961
962         // Return it
963         return $data;
964 }
965
966 // Checks wether given user data is set to 'Y'
967 function isUserDataEnabled ($column) {
968         // Do we have cache?
969         if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
970                 // Determine it
971                 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
972         } // END - if
973
974         // Return cache
975         return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
976 }
977
978 // Geter for whole user data array
979 function getUserDataArray () {
980         // Get user id
981         $userid = getCurrentUserId();
982
983         // Is the current userid valid?
984         if (!isValidUserId($userid)) {
985                 // Should be always valid
986                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
987         } // END - if
988
989         // Get the whole array if found
990         if (isset($GLOBALS['user_data'][$userid])) {
991                 // Found, so return it
992                 return $GLOBALS['user_data'][$userid];
993         } else {
994                 // Return empty array
995                 return array();
996         }
997 }
998
999 // Checks if the user data is valid, this may indicate that the user has logged
1000 // in, but you should use isMember() if you want to find that out.
1001 function isUserDataValid () {
1002         // User id should not be zero so abort here
1003         if (!isCurrentUserIdSet()) return false;
1004
1005         // Is it cached?
1006         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1007                 // Determine it
1008                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1009         } // END - if
1010
1011         // Return the result
1012         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1013 }
1014
1015 // Setter for current userid
1016 function setCurrentUserId ($userid) {
1017         // Set userid
1018         $GLOBALS['current_userid'] = bigintval($userid);
1019
1020         // Unset it to re-determine the actual state
1021         unset($GLOBALS['is_userdata_valid'][$userid]);
1022 }
1023
1024 // Getter for current userid
1025 function getCurrentUserId () {
1026         // Userid must be set before it can be used
1027         if (!isCurrentUserIdSet()) {
1028                 // Not set
1029                 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1030         } // END - if
1031
1032         // Return the userid
1033         return $GLOBALS['current_userid'];
1034 }
1035
1036 // Checks if current userid is set
1037 function isCurrentUserIdSet () {
1038         return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1039 }
1040
1041 // Checks wether we are debugging template cache
1042 function isDebuggingTemplateCache () {
1043         // Do we have cache?
1044         if (!isset($GLOBALS[__FUNCTION__])) {
1045                 // Determine it
1046                 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1047         } // END - if
1048
1049         // Return cache
1050         return $GLOBALS[__FUNCTION__];
1051 }
1052
1053 // Wrapper for fetchUserData() and getUserData() calls
1054 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1055         // Is it cached?
1056         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1057                 // Default is 'guest'
1058                 $data = '{--USERNAME_GUEST--}';
1059
1060                 // Can we fetch the user data?
1061                 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1062                         // Now get the data back
1063                         $data = getUserData($valueColumn);
1064                 } // END - if
1065
1066                 // Cache it
1067                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1068         } // END - if
1069
1070         // Return it
1071         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1072 }
1073
1074 // Wrapper for strpos() to ease porting from deprecated ereg() function
1075 function isInString ($needle, $haystack) {
1076         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1077         return (strpos($haystack, $needle) !== false);
1078 }
1079
1080 // Wrapper for strpos() to ease porting from deprecated eregi() function
1081 // This function is case-insensitive
1082 function isInStringIgnoreCase ($needle, $haystack) {
1083         return (isInString(strtolower($needle), strtolower($haystack)));
1084 }
1085
1086 // Wrapper to check for if fatal errors where detected
1087 function ifFatalErrorsDetected () {
1088         // Just call the inner function
1089         return (getTotalFatalErrors() > 0);
1090 }
1091
1092 // Setter for HTTP status
1093 function setHttpStatus ($status) {
1094         $GLOBALS['http_status'] = (string) $status;
1095 }
1096
1097 // Getter for HTTP status
1098 function getHttpStatus () {
1099         // Is the status set?
1100         if (!isset($GLOBALS['http_status'])) {
1101                 // Abort here
1102                 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1103         } // END - if
1104
1105         // Return it
1106         return $GLOBALS['http_status'];
1107 }
1108
1109 /**
1110  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1111  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1112  *
1113  * ----------------------------------------------------------------------------
1114  * If you want to redirect, please use redirectToUrl(); instead
1115  * ----------------------------------------------------------------------------
1116  *
1117  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1118  *
1119  * @link    http://support.microsoft.com/kb/q176113/
1120  * @author  Andreas Gohr <andi@splitbrain.org>
1121  * @access  private
1122  */
1123 function sendRawRedirect ($url) {
1124         // Send helping header
1125         setHttpStatus('302 Found');
1126
1127         // always close the session
1128         session_write_close();
1129
1130         // Revert entity &amp;
1131         $url = str_replace('&amp;', '&', $url);
1132
1133         // check if running on IIS < 6 with CGI-PHP
1134         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1135                 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
1136                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1137                 ($matches[1] < 6)) {
1138                 // Send the IIS header
1139                 sendHeader('Refresh: 0;url=' . $url);
1140         } else {
1141                 // Send generic header
1142                 sendHeader('Location: ' . $url);
1143         }
1144
1145         // Shutdown here
1146         shutdown();
1147 }
1148
1149 // Determines the country of the given user id
1150 function determineCountry ($userid) {
1151         // Do we have cache?
1152         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1153                 // Default is 'invalid'
1154                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1155
1156                 // Is extension country active?
1157                 if (isExtensionActive('country')) {
1158                         // Determine the right country code through the country id
1159                         $id = getUserData('country_code');
1160
1161                         // Then handle it over
1162                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1163                 } else {
1164                         // Get raw code from user data
1165                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1166                 }
1167         } // END - if
1168
1169         // Return cache
1170         return $GLOBALS[__FUNCTION__][$userid];
1171 }
1172
1173 // "Getter" for total confirmed user accounts
1174 function getTotalConfirmedUser () {
1175         // Is it cached?
1176         if (!isset($GLOBALS[__FUNCTION__])) {
1177                 // Then do it
1178                 if (isExtensionActive('user')) {
1179                         $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1180                 } else {
1181                         $GLOBALS[__FUNCTION__] = 0;
1182                 }
1183         } // END - if
1184
1185         // Return cached value
1186         return $GLOBALS[__FUNCTION__];
1187 }
1188
1189 // "Getter" for total unconfirmed user accounts
1190 function getTotalUnconfirmedUser () {
1191         // Is it cached?
1192         if (!isset($GLOBALS[__FUNCTION__])) {
1193                 // Then do it
1194                 if (isExtensionActive('user')) {
1195                         $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1196                 } else {
1197                         $GLOBALS[__FUNCTION__] = 0;
1198                 }
1199         } // END - if
1200
1201         // Return cached value
1202         return $GLOBALS[__FUNCTION__];
1203 }
1204
1205 // "Getter" for total locked user accounts
1206 function getTotalLockedUser () {
1207         // Is it cached?
1208         if (!isset($GLOBALS[__FUNCTION__])) {
1209                 // Then do it
1210                 if (isExtensionActive('user')) {
1211                         $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1212                 } else {
1213                         $GLOBALS[__FUNCTION__] = 0;
1214                 }
1215         } // END - if
1216
1217         // Return cached value
1218         return $GLOBALS[__FUNCTION__];
1219 }
1220
1221 // Is given userid valid?
1222 function isValidUserId ($userid) {
1223         // Do we have cache?
1224         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1225                 // Check it out
1226                 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1227         } // END - if
1228
1229         // Return cache
1230         return $GLOBALS[__FUNCTION__][$userid];
1231 }
1232
1233 // Encodes entities
1234 function encodeEntities ($str) {
1235         // Secure it first
1236         $str = secureString($str, true, true);
1237
1238         // Encode dollar sign as well
1239         $str = str_replace('$', '&#36;', $str);
1240
1241         // Return it
1242         return $str;
1243 }
1244
1245 // "Getter" for date from patch_ctime
1246 function getDateFromPatchTime () {
1247         // Is it cached?
1248         if (!isset($GLOBALS[__FUNCTION__])) {
1249                 // Then set it
1250                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1251         } // END - if
1252
1253         // Return cache
1254         return $GLOBALS[__FUNCTION__];
1255 }
1256
1257 // Getter for current year (default)
1258 function getYear ($timestamp = null) {
1259         // Is it cached?
1260         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1261                 // null is time()
1262                 if (is_null($timestamp)) {
1263                         $timestamp = time();
1264                 } // END - if
1265
1266                 // Then create it
1267                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1268         } // END - if
1269
1270         // Return cache
1271         return $GLOBALS[__FUNCTION__][$timestamp];
1272 }
1273
1274 // Getter for current month (default)
1275 function getMonth ($timestamp = null) {
1276         // Is it cached?
1277         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1278                 // If null is set, use time()
1279                 if (is_null($timestamp)) {
1280                         // Use time() which is current timestamp
1281                         $timestamp = time();
1282                 } // END - if
1283
1284                 // Then create it
1285                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1286         } // END - if
1287
1288         // Return cache
1289         return $GLOBALS[__FUNCTION__][$timestamp];
1290 }
1291
1292 // Getter for current hour (default)
1293 function getHour ($timestamp = null) {
1294         // Is it cached?
1295         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1296                 // null is time()
1297                 if (is_null($timestamp)) {
1298                         $timestamp = time();
1299                 } // END - if
1300
1301                 // Then create it
1302                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1303         } // END - if
1304
1305         // Return cache
1306         return $GLOBALS[__FUNCTION__][$timestamp];
1307 }
1308
1309 // Getter for current day (default)
1310 function getDay ($timestamp = null) {
1311         // Is it cached?
1312         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1313                 // null is time()
1314                 if (is_null($timestamp)) {
1315                         $timestamp = time();
1316                 } // END - if
1317
1318                 // Then create it
1319                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1320         } // END - if
1321
1322         // Return cache
1323         return $GLOBALS[__FUNCTION__][$timestamp];
1324 }
1325
1326 // Getter for current week (default)
1327 function getWeek ($timestamp = null) {
1328         // Is it cached?
1329         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1330                 // null is time()
1331                 if (is_null($timestamp)) $timestamp = time();
1332
1333                 // Then create it
1334                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1335         } // END - if
1336
1337         // Return cache
1338         return $GLOBALS[__FUNCTION__][$timestamp];
1339 }
1340
1341 // Getter for current short_hour (default)
1342 function getShortHour ($timestamp = null) {
1343         // Is it cached?
1344         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1345                 // null is time()
1346                 if (is_null($timestamp)) $timestamp = time();
1347
1348                 // Then create it
1349                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1350         } // END - if
1351
1352         // Return cache
1353         return $GLOBALS[__FUNCTION__][$timestamp];
1354 }
1355
1356 // Getter for current long_hour (default)
1357 function getLongHour ($timestamp = null) {
1358         // Is it cached?
1359         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1360                 // null is time()
1361                 if (is_null($timestamp)) $timestamp = time();
1362
1363                 // Then create it
1364                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1365         } // END - if
1366
1367         // Return cache
1368         return $GLOBALS[__FUNCTION__][$timestamp];
1369 }
1370
1371 // Getter for current second (default)
1372 function getSecond ($timestamp = null) {
1373         // Is it cached?
1374         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1375                 // null is time()
1376                 if (is_null($timestamp)) $timestamp = time();
1377
1378                 // Then create it
1379                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1380         } // END - if
1381
1382         // Return cache
1383         return $GLOBALS[__FUNCTION__][$timestamp];
1384 }
1385
1386 // Getter for current minute (default)
1387 function getMinute ($timestamp = null) {
1388         // Is it cached?
1389         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1390                 // null is time()
1391                 if (is_null($timestamp)) $timestamp = time();
1392
1393                 // Then create it
1394                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1395         } // END - if
1396
1397         // Return cache
1398         return $GLOBALS[__FUNCTION__][$timestamp];
1399 }
1400
1401 // Checks wether the title decoration is enabled
1402 function isTitleDecorationEnabled () {
1403         // Do we have cache?
1404         if (!isset($GLOBALS[__FUNCTION__])) {
1405                 // Just check it
1406                 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1407         } // END - if
1408
1409         // Return cache
1410         return $GLOBALS[__FUNCTION__];
1411 }
1412
1413 // Checks wether filter usage updates are enabled (expensive queries!)
1414 function isFilterUsageUpdateEnabled () {
1415         // Do we have cache?
1416         if (!isset($GLOBALS[__FUNCTION__])) {
1417                 // Determine it
1418                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1419         } // END - if
1420
1421         // Return cache
1422         return $GLOBALS[__FUNCTION__];
1423 }
1424
1425 // Checks wether debugging of weekly resets is enabled
1426 function isWeeklyResetDebugEnabled () {
1427         // Do we have cache?
1428         if (!isset($GLOBALS[__FUNCTION__])) {
1429                 // Determine it
1430                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1431         } // END - if
1432
1433         // Return cache
1434         return $GLOBALS[__FUNCTION__];
1435 }
1436
1437 // Checks wether debugging of monthly resets is enabled
1438 function isMonthlyResetDebugEnabled () {
1439         // Do we have cache?
1440         if (!isset($GLOBALS[__FUNCTION__])) {
1441                 // Determine it
1442                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1443         } // END - if
1444
1445         // Return cache
1446         return $GLOBALS[__FUNCTION__];
1447 }
1448
1449 // Checks wether displaying of debug SQLs are enabled
1450 function isDisplayDebugSqlEnabled () {
1451         // Do we have cache?
1452         if (!isset($GLOBALS[__FUNCTION__])) {
1453                 // Determine it
1454                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1455         } // END - if
1456
1457         // Return cache
1458         return $GLOBALS[__FUNCTION__];
1459 }
1460
1461 // Checks wether module title is enabled
1462 function isModuleTitleEnabled () {
1463         // Do we have cache?
1464         if (!isset($GLOBALS[__FUNCTION__])) {
1465                 // Determine it
1466                 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1467         } // END - if
1468
1469         // Return cache
1470         return $GLOBALS[__FUNCTION__];
1471 }
1472
1473 // Checks wether what title is enabled
1474 function isWhatTitleEnabled () {
1475         // Do we have cache?
1476         if (!isset($GLOBALS[__FUNCTION__])) {
1477                 // Determine it
1478                 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1479         } // END - if
1480
1481         // Return cache
1482         return $GLOBALS[__FUNCTION__];
1483 }
1484
1485 // Checks wether stats are enabled
1486 function ifStatsAreEnabled () {
1487         // Do we have cache?
1488         if (!isset($GLOBALS[__FUNCTION__])) {
1489                 // Then determine it
1490                 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1491         } // END - if
1492
1493         // Return cached value
1494         return $GLOBALS[__FUNCTION__];
1495 }
1496
1497 // Checks wether admin-notification of certain user actions is enabled
1498 function isAdminNotificationEnabled () {
1499         // Do we have cache?
1500         if (!isset($GLOBALS[__FUNCTION__])) {
1501                 // Determine it
1502                 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1503         } // END - if
1504
1505         // Return cache
1506         return $GLOBALS[__FUNCTION__];
1507 }
1508
1509 // Checks wether random referal id selection is enabled
1510 function isRandomReferalIdEnabled () {
1511         // Do we have cache?
1512         if (!isset($GLOBALS[__FUNCTION__])) {
1513                 // Determine it
1514                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1515         } // END - if
1516
1517         // Return cache
1518         return $GLOBALS[__FUNCTION__];
1519 }
1520
1521 // "Getter" for default language
1522 function getDefaultLanguage () {
1523         // Do we have cache?
1524         if (!isset($GLOBALS[__FUNCTION__])) {
1525                 // Determine it
1526                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1527         } // END - if
1528
1529         // Return cache
1530         return $GLOBALS[__FUNCTION__];
1531 }
1532
1533 // "Getter" for default referal id
1534 function getDefRefid () {
1535         // Do we have cache?
1536         if (!isset($GLOBALS[__FUNCTION__])) {
1537                 // Determine it
1538                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1539         } // END - if
1540
1541         // Return cache
1542         return $GLOBALS[__FUNCTION__];
1543 }
1544
1545 // "Getter" for path
1546 function getPath () {
1547         // Do we have cache?
1548         if (!isset($GLOBALS[__FUNCTION__])) {
1549                 // Determine it
1550                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1551         } // END - if
1552
1553         // Return cache
1554         return $GLOBALS[__FUNCTION__];
1555 }
1556
1557 // "Getter" for url
1558 function getUrl () {
1559         // Do we have cache?
1560         if (!isset($GLOBALS[__FUNCTION__])) {
1561                 // Determine it
1562                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1563         } // END - if
1564
1565         // Return cache
1566         return $GLOBALS[__FUNCTION__];
1567 }
1568
1569 // "Getter" for cache_path
1570 function getCachePath () {
1571         // Do we have cache?
1572         if (!isset($GLOBALS[__FUNCTION__])) {
1573                 // Determine it
1574                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1575         } // END - if
1576
1577         // Return cache
1578         return $GLOBALS[__FUNCTION__];
1579 }
1580
1581 // "Getter" for secret_key
1582 function getSecretKey () {
1583         // Do we have cache?
1584         if (!isset($GLOBALS[__FUNCTION__])) {
1585                 // Determine it
1586                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1587         } // END - if
1588
1589         // Return cache
1590         return $GLOBALS[__FUNCTION__];
1591 }
1592
1593 // "Getter" for SITE_KEY
1594 function getSiteKey () {
1595         // Do we have cache?
1596         if (!isset($GLOBALS[__FUNCTION__])) {
1597                 // Determine it
1598                 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1599         } // END - if
1600
1601         // Return cache
1602         return $GLOBALS[__FUNCTION__];
1603 }
1604
1605 // "Getter" for DATE_KEY
1606 function getDateKey () {
1607         // Do we have cache?
1608         if (!isset($GLOBALS[__FUNCTION__])) {
1609                 // Determine it
1610                 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1611         } // END - if
1612
1613         // Return cache
1614         return $GLOBALS[__FUNCTION__];
1615 }
1616
1617 // "Getter" for master_salt
1618 function getMasterSalt () {
1619         // Do we have cache?
1620         if (!isset($GLOBALS[__FUNCTION__])) {
1621                 // Determine it
1622                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1623         } // END - if
1624
1625         // Return cache
1626         return $GLOBALS[__FUNCTION__];
1627 }
1628
1629 // "Getter" for prime
1630 function getPrime () {
1631         // Do we have cache?
1632         if (!isset($GLOBALS[__FUNCTION__])) {
1633                 // Determine it
1634                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1635         } // END - if
1636
1637         // Return cache
1638         return $GLOBALS[__FUNCTION__];
1639 }
1640
1641 // "Getter" for encrypt_seperator
1642 function getEncryptSeperator () {
1643         // Do we have cache?
1644         if (!isset($GLOBALS[__FUNCTION__])) {
1645                 // Determine it
1646                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1647         } // END - if
1648
1649         // Return cache
1650         return $GLOBALS[__FUNCTION__];
1651 }
1652
1653 // "Getter" for mysql_prefix
1654 function getMysqlPrefix () {
1655         // Do we have cache?
1656         if (!isset($GLOBALS[__FUNCTION__])) {
1657                 // Determine it
1658                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1659         } // END - if
1660
1661         // Return cache
1662         return $GLOBALS[__FUNCTION__];
1663 }
1664
1665 // "Getter" for table_type
1666 function getTableType () {
1667         // Do we have cache?
1668         if (!isset($GLOBALS[__FUNCTION__])) {
1669                 // Determine it
1670                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1671         } // END - if
1672
1673         // Return cache
1674         return $GLOBALS[__FUNCTION__];
1675 }
1676
1677 // "Getter" for salt_length
1678 function getSaltLength () {
1679         // Do we have cache?
1680         if (!isset($GLOBALS[__FUNCTION__])) {
1681                 // Determine it
1682                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1683         } // END - if
1684
1685         // Return cache
1686         return $GLOBALS[__FUNCTION__];
1687 }
1688
1689 // "Getter" for output_mode
1690 function getOutputMode () {
1691         // Do we have cache?
1692         if (!isset($GLOBALS[__FUNCTION__])) {
1693                 // Determine it
1694                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1695         } // END - if
1696
1697         // Return cache
1698         return $GLOBALS[__FUNCTION__];
1699 }
1700
1701 // "Getter" for full_version
1702 function getFullVersion () {
1703         // Do we have cache?
1704         if (!isset($GLOBALS[__FUNCTION__])) {
1705                 // Determine it
1706                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1707         } // END - if
1708
1709         // Return cache
1710         return $GLOBALS[__FUNCTION__];
1711 }
1712
1713 // "Getter" for title
1714 function getTitle () {
1715         // Do we have cache?
1716         if (!isset($GLOBALS[__FUNCTION__])) {
1717                 // Determine it
1718                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1719         } // END - if
1720
1721         // Return cache
1722         return $GLOBALS[__FUNCTION__];
1723 }
1724
1725 // "Getter" for curr_svn_revision
1726 function getCurrentRepositoryRevision () {
1727         // Do we have cache?
1728         if (!isset($GLOBALS[__FUNCTION__])) {
1729                 // Determine it
1730                 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1731         } // END - if
1732
1733         // Return cache
1734         return $GLOBALS[__FUNCTION__];
1735 }
1736
1737 // "Getter" for server_url
1738 function getServerUrl () {
1739         // Do we have cache?
1740         if (!isset($GLOBALS[__FUNCTION__])) {
1741                 // Determine it
1742                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1743         } // END - if
1744
1745         // Return cache
1746         return $GLOBALS[__FUNCTION__];
1747 }
1748
1749 // "Getter" for mt_word
1750 function getMtWord () {
1751         // Do we have cache?
1752         if (!isset($GLOBALS[__FUNCTION__])) {
1753                 // Determine it
1754                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1755         } // END - if
1756
1757         // Return cache
1758         return $GLOBALS[__FUNCTION__];
1759 }
1760
1761 // "Getter" for mt_word2
1762 function getMtWord2 () {
1763         // Do we have cache?
1764         if (!isset($GLOBALS[__FUNCTION__])) {
1765                 // Determine it
1766                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1767         } // END - if
1768
1769         // Return cache
1770         return $GLOBALS[__FUNCTION__];
1771 }
1772
1773 // "Getter" for main_title
1774 function getMainTitle () {
1775         // Do we have cache?
1776         if (!isset($GLOBALS[__FUNCTION__])) {
1777                 // Determine it
1778                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1779         } // END - if
1780
1781         // Return cache
1782         return $GLOBALS[__FUNCTION__];
1783 }
1784
1785 // "Getter" for file_hash
1786 function getFileHash () {
1787         // Do we have cache?
1788         if (!isset($GLOBALS[__FUNCTION__])) {
1789                 // Determine it
1790                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1791         } // END - if
1792
1793         // Return cache
1794         return $GLOBALS[__FUNCTION__];
1795 }
1796
1797 // "Getter" for pass_scramble
1798 function getPassScramble () {
1799         // Do we have cache?
1800         if (!isset($GLOBALS[__FUNCTION__])) {
1801                 // Determine it
1802                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1803         } // END - if
1804
1805         // Return cache
1806         return $GLOBALS[__FUNCTION__];
1807 }
1808
1809 // "Getter" for ap_inactive_since
1810 function getApInactiveSince () {
1811         // Do we have cache?
1812         if (!isset($GLOBALS[__FUNCTION__])) {
1813                 // Determine it
1814                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1815         } // END - if
1816
1817         // Return cache
1818         return $GLOBALS[__FUNCTION__];
1819 }
1820
1821 // "Getter" for user_min_confirmed
1822 function getUserMinConfirmed () {
1823         // Do we have cache?
1824         if (!isset($GLOBALS[__FUNCTION__])) {
1825                 // Determine it
1826                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1827         } // END - if
1828
1829         // Return cache
1830         return $GLOBALS[__FUNCTION__];
1831 }
1832
1833 // "Getter" for auto_purge
1834 function getAutoPurge () {
1835         // Do we have cache?
1836         if (!isset($GLOBALS[__FUNCTION__])) {
1837                 // Determine it
1838                 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1839         } // END - if
1840
1841         // Return cache
1842         return $GLOBALS[__FUNCTION__];
1843 }
1844
1845 // "Getter" for bonus_userid
1846 function getBonusUserid () {
1847         // Do we have cache?
1848         if (!isset($GLOBALS[__FUNCTION__])) {
1849                 // Determine it
1850                 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1851         } // END - if
1852
1853         // Return cache
1854         return $GLOBALS[__FUNCTION__];
1855 }
1856
1857 // "Getter" for ap_inactive_time
1858 function getApInactiveTime () {
1859         // Do we have cache?
1860         if (!isset($GLOBALS[__FUNCTION__])) {
1861                 // Determine it
1862                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1863         } // END - if
1864
1865         // Return cache
1866         return $GLOBALS[__FUNCTION__];
1867 }
1868
1869 // "Getter" for ap_dm_timeout
1870 function getApDmTimeout () {
1871         // Do we have cache?
1872         if (!isset($GLOBALS[__FUNCTION__])) {
1873                 // Determine it
1874                 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1875         } // END - if
1876
1877         // Return cache
1878         return $GLOBALS[__FUNCTION__];
1879 }
1880
1881 // "Getter" for ap_tasks_time
1882 function getApTasksTime () {
1883         // Do we have cache?
1884         if (!isset($GLOBALS[__FUNCTION__])) {
1885                 // Determine it
1886                 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1887         } // END - if
1888
1889         // Return cache
1890         return $GLOBALS[__FUNCTION__];
1891 }
1892
1893 // "Getter" for ap_unconfirmed_time
1894 function getApUnconfirmedTime () {
1895         // Do we have cache?
1896         if (!isset($GLOBALS[__FUNCTION__])) {
1897                 // Determine it
1898                 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1899         } // END - if
1900
1901         // Return cache
1902         return $GLOBALS[__FUNCTION__];
1903 }
1904
1905 // "Getter" for points
1906 function getPoints () {
1907         // Do we have cache?
1908         if (!isset($GLOBALS[__FUNCTION__])) {
1909                 // Determine it
1910                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1911         } // END - if
1912
1913         // Return cache
1914         return $GLOBALS[__FUNCTION__];
1915 }
1916
1917 // "Getter" for slogan
1918 function getSlogan () {
1919         // Do we have cache?
1920         if (!isset($GLOBALS[__FUNCTION__])) {
1921                 // Determine it
1922                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1923         } // END - if
1924
1925         // Return cache
1926         return $GLOBALS[__FUNCTION__];
1927 }
1928
1929 // "Getter" for copy
1930 function getCopy () {
1931         // Do we have cache?
1932         if (!isset($GLOBALS[__FUNCTION__])) {
1933                 // Determine it
1934                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1935         } // END - if
1936
1937         // Return cache
1938         return $GLOBALS[__FUNCTION__];
1939 }
1940
1941 // "Getter" for webmaster
1942 function getWebmaster () {
1943         // Do we have cache?
1944         if (!isset($GLOBALS[__FUNCTION__])) {
1945                 // Determine it
1946                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1947         } // END - if
1948
1949         // Return cache
1950         return $GLOBALS[__FUNCTION__];
1951 }
1952
1953 // "Getter" for sql_count
1954 function getSqlCount () {
1955         // Do we have cache?
1956         if (!isset($GLOBALS[__FUNCTION__])) {
1957                 // Determine it
1958                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1959         } // END - if
1960
1961         // Return cache
1962         return $GLOBALS[__FUNCTION__];
1963 }
1964
1965 // "Getter" for num_templates
1966 function getNumTemplates () {
1967         // Do we have cache?
1968         if (!isset($GLOBALS[__FUNCTION__])) {
1969                 // Determine it
1970                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1971         } // END - if
1972
1973         // Return cache
1974         return $GLOBALS[__FUNCTION__];
1975 }
1976
1977 // "Getter" for dns_cache_timeout
1978 function getDnsCacheTimeout () {
1979         // Do we have cache?
1980         if (!isset($GLOBALS[__FUNCTION__])) {
1981                 // Determine it
1982                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1983         } // END - if
1984
1985         // Return cache
1986         return $GLOBALS[__FUNCTION__];
1987 }
1988
1989 // "Getter" for menu_blur_spacer
1990 function getMenuBlurSpacer () {
1991         // Do we have cache?
1992         if (!isset($GLOBALS[__FUNCTION__])) {
1993                 // Determine it
1994                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1995         } // END - if
1996
1997         // Return cache
1998         return $GLOBALS[__FUNCTION__];
1999 }
2000
2001 // "Getter" for points_register
2002 function getPointsRegister () {
2003         // Do we have cache?
2004         if (!isset($GLOBALS[__FUNCTION__])) {
2005                 // Determine it
2006                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2007         } // END - if
2008
2009         // Return cache
2010         return $GLOBALS[__FUNCTION__];
2011 }
2012
2013 // "Getter" for points_ref
2014 function getPointsRef () {
2015         // Do we have cache?
2016         if (!isset($GLOBALS[__FUNCTION__])) {
2017                 // Determine it
2018                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2019         } // END - if
2020
2021         // Return cache
2022         return $GLOBALS[__FUNCTION__];
2023 }
2024
2025 // "Getter" for ref_payout
2026 function getRefPayout () {
2027         // Do we have cache?
2028         if (!isset($GLOBALS[__FUNCTION__])) {
2029                 // Determine it
2030                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2031         } // END - if
2032
2033         // Return cache
2034         return $GLOBALS[__FUNCTION__];
2035 }
2036
2037 // "Getter" for online_timeout
2038 function getOnlineTimeout () {
2039         // Do we have cache?
2040         if (!isset($GLOBALS[__FUNCTION__])) {
2041                 // Determine it
2042                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2043         } // END - if
2044
2045         // Return cache
2046         return $GLOBALS[__FUNCTION__];
2047 }
2048
2049 // "Getter" for index_home
2050 function getIndexHome () {
2051         // Do we have cache?
2052         if (!isset($GLOBALS[__FUNCTION__])) {
2053                 // Determine it
2054                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2055         } // END - if
2056
2057         // Return cache
2058         return $GLOBALS[__FUNCTION__];
2059 }
2060
2061 // "Getter" for one_day
2062 function getOneDay () {
2063         // Do we have cache?
2064         if (!isset($GLOBALS[__FUNCTION__])) {
2065                 // Determine it
2066                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2067         } // END - if
2068
2069         // Return cache
2070         return $GLOBALS[__FUNCTION__];
2071 }
2072
2073 // "Getter" for activate_xchange
2074 function getActivateXchange () {
2075         // Do we have cache?
2076         if (!isset($GLOBALS[__FUNCTION__])) {
2077                 // Determine it
2078                 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2079         } // END - if
2080
2081         // Return cache
2082         return $GLOBALS[__FUNCTION__];
2083 }
2084
2085 // "Getter" for img_type
2086 function getImgType () {
2087         // Do we have cache?
2088         if (!isset($GLOBALS[__FUNCTION__])) {
2089                 // Determine it
2090                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2091         } // END - if
2092
2093         // Return cache
2094         return $GLOBALS[__FUNCTION__];
2095 }
2096
2097 // "Getter" for code_length
2098 function getCodeLength () {
2099         // Do we have cache?
2100         if (!isset($GLOBALS[__FUNCTION__])) {
2101                 // Determine it
2102                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2103         } // END - if
2104
2105         // Return cache
2106         return $GLOBALS[__FUNCTION__];
2107 }
2108
2109 // "Getter" for least_cats
2110 function getLeastCats () {
2111         // Do we have cache?
2112         if (!isset($GLOBALS[__FUNCTION__])) {
2113                 // Determine it
2114                 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2115         } // END - if
2116
2117         // Return cache
2118         return $GLOBALS[__FUNCTION__];
2119 }
2120
2121 // "Getter" for pass_len
2122 function getPassLen () {
2123         // Do we have cache?
2124         if (!isset($GLOBALS[__FUNCTION__])) {
2125                 // Determine it
2126                 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2127         } // END - if
2128
2129         // Return cache
2130         return $GLOBALS[__FUNCTION__];
2131 }
2132
2133 // "Getter" for admin_menu
2134 function getAdminMenu () {
2135         // Do we have cache?
2136         if (!isset($GLOBALS[__FUNCTION__])) {
2137                 // Determine it
2138                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2139         } // END - if
2140
2141         // Return cache
2142         return $GLOBALS[__FUNCTION__];
2143 }
2144
2145 // "Getter" for last_month
2146 function getLastMonth () {
2147         // Do we have cache?
2148         if (!isset($GLOBALS[__FUNCTION__])) {
2149                 // Determine it
2150                 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2151         } // END - if
2152
2153         // Return cache
2154         return $GLOBALS[__FUNCTION__];
2155 }
2156
2157 // "Getter" for max_send
2158 function getMaxSend () {
2159         // Do we have cache?
2160         if (!isset($GLOBALS[__FUNCTION__])) {
2161                 // Determine it
2162                 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2163         } // END - if
2164
2165         // Return cache
2166         return $GLOBALS[__FUNCTION__];
2167 }
2168
2169 // "Getter" for mails_page
2170 function getMailsPage () {
2171         // Do we have cache?
2172         if (!isset($GLOBALS[__FUNCTION__])) {
2173                 // Determine it
2174                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2175         } // END - if
2176
2177         // Return cache
2178         return $GLOBALS[__FUNCTION__];
2179 }
2180
2181 // "Getter" for rand_no
2182 function getRandNo () {
2183         // Do we have cache?
2184         if (!isset($GLOBALS[__FUNCTION__])) {
2185                 // Determine it
2186                 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2187         } // END - if
2188
2189         // Return cache
2190         return $GLOBALS[__FUNCTION__];
2191 }
2192
2193 // "Getter" for __DB_NAME
2194 function getDbName () {
2195         // Do we have cache?
2196         if (!isset($GLOBALS[__FUNCTION__])) {
2197                 // Determine it
2198                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2199         } // END - if
2200
2201         // Return cache
2202         return $GLOBALS[__FUNCTION__];
2203 }
2204
2205 // "Getter" for DOMAIN
2206 function getDomain () {
2207         // Do we have cache?
2208         if (!isset($GLOBALS[__FUNCTION__])) {
2209                 // Determine it
2210                 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2211         } // END - if
2212
2213         // Return cache
2214         return $GLOBALS[__FUNCTION__];
2215 }
2216
2217 // "Getter" for proxy_username
2218 function getProxyUsername () {
2219         // Do we have cache?
2220         if (!isset($GLOBALS[__FUNCTION__])) {
2221                 // Determine it
2222                 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2223         } // END - if
2224
2225         // Return cache
2226         return $GLOBALS[__FUNCTION__];
2227 }
2228
2229 // "Getter" for proxy_password
2230 function getProxyPassword () {
2231         // Do we have cache?
2232         if (!isset($GLOBALS[__FUNCTION__])) {
2233                 // Determine it
2234                 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2235         } // END - if
2236
2237         // Return cache
2238         return $GLOBALS[__FUNCTION__];
2239 }
2240
2241 // "Getter" for proxy_host
2242 function getProxyHost () {
2243         // Do we have cache?
2244         if (!isset($GLOBALS[__FUNCTION__])) {
2245                 // Determine it
2246                 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2247         } // END - if
2248
2249         // Return cache
2250         return $GLOBALS[__FUNCTION__];
2251 }
2252
2253 // "Getter" for proxy_port
2254 function getProxyPort () {
2255         // Do we have cache?
2256         if (!isset($GLOBALS[__FUNCTION__])) {
2257                 // Determine it
2258                 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2259         } // END - if
2260
2261         // Return cache
2262         return $GLOBALS[__FUNCTION__];
2263 }
2264
2265 // "Getter" for SMTP_HOSTNAME
2266 function getSmtpHostname () {
2267         // Do we have cache?
2268         if (!isset($GLOBALS[__FUNCTION__])) {
2269                 // Determine it
2270                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2271         } // END - if
2272
2273         // Return cache
2274         return $GLOBALS[__FUNCTION__];
2275 }
2276
2277 // "Getter" for SMTP_USER
2278 function getSmtpUser () {
2279         // Do we have cache?
2280         if (!isset($GLOBALS[__FUNCTION__])) {
2281                 // Determine it
2282                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2283         } // END - if
2284
2285         // Return cache
2286         return $GLOBALS[__FUNCTION__];
2287 }
2288
2289 // "Getter" for SMTP_PASSWORD
2290 function getSmtpPassword () {
2291         // Do we have cache?
2292         if (!isset($GLOBALS[__FUNCTION__])) {
2293                 // Determine it
2294                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2295         } // END - if
2296
2297         // Return cache
2298         return $GLOBALS[__FUNCTION__];
2299 }
2300
2301 // "Getter" for points_word
2302 function getPointsWord () {
2303         // Do we have cache?
2304         if (!isset($GLOBALS[__FUNCTION__])) {
2305                 // Determine it
2306                 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2307         } // END - if
2308
2309         // Return cache
2310         return $GLOBALS[__FUNCTION__];
2311 }
2312
2313 // "Getter" for profile_lock
2314 function getProfileLock () {
2315         // Do we have cache?
2316         if (!isset($GLOBALS[__FUNCTION__])) {
2317                 // Determine it
2318                 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2319         } // END - if
2320
2321         // Return cache
2322         return $GLOBALS[__FUNCTION__];
2323 }
2324
2325 // "Getter" for url_tlock
2326 function getUrlTlock () {
2327         // Do we have cache?
2328         if (!isset($GLOBALS[__FUNCTION__])) {
2329                 // Determine it
2330                 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2331         } // END - if
2332
2333         // Return cache
2334         return $GLOBALS[__FUNCTION__];
2335 }
2336
2337 // Checks wether proxy configuration is used
2338 function isProxyUsed () {
2339         // Do we have cache?
2340         if (!isset($GLOBALS[__FUNCTION__])) {
2341                 // Determine it
2342                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2343         } // END - if
2344
2345         // Return cache
2346         return $GLOBALS[__FUNCTION__];
2347 }
2348
2349 // Checks wether POST data contains selections
2350 function ifPostContainsSelections ($element = 'sel') {
2351         // Do we have cache?
2352         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2353                 // Determine it
2354                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
2355         } // END - if
2356
2357         // Return cache
2358         return $GLOBALS[__FUNCTION__][$element];
2359 }
2360
2361 // Checks wether verbose_sql is Y and returns true/false if so
2362 function isVerboseSqlEnabled () {
2363         // Do we have cache?
2364         if (!isset($GLOBALS[__FUNCTION__])) {
2365                 // Determine it
2366                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2367         } // END - if
2368
2369         // Return cache
2370         return $GLOBALS[__FUNCTION__];
2371 }
2372
2373 // "Getter" for total user points
2374 function getTotalPoints ($userid) {
2375         // Do we have cache?
2376         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2377                 // Init array for filter chain
2378                 $data = array(
2379                         'userid' => $userid,
2380                         'points' => 0
2381                 );
2382
2383                 // Run filter chain for getting more point values
2384                 $data = runFilterChain('get_total_points', $data);
2385
2386                 // Determine it
2387                 $GLOBALS[__FUNCTION__][$userid] = $data['points']  - countSumTotalData($userid, 'user_data', 'used_points');
2388         } // END - if
2389
2390         // Return cache
2391         return $GLOBALS[__FUNCTION__][$userid];
2392 }
2393
2394 // Wrapper to check if url_blacklist is enabled
2395 function isUrlBlacklistEnabled () {
2396         // Do we have cache?
2397         if (!isset($GLOBALS[__FUNCTION__])) {
2398                 // Determine it
2399                 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2400         } // END - if
2401
2402         // Return cache
2403         return $GLOBALS[__FUNCTION__];
2404 }
2405
2406 // Checks wether direct payment is allowed in configuration
2407 function isDirectPaymentEnabled () {
2408         // Do we have cache?
2409         if (!isset($GLOBALS[__FUNCTION__])) {
2410                 // Determine it
2411                 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2412         } // END - if
2413
2414         // Return cache
2415         return $GLOBALS[__FUNCTION__];
2416 }
2417
2418 // Wrapper to check if current task is for extension (not update)
2419 function isExtensionTask ($content) {
2420         // Do we have cache?
2421         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2422                 // Determine it
2423                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2424         } // END - if
2425
2426         // Return cache
2427         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2428 }
2429
2430 // Wrapper to check if output mode is CSS
2431 function isCssOutputMode () {
2432         // Determine it
2433         return (getScriptOutputMode() == 1);
2434 }
2435
2436 // Wrapper to check if output mode is HTML
2437 function isHtmlOutputMode () {
2438         // Determine it
2439         return (getScriptOutputMode() == 0);
2440 }
2441
2442 // Wrapper to check if output mode is RAW
2443 function isRawOutputMode () {
2444         // Determine it
2445         return (getScriptOutputMode() == -1);
2446 }
2447
2448 // Wrapper to generate a user email link
2449 function generateWrappedUserEmailLink ($email) {
2450         // Just call the inner function
2451         return generateEmailLink($email, 'user_data');
2452 }
2453
2454 // Wrapper to check if user points are locked
2455 function ifUserPointsLocked ($userid) {
2456         // Do we have cache?
2457         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2458                 // Determine it
2459                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2460         } // END - if
2461
2462         // Return cache
2463         return $GLOBALS[__FUNCTION__][$userid];
2464 }
2465
2466 // Appends a line to an existing file or creates it instantly with given content.
2467 // This function does always add a new-line character to every line.
2468 function appendLineToFile ($file, $line) {
2469         $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2470         fwrite($fp, $line . "\n");
2471         fclose($fp);
2472 }
2473
2474 // Wrapper for changeDataInFile() but with full path added
2475 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
2476         // Add full path
2477         $FQFN = getPath() . $FQFN;
2478
2479         // Call inner function
2480         return changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
2481 }
2482
2483 // Wrapper for changing entries in config-local.php
2484 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $DATA, $seek = 0) {
2485         // Call the inner function
2486         return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $DATA, $seek);
2487 }
2488
2489 // Shortens ucfirst(strtolower()) calls
2490 function firstCharUpperCase ($str) {
2491         return ucfirst(strtolower($str));
2492 }
2493
2494 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2495 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2496         // Get the configuration entry
2497         $configValue = getConfig($configEntry);
2498
2499         // Call inner method
2500         return createTimeSelections($configValue, $configEntry, $stamps, $align);
2501 }
2502
2503 // Shortens converting of German comma to Computer's version in POST data
2504 function convertCommaToDotInPostData ($postEntry) {
2505         // Read and convert given entry
2506         $postValue = convertCommaToDot(postRequestParameter($postEntry));
2507
2508         // ... and set it again
2509         setPostRequestParameter($postEntry, $postValue);
2510 }
2511
2512 // Converts German commas to Computer's version in all entries
2513 function convertCommaToDotInPostDataArray (array $postEntries) {
2514         // Replace german decimal comma with computer decimal dot
2515         foreach ($postEntries as $entry) {
2516                 // Is the entry there?
2517                 if (isPostRequestParameterSet($entry)) {
2518                         // Then convert it
2519                         convertCommaToDotInPostData($entry);
2520                 } // END - if
2521         } // END - foreach
2522 }
2523
2524 // Getter for 'check_double_email'
2525 function getCheckDoubleEmail () {
2526         // Is the cache entry set?
2527         if (!isset($GLOBALS[__FUNCTION__])) {
2528                 // No, so determine it
2529                 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2530         } // END - if
2531
2532         // Return cached entry
2533         return $GLOBALS[__FUNCTION__];
2534 }
2535
2536 // Checks wether 'check_double_email' is "YES"
2537 function isCheckDoubleEmailEnabled () {
2538         // Is the cache entry set?
2539         if (!isset($GLOBALS[__FUNCTION__])) {
2540                 // No, so determine it
2541                 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2542         } // END - if
2543
2544         // Return cached entry
2545         return $GLOBALS[__FUNCTION__];
2546 }
2547
2548 // [EOF]
2549 ?>