Function is now cached
[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         // Return the value
955         return $GLOBALS['user_data'][getCurrentUserId()][$column];
956 }
957
958 // Checks wether given user data is set to 'Y'
959 function isUserDataEnabled ($column) {
960         // Do we have cache?
961         if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
962                 // Determine it
963                 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
964         } // END - if
965
966         // Return cache
967         return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
968 }
969
970 // Geter for whole user data array
971 function getUserDataArray () {
972         // Get user id
973         $userid = getCurrentUserId();
974
975         // Is the current userid valid?
976         if (!isValidUserId($userid)) {
977                 // Should be always valid
978                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
979         } // END - if
980
981         // Get the whole array if found
982         if (isset($GLOBALS['user_data'][$userid])) {
983                 // Found, so return it
984                 return $GLOBALS['user_data'][$userid];
985         } else {
986                 // Return empty array
987                 return array();
988         }
989 }
990
991 // Checks if the user data is valid, this may indicate that the user has logged
992 // in, but you should use isMember() if you want to find that out.
993 function isUserDataValid () {
994         // User id should not be zero so abort here
995         if (!isCurrentUserIdSet()) return false;
996
997         // Is it cached?
998         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
999                 // Determine it
1000                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1001         } // END - if
1002
1003         // Return the result
1004         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1005 }
1006
1007 // Setter for current userid
1008 function setCurrentUserId ($userid) {
1009         // Set userid
1010         $GLOBALS['current_userid'] = bigintval($userid);
1011
1012         // Unset it to re-determine the actual state
1013         unset($GLOBALS['is_userdata_valid'][$userid]);
1014 }
1015
1016 // Getter for current userid
1017 function getCurrentUserId () {
1018         // Userid must be set before it can be used
1019         if (!isCurrentUserIdSet()) {
1020                 // Not set
1021                 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
1022         } // END - if
1023
1024         // Return the userid
1025         return $GLOBALS['current_userid'];
1026 }
1027
1028 // Checks if current userid is set
1029 function isCurrentUserIdSet () {
1030         return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
1031 }
1032
1033 // Checks wether we are debugging template cache
1034 function isDebuggingTemplateCache () {
1035         // Do we have cache?
1036         if (!isset($GLOBALS[__FUNCTION__])) {
1037                 // Determine it
1038                 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
1039         } // END - if
1040
1041         // Return cache
1042         return $GLOBALS[__FUNCTION__];
1043 }
1044
1045 // Wrapper for fetchUserData() and getUserData() calls
1046 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1047         // Is it cached?
1048         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1049                 // Default is 'guest'
1050                 $data = '{--USERNAME_GUEST--}';
1051
1052                 // Can we fetch the user data?
1053                 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1054                         // Now get the data back
1055                         $data = getUserData($valueColumn);
1056                 } // END - if
1057
1058                 // Cache it
1059                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1060         } // END - if
1061
1062         // Return it
1063         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1064 }
1065
1066 // Wrapper for strpos() to ease porting from deprecated ereg() function
1067 function isInString ($needle, $haystack) {
1068         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1069         return (strpos($haystack, $needle) !== false);
1070 }
1071
1072 // Wrapper for strpos() to ease porting from deprecated eregi() function
1073 // This function is case-insensitive
1074 function isInStringIgnoreCase ($needle, $haystack) {
1075         return (isInString(strtolower($needle), strtolower($haystack)));
1076 }
1077
1078 // Wrapper to check for if fatal errors where detected
1079 function ifFatalErrorsDetected () {
1080         // Just call the inner function
1081         return (getTotalFatalErrors() > 0);
1082 }
1083
1084 // Setter for HTTP status
1085 function setHttpStatus ($status) {
1086         $GLOBALS['http_status'] = (string) $status;
1087 }
1088
1089 // Getter for HTTP status
1090 function getHttpStatus () {
1091         // Is the status set?
1092         if (!isset($GLOBALS['http_status'])) {
1093                 // Abort here
1094                 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1095         } // END - if
1096
1097         // Return it
1098         return $GLOBALS['http_status'];
1099 }
1100
1101 /**
1102  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1103  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1104  *
1105  * ----------------------------------------------------------------------------
1106  * If you want to redirect, please use redirectToUrl(); instead
1107  * ----------------------------------------------------------------------------
1108  *
1109  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1110  *
1111  * @link    http://support.microsoft.com/kb/q176113/
1112  * @author  Andreas Gohr <andi@splitbrain.org>
1113  * @access  private
1114  */
1115 function sendRawRedirect ($url) {
1116         // Send helping header
1117         setHttpStatus('302 Found');
1118
1119         // always close the session
1120         session_write_close();
1121
1122         // Revert entity &amp;
1123         $url = str_replace('&amp;', '&', $url);
1124
1125         // check if running on IIS < 6 with CGI-PHP
1126         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1127                 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
1128                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1129                 ($matches[1] < 6)) {
1130                 // Send the IIS header
1131                 sendHeader('Refresh: 0;url=' . $url);
1132         } else {
1133                 // Send generic header
1134                 sendHeader('Location: ' . $url);
1135         }
1136
1137         // Shutdown here
1138         shutdown();
1139 }
1140
1141 // Determines the country of the given user id
1142 function determineCountry ($userid) {
1143         // Do we have cache?
1144         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1145                 // Default is 'invalid'
1146                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1147
1148                 // Is extension country active?
1149                 if (isExtensionActive('country')) {
1150                         // Determine the right country code through the country id
1151                         $id = getUserData('country_code');
1152
1153                         // Then handle it over
1154                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1155                 } else {
1156                         // Get raw code from user data
1157                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1158                 }
1159         } // END - if
1160
1161         // Return cache
1162         return $GLOBALS[__FUNCTION__][$userid];
1163 }
1164
1165 // "Getter" for total confirmed user accounts
1166 function getTotalConfirmedUser () {
1167         // Is it cached?
1168         if (!isset($GLOBALS[__FUNCTION__])) {
1169                 // Then do it
1170                 if (isExtensionActive('user')) {
1171                         $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1172                 } else {
1173                         $GLOBALS[__FUNCTION__] = 0;
1174                 }
1175         } // END - if
1176
1177         // Return cached value
1178         return $GLOBALS[__FUNCTION__];
1179 }
1180
1181 // "Getter" for total unconfirmed user accounts
1182 function getTotalUnconfirmedUser () {
1183         // Is it cached?
1184         if (!isset($GLOBALS[__FUNCTION__])) {
1185                 // Then do it
1186                 if (isExtensionActive('user')) {
1187                         $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1188                 } else {
1189                         $GLOBALS[__FUNCTION__] = 0;
1190                 }
1191         } // END - if
1192
1193         // Return cached value
1194         return $GLOBALS[__FUNCTION__];
1195 }
1196
1197 // "Getter" for total locked user accounts
1198 function getTotalLockedUser () {
1199         // Is it cached?
1200         if (!isset($GLOBALS[__FUNCTION__])) {
1201                 // Then do it
1202                 if (isExtensionActive('user')) {
1203                         $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1204                 } else {
1205                         $GLOBALS[__FUNCTION__] = 0;
1206                 }
1207         } // END - if
1208
1209         // Return cached value
1210         return $GLOBALS[__FUNCTION__];
1211 }
1212
1213 // Is given userid valid?
1214 function isValidUserId ($userid) {
1215         // Do we have cache?
1216         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1217                 // Check it out
1218                 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1219         } // END - if
1220
1221         // Return cache
1222         return $GLOBALS[__FUNCTION__][$userid];
1223 }
1224
1225 // Encodes entities
1226 function encodeEntities ($str) {
1227         // Secure it first
1228         $str = secureString($str, true, true);
1229
1230         // Encode dollar sign as well
1231         $str = str_replace('$', '&#36;', $str);
1232
1233         // Return it
1234         return $str;
1235 }
1236
1237 // "Getter" for date from patch_ctime
1238 function getDateFromPatchTime () {
1239         // Is it cached?
1240         if (!isset($GLOBALS[__FUNCTION__])) {
1241                 // Then set it
1242                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1243         } // END - if
1244
1245         // Return cache
1246         return $GLOBALS[__FUNCTION__];
1247 }
1248
1249 // Getter for current year (default)
1250 function getYear ($timestamp = null) {
1251         // Is it cached?
1252         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1253                 // null is time()
1254                 if (is_null($timestamp)) {
1255                         $timestamp = time();
1256                 } // END - if
1257
1258                 // Then create it
1259                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1260         } // END - if
1261
1262         // Return cache
1263         return $GLOBALS[__FUNCTION__][$timestamp];
1264 }
1265
1266 // Getter for current month (default)
1267 function getMonth ($timestamp = null) {
1268         // Is it cached?
1269         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1270                 // If null is set, use time()
1271                 if (is_null($timestamp)) {
1272                         // Use time() which is current timestamp
1273                         $timestamp = time();
1274                 } // END - if
1275
1276                 // Then create it
1277                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1278         } // END - if
1279
1280         // Return cache
1281         return $GLOBALS[__FUNCTION__][$timestamp];
1282 }
1283
1284 // Getter for current hour (default)
1285 function getHour ($timestamp = null) {
1286         // Is it cached?
1287         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1288                 // null is time()
1289                 if (is_null($timestamp)) {
1290                         $timestamp = time();
1291                 } // END - if
1292
1293                 // Then create it
1294                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1295         } // END - if
1296
1297         // Return cache
1298         return $GLOBALS[__FUNCTION__][$timestamp];
1299 }
1300
1301 // Getter for current day (default)
1302 function getDay ($timestamp = null) {
1303         // Is it cached?
1304         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1305                 // null is time()
1306                 if (is_null($timestamp)) {
1307                         $timestamp = time();
1308                 } // END - if
1309
1310                 // Then create it
1311                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1312         } // END - if
1313
1314         // Return cache
1315         return $GLOBALS[__FUNCTION__][$timestamp];
1316 }
1317
1318 // Getter for current week (default)
1319 function getWeek ($timestamp = null) {
1320         // Is it cached?
1321         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1322                 // null is time()
1323                 if (is_null($timestamp)) $timestamp = time();
1324
1325                 // Then create it
1326                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1327         } // END - if
1328
1329         // Return cache
1330         return $GLOBALS[__FUNCTION__][$timestamp];
1331 }
1332
1333 // Getter for current short_hour (default)
1334 function getShortHour ($timestamp = null) {
1335         // Is it cached?
1336         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1337                 // null is time()
1338                 if (is_null($timestamp)) $timestamp = time();
1339
1340                 // Then create it
1341                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1342         } // END - if
1343
1344         // Return cache
1345         return $GLOBALS[__FUNCTION__][$timestamp];
1346 }
1347
1348 // Getter for current long_hour (default)
1349 function getLongHour ($timestamp = null) {
1350         // Is it cached?
1351         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1352                 // null is time()
1353                 if (is_null($timestamp)) $timestamp = time();
1354
1355                 // Then create it
1356                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1357         } // END - if
1358
1359         // Return cache
1360         return $GLOBALS[__FUNCTION__][$timestamp];
1361 }
1362
1363 // Getter for current second (default)
1364 function getSecond ($timestamp = null) {
1365         // Is it cached?
1366         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1367                 // null is time()
1368                 if (is_null($timestamp)) $timestamp = time();
1369
1370                 // Then create it
1371                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1372         } // END - if
1373
1374         // Return cache
1375         return $GLOBALS[__FUNCTION__][$timestamp];
1376 }
1377
1378 // Getter for current minute (default)
1379 function getMinute ($timestamp = null) {
1380         // Is it cached?
1381         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1382                 // null is time()
1383                 if (is_null($timestamp)) $timestamp = time();
1384
1385                 // Then create it
1386                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1387         } // END - if
1388
1389         // Return cache
1390         return $GLOBALS[__FUNCTION__][$timestamp];
1391 }
1392
1393 // Checks wether the title decoration is enabled
1394 function isTitleDecorationEnabled () {
1395         // Do we have cache?
1396         if (!isset($GLOBALS[__FUNCTION__])) {
1397                 // Just check it
1398                 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1399         } // END - if
1400
1401         // Return cache
1402         return $GLOBALS[__FUNCTION__];
1403 }
1404
1405 // Checks wether filter usage updates are enabled (expensive queries!)
1406 function isFilterUsageUpdateEnabled () {
1407         // Do we have cache?
1408         if (!isset($GLOBALS[__FUNCTION__])) {
1409                 // Determine it
1410                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1411         } // END - if
1412
1413         // Return cache
1414         return $GLOBALS[__FUNCTION__];
1415 }
1416
1417 // Checks wether debugging of weekly resets is enabled
1418 function isWeeklyResetDebugEnabled () {
1419         // Do we have cache?
1420         if (!isset($GLOBALS[__FUNCTION__])) {
1421                 // Determine it
1422                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1423         } // END - if
1424
1425         // Return cache
1426         return $GLOBALS[__FUNCTION__];
1427 }
1428
1429 // Checks wether debugging of monthly resets is enabled
1430 function isMonthlyResetDebugEnabled () {
1431         // Do we have cache?
1432         if (!isset($GLOBALS[__FUNCTION__])) {
1433                 // Determine it
1434                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1435         } // END - if
1436
1437         // Return cache
1438         return $GLOBALS[__FUNCTION__];
1439 }
1440
1441 // Checks wether displaying of debug SQLs are enabled
1442 function isDisplayDebugSqlEnabled () {
1443         // Do we have cache?
1444         if (!isset($GLOBALS[__FUNCTION__])) {
1445                 // Determine it
1446                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1447         } // END - if
1448
1449         // Return cache
1450         return $GLOBALS[__FUNCTION__];
1451 }
1452
1453 // Checks wether module title is enabled
1454 function isModuleTitleEnabled () {
1455         // Do we have cache?
1456         if (!isset($GLOBALS[__FUNCTION__])) {
1457                 // Determine it
1458                 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1459         } // END - if
1460
1461         // Return cache
1462         return $GLOBALS[__FUNCTION__];
1463 }
1464
1465 // Checks wether what title is enabled
1466 function isWhatTitleEnabled () {
1467         // Do we have cache?
1468         if (!isset($GLOBALS[__FUNCTION__])) {
1469                 // Determine it
1470                 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1471         } // END - if
1472
1473         // Return cache
1474         return $GLOBALS[__FUNCTION__];
1475 }
1476
1477 // Checks wether stats are enabled
1478 function ifStatsAreEnabled () {
1479         // Do we have cache?
1480         if (!isset($GLOBALS[__FUNCTION__])) {
1481                 // Then determine it
1482                 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1483         } // END - if
1484
1485         // Return cached value
1486         return $GLOBALS[__FUNCTION__];
1487 }
1488
1489 // Checks wether admin-notification of certain user actions is enabled
1490 function isAdminNotificationEnabled () {
1491         // Do we have cache?
1492         if (!isset($GLOBALS[__FUNCTION__])) {
1493                 // Determine it
1494                 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1495         } // END - if
1496
1497         // Return cache
1498         return $GLOBALS[__FUNCTION__];
1499 }
1500
1501 // Checks wether random referal id selection is enabled
1502 function isRandomReferalIdEnabled () {
1503         // Do we have cache?
1504         if (!isset($GLOBALS[__FUNCTION__])) {
1505                 // Determine it
1506                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1507         } // END - if
1508
1509         // Return cache
1510         return $GLOBALS[__FUNCTION__];
1511 }
1512
1513 // "Getter" for default language
1514 function getDefaultLanguage () {
1515         // Do we have cache?
1516         if (!isset($GLOBALS[__FUNCTION__])) {
1517                 // Determine it
1518                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1519         } // END - if
1520
1521         // Return cache
1522         return $GLOBALS[__FUNCTION__];
1523 }
1524
1525 // "Getter" for default referal id
1526 function getDefRefid () {
1527         // Do we have cache?
1528         if (!isset($GLOBALS[__FUNCTION__])) {
1529                 // Determine it
1530                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1531         } // END - if
1532
1533         // Return cache
1534         return $GLOBALS[__FUNCTION__];
1535 }
1536
1537 // "Getter" for path
1538 function getPath () {
1539         // Do we have cache?
1540         if (!isset($GLOBALS[__FUNCTION__])) {
1541                 // Determine it
1542                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1543         } // END - if
1544
1545         // Return cache
1546         return $GLOBALS[__FUNCTION__];
1547 }
1548
1549 // "Getter" for url
1550 function getUrl () {
1551         // Do we have cache?
1552         if (!isset($GLOBALS[__FUNCTION__])) {
1553                 // Determine it
1554                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1555         } // END - if
1556
1557         // Return cache
1558         return $GLOBALS[__FUNCTION__];
1559 }
1560
1561 // "Getter" for cache_path
1562 function getCachePath () {
1563         // Do we have cache?
1564         if (!isset($GLOBALS[__FUNCTION__])) {
1565                 // Determine it
1566                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1567         } // END - if
1568
1569         // Return cache
1570         return $GLOBALS[__FUNCTION__];
1571 }
1572
1573 // "Getter" for secret_key
1574 function getSecretKey () {
1575         // Do we have cache?
1576         if (!isset($GLOBALS[__FUNCTION__])) {
1577                 // Determine it
1578                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1579         } // END - if
1580
1581         // Return cache
1582         return $GLOBALS[__FUNCTION__];
1583 }
1584
1585 // "Getter" for SITE_KEY
1586 function getSiteKey () {
1587         // Do we have cache?
1588         if (!isset($GLOBALS[__FUNCTION__])) {
1589                 // Determine it
1590                 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1591         } // END - if
1592
1593         // Return cache
1594         return $GLOBALS[__FUNCTION__];
1595 }
1596
1597 // "Getter" for DATE_KEY
1598 function getDateKey () {
1599         // Do we have cache?
1600         if (!isset($GLOBALS[__FUNCTION__])) {
1601                 // Determine it
1602                 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1603         } // END - if
1604
1605         // Return cache
1606         return $GLOBALS[__FUNCTION__];
1607 }
1608
1609 // "Getter" for master_salt
1610 function getMasterSalt () {
1611         // Do we have cache?
1612         if (!isset($GLOBALS[__FUNCTION__])) {
1613                 // Determine it
1614                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1615         } // END - if
1616
1617         // Return cache
1618         return $GLOBALS[__FUNCTION__];
1619 }
1620
1621 // "Getter" for prime
1622 function getPrime () {
1623         // Do we have cache?
1624         if (!isset($GLOBALS[__FUNCTION__])) {
1625                 // Determine it
1626                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1627         } // END - if
1628
1629         // Return cache
1630         return $GLOBALS[__FUNCTION__];
1631 }
1632
1633 // "Getter" for encrypt_seperator
1634 function getEncryptSeperator () {
1635         // Do we have cache?
1636         if (!isset($GLOBALS[__FUNCTION__])) {
1637                 // Determine it
1638                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1639         } // END - if
1640
1641         // Return cache
1642         return $GLOBALS[__FUNCTION__];
1643 }
1644
1645 // "Getter" for mysql_prefix
1646 function getMysqlPrefix () {
1647         // Do we have cache?
1648         if (!isset($GLOBALS[__FUNCTION__])) {
1649                 // Determine it
1650                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1651         } // END - if
1652
1653         // Return cache
1654         return $GLOBALS[__FUNCTION__];
1655 }
1656
1657 // "Getter" for table_type
1658 function getTableType () {
1659         // Do we have cache?
1660         if (!isset($GLOBALS[__FUNCTION__])) {
1661                 // Determine it
1662                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1663         } // END - if
1664
1665         // Return cache
1666         return $GLOBALS[__FUNCTION__];
1667 }
1668
1669 // "Getter" for salt_length
1670 function getSaltLength () {
1671         // Do we have cache?
1672         if (!isset($GLOBALS[__FUNCTION__])) {
1673                 // Determine it
1674                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1675         } // END - if
1676
1677         // Return cache
1678         return $GLOBALS[__FUNCTION__];
1679 }
1680
1681 // "Getter" for output_mode
1682 function getOutputMode () {
1683         // Do we have cache?
1684         if (!isset($GLOBALS[__FUNCTION__])) {
1685                 // Determine it
1686                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1687         } // END - if
1688
1689         // Return cache
1690         return $GLOBALS[__FUNCTION__];
1691 }
1692
1693 // "Getter" for full_version
1694 function getFullVersion () {
1695         // Do we have cache?
1696         if (!isset($GLOBALS[__FUNCTION__])) {
1697                 // Determine it
1698                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1699         } // END - if
1700
1701         // Return cache
1702         return $GLOBALS[__FUNCTION__];
1703 }
1704
1705 // "Getter" for title
1706 function getTitle () {
1707         // Do we have cache?
1708         if (!isset($GLOBALS[__FUNCTION__])) {
1709                 // Determine it
1710                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1711         } // END - if
1712
1713         // Return cache
1714         return $GLOBALS[__FUNCTION__];
1715 }
1716
1717 // "Getter" for curr_svn_revision
1718 function getCurrentRepositoryRevision () {
1719         // Do we have cache?
1720         if (!isset($GLOBALS[__FUNCTION__])) {
1721                 // Determine it
1722                 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1723         } // END - if
1724
1725         // Return cache
1726         return $GLOBALS[__FUNCTION__];
1727 }
1728
1729 // "Getter" for server_url
1730 function getServerUrl () {
1731         // Do we have cache?
1732         if (!isset($GLOBALS[__FUNCTION__])) {
1733                 // Determine it
1734                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1735         } // END - if
1736
1737         // Return cache
1738         return $GLOBALS[__FUNCTION__];
1739 }
1740
1741 // "Getter" for mt_word
1742 function getMtWord () {
1743         // Do we have cache?
1744         if (!isset($GLOBALS[__FUNCTION__])) {
1745                 // Determine it
1746                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1747         } // END - if
1748
1749         // Return cache
1750         return $GLOBALS[__FUNCTION__];
1751 }
1752
1753 // "Getter" for mt_word2
1754 function getMtWord2 () {
1755         // Do we have cache?
1756         if (!isset($GLOBALS[__FUNCTION__])) {
1757                 // Determine it
1758                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1759         } // END - if
1760
1761         // Return cache
1762         return $GLOBALS[__FUNCTION__];
1763 }
1764
1765 // "Getter" for main_title
1766 function getMainTitle () {
1767         // Do we have cache?
1768         if (!isset($GLOBALS[__FUNCTION__])) {
1769                 // Determine it
1770                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1771         } // END - if
1772
1773         // Return cache
1774         return $GLOBALS[__FUNCTION__];
1775 }
1776
1777 // "Getter" for file_hash
1778 function getFileHash () {
1779         // Do we have cache?
1780         if (!isset($GLOBALS[__FUNCTION__])) {
1781                 // Determine it
1782                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1783         } // END - if
1784
1785         // Return cache
1786         return $GLOBALS[__FUNCTION__];
1787 }
1788
1789 // "Getter" for pass_scramble
1790 function getPassScramble () {
1791         // Do we have cache?
1792         if (!isset($GLOBALS[__FUNCTION__])) {
1793                 // Determine it
1794                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1795         } // END - if
1796
1797         // Return cache
1798         return $GLOBALS[__FUNCTION__];
1799 }
1800
1801 // "Getter" for ap_inactive_since
1802 function getApInactiveSince () {
1803         // Do we have cache?
1804         if (!isset($GLOBALS[__FUNCTION__])) {
1805                 // Determine it
1806                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1807         } // END - if
1808
1809         // Return cache
1810         return $GLOBALS[__FUNCTION__];
1811 }
1812
1813 // "Getter" for user_min_confirmed
1814 function getUserMinConfirmed () {
1815         // Do we have cache?
1816         if (!isset($GLOBALS[__FUNCTION__])) {
1817                 // Determine it
1818                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1819         } // END - if
1820
1821         // Return cache
1822         return $GLOBALS[__FUNCTION__];
1823 }
1824
1825 // "Getter" for auto_purge
1826 function getAutoPurge () {
1827         // Do we have cache?
1828         if (!isset($GLOBALS[__FUNCTION__])) {
1829                 // Determine it
1830                 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1831         } // END - if
1832
1833         // Return cache
1834         return $GLOBALS[__FUNCTION__];
1835 }
1836
1837 // "Getter" for bonus_userid
1838 function getBonusUserid () {
1839         // Do we have cache?
1840         if (!isset($GLOBALS[__FUNCTION__])) {
1841                 // Determine it
1842                 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1843         } // END - if
1844
1845         // Return cache
1846         return $GLOBALS[__FUNCTION__];
1847 }
1848
1849 // "Getter" for ap_inactive_time
1850 function getApInactiveTime () {
1851         // Do we have cache?
1852         if (!isset($GLOBALS[__FUNCTION__])) {
1853                 // Determine it
1854                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1855         } // END - if
1856
1857         // Return cache
1858         return $GLOBALS[__FUNCTION__];
1859 }
1860
1861 // "Getter" for ap_dm_timeout
1862 function getApDmTimeout () {
1863         // Do we have cache?
1864         if (!isset($GLOBALS[__FUNCTION__])) {
1865                 // Determine it
1866                 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1867         } // END - if
1868
1869         // Return cache
1870         return $GLOBALS[__FUNCTION__];
1871 }
1872
1873 // "Getter" for ap_tasks_time
1874 function getApTasksTime () {
1875         // Do we have cache?
1876         if (!isset($GLOBALS[__FUNCTION__])) {
1877                 // Determine it
1878                 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1879         } // END - if
1880
1881         // Return cache
1882         return $GLOBALS[__FUNCTION__];
1883 }
1884
1885 // "Getter" for ap_unconfirmed_time
1886 function getApUnconfirmedTime () {
1887         // Do we have cache?
1888         if (!isset($GLOBALS[__FUNCTION__])) {
1889                 // Determine it
1890                 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1891         } // END - if
1892
1893         // Return cache
1894         return $GLOBALS[__FUNCTION__];
1895 }
1896
1897 // "Getter" for points
1898 function getPoints () {
1899         // Do we have cache?
1900         if (!isset($GLOBALS[__FUNCTION__])) {
1901                 // Determine it
1902                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1903         } // END - if
1904
1905         // Return cache
1906         return $GLOBALS[__FUNCTION__];
1907 }
1908
1909 // "Getter" for slogan
1910 function getSlogan () {
1911         // Do we have cache?
1912         if (!isset($GLOBALS[__FUNCTION__])) {
1913                 // Determine it
1914                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1915         } // END - if
1916
1917         // Return cache
1918         return $GLOBALS[__FUNCTION__];
1919 }
1920
1921 // "Getter" for copy
1922 function getCopy () {
1923         // Do we have cache?
1924         if (!isset($GLOBALS[__FUNCTION__])) {
1925                 // Determine it
1926                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1927         } // END - if
1928
1929         // Return cache
1930         return $GLOBALS[__FUNCTION__];
1931 }
1932
1933 // "Getter" for webmaster
1934 function getWebmaster () {
1935         // Do we have cache?
1936         if (!isset($GLOBALS[__FUNCTION__])) {
1937                 // Determine it
1938                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1939         } // END - if
1940
1941         // Return cache
1942         return $GLOBALS[__FUNCTION__];
1943 }
1944
1945 // "Getter" for sql_count
1946 function getSqlCount () {
1947         // Do we have cache?
1948         if (!isset($GLOBALS[__FUNCTION__])) {
1949                 // Determine it
1950                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1951         } // END - if
1952
1953         // Return cache
1954         return $GLOBALS[__FUNCTION__];
1955 }
1956
1957 // "Getter" for num_templates
1958 function getNumTemplates () {
1959         // Do we have cache?
1960         if (!isset($GLOBALS[__FUNCTION__])) {
1961                 // Determine it
1962                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1963         } // END - if
1964
1965         // Return cache
1966         return $GLOBALS[__FUNCTION__];
1967 }
1968
1969 // "Getter" for dns_cache_timeout
1970 function getDnsCacheTimeout () {
1971         // Do we have cache?
1972         if (!isset($GLOBALS[__FUNCTION__])) {
1973                 // Determine it
1974                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1975         } // END - if
1976
1977         // Return cache
1978         return $GLOBALS[__FUNCTION__];
1979 }
1980
1981 // "Getter" for menu_blur_spacer
1982 function getMenuBlurSpacer () {
1983         // Do we have cache?
1984         if (!isset($GLOBALS[__FUNCTION__])) {
1985                 // Determine it
1986                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1987         } // END - if
1988
1989         // Return cache
1990         return $GLOBALS[__FUNCTION__];
1991 }
1992
1993 // "Getter" for points_register
1994 function getPointsRegister () {
1995         // Do we have cache?
1996         if (!isset($GLOBALS[__FUNCTION__])) {
1997                 // Determine it
1998                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
1999         } // END - if
2000
2001         // Return cache
2002         return $GLOBALS[__FUNCTION__];
2003 }
2004
2005 // "Getter" for points_ref
2006 function getPointsRef () {
2007         // Do we have cache?
2008         if (!isset($GLOBALS[__FUNCTION__])) {
2009                 // Determine it
2010                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2011         } // END - if
2012
2013         // Return cache
2014         return $GLOBALS[__FUNCTION__];
2015 }
2016
2017 // "Getter" for ref_payout
2018 function getRefPayout () {
2019         // Do we have cache?
2020         if (!isset($GLOBALS[__FUNCTION__])) {
2021                 // Determine it
2022                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2023         } // END - if
2024
2025         // Return cache
2026         return $GLOBALS[__FUNCTION__];
2027 }
2028
2029 // "Getter" for online_timeout
2030 function getOnlineTimeout () {
2031         // Do we have cache?
2032         if (!isset($GLOBALS[__FUNCTION__])) {
2033                 // Determine it
2034                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2035         } // END - if
2036
2037         // Return cache
2038         return $GLOBALS[__FUNCTION__];
2039 }
2040
2041 // "Getter" for index_home
2042 function getIndexHome () {
2043         // Do we have cache?
2044         if (!isset($GLOBALS[__FUNCTION__])) {
2045                 // Determine it
2046                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2047         } // END - if
2048
2049         // Return cache
2050         return $GLOBALS[__FUNCTION__];
2051 }
2052
2053 // "Getter" for one_day
2054 function getOneDay () {
2055         // Do we have cache?
2056         if (!isset($GLOBALS[__FUNCTION__])) {
2057                 // Determine it
2058                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2059         } // END - if
2060
2061         // Return cache
2062         return $GLOBALS[__FUNCTION__];
2063 }
2064
2065 // "Getter" for activate_xchange
2066 function getActivateXchange () {
2067         // Do we have cache?
2068         if (!isset($GLOBALS[__FUNCTION__])) {
2069                 // Determine it
2070                 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
2071         } // END - if
2072
2073         // Return cache
2074         return $GLOBALS[__FUNCTION__];
2075 }
2076
2077 // "Getter" for img_type
2078 function getImgType () {
2079         // Do we have cache?
2080         if (!isset($GLOBALS[__FUNCTION__])) {
2081                 // Determine it
2082                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2083         } // END - if
2084
2085         // Return cache
2086         return $GLOBALS[__FUNCTION__];
2087 }
2088
2089 // "Getter" for code_length
2090 function getCodeLength () {
2091         // Do we have cache?
2092         if (!isset($GLOBALS[__FUNCTION__])) {
2093                 // Determine it
2094                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2095         } // END - if
2096
2097         // Return cache
2098         return $GLOBALS[__FUNCTION__];
2099 }
2100
2101 // "Getter" for least_cats
2102 function getLeastCats () {
2103         // Do we have cache?
2104         if (!isset($GLOBALS[__FUNCTION__])) {
2105                 // Determine it
2106                 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2107         } // END - if
2108
2109         // Return cache
2110         return $GLOBALS[__FUNCTION__];
2111 }
2112
2113 // "Getter" for pass_len
2114 function getPassLen () {
2115         // Do we have cache?
2116         if (!isset($GLOBALS[__FUNCTION__])) {
2117                 // Determine it
2118                 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2119         } // END - if
2120
2121         // Return cache
2122         return $GLOBALS[__FUNCTION__];
2123 }
2124
2125 // "Getter" for admin_menu
2126 function getAdminMenu () {
2127         // Do we have cache?
2128         if (!isset($GLOBALS[__FUNCTION__])) {
2129                 // Determine it
2130                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2131         } // END - if
2132
2133         // Return cache
2134         return $GLOBALS[__FUNCTION__];
2135 }
2136
2137 // "Getter" for last_month
2138 function getLastMonth () {
2139         // Do we have cache?
2140         if (!isset($GLOBALS[__FUNCTION__])) {
2141                 // Determine it
2142                 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2143         } // END - if
2144
2145         // Return cache
2146         return $GLOBALS[__FUNCTION__];
2147 }
2148
2149 // "Getter" for max_send
2150 function getMaxSend () {
2151         // Do we have cache?
2152         if (!isset($GLOBALS[__FUNCTION__])) {
2153                 // Determine it
2154                 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2155         } // END - if
2156
2157         // Return cache
2158         return $GLOBALS[__FUNCTION__];
2159 }
2160
2161 // "Getter" for mails_page
2162 function getMailsPage () {
2163         // Do we have cache?
2164         if (!isset($GLOBALS[__FUNCTION__])) {
2165                 // Determine it
2166                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2167         } // END - if
2168
2169         // Return cache
2170         return $GLOBALS[__FUNCTION__];
2171 }
2172
2173 // "Getter" for rand_no
2174 function getRandNo () {
2175         // Do we have cache?
2176         if (!isset($GLOBALS[__FUNCTION__])) {
2177                 // Determine it
2178                 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2179         } // END - if
2180
2181         // Return cache
2182         return $GLOBALS[__FUNCTION__];
2183 }
2184
2185 // "Getter" for __DB_NAME
2186 function getDbName () {
2187         // Do we have cache?
2188         if (!isset($GLOBALS[__FUNCTION__])) {
2189                 // Determine it
2190                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2191         } // END - if
2192
2193         // Return cache
2194         return $GLOBALS[__FUNCTION__];
2195 }
2196
2197 // "Getter" for DOMAIN
2198 function getDomain () {
2199         // Do we have cache?
2200         if (!isset($GLOBALS[__FUNCTION__])) {
2201                 // Determine it
2202                 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2203         } // END - if
2204
2205         // Return cache
2206         return $GLOBALS[__FUNCTION__];
2207 }
2208
2209 // "Getter" for proxy_username
2210 function getProxyUsername () {
2211         // Do we have cache?
2212         if (!isset($GLOBALS[__FUNCTION__])) {
2213                 // Determine it
2214                 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2215         } // END - if
2216
2217         // Return cache
2218         return $GLOBALS[__FUNCTION__];
2219 }
2220
2221 // "Getter" for proxy_password
2222 function getProxyPassword () {
2223         // Do we have cache?
2224         if (!isset($GLOBALS[__FUNCTION__])) {
2225                 // Determine it
2226                 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2227         } // END - if
2228
2229         // Return cache
2230         return $GLOBALS[__FUNCTION__];
2231 }
2232
2233 // "Getter" for proxy_host
2234 function getProxyHost () {
2235         // Do we have cache?
2236         if (!isset($GLOBALS[__FUNCTION__])) {
2237                 // Determine it
2238                 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2239         } // END - if
2240
2241         // Return cache
2242         return $GLOBALS[__FUNCTION__];
2243 }
2244
2245 // "Getter" for proxy_port
2246 function getProxyPort () {
2247         // Do we have cache?
2248         if (!isset($GLOBALS[__FUNCTION__])) {
2249                 // Determine it
2250                 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2251         } // END - if
2252
2253         // Return cache
2254         return $GLOBALS[__FUNCTION__];
2255 }
2256
2257 // "Getter" for SMTP_HOSTNAME
2258 function getSmtpHostname () {
2259         // Do we have cache?
2260         if (!isset($GLOBALS[__FUNCTION__])) {
2261                 // Determine it
2262                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2263         } // END - if
2264
2265         // Return cache
2266         return $GLOBALS[__FUNCTION__];
2267 }
2268
2269 // "Getter" for SMTP_USER
2270 function getSmtpUser () {
2271         // Do we have cache?
2272         if (!isset($GLOBALS[__FUNCTION__])) {
2273                 // Determine it
2274                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2275         } // END - if
2276
2277         // Return cache
2278         return $GLOBALS[__FUNCTION__];
2279 }
2280
2281 // "Getter" for SMTP_PASSWORD
2282 function getSmtpPassword () {
2283         // Do we have cache?
2284         if (!isset($GLOBALS[__FUNCTION__])) {
2285                 // Determine it
2286                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2287         } // END - if
2288
2289         // Return cache
2290         return $GLOBALS[__FUNCTION__];
2291 }
2292
2293 // "Getter" for points_word
2294 function getPointsWord () {
2295         // Do we have cache?
2296         if (!isset($GLOBALS[__FUNCTION__])) {
2297                 // Determine it
2298                 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2299         } // END - if
2300
2301         // Return cache
2302         return $GLOBALS[__FUNCTION__];
2303 }
2304
2305 // "Getter" for profile_lock
2306 function getProfileLock () {
2307         // Do we have cache?
2308         if (!isset($GLOBALS[__FUNCTION__])) {
2309                 // Determine it
2310                 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2311         } // END - if
2312
2313         // Return cache
2314         return $GLOBALS[__FUNCTION__];
2315 }
2316
2317 // "Getter" for url_tlock
2318 function getUrlTlock () {
2319         // Do we have cache?
2320         if (!isset($GLOBALS[__FUNCTION__])) {
2321                 // Determine it
2322                 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2323         } // END - if
2324
2325         // Return cache
2326         return $GLOBALS[__FUNCTION__];
2327 }
2328
2329 // Checks wether proxy configuration is used
2330 function isProxyUsed () {
2331         // Do we have cache?
2332         if (!isset($GLOBALS[__FUNCTION__])) {
2333                 // Determine it
2334                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2335         } // END - if
2336
2337         // Return cache
2338         return $GLOBALS[__FUNCTION__];
2339 }
2340
2341 // Checks wether POST data contains selections
2342 function ifPostContainsSelections ($element = 'sel') {
2343         // Do we have cache?
2344         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2345                 // Determine it
2346                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
2347         } // END - if
2348
2349         // Return cache
2350         return $GLOBALS[__FUNCTION__][$element];
2351 }
2352
2353 // Checks wether verbose_sql is Y and returns true/false if so
2354 function isVerboseSqlEnabled () {
2355         // Do we have cache?
2356         if (!isset($GLOBALS[__FUNCTION__])) {
2357                 // Determine it
2358                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2359         } // END - if
2360
2361         // Return cache
2362         return $GLOBALS[__FUNCTION__];
2363 }
2364
2365 // "Getter" for total user points
2366 function getTotalPoints ($userid) {
2367         // Do we have cache?
2368         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2369                 // Init array for filter chain
2370                 $data = array(
2371                         'userid' => $userid,
2372                         'points' => 0
2373                 );
2374
2375                 // Run filter chain for getting more point values
2376                 $data = runFilterChain('get_total_points', $data);
2377
2378                 // Determine it
2379                 $GLOBALS[__FUNCTION__][$userid] = $data['points']  - countSumTotalData($userid, 'user_data', 'used_points');
2380         } // END - if
2381
2382         // Return cache
2383         return $GLOBALS[__FUNCTION__][$userid];
2384 }
2385
2386 // Wrapper to check if url_blacklist is enabled
2387 function isUrlBlacklistEnabled () {
2388         // Do we have cache?
2389         if (!isset($GLOBALS[__FUNCTION__])) {
2390                 // Determine it
2391                 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2392         } // END - if
2393
2394         // Return cache
2395         return $GLOBALS[__FUNCTION__];
2396 }
2397
2398 // Checks wether direct payment is allowed in configuration
2399 function isDirectPaymentEnabled () {
2400         // Do we have cache?
2401         if (!isset($GLOBALS[__FUNCTION__])) {
2402                 // Determine it
2403                 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2404         } // END - if
2405
2406         // Return cache
2407         return $GLOBALS[__FUNCTION__];
2408 }
2409
2410 // Wrapper to check if current task is for extension (not update)
2411 function isExtensionTask ($content) {
2412         // Do we have cache?
2413         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2414                 // Determine it
2415                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2416         } // END - if
2417
2418         // Return cache
2419         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2420 }
2421
2422 // Wrapper to check if output mode is CSS
2423 function isCssOutputMode () {
2424         // Determine it
2425         return (getScriptOutputMode() == 1);
2426 }
2427
2428 // Wrapper to check if output mode is HTML
2429 function isHtmlOutputMode () {
2430         // Determine it
2431         return (getScriptOutputMode() == 0);
2432 }
2433
2434 // Wrapper to check if output mode is RAW
2435 function isRawOutputMode () {
2436         // Determine it
2437         return (getScriptOutputMode() == -1);
2438 }
2439
2440 // Wrapper to generate a user email link
2441 function generateWrappedUserEmailLink ($email) {
2442         // Just call the inner function
2443         return generateEmailLink($email, 'user_data');
2444 }
2445
2446 // Wrapper to check if user points are locked
2447 function ifUserPointsLocked ($userid) {
2448         // Do we have cache?
2449         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2450                 // Determine it
2451                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2452         } // END - if
2453
2454         // Return cache
2455         return $GLOBALS[__FUNCTION__][$userid];
2456 }
2457
2458 // Appends a line to an existing file or creates it instantly with given content.
2459 // This function does always add a new-line character to every line.
2460 function appendLineToFile ($file, $line) {
2461         $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2462         fwrite($fp, $line . "\n");
2463         fclose($fp);
2464 }
2465
2466 // Wrapper for changeDataInFile() but with full path added
2467 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
2468         // Add full path
2469         $FQFN = getPath() . $FQFN;
2470
2471         // Call inner function
2472         return changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
2473 }
2474
2475 // Wrapper for changing entries in config-local.php
2476 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $DATA, $seek = 0) {
2477         // Call the inner function
2478         return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $DATA, $seek);
2479 }
2480
2481 // Shortens ucfirst(strtolower()) calls
2482 function firstCharUpperCase ($str) {
2483         return ucfirst(strtolower($str));
2484 }
2485
2486 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
2487 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
2488         // Get the configuration entry
2489         $configValue = getConfig($configEntry);
2490
2491         // Call inner method
2492         return createTimeSelections($configValue, $configEntry, $stamps, $align);
2493 }
2494
2495 // Shortens converting of German comma to Computer's version in POST data
2496 function convertCommaToDotInPostData ($postEntry) {
2497         // Read and convert given entry
2498         $postValue = convertCommaToDot(postRequestParameter($postEntry));
2499
2500         // ... and set it again
2501         setPostRequestParameter($postEntry, $postValue);
2502 }
2503
2504 // Converts German commas to Computer's version in all entries
2505 function convertCommaToDotInPostDataArray (array $postEntries) {
2506         // Replace german decimal comma with computer decimal dot
2507         foreach ($postEntries as $entry) {
2508                 // Is the entry there?
2509                 if (isPostRequestParameterSet($entry)) {
2510                         // Then convert it
2511                         convertCommaToDotInPostData($entry);
2512                 } // END - if
2513         } // END - foreach
2514 }
2515
2516 // Getter for 'check_double_email'
2517 function getCheckDoubleEmail () {
2518         // Is the cache entry set?
2519         if (!isset($GLOBALS[__FUNCTION__])) {
2520                 // No, so determine it
2521                 $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
2522         } // END - if
2523
2524         // Return cached entry
2525         return $GLOBALS[__FUNCTION__];
2526 }
2527
2528 // Checks wether 'check_double_email' is "YES"
2529 function isCheckDoubleEmailEnabled () {
2530         // Is the cache entry set?
2531         if (!isset($GLOBALS[__FUNCTION__])) {
2532                 // No, so determine it
2533                 $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
2534         } // END - if
2535
2536         // Return cached entry
2537         return $GLOBALS[__FUNCTION__];
2538 }
2539
2540 // [EOF]
2541 ?>