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