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