Extensions bitcoins/yacy added, new API functions for handling proxy/non-proxy added:
[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 reset mode is active
374 function isResetModeEnabled () {
375         // Now simply check it
376         return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
377 }
378
379 // Checks wether the debug mode is enabled
380 function isDebugModeEnabled () {
381         // Is cache set?
382         if (!isset($GLOBALS[__FUNCTION__])) {
383                 // Simply check it
384                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
385         } // END - if
386
387         // Return it
388         return $GLOBALS[__FUNCTION__];
389 }
390
391 // Checks wether SQL debugging is enabled
392 function isSqlDebuggingEnabled () {
393         // Is cache set?
394         if (!isset($GLOBALS[__FUNCTION__])) {
395                 // Determine if SQL debugging is enabled
396                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
397         } // END - if
398
399         // Return it
400         return $GLOBALS[__FUNCTION__];
401 }
402
403 // Checks wether we shall debug regular expressions
404 function isDebugRegularExpressionEnabled () {
405         // Is cache set?
406         if (!isset($GLOBALS[__FUNCTION__])) {
407                 // Simply check it
408                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
409         } // END - if
410
411         // Return it
412         return $GLOBALS[__FUNCTION__];
413 }
414
415 // Checks wether the cache instance is valid
416 function isCacheInstanceValid () {
417         return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
418 }
419
420 // Copies a file from source to destination and verifies if that goes fine.
421 // This function should wrap the copy() command and make a nicer debug backtrace
422 // even if there is no xdebug extension installed.
423 function copyFileVerified ($source, $dest, $chmod = '') {
424         // Failed is the default
425         $status = false;
426
427         // Is the source file there?
428         if (!isFileReadable($source)) {
429                 // Then abort here
430                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
431         } // END - if
432
433         // Is the target directory there?
434         if (!isDirectory(dirname($dest))) {
435                 // Then abort here
436                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
437         } // END - if
438
439         // Now try to copy it
440         if (!copy($source, $dest)) {
441                 // Something went wrong
442                 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
443         } else {
444                 // Reset cache
445                 $GLOBALS['file_readable'][$dest] = true;
446         }
447
448         // If there are chmod rights set, apply them
449         if (!empty($chmod)) {
450                 // Try to apply them
451                 $status = changeMode($dest, $chmod);
452         } else {
453                 // All fine
454                 $status = true;
455         }
456
457         // All fine
458         return $status;
459 }
460
461 // Wrapper function for header()
462 // Send a header but checks before if we can do so
463 function sendHeader ($header) {
464         // Send the header
465         //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
466         $GLOBALS['header'][] = trim($header);
467 }
468
469 // Flushes all headers
470 function flushHeaders () {
471         // Is the header already sent?
472         if (headers_sent()) {
473                 // Then abort here
474                 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
475         } // END - if
476
477         // Flush all headers if found
478         if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
479                 foreach ($GLOBALS['header'] as $header) {
480                         header($header);
481                 } // END - foreach
482         } // END - if
483
484         // Mark them as flushed
485         $GLOBALS['header'] = array();
486 }
487
488 // Wrapper function for chmod()
489 // @TODO Do some more sanity check here
490 function changeMode ($FQFN, $mode) {
491         // Is the file/directory there?
492         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
493                 // Neither, so abort here
494                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
495         } // END - if
496
497         // Try to set them
498         return chmod($FQFN, $mode);
499 }
500
501 // Wrapper for unlink()
502 function removeFile ($FQFN) {
503         // Is the file there?
504         if (isFileReadable($FQFN)) {
505                 // Reset cache first
506                 $GLOBALS['file_readable'][$FQFN] = false;
507
508                 // Yes, so remove it
509                 return unlink($FQFN);
510         } // END - if
511
512         // All fine if no file was removed. If we change this to 'false' or rewrite
513         // above if() block it would be to restrictive.
514         return true;
515 }
516
517 // Wrapper for $_POST['sel']
518 function countPostSelection ($element = 'sel') {
519         // Is it set?
520         if (isPostRequestParameterSet($element)) {
521                 // Return counted elements
522                 return countSelection(postRequestParameter($element));
523         } else {
524                 // Return zero if not found
525                 return 0;
526         }
527 }
528
529 // Checks wether the config-local.php is loaded
530 function isConfigLocalLoaded () {
531         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
532 }
533
534 // Checks wether a nickname or userid was entered and caches the result
535 function isNicknameUsed ($userid) {
536         // Is the cache there
537         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
538                 // Determine it
539                 $GLOBALS[__FUNCTION__][$userid] = (('' . round($userid) . '') != $userid);
540         } // END - if
541
542         // Return the result
543         return $GLOBALS[__FUNCTION__][$userid];
544 }
545
546 // Getter for 'what' value
547 function getWhat () {
548         // Default is null
549         $what = null;
550
551         // Is the value set?
552         if (isWhatSet(true)) {
553                 // Then use it
554                 $what = $GLOBALS['what'];
555         } // END - if
556
557         // Return it
558         return $what;
559 }
560
561 // Setter for 'what' value
562 function setWhat ($newWhat) {
563         $GLOBALS['what'] = SQL_ESCAPE($newWhat);
564 }
565
566 // Setter for 'what' from configuration
567 function setWhatFromConfig ($configEntry) {
568         // Get 'what' from config
569         $what = getConfig($configEntry);
570
571         // Set it
572         setWhat($what);
573 }
574
575 // Checks wether what is set and optionally aborts on miss
576 function isWhatSet ($strict =  false) {
577         // Check for it
578         $isset = isset($GLOBALS['what']);
579
580         // Should we abort here?
581         if (($strict === true) && ($isset === false)) {
582                 // Output backtrace
583                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
584         } // END - if
585
586         // Return it
587         return $isset;
588 }
589
590 // Getter for 'action' value
591 function getAction ($strict = true) {
592         // Default is null
593         $action = null;
594
595         // Is the value set?
596         if (isActionSet(($strict) && (isHtmlOutputMode()))) {
597                 // Then use it
598                 $action = $GLOBALS['action'];
599         } // END - if
600
601         // Return it
602         return $action;
603 }
604
605 // Setter for 'action' value
606 function setAction ($newAction) {
607         $GLOBALS['action'] = SQL_ESCAPE($newAction);
608 }
609
610 // Checks wether action is set and optionally aborts on miss
611 function isActionSet ($strict =  false) {
612         // Check for it
613         $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
614
615         // Should we abort here?
616         if (($strict === true) && ($isset === false)) {
617                 // Output backtrace
618                 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
619         } // END - if
620
621         // Return it
622         return $isset;
623 }
624
625 // Getter for 'module' value
626 function getModule ($strict = true) {
627         // Default is null
628         $module = null;
629
630         // Is the value set?
631         if (isModuleSet($strict)) {
632                 // Then use it
633                 $module = $GLOBALS['module'];
634         } // END - if
635
636         // Return it
637         return $module;
638 }
639
640 // Setter for 'module' value
641 function setModule ($newModule) {
642         // Secure it and make all modules lower-case
643         $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
644 }
645
646 // Checks wether module is set and optionally aborts on miss
647 function isModuleSet ($strict =  false) {
648         // Check for it
649         $isset = (!empty($GLOBALS['module']));
650
651         // Should we abort here?
652         if (($strict === true) && ($isset === false)) {
653                 // Output backtrace
654                 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
655         } // END - if
656
657         // Return it
658         return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
659 }
660
661 // Getter for 'output_mode' value
662 function getScriptOutputMode () {
663         // Default is null
664         $output_mode = null;
665
666         // Is the value set?
667         if (isOutputModeSet(true)) {
668                 // Then use it
669                 $output_mode = $GLOBALS['output_mode'];
670         } // END - if
671
672         // Return it
673         return $output_mode;
674 }
675
676 // Setter for 'output_mode' value
677 function setOutputMode ($newOutputMode) {
678         $GLOBALS['output_mode'] = (int) $newOutputMode;
679 }
680
681 // Checks wether output_mode is set and optionally aborts on miss
682 function isOutputModeSet ($strict =  false) {
683         // Check for it
684         $isset = (isset($GLOBALS['output_mode']));
685
686         // Should we abort here?
687         if (($strict === true) && ($isset === false)) {
688                 // Output backtrace
689                 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
690         } // END - if
691
692         // Return it
693         return $isset;
694 }
695
696 // Enables block-mode
697 function enableBlockMode ($enabled = true) {
698         $GLOBALS['block_mode'] = $enabled;
699 }
700
701 // Checks wether block-mode is enabled
702 function isBlockModeEnabled () {
703         // Abort if not set
704         if (!isset($GLOBALS['block_mode'])) {
705                 // Needs to be fixed
706                 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
707         } // END - if
708
709         // Return it
710         return $GLOBALS['block_mode'];
711 }
712
713 // Wrapper function for addPointsThroughReferalSystem()
714 function addPointsDirectly ($subject, $userid, $points) {
715         // Reset level here
716         unset($GLOBALS['ref_level']);
717
718         // Call more complicated method (due to more parameters)
719         return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'direct');
720 }
721
722 // Wrapper for redirectToUrl but URL comes from a configuration entry
723 function redirectToConfiguredUrl ($configEntry) {
724         // Load the URL
725         redirectToUrl(getConfig($configEntry));
726 }
727
728 // Wrapper function to redirect from member-only modules to index
729 function redirectToIndexMemberOnlyModule () {
730         // Do the redirect here
731         redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
732 }
733
734 // Wrapper function to redirect to current URL
735 function redirectToRequestUri () {
736         redirectToUrl(basename(detectRequestUri()));
737 }
738
739 // Wrapper function to redirect to de-refered URL
740 function redirectToDereferedUrl ($URL) {
741         // Redirect to to
742         redirectToUrl(generateDerefererUrl($URL));
743 }
744
745 // Wrapper function for checking if extension is installed and newer or same version
746 function isExtensionInstalledAndNewer ($ext_name, $version) {
747         // Is an cache entry found?
748         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
749                 // Determine it
750                 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
751         } else {
752                 // Cache hits should be incremented twice
753                 incrementStatsEntry('cache_hits', 2);
754         }
755
756         // Return it
757         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
758         return $GLOBALS[__FUNCTION__][$ext_name][$version];
759 }
760
761 // Wrapper function for checking if extension is installed and older than given version
762 function isExtensionInstalledAndOlder ($ext_name, $version) {
763         // Is an cache entry found?
764         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
765                 // Determine it
766                 $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
767         } else {
768                 // Cache hits should be incremented twice
769                 incrementStatsEntry('cache_hits', 2);
770         }
771
772         // Return it
773         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
774         return $GLOBALS[__FUNCTION__][$ext_name][$version];
775 }
776
777 // Set username
778 function setUsername ($userName) {
779         $GLOBALS['username'] = (string) $userName;
780 }
781
782 // Get username
783 function getUsername () {
784         // User name set?
785         if (!isset($GLOBALS['username'])) {
786                 // No, so it has to be a guest
787                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
788         } // END - if
789
790         // Return it
791         return $GLOBALS['username'];
792 }
793
794 // Wrapper function for installation phase
795 function isInstallationPhase () {
796         // Do we have cache?
797         if (!isset($GLOBALS[__FUNCTION__])) {
798                 // Determine it
799                 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
800         } // END - if
801
802         // Return result
803         return $GLOBALS[__FUNCTION__];
804 }
805
806 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
807 function isDemoModeActive () {
808         // Is cache set?
809         if (!isset($GLOBALS[__FUNCTION__])) {
810                 // Simply check it
811                 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
812         } // END - if
813
814         // Return it
815         return $GLOBALS[__FUNCTION__];
816 }
817
818 // Getter for PHP caching value
819 function getPhpCaching () {
820         return $GLOBALS['php_caching'];
821 }
822
823 // Checks wether the admin hash is set
824 function isAdminHashSet ($adminId) {
825         // Is the array there?
826         if (!isset($GLOBALS['cache_array']['admin'])) {
827                 // Missing array should be reported
828                 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
829         } // END - if
830
831         // Check for admin hash
832         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
833 }
834
835 // Setter for admin hash
836 function setAdminHash ($adminId, $hash) {
837         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
838 }
839
840 // Getter for current admin login
841 function getCurrentAdminLogin () {
842         // Log debug message
843         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
844
845         // Do we have cache?
846         if (!isset($GLOBALS[__FUNCTION__])) {
847                 // Determine it
848                 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
849         } // END - if
850
851         // Return it
852         return $GLOBALS[__FUNCTION__];
853 }
854
855 // Setter for admin id (and current)
856 function setAdminId ($adminId) {
857         // Log debug message
858         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
859
860         // Set session
861         $status = setSession('admin_id', bigintval($adminId));
862
863         // Set current id
864         setCurrentAdminId($adminId);
865
866         // Return status
867         return $status;
868 }
869
870 // Setter for admin_last
871 function setAdminLast ($adminLast) {
872         // Log debug message
873         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
874
875         // Set session
876         $status = setSession('admin_last', $adminLast);
877
878         // Return status
879         return $status;
880 }
881
882 // Setter for admin_md5
883 function setAdminMd5 ($adminMd5) {
884         // Log debug message
885         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
886
887         // Set session
888         $status = setSession('admin_md5', $adminMd5);
889
890         // Return status
891         return $status;
892 }
893
894 // Getter for admin_md5
895 function getAdminMd5 () {
896         // Log debug message
897         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
898
899         // Get session
900         return getSession('admin_md5');
901 }
902
903 // Init user data array
904 function initUserData () {
905         // User id should not be zero
906         if (!isValidUserId(getCurrentUserId())) {
907                 // Should be always valid
908                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
909         } // END - if
910
911         // Init the user
912         $GLOBALS['user_data'][getCurrentUserId()] = array();
913 }
914
915 // Getter for user data
916 function getUserData ($column) {
917         // User id should not be zero
918         if (!isValidUserId(getCurrentUserId())) {
919                 // Should be always valid
920                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
921         } // END - if
922
923         // Return the value
924         return $GLOBALS['user_data'][getCurrentUserId()][$column];
925 }
926
927 // Geter for whole user data array
928 function getUserDataArray () {
929         // Get user id
930         $userid = getCurrentUserId();
931
932         // Is the current userid valid?
933         if (!isValidUserId($userid)) {
934                 // Should be always valid
935                 debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
936         } // END - if
937
938         // Get the whole array if found
939         if (isset($GLOBALS['user_data'][$userid])) {
940                 // Found, so return it
941                 return $GLOBALS['user_data'][$userid];
942         } else {
943                 // Return empty array
944                 return array();
945         }
946 }
947
948 // Checks if the user data is valid, this may indicate that the user has logged
949 // in, but you should use isMember() if you want to find that out.
950 function isUserDataValid () {
951         // User id should not be zero so abort here
952         if (!isCurrentUserIdSet()) return false;
953
954         // Is it cached?
955         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
956                 // Determine it
957                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
958         } // END - if
959
960         // Return the result
961         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
962 }
963
964 // Setter for current userid
965 function setCurrentUserId ($userid) {
966         // Set userid
967         $GLOBALS['current_userid'] = bigintval($userid);
968
969         // Unset it to re-determine the actual state
970         unset($GLOBALS['is_userdata_valid'][$userid]);
971 }
972
973 // Getter for current userid
974 function getCurrentUserId () {
975         // Userid must be set before it can be used
976         if (!isCurrentUserIdSet()) {
977                 // Not set
978                 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
979         } // END - if
980
981         // Return the userid
982         return $GLOBALS['current_userid'];
983 }
984
985 // Checks if current userid is set
986 function isCurrentUserIdSet () {
987         return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
988 }
989
990 // Checks wether we are debugging template cache
991 function isDebuggingTemplateCache () {
992         // Do we have cache?
993         if (!isset($GLOBALS[__FUNCTION__])) {
994                 // Determine it
995                 $GLOBALS[__FUNCTION__] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
996         } // END - if
997
998         // Return cache
999         return $GLOBALS[__FUNCTION__];
1000 }
1001
1002 // Wrapper for fetchUserData() and getUserData() calls
1003 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1004         // Is it cached?
1005         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1006                 // Default is 'guest'
1007                 $data = '{--USERNAME_GUEST--}';
1008
1009                 // Can we fetch the user data?
1010                 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
1011                         // Now get the data back
1012                         $data = getUserData($valueColumn);
1013                 } // END - if
1014
1015                 // Cache it
1016                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1017         } // END - if
1018
1019         // Return it
1020         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1021 }
1022
1023 // Wrapper for strpos() to ease porting from deprecated ereg() function
1024 function isInString ($needle, $haystack) {
1025         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
1026         return (strpos($haystack, $needle) !== false);
1027 }
1028
1029 // Wrapper for strpos() to ease porting from deprecated eregi() function
1030 // This function is case-insensitive
1031 function isInStringIgnoreCase ($needle, $haystack) {
1032         return (isInString(strtolower($needle), strtolower($haystack)));
1033 }
1034
1035 // Wrapper to check for if fatal errors where detected
1036 function ifFatalErrorsDetected () {
1037         // Just call the inner function
1038         return (getTotalFatalErrors() > 0);
1039 }
1040
1041 // Setter for HTTP status
1042 function setHttpStatus ($status) {
1043         $GLOBALS['http_status'] = (string) $status;
1044 }
1045
1046 // Getter for HTTP status
1047 function getHttpStatus () {
1048         // Is the status set?
1049         if (!isset($GLOBALS['http_status'])) {
1050                 // Abort here
1051                 debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1052         } // END - if
1053
1054         // Return it
1055         return $GLOBALS['http_status'];
1056 }
1057
1058 /**
1059  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1060  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1061  *
1062  * ----------------------------------------------------------------------------
1063  * If you want to redirect, please use redirectToUrl(); instead
1064  * ----------------------------------------------------------------------------
1065  *
1066  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1067  *
1068  * @link    http://support.microsoft.com/kb/q176113/
1069  * @author  Andreas Gohr <andi@splitbrain.org>
1070  * @access  private
1071  */
1072 function sendRawRedirect ($url) {
1073         // Send helping header
1074         setHttpStatus('302 Found');
1075
1076         // always close the session
1077         session_write_close();
1078
1079         // Revert entity &amp;
1080         $url = str_replace('&amp;', '&', $url);
1081
1082         // check if running on IIS < 6 with CGI-PHP
1083         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1084                 (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
1085                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1086                 ($matches[1] < 6)) {
1087                 // Send the IIS header
1088                 sendHeader('Refresh: 0;url=' . $url);
1089         } else {
1090                 // Send generic header
1091                 sendHeader('Location: ' . $url);
1092         }
1093
1094         // Shutdown here
1095         shutdown();
1096 }
1097
1098 // Determines the country of the given user id
1099 function determineCountry ($userid) {
1100         // Do we have cache?
1101         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1102                 // Default is 'invalid'
1103                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1104
1105                 // Is extension country active?
1106                 if (isExtensionActive('country')) {
1107                         // Determine the right country code through the country id
1108                         $id = getUserData('country_code');
1109
1110                         // Then handle it over
1111                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1112                 } else {
1113                         // Get raw code from user data
1114                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1115                 }
1116         } // END - if
1117
1118         // Return cache
1119         return $GLOBALS[__FUNCTION__][$userid];
1120 }
1121
1122 // "Getter" for total confirmed user accounts
1123 function getTotalConfirmedUser () {
1124         // Is it cached?
1125         if (!isset($GLOBALS[__FUNCTION__])) {
1126                 // Then do it
1127                 $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1128         } // END - if
1129
1130         // Return cached value
1131         return $GLOBALS[__FUNCTION__];
1132 }
1133
1134 // "Getter" for total unconfirmed user accounts
1135 function getTotalUnconfirmedUser () {
1136         // Is it cached?
1137         if (!isset($GLOBALS[__FUNCTION__])) {
1138                 // Then do it
1139                 $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1140         } // END - if
1141
1142         // Return cached value
1143         return $GLOBALS[__FUNCTION__];
1144 }
1145
1146 // "Getter" for total locked user accounts
1147 function getTotalLockedUser () {
1148         // Is it cached?
1149         if (!isset($GLOBALS[__FUNCTION__])) {
1150                 // Then do it
1151                 $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1152         } // END - if
1153
1154         // Return cached value
1155         return $GLOBALS[__FUNCTION__];
1156 }
1157
1158 // Is given userid valid?
1159 function isValidUserId ($userid) {
1160         // Do we have cache?
1161         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1162                 // Check it out
1163                 $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1164         } // END - if
1165
1166         // Return cache
1167         return $GLOBALS[__FUNCTION__][$userid];
1168 }
1169
1170 // Encodes entities
1171 function encodeEntities ($str) {
1172         // Secure it first
1173         $str = secureString($str, true, true);
1174
1175         // Encode dollar sign as well
1176         $str = str_replace('$', '&#36;', $str);
1177
1178         // Return it
1179         return $str;
1180 }
1181
1182 // "Getter" for date from patch_ctime
1183 function getDateFromPatchTime () {
1184         // Is it cached?
1185         if (!isset($GLOBALS[__FUNCTION__])) {
1186                 // Then set it
1187                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1188         } // END - if
1189
1190         // Return cache
1191         return $GLOBALS[__FUNCTION__];
1192 }
1193
1194 // Getter for current year (default)
1195 function getYear ($timestamp = null) {
1196         // Is it cached?
1197         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1198                 // null is time()
1199                 if (is_null($timestamp)) $timestamp = time();
1200
1201                 // Then create it
1202                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1203         } // END - if
1204
1205         // Return cache
1206         return $GLOBALS[__FUNCTION__][$timestamp];
1207 }
1208
1209 // Getter for current month (default)
1210 function getMonth ($timestamp = null) {
1211         // Is it cached?
1212         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1213                 // If null is set, use time()
1214                 if (is_null($timestamp)) {
1215                         // Use time() which is current timestamp
1216                         $timestamp = time();
1217                 } // END - if
1218
1219                 // Then create it
1220                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1221         } // END - if
1222
1223         // Return cache
1224         return $GLOBALS[__FUNCTION__][$timestamp];
1225 }
1226
1227 // Getter for current day (default)
1228 function getDay ($timestamp = null) {
1229         // Is it cached?
1230         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1231                 // null is time()
1232                 if (is_null($timestamp)) $timestamp = time();
1233
1234                 // Then create it
1235                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1236         } // END - if
1237
1238         // Return cache
1239         return $GLOBALS[__FUNCTION__][$timestamp];
1240 }
1241
1242 // Getter for current week (default)
1243 function getWeek ($timestamp = null) {
1244         // Is it cached?
1245         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1246                 // null is time()
1247                 if (is_null($timestamp)) $timestamp = time();
1248
1249                 // Then create it
1250                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1251         } // END - if
1252
1253         // Return cache
1254         return $GLOBALS[__FUNCTION__][$timestamp];
1255 }
1256
1257 // Getter for current short_hour (default)
1258 function getShortHour ($timestamp = null) {
1259         // Is it cached?
1260         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1261                 // null is time()
1262                 if (is_null($timestamp)) $timestamp = time();
1263
1264                 // Then create it
1265                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1266         } // END - if
1267
1268         // Return cache
1269         return $GLOBALS[__FUNCTION__][$timestamp];
1270 }
1271
1272 // Getter for current long_hour (default)
1273 function getLongHour ($timestamp = null) {
1274         // Is it cached?
1275         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1276                 // null is time()
1277                 if (is_null($timestamp)) $timestamp = time();
1278
1279                 // Then create it
1280                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1281         } // END - if
1282
1283         // Return cache
1284         return $GLOBALS[__FUNCTION__][$timestamp];
1285 }
1286
1287 // Getter for current second (default)
1288 function getSecond ($timestamp = null) {
1289         // Is it cached?
1290         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1291                 // null is time()
1292                 if (is_null($timestamp)) $timestamp = time();
1293
1294                 // Then create it
1295                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1296         } // END - if
1297
1298         // Return cache
1299         return $GLOBALS[__FUNCTION__][$timestamp];
1300 }
1301
1302 // Getter for current minute (default)
1303 function getMinute ($timestamp = null) {
1304         // Is it cached?
1305         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1306                 // null is time()
1307                 if (is_null($timestamp)) $timestamp = time();
1308
1309                 // Then create it
1310                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1311         } // END - if
1312
1313         // Return cache
1314         return $GLOBALS[__FUNCTION__][$timestamp];
1315 }
1316
1317 // Checks wether the title decoration is enabled
1318 function isTitleDecorationEnabled () {
1319         // Do we have cache?
1320         if (!isset($GLOBALS[__FUNCTION__])) {
1321                 // Just check it
1322                 $GLOBALS[__FUNCTION__] = (getConfig('enable_title_deco') == 'Y');
1323         } // END - if
1324
1325         // Return cache
1326         return $GLOBALS[__FUNCTION__];
1327 }
1328
1329 // Checks wether filter usage updates are enabled (expensive queries!)
1330 function isFilterUsageUpdateEnabled () {
1331         // Do we have cache?
1332         if (!isset($GLOBALS[__FUNCTION__])) {
1333                 // Determine it
1334                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1335         } // END - if
1336
1337         // Return cache
1338         return $GLOBALS[__FUNCTION__];
1339 }
1340
1341 // Checks wether debugging of weekly resets is enabled
1342 function isWeeklyResetDebugEnabled () {
1343         // Do we have cache?
1344         if (!isset($GLOBALS[__FUNCTION__])) {
1345                 // Determine it
1346                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1347         } // END - if
1348
1349         // Return cache
1350         return $GLOBALS[__FUNCTION__];
1351 }
1352
1353 // Checks wether debugging of monthly resets is enabled
1354 function isMonthlyResetDebugEnabled () {
1355         // Do we have cache?
1356         if (!isset($GLOBALS[__FUNCTION__])) {
1357                 // Determine it
1358                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1359         } // END - if
1360
1361         // Return cache
1362         return $GLOBALS[__FUNCTION__];
1363 }
1364
1365 // Checks wether displaying of debug SQLs are enabled
1366 function isDisplayDebugSqlEnabled () {
1367         // Do we have cache?
1368         if (!isset($GLOBALS[__FUNCTION__])) {
1369                 // Determine it
1370                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1371         } // END - if
1372
1373         // Return cache
1374         return $GLOBALS[__FUNCTION__];
1375 }
1376
1377 // Checks wether module title is enabled
1378 function isModuleTitleEnabled () {
1379         // Do we have cache?
1380         if (!isset($GLOBALS[__FUNCTION__])) {
1381                 // Determine it
1382                 $GLOBALS[__FUNCTION__] = (getConfig('enable_mod_title') == 'Y');
1383         } // END - if
1384
1385         // Return cache
1386         return $GLOBALS[__FUNCTION__];
1387 }
1388
1389 // Checks wether what title is enabled
1390 function isWhatTitleEnabled () {
1391         // Do we have cache?
1392         if (!isset($GLOBALS[__FUNCTION__])) {
1393                 // Determine it
1394                 $GLOBALS[__FUNCTION__] = (getConfig('enable_what_title') == 'Y');
1395         } // END - if
1396
1397         // Return cache
1398         return $GLOBALS[__FUNCTION__];
1399 }
1400
1401 // Checks wether stats are enabled
1402 function ifStatsAreEnabled () {
1403         // Do we have cache?
1404         if (!isset($GLOBALS[__FUNCTION__])) {
1405                 // Then determine it
1406                 $GLOBALS[__FUNCTION__] = (getConfig('stats_enabled') == 'Y');
1407         } // END - if
1408
1409         // Return cached value
1410         return $GLOBALS[__FUNCTION__];
1411 }
1412
1413 // Checks wether admin-notification of certain user actions is enabled
1414 function isAdminNotificationEnabled () {
1415         // Do we have cache?
1416         if (!isset($GLOBALS[__FUNCTION__])) {
1417                 // Determine it
1418                 $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y');
1419         } // END - if
1420
1421         // Return cache
1422         return $GLOBALS[__FUNCTION__];
1423 }
1424
1425 // Checks wether random referal id selection is enabled
1426 function isRandomReferalIdEnabled () {
1427         // Do we have cache?
1428         if (!isset($GLOBALS[__FUNCTION__])) {
1429                 // Determine it
1430                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
1431         } // END - if
1432
1433         // Return cache
1434         return $GLOBALS[__FUNCTION__];
1435 }
1436
1437 // "Getter" for default language
1438 function getDefaultLanguage () {
1439         // Do we have cache?
1440         if (!isset($GLOBALS[__FUNCTION__])) {
1441                 // Determine it
1442                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1443         } // END - if
1444
1445         // Return cache
1446         return $GLOBALS[__FUNCTION__];
1447 }
1448
1449 // "Getter" for default referal id
1450 function getDefRefid () {
1451         // Do we have cache?
1452         if (!isset($GLOBALS[__FUNCTION__])) {
1453                 // Determine it
1454                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1455         } // END - if
1456
1457         // Return cache
1458         return $GLOBALS[__FUNCTION__];
1459 }
1460
1461 // "Getter" for path
1462 function getPath () {
1463         // Do we have cache?
1464         if (!isset($GLOBALS[__FUNCTION__])) {
1465                 // Determine it
1466                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1467         } // END - if
1468
1469         // Return cache
1470         return $GLOBALS[__FUNCTION__];
1471 }
1472
1473 // "Getter" for url
1474 function getUrl () {
1475         // Do we have cache?
1476         if (!isset($GLOBALS[__FUNCTION__])) {
1477                 // Determine it
1478                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1479         } // END - if
1480
1481         // Return cache
1482         return $GLOBALS[__FUNCTION__];
1483 }
1484
1485 // "Getter" for cache_path
1486 function getCachePath () {
1487         // Do we have cache?
1488         if (!isset($GLOBALS[__FUNCTION__])) {
1489                 // Determine it
1490                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1491         } // END - if
1492
1493         // Return cache
1494         return $GLOBALS[__FUNCTION__];
1495 }
1496
1497 // "Getter" for secret_key
1498 function getSecretKey () {
1499         // Do we have cache?
1500         if (!isset($GLOBALS[__FUNCTION__])) {
1501                 // Determine it
1502                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1503         } // END - if
1504
1505         // Return cache
1506         return $GLOBALS[__FUNCTION__];
1507 }
1508
1509 // "Getter" for master_salt
1510 function getMasterSalt () {
1511         // Do we have cache?
1512         if (!isset($GLOBALS[__FUNCTION__])) {
1513                 // Determine it
1514                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1515         } // END - if
1516
1517         // Return cache
1518         return $GLOBALS[__FUNCTION__];
1519 }
1520
1521 // "Getter" for prime
1522 function getPrime () {
1523         // Do we have cache?
1524         if (!isset($GLOBALS[__FUNCTION__])) {
1525                 // Determine it
1526                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1527         } // END - if
1528
1529         // Return cache
1530         return $GLOBALS[__FUNCTION__];
1531 }
1532
1533 // "Getter" for encrypt_seperator
1534 function getEncryptSeperator () {
1535         // Do we have cache?
1536         if (!isset($GLOBALS[__FUNCTION__])) {
1537                 // Determine it
1538                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPERATOR');
1539         } // END - if
1540
1541         // Return cache
1542         return $GLOBALS[__FUNCTION__];
1543 }
1544
1545 // "Getter" for mysql_prefix
1546 function getMysqlPrefix () {
1547         // Do we have cache?
1548         if (!isset($GLOBALS[__FUNCTION__])) {
1549                 // Determine it
1550                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1551         } // END - if
1552
1553         // Return cache
1554         return $GLOBALS[__FUNCTION__];
1555 }
1556
1557 // "Getter" for table_type
1558 function getTableType () {
1559         // Do we have cache?
1560         if (!isset($GLOBALS[__FUNCTION__])) {
1561                 // Determine it
1562                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1563         } // END - if
1564
1565         // Return cache
1566         return $GLOBALS[__FUNCTION__];
1567 }
1568
1569 // "Getter" for salt_length
1570 function getSaltLength () {
1571         // Do we have cache?
1572         if (!isset($GLOBALS[__FUNCTION__])) {
1573                 // Determine it
1574                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1575         } // END - if
1576
1577         // Return cache
1578         return $GLOBALS[__FUNCTION__];
1579 }
1580
1581 // "Getter" for output_mode
1582 function getOutputMode () {
1583         // Do we have cache?
1584         if (!isset($GLOBALS[__FUNCTION__])) {
1585                 // Determine it
1586                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1587         } // END - if
1588
1589         // Return cache
1590         return $GLOBALS[__FUNCTION__];
1591 }
1592
1593 // "Getter" for full_version
1594 function getFullVersion () {
1595         // Do we have cache?
1596         if (!isset($GLOBALS[__FUNCTION__])) {
1597                 // Determine it
1598                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1599         } // END - if
1600
1601         // Return cache
1602         return $GLOBALS[__FUNCTION__];
1603 }
1604
1605 // "Getter" for title
1606 function getTitle () {
1607         // Do we have cache?
1608         if (!isset($GLOBALS[__FUNCTION__])) {
1609                 // Determine it
1610                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1611         } // END - if
1612
1613         // Return cache
1614         return $GLOBALS[__FUNCTION__];
1615 }
1616
1617 // "Getter" for curr_svn_revision
1618 function getCurrentRepositoryRevision () {
1619         // Do we have cache?
1620         if (!isset($GLOBALS[__FUNCTION__])) {
1621                 // Determine it
1622                 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1623         } // END - if
1624
1625         // Return cache
1626         return $GLOBALS[__FUNCTION__];
1627 }
1628
1629 // "Getter" for server_url
1630 function getServerUrl () {
1631         // Do we have cache?
1632         if (!isset($GLOBALS[__FUNCTION__])) {
1633                 // Determine it
1634                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1635         } // END - if
1636
1637         // Return cache
1638         return $GLOBALS[__FUNCTION__];
1639 }
1640
1641 // "Getter" for mt_word
1642 function getMtWord () {
1643         // Do we have cache?
1644         if (!isset($GLOBALS[__FUNCTION__])) {
1645                 // Determine it
1646                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1647         } // END - if
1648
1649         // Return cache
1650         return $GLOBALS[__FUNCTION__];
1651 }
1652
1653 // "Getter" for mt_word2
1654 function getMtWord2 () {
1655         // Do we have cache?
1656         if (!isset($GLOBALS[__FUNCTION__])) {
1657                 // Determine it
1658                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1659         } // END - if
1660
1661         // Return cache
1662         return $GLOBALS[__FUNCTION__];
1663 }
1664
1665 // "Getter" for main_title
1666 function getMainTitle () {
1667         // Do we have cache?
1668         if (!isset($GLOBALS[__FUNCTION__])) {
1669                 // Determine it
1670                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
1671         } // END - if
1672
1673         // Return cache
1674         return $GLOBALS[__FUNCTION__];
1675 }
1676
1677 // "Getter" for file_hash
1678 function getFileHash () {
1679         // Do we have cache?
1680         if (!isset($GLOBALS[__FUNCTION__])) {
1681                 // Determine it
1682                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
1683         } // END - if
1684
1685         // Return cache
1686         return $GLOBALS[__FUNCTION__];
1687 }
1688
1689 // "Getter" for pass_scramble
1690 function getPassScramble () {
1691         // Do we have cache?
1692         if (!isset($GLOBALS[__FUNCTION__])) {
1693                 // Determine it
1694                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
1695         } // END - if
1696
1697         // Return cache
1698         return $GLOBALS[__FUNCTION__];
1699 }
1700
1701 // "Getter" for ap_inactive_since
1702 function getApInactiveSince () {
1703         // Do we have cache?
1704         if (!isset($GLOBALS[__FUNCTION__])) {
1705                 // Determine it
1706                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
1707         } // END - if
1708
1709         // Return cache
1710         return $GLOBALS[__FUNCTION__];
1711 }
1712
1713 // "Getter" for user_min_confirmed
1714 function getUserMinConfirmed () {
1715         // Do we have cache?
1716         if (!isset($GLOBALS[__FUNCTION__])) {
1717                 // Determine it
1718                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
1719         } // END - if
1720
1721         // Return cache
1722         return $GLOBALS[__FUNCTION__];
1723 }
1724
1725 // "Getter" for auto_purge
1726 function getAutoPurge () {
1727         // Do we have cache?
1728         if (!isset($GLOBALS[__FUNCTION__])) {
1729                 // Determine it
1730                 $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
1731         } // END - if
1732
1733         // Return cache
1734         return $GLOBALS[__FUNCTION__];
1735 }
1736
1737 // "Getter" for bonus_userid
1738 function getBonusUserid () {
1739         // Do we have cache?
1740         if (!isset($GLOBALS[__FUNCTION__])) {
1741                 // Determine it
1742                 $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
1743         } // END - if
1744
1745         // Return cache
1746         return $GLOBALS[__FUNCTION__];
1747 }
1748
1749 // "Getter" for ap_inactive_time
1750 function getApInactiveTime () {
1751         // Do we have cache?
1752         if (!isset($GLOBALS[__FUNCTION__])) {
1753                 // Determine it
1754                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
1755         } // END - if
1756
1757         // Return cache
1758         return $GLOBALS[__FUNCTION__];
1759 }
1760
1761 // "Getter" for ap_dm_timeout
1762 function getApDmTimeout () {
1763         // Do we have cache?
1764         if (!isset($GLOBALS[__FUNCTION__])) {
1765                 // Determine it
1766                 $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
1767         } // END - if
1768
1769         // Return cache
1770         return $GLOBALS[__FUNCTION__];
1771 }
1772
1773 // "Getter" for ap_tasks_time
1774 function getApTasksTime () {
1775         // Do we have cache?
1776         if (!isset($GLOBALS[__FUNCTION__])) {
1777                 // Determine it
1778                 $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
1779         } // END - if
1780
1781         // Return cache
1782         return $GLOBALS[__FUNCTION__];
1783 }
1784
1785 // "Getter" for ap_unconfirmed_time
1786 function getApUnconfirmedTime () {
1787         // Do we have cache?
1788         if (!isset($GLOBALS[__FUNCTION__])) {
1789                 // Determine it
1790                 $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
1791         } // END - if
1792
1793         // Return cache
1794         return $GLOBALS[__FUNCTION__];
1795 }
1796
1797 // "Getter" for points
1798 function getPoints () {
1799         // Do we have cache?
1800         if (!isset($GLOBALS[__FUNCTION__])) {
1801                 // Determine it
1802                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
1803         } // END - if
1804
1805         // Return cache
1806         return $GLOBALS[__FUNCTION__];
1807 }
1808
1809 // "Getter" for slogan
1810 function getSlogan () {
1811         // Do we have cache?
1812         if (!isset($GLOBALS[__FUNCTION__])) {
1813                 // Determine it
1814                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
1815         } // END - if
1816
1817         // Return cache
1818         return $GLOBALS[__FUNCTION__];
1819 }
1820
1821 // "Getter" for copy
1822 function getCopy () {
1823         // Do we have cache?
1824         if (!isset($GLOBALS[__FUNCTION__])) {
1825                 // Determine it
1826                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
1827         } // END - if
1828
1829         // Return cache
1830         return $GLOBALS[__FUNCTION__];
1831 }
1832
1833 // "Getter" for webmaster
1834 function getWebmaster () {
1835         // Do we have cache?
1836         if (!isset($GLOBALS[__FUNCTION__])) {
1837                 // Determine it
1838                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
1839         } // END - if
1840
1841         // Return cache
1842         return $GLOBALS[__FUNCTION__];
1843 }
1844
1845 // "Getter" for sql_count
1846 function getSqlCount () {
1847         // Do we have cache?
1848         if (!isset($GLOBALS[__FUNCTION__])) {
1849                 // Determine it
1850                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
1851         } // END - if
1852
1853         // Return cache
1854         return $GLOBALS[__FUNCTION__];
1855 }
1856
1857 // "Getter" for num_templates
1858 function getNumTemplates () {
1859         // Do we have cache?
1860         if (!isset($GLOBALS[__FUNCTION__])) {
1861                 // Determine it
1862                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
1863         } // END - if
1864
1865         // Return cache
1866         return $GLOBALS[__FUNCTION__];
1867 }
1868
1869 // "Getter" for dns_cache_timeout
1870 function getDnsCacheTimeout () {
1871         // Do we have cache?
1872         if (!isset($GLOBALS[__FUNCTION__])) {
1873                 // Determine it
1874                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
1875         } // END - if
1876
1877         // Return cache
1878         return $GLOBALS[__FUNCTION__];
1879 }
1880
1881 // "Getter" for menu_blur_spacer
1882 function getMenuBlurSpacer () {
1883         // Do we have cache?
1884         if (!isset($GLOBALS[__FUNCTION__])) {
1885                 // Determine it
1886                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
1887         } // END - if
1888
1889         // Return cache
1890         return $GLOBALS[__FUNCTION__];
1891 }
1892
1893 // "Getter" for points_register
1894 function getPointsRegister () {
1895         // Do we have cache?
1896         if (!isset($GLOBALS[__FUNCTION__])) {
1897                 // Determine it
1898                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
1899         } // END - if
1900
1901         // Return cache
1902         return $GLOBALS[__FUNCTION__];
1903 }
1904
1905 // "Getter" for points_ref
1906 function getPointsRef () {
1907         // Do we have cache?
1908         if (!isset($GLOBALS[__FUNCTION__])) {
1909                 // Determine it
1910                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
1911         } // END - if
1912
1913         // Return cache
1914         return $GLOBALS[__FUNCTION__];
1915 }
1916
1917 // "Getter" for ref_payout
1918 function getRefPayout () {
1919         // Do we have cache?
1920         if (!isset($GLOBALS[__FUNCTION__])) {
1921                 // Determine it
1922                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
1923         } // END - if
1924
1925         // Return cache
1926         return $GLOBALS[__FUNCTION__];
1927 }
1928
1929 // "Getter" for online_timeout
1930 function getOnlineTimeout () {
1931         // Do we have cache?
1932         if (!isset($GLOBALS[__FUNCTION__])) {
1933                 // Determine it
1934                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
1935         } // END - if
1936
1937         // Return cache
1938         return $GLOBALS[__FUNCTION__];
1939 }
1940
1941 // "Getter" for index_home
1942 function getIndexHome () {
1943         // Do we have cache?
1944         if (!isset($GLOBALS[__FUNCTION__])) {
1945                 // Determine it
1946                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
1947         } // END - if
1948
1949         // Return cache
1950         return $GLOBALS[__FUNCTION__];
1951 }
1952
1953 // "Getter" for one_day
1954 function getOneDay () {
1955         // Do we have cache?
1956         if (!isset($GLOBALS[__FUNCTION__])) {
1957                 // Determine it
1958                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
1959         } // END - if
1960
1961         // Return cache
1962         return $GLOBALS[__FUNCTION__];
1963 }
1964
1965 // "Getter" for activate_xchange
1966 function getActivateXchange () {
1967         // Do we have cache?
1968         if (!isset($GLOBALS[__FUNCTION__])) {
1969                 // Determine it
1970                 $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
1971         } // END - if
1972
1973         // Return cache
1974         return $GLOBALS[__FUNCTION__];
1975 }
1976
1977 // "Getter" for img_type
1978 function getImgType () {
1979         // Do we have cache?
1980         if (!isset($GLOBALS[__FUNCTION__])) {
1981                 // Determine it
1982                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
1983         } // END - if
1984
1985         // Return cache
1986         return $GLOBALS[__FUNCTION__];
1987 }
1988
1989 // "Getter" for code_length
1990 function getCodeLength () {
1991         // Do we have cache?
1992         if (!isset($GLOBALS[__FUNCTION__])) {
1993                 // Determine it
1994                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
1995         } // END - if
1996
1997         // Return cache
1998         return $GLOBALS[__FUNCTION__];
1999 }
2000
2001 // "Getter" for least_cats
2002 function getLeastCats () {
2003         // Do we have cache?
2004         if (!isset($GLOBALS[__FUNCTION__])) {
2005                 // Determine it
2006                 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
2007         } // END - if
2008
2009         // Return cache
2010         return $GLOBALS[__FUNCTION__];
2011 }
2012
2013 // "Getter" for pass_len
2014 function getPassLen () {
2015         // Do we have cache?
2016         if (!isset($GLOBALS[__FUNCTION__])) {
2017                 // Determine it
2018                 $GLOBALS[__FUNCTION__] = getConfig('pass_len');
2019         } // END - if
2020
2021         // Return cache
2022         return $GLOBALS[__FUNCTION__];
2023 }
2024
2025 // "Getter" for admin_menu
2026 function getAdminMenu () {
2027         // Do we have cache?
2028         if (!isset($GLOBALS[__FUNCTION__])) {
2029                 // Determine it
2030                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2031         } // END - if
2032
2033         // Return cache
2034         return $GLOBALS[__FUNCTION__];
2035 }
2036
2037 // "Getter" for last_month
2038 function getLastMonth () {
2039         // Do we have cache?
2040         if (!isset($GLOBALS[__FUNCTION__])) {
2041                 // Determine it
2042                 $GLOBALS[__FUNCTION__] = getConfig('last_month');
2043         } // END - if
2044
2045         // Return cache
2046         return $GLOBALS[__FUNCTION__];
2047 }
2048
2049 // "Getter" for max_send
2050 function getMaxSend () {
2051         // Do we have cache?
2052         if (!isset($GLOBALS[__FUNCTION__])) {
2053                 // Determine it
2054                 $GLOBALS[__FUNCTION__] = getConfig('max_send');
2055         } // END - if
2056
2057         // Return cache
2058         return $GLOBALS[__FUNCTION__];
2059 }
2060
2061 // "Getter" for mails_page
2062 function getMailsPage () {
2063         // Do we have cache?
2064         if (!isset($GLOBALS[__FUNCTION__])) {
2065                 // Determine it
2066                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2067         } // END - if
2068
2069         // Return cache
2070         return $GLOBALS[__FUNCTION__];
2071 }
2072
2073 // "Getter" for __DB_NAME
2074 function getDbName () {
2075         // Do we have cache?
2076         if (!isset($GLOBALS[__FUNCTION__])) {
2077                 // Determine it
2078                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2079         } // END - if
2080
2081         // Return cache
2082         return $GLOBALS[__FUNCTION__];
2083 }
2084
2085 // Checks wether proxy configuration is used
2086 function isProxyUsed () {
2087         // Do we have cache?
2088         if (!isset($GLOBALS[__FUNCTION__])) {
2089                 // Determine it
2090                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
2091         } // END - if
2092
2093         // Return cache
2094         return $GLOBALS[__FUNCTION__];
2095 }
2096
2097 // Checks wether POST data contains selections
2098 function ifPostContainsSelections ($element = 'sel') {
2099         // Do we have cache?
2100         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2101                 // Determine it
2102                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
2103         } // END - if
2104
2105         // Return cache
2106         return $GLOBALS[__FUNCTION__][$element];
2107 }
2108
2109 // Checks wether verbose_sql is Y and returns true/false if so
2110 function isVerboseSqlEnabled () {
2111         // Do we have cache?
2112         if (!isset($GLOBALS[__FUNCTION__])) {
2113                 // Determine it
2114                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2115         } // END - if
2116
2117         // Return cache
2118         return $GLOBALS[__FUNCTION__];
2119 }
2120
2121 // "Getter" for total user points
2122 function getTotalPoints ($userid) {
2123         // Do we have cache?
2124         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2125                 // Determine it
2126                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points');
2127         } // END - if
2128
2129         // Return cache
2130         return $GLOBALS[__FUNCTION__][$userid];
2131 }
2132
2133 // Wrapper to check if url_blacklist is enabled
2134 function isUrlBlacklistEnabled () {
2135         // Do we have cache?
2136         if (!isset($GLOBALS[__FUNCTION__])) {
2137                 // Determine it
2138                 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
2139         } // END - if
2140
2141         // Return cache
2142         return $GLOBALS[__FUNCTION__];
2143 }
2144
2145 // Checks wether direct payment is allowed in configuration
2146 function isDirectPaymentEnabled () {
2147         // Do we have cache?
2148         if (!isset($GLOBALS[__FUNCTION__])) {
2149                 // Determine it
2150                 $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
2151         } // END - if
2152
2153         // Return cache
2154         return $GLOBALS[__FUNCTION__];
2155 }
2156
2157 // Wrapper to check if current task is for extension (not update)
2158 function isExtensionTask ($content) {
2159         // Do we have cache?
2160         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2161                 // Determine it
2162                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
2163         } // END - if
2164
2165         // Return cache
2166         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2167 }
2168
2169 // Wrapper to check if output mode is CSS
2170 function isCssOutputMode () {
2171         // Determine it
2172         return (getScriptOutputMode() == 1);
2173 }
2174
2175 // Wrapper to check if output mode is HTML
2176 function isHtmlOutputMode () {
2177         // Determine it
2178         return (getScriptOutputMode() == 0);
2179 }
2180
2181 // Wrapper to check if output mode is RAW
2182 function isRawOutputMode () {
2183         // Determine it
2184         return (getScriptOutputMode() == -1);
2185 }
2186
2187 // Wrapper to generate a user email link
2188 function generateWrappedUserEmailLink ($email) {
2189         // Just call the inner function
2190         return generateEmailLink($email, 'user_data');
2191 }
2192
2193 // Wrapper to check if user points are locked
2194 function ifUserPointsLocked ($userid) {
2195         // Do we have cache?
2196         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2197                 // Determine it
2198                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
2199         } // END - if
2200
2201         // Return cache
2202         return $GLOBALS[__FUNCTION__][$userid];
2203 }
2204
2205 // Appends a line to an existing file or creates it instantly with given content.
2206 // This function does always add a new-line character to every line.
2207 function appendLineToFile ($file, $line) {
2208         $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
2209         fwrite($fp, $line . "\n");
2210         fclose($fp);
2211 }
2212
2213 // Wrapper for changeDataInFile() but with full path added
2214 function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
2215         // Add full path
2216         $FQFN = getPath() . $FQFN;
2217
2218         // Call inner function
2219         changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
2220 }
2221
2222 // Shortens ucfirst(strtolower()) calls
2223 function firstCharUpperCase ($str) {
2224         return ucfirst(strtolower($str));
2225 }
2226
2227 // [EOF]
2228 ?>