2a64684ed44874018d4272f62782baee48a25d5e
[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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } // END - if
44
45 // Read a given file
46 function readFromFile ($FQFN) {
47         // Sanity-check if file is there (should be there, but just to make it sure)
48         if (!isFileReadable($FQFN)) {
49                 // This should not happen
50                 debug_report_bug(__FUNCTION__.': File ' . basename($FQFN) . ' is not readable!');
51         } // END - if
52
53         // Is it cached?
54         if (!isset($GLOBALS['file_content'][$FQFN])) {
55                 // Load the file
56                 if (function_exists('file_get_contents')) {
57                         // Use new function
58                         $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
59                 } else {
60                         // Fall-back to implode-file chain
61                         $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
62                 }
63         } // END - if
64
65         // Return the content
66         return $GLOBALS['file_content'][$FQFN];
67 }
68
69 // Writes content to a file
70 function writeToFile ($FQFN, $content, $aquireLock = false) {
71         // Is the file writeable?
72         if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
73                 // Not writeable!
74                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
75
76                 // Failed! :(
77                 return false;
78         } // END - if
79
80         // By default all is failed...
81         $return = false;
82
83         // Is the function there?
84         if (function_exists('file_put_contents')) {
85                 // With lock?
86                 if ($aquireLock === true) {
87                         // Write it directly with lock
88                         $return = file_put_contents($FQFN, $content, LOCK_EX);
89                 } else {
90                         // Write it directly
91                         $return = file_put_contents($FQFN, $content);
92                 }
93         } else {
94                 // Write it with fopen
95                 $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
96
97                 // Aquire lock
98                 if ($aquireLock === true) flock($fp, LOCK_EX);
99
100                 // Write content
101                 fwrite($fp, $content);
102
103                 // Close stream
104                 fclose($fp);
105         }
106
107         // Mark it as readable
108         $GLOBALS['file_readable'][$FQFN] = true;
109
110         // Remember content in cache
111         $GLOBALS['file_content'][$FQFN] = $content;
112
113         // Return status
114         return changeMode($FQFN, 0644);
115 }
116
117 // Clears the output buffer. This function does *NOT* backup sent content.
118 function clearOutputBuffer () {
119         // Trigger an error on failure
120         if ((ob_get_length() > 0) && (!ob_end_clean())) {
121                 // Failed!
122                 debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
123         } // END - if
124 }
125
126 // Encode strings
127 // @TODO Implement $compress
128 function encodeString ($str, $compress = true) {
129         $str = urlencode(base64_encode(compileUriCode($str)));
130         return $str;
131 }
132
133 // Decode strings encoded with encodeString()
134 // @TODO Implement $decompress
135 function decodeString ($str, $decompress = true) {
136         $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
137         return $str;
138 }
139
140 // Decode entities in a nicer way
141 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
142         // Decode the entities to UTF-8 now
143         $decodedString = html_entity_decode($str, $quote, 'UTF-8');
144
145         // Return decoded string
146         return $decodedString;
147 }
148
149 // Merges an array together but only if both are arrays
150 function merge_array ($array1, $array2) {
151         // Are both an array?
152         if ((!is_array($array1)) && (!is_array($array2))) {
153                 // Both are not arrays
154                 debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
155         } elseif (!is_array($array1)) {
156                 // Left one is not an array
157                 debug_report_bug(__FILE__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
158         } elseif (!is_array($array2)) {
159                 // Right one is not an array
160                 debug_report_bug(__FILE__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
161         }
162
163         // Merge all together
164         return array_merge($array1, $array2);
165 }
166
167 // Check if given FQFN is a readable file
168 function isFileReadable ($FQFN) {
169         // Do we have cache?
170         if (!isset($GLOBALS['file_readable'][$FQFN])) {
171                 // Check all...
172                 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
173
174                 // Debug message
175                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($FQFN) . ' - CHECK! (' . intval($GLOBALS['file_readable'][$FQFN]) . ')');
176         } else {
177                 // Cache used
178                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($FQFN) . ' - CACHE! (' . intval($GLOBALS['file_readable'][$FQFN]) . ')');
179         }
180
181         // Return result
182         return $GLOBALS['file_readable'][$FQFN];
183 }
184
185 // Checks wether the given FQFN is a directory and not ., .. or .svn
186 function isDirectory ($FQFN) {
187         // Do we have cache?
188         if (!isset($GLOBALS['is_directory'][$FQFN])) {
189                 // Generate baseName
190                 $baseName = basename($FQFN);
191
192                 // Check it
193                 $GLOBALS['is_directory'][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
194         } // END - if
195
196         // Return the result
197         return $GLOBALS['is_directory'][$FQFN];
198 }
199
200 // "Getter" for remote IP number
201 function detectRemoteAddr () {
202         // Get remote ip from environment
203         $remoteAddr = determineRealRemoteAddress();
204
205         // Is removeip installed?
206         if (isExtensionActive('removeip')) {
207                 // Then anonymize it
208                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
209         } // END - if
210
211         // Return it
212         return $remoteAddr;
213 }
214
215 // "Getter" for remote hostname
216 function detectRemoteHostname () {
217         // Get remote ip from environment
218         $remoteHost = getenv('REMOTE_HOST');
219
220         // Is removeip installed?
221         if (isExtensionActive('removeip')) {
222                 // Then anonymize it
223                 $remoteHost = getAnonymousRemoteHost($remoteHost);
224         } // END - if
225
226         // Return it
227         return $remoteHost;
228 }
229
230 // "Getter" for user agent
231 function detectUserAgent ($alwaysReal = false) {
232         // Get remote ip from environment
233         $userAgent = getenv('HTTP_USER_AGENT');
234
235         // Is removeip installed?
236         if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
237                 // Then anonymize it
238                 $userAgent = getAnonymousUserAgent($userAgent);
239         } // END - if
240
241         // Return it
242         return $userAgent;
243 }
244
245 // "Getter" for referer
246 function detectReferer () {
247         // Get remote ip from environment
248         $referer = getenv('HTTP_REFERER');
249
250         // Is removeip installed?
251         if (isExtensionActive('removeip')) {
252                 // Then anonymize it
253                 $referer = getAnonymousReferer($referer);
254         } // END - if
255
256         // Return it
257         return $referer;
258 }
259
260 // "Getter" for request URI
261 function detectRequestUri () {
262         // Return it
263         return (getenv('REQUEST_URI'));
264 }
265
266 // "Getter" for query string
267 function detectQueryString () {
268         return str_replace('&', '&amp;', (getenv('QUERY_STRING')));
269 }
270
271 // "Getter" for SERVER_NAME
272 function detectServerName () {
273         // Return it
274         return (getenv('SERVER_NAME'));
275 }
276
277 // Check wether we are installing
278 function isInstalling () {
279         // Determine wether we are installing
280         if (!isset($GLOBALS['mailer_installing'])) {
281                 // Check URL (css.php/js.php need this)
282                 $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
283         } // END - if
284
285         // Return result
286         return $GLOBALS['mailer_installing'];
287 }
288
289 // Check wether this script is installed
290 function isInstalled () {
291         // Do we have cache?
292         if (!isset($GLOBALS['is_installed'])) {
293                 // Determine wether this script is installed
294                 $GLOBALS['is_installed'] = (
295                 (
296                         // First is config
297                         (
298                                 (
299                                         isConfigEntrySet('MXCHANGE_INSTALLED')
300                                 ) && (
301                                         getConfig('MXCHANGE_INSTALLED') == 'Y'
302                                 )
303                         )
304                 ) || (
305                         // New config file found and loaded
306                         isIncludeReadable(getCachePath() . 'config-local.php')
307                 ) || (
308                         (
309                                 // New config file found, but not yet read
310                                 isIncludeReadable(getCachePath() . 'config-local.php')
311                         ) && (
312                                 (
313                                         // Only new config file is found
314                                         !isIncludeReadable('inc/config.php')
315                                 ) || (
316                                         // Is installation mode
317                                         !isInstalling()
318                                 )
319                         )
320                 ));
321         } // END - if
322
323         // Then use the cache
324         return $GLOBALS['is_installed'];
325 }
326
327 // Check wether an admin is registered
328 function isAdminRegistered () {
329         // Is cache set?
330         if (!isset($GLOBALS['is_admin_registered'])) {
331                 // Simply check it
332                 $GLOBALS['is_admin_registered'] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
333         } // END - if
334
335         // Return it
336         return $GLOBALS['is_admin_registered'];
337 }
338
339 // Checks wether the reset mode is active
340 function isResetModeEnabled () {
341         // Now simply check it
342         return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
343 }
344
345 // Checks wether the debug mode is enabled
346 function isDebugModeEnabled () {
347         // Is cache set?
348         if (!isset($GLOBALS['is_debugmode_enabled'])) {
349                 // Simply check it
350                 $GLOBALS['is_debugmode_enabled'] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
351         } // END - if
352
353         // Return it
354         return $GLOBALS['is_debugmode_enabled'];
355 }
356
357 // Checks wether SQL debugging is enabled
358 function isSqlDebuggingEnabled () {
359         // Is cache set?
360         if (!isset($GLOBALS['is_sql_debug_enabled'])) {
361                 // Determine if SQL debugging is enabled
362                 $GLOBALS['is_sql_debug_enabled'] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
363         } // END - if
364
365         // Return it
366         return $GLOBALS['is_sql_debug_enabled'];
367 }
368
369 // Checks wether we shall debug regular expressions
370 function isDebugRegularExpressionEnabled () {
371         // Is cache set?
372         if (!isset($GLOBALS['is_regular_exp_debug_enabled'])) {
373                 // Simply check it
374                 $GLOBALS['is_regular_exp_debug_enabled'] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
375         } // END - if
376
377         // Return it
378         return $GLOBALS['is_regular_exp_debug_enabled'];
379 }
380
381 // Checks wether the cache instance is valid
382 function isCacheInstanceValid () {
383         return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
384 }
385
386 // Copies a file from source to destination and verifies if that goes fine.
387 // This function should wrap the copy() command and make a nicer debug backtrace
388 // even if there is no xdebug extension installed.
389 function copyFileVerified ($source, $dest, $chmod = '') {
390         // Failed is the default
391         $status = false;
392
393         // Is the source file there?
394         if (!isFileReadable($source)) {
395                 // Then abort here
396                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
397         } // END - if
398
399         // Is the target directory there?
400         if (!isDirectory(dirname($dest))) {
401                 // Then abort here
402                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
403         } // END - if
404
405         // Now try to copy it
406         if (!copy($source, $dest)) {
407                 // Something went wrong
408                 debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
409         } else {
410                 // Reset cache
411                 $GLOBALS['file_readable'][$dest] = true;
412         }
413
414         // If there are chmod rights set, apply them
415         if (!empty($chmod)) {
416                 // Try to apply them
417                 $status = changeMode($dest, $chmod);
418         } else {
419                 // All fine
420                 $status = true;
421         }
422
423         // All fine
424         return $status;
425 }
426
427 // Wrapper function for header()
428 // Send a header but checks before if we can do so
429 function sendHeader ($header) {
430         // Send the header
431         //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
432         $GLOBALS['header'][] = trim($header);
433 }
434
435 // Flushes all headers
436 function flushHeaders () {
437         // Is the header already sent?
438         if (headers_sent()) {
439                 // Then abort here
440                 debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
441         } // END - if
442
443         // Flush all headers if found
444         if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
445                 foreach ($GLOBALS['header'] as $header) {
446                         header($header);
447                 } // END - foreach
448         } // END - if
449
450         // Mark them as flushed
451         $GLOBALS['header'] = array();
452 }
453
454 // Wrapper function for chmod()
455 // @TODO Do some more sanity check here
456 function changeMode ($FQFN, $mode) {
457         // Is the file/directory there?
458         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
459                 // Neither, so abort here
460                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
461         } // END - if
462
463         // Try to set them
464         chmod($FQFN, $mode);
465 }
466
467 // Wrapper for unlink()
468 function removeFile ($FQFN) {
469         // Is the file there?
470         if (isFileReadable($FQFN)) {
471                 // Reset cache first
472                 $GLOBALS['file_readable'][$FQFN] = false;
473
474                 // Yes, so remove it
475                 return unlink($FQFN);
476         } // END - if
477
478         // All fine if no file was removed. If we change this to 'false' or rewrite
479         // above if() block it would be to restrictive.
480         return true;
481 }
482
483 // Wrapper for $_POST['sel']
484 function countPostSelection ($element = 'sel') {
485         // Is it set?
486         if (isPostRequestParameterSet($element)) {
487                 // Return counted elements
488                 return countSelection(postRequestParameter($element));
489         } else {
490                 // Return zero if not found
491                 return 0;
492         }
493 }
494
495 // Checks wether the config-local.php is loaded
496 function isConfigLocalLoaded () {
497         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
498 }
499
500 // Checks wether a nickname or userid was entered and caches the result
501 function isNicknameUsed ($userid) {
502         // Default is false
503         $isUsed = false;
504
505         // Is the cache there
506         if (isset($GLOBALS['is_nickname_used'][$userid])) {
507                 // Then use it
508                 $isUsed = $GLOBALS['is_nickname_used'][$userid];
509         } else {
510                 // Determine it
511                 $isUsed = (('' . round($userid) . '') != $userid);
512
513                 // And write it to the cache
514                 $GLOBALS['is_nickname_used'][$userid] = $isUsed;
515         }
516
517         // Return the result
518         return $isUsed;
519 }
520
521 // Getter for 'what' value
522 function getWhat () {
523         // Default is null
524         $what = null;
525
526         // Is the value set?
527         if (isWhatSet(true)) {
528                 // Then use it
529                 $what = $GLOBALS['what'];
530         } // END - if
531
532         // Return it
533         return $what;
534 }
535
536 // Setter for 'what' value
537 function setWhat ($newWhat) {
538         $GLOBALS['what'] = SQL_ESCAPE($newWhat);
539 }
540
541 // Setter for 'what' from configuration
542 function setWhatFromConfig ($configEntry) {
543         // Get 'what' from config
544         $what = getConfig($configEntry);
545
546         // Set it
547         setWhat($what);
548 }
549
550 // Checks wether what is set and optionally aborts on miss
551 function isWhatSet ($strict =  false) {
552         // Check for it
553         $isset = isset($GLOBALS['what']);
554
555         // Should we abort here?
556         if (($strict === true) && ($isset === false)) {
557                 // Output backtrace
558                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
559         } // END - if
560
561         // Return it
562         return $isset;
563 }
564
565 // Getter for 'action' value
566 function getAction ($strict = true) {
567         // Default is null
568         $action = null;
569
570         // Is the value set?
571         if (isActionSet(($strict) && (getOutputMode() == 0))) {
572                 // Then use it
573                 $action = $GLOBALS['action'];
574         } // END - if
575
576         // Return it
577         return $action;
578 }
579
580 // Setter for 'action' value
581 function setAction ($newAction) {
582         $GLOBALS['action'] = SQL_ESCAPE($newAction);
583 }
584
585 // Checks wether action is set and optionally aborts on miss
586 function isActionSet ($strict =  false) {
587         // Check for it
588         $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
589
590         // Should we abort here?
591         if (($strict === true) && ($isset === false)) {
592                 // Output backtrace
593                 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
594         } // END - if
595
596         // Return it
597         return $isset;
598 }
599
600 // Getter for 'module' value
601 function getModule ($strict = true) {
602         // Default is null
603         $module = null;
604
605         // Is the value set?
606         if (isModuleSet($strict)) {
607                 // Then use it
608                 $module = $GLOBALS['module'];
609         } // END - if
610
611         // Return it
612         return $module;
613 }
614
615 // Setter for 'module' value
616 function setModule ($newModule) {
617         // Secure it and make all modules lower-case
618         $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
619 }
620
621 // Checks wether module is set and optionally aborts on miss
622 function isModuleSet ($strict =  false) {
623         // Check for it
624         $isset = (!empty($GLOBALS['module']));
625
626         // Should we abort here?
627         if (($strict === true) && ($isset === false)) {
628                 // Output backtrace
629                 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
630         } // END - if
631
632         // Return it
633         return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
634 }
635
636 // Getter for 'output_mode' value
637 function getOutputMode () {
638         // Default is null
639         $output_mode = null;
640
641         // Is the value set?
642         if (isOutputModeSet(true)) {
643                 // Then use it
644                 $output_mode = $GLOBALS['output_mode'];
645         } // END - if
646
647         // Return it
648         return $output_mode;
649 }
650
651 // Setter for 'output_mode' value
652 function setOutputMode ($newOutputMode) {
653         $GLOBALS['output_mode'] = (int) $newOutputMode;
654 }
655
656 // Checks wether output_mode is set and optionally aborts on miss
657 function isOutputModeSet ($strict =  false) {
658         // Check for it
659         $isset = (isset($GLOBALS['output_mode']));
660
661         // Should we abort here?
662         if (($strict === true) && ($isset === false)) {
663                 // Output backtrace
664                 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
665         } // END - if
666
667         // Return it
668         return $isset;
669 }
670
671 // Enables block-mode
672 function enableBlockMode ($enabled = true) {
673         $GLOBALS['block_mode'] = $enabled;
674 }
675
676 // Checks wether block-mode is enabled
677 function isBlockModeEnabled () {
678         // Abort if not set
679         if (!isset($GLOBALS['block_mode'])) {
680                 // Needs to be fixed
681                 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
682         } // END - if
683
684         // Return it
685         return $GLOBALS['block_mode'];
686 }
687
688 // Wrapper function for addPointsThroughReferalSystem()
689 function addPointsDirectly ($subject, $userid, $points) {
690         // Reset level here
691         unset($GLOBALS['ref_level']);
692
693         // Call more complicated method (due to more parameters)
694         return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, false, 'direct');
695 }
696
697 // Wrapper for redirectToUrl but URL comes from a configuration entry
698 function redirectToConfiguredUrl ($configEntry) {
699         // Load the URL
700         redirectToUrl(getConfig($configEntry));
701 }
702
703 // Wrapper function to redirect from member-only modules to index
704 function redirectToIndexMemberOnlyModule () {
705         // Do the redirect here
706         redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
707 }
708
709 // Wrapper function to redirect to current URL
710 function redirectToRequestUri () {
711         redirectToUrl(basename(detectRequestUri()));
712 }
713
714 // Wrapper function to redirect to de-refered URL
715 function redirectToDereferedUrl ($URL) {
716         // Redirect to to
717         redirectToUrl(generateDerefererUrl($URL));
718 }
719
720 // Wrapper function for checking if extension is installed and newer or same version
721 function isExtensionInstalledAndNewer ($ext_name, $version) {
722         // Is an cache entry found?
723         if (!isset($GLOBALS['ext_installed_newer'][$ext_name][$version])) {
724                 $GLOBALS['ext_installed_newer'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
725         } else {
726                 // Cache hits should be incremented twice
727                 incrementStatsEntry('cache_hits', 2);
728         }
729
730         // Return it
731         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]));
732         return $GLOBALS['ext_installed_newer'][$ext_name][$version];
733 }
734
735 // Wrapper function for checking if extension is installed and older than given version
736 function isExtensionInstalledAndOlder ($ext_name, $version) {
737         // Is an cache entry found?
738         if (!isset($GLOBALS['ext_installed_older'][$ext_name][$version])) {
739                 $GLOBALS['ext_installed_older'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
740         } else {
741                 // Cache hits should be incremented twice
742                 incrementStatsEntry('cache_hits', 2);
743         }
744
745         // Return it
746         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]));
747         return $GLOBALS['ext_installed_older'][$ext_name][$version];
748 }
749
750 // Set username
751 function setUsername ($userName) {
752         $GLOBALS['username'] = (string) $userName;
753 }
754
755 // Get username
756 function getUsername () {
757         // User name set?
758         if (!isset($GLOBALS['username'])) {
759                 // No, so it has to be a guest
760                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
761         } // END - if
762
763         // Return it
764         return $GLOBALS['username'];
765 }
766
767 // Wrapper function for installation phase
768 function isInstallationPhase () {
769         // Do we have cache?
770         if (!isset($GLOBALS['installation_phase'])) {
771                 // Determine it
772                 $GLOBALS['installation_phase'] = ((!isInstalled()) || (isInstalling()));
773         } // END - if
774
775         // Return result
776         return $GLOBALS['installation_phase'];
777 }
778
779 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
780 function isDemoModeActive () {
781         // Is cache set?
782         if (!isset($GLOBALS['demo_mode_active'])) {
783                 // Simply check it
784                 $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
785         } // END - if
786
787         // Return it
788         return $GLOBALS['demo_mode_active'];
789 }
790
791 // Getter for PHP caching value
792 function getPhpCaching () {
793         return $GLOBALS['php_caching'];
794 }
795
796 // Checks wether the admin hash is set
797 function isAdminHashSet ($adminId) {
798         // Is the array there?
799         if (!isset($GLOBALS['cache_array']['admin'])) {
800                 // Missing array should be reported
801                 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
802         } // END - if
803
804         // Check for admin hash
805         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
806 }
807
808 // Setter for admin hash
809 function setAdminHash ($adminId, $hash) {
810         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
811 }
812
813 // Init user data array
814 function initUserData () {
815         // User id should not be zero
816         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
817
818         // Init the user
819         $GLOBALS['user_data'][getCurrentUserId()] = array();
820 }
821
822 // Getter for user data
823 function getUserData ($column) {
824         // User id should not be zero
825         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
826
827         // Return the value
828         return $GLOBALS['user_data'][getCurrentUserId()][$column];
829 }
830
831 // Geter for whole user data array
832 function getUserDataArray () {
833         // Get user id
834         $uid = getCurrentUserId();
835
836         // User id should not be zero
837         if ($uid < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
838
839         // Get the whole array if found
840         if (isset($GLOBALS['user_data'][$uid])) {
841                 // Found, so return it
842                 return $GLOBALS['user_data'][$uid];
843         } else {
844                 // Return empty array
845                 return array();
846         }
847 }
848
849 // Checks if the user data is valid, this may indicate that the user has logged
850 // in, but you should use isMember() if you want to find that out.
851 function isUserDataValid () {
852         // User id should not be zero so abort here
853         if (!isCurrentUserIdSet()) return false;
854
855         // Is it cached?
856         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
857                 // Determine it
858                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
859         } // END - if
860
861         // Return the result
862         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
863 }
864
865 // Setter for current userid
866 function setCurrentUserId ($userid) {
867         // Set userid
868         $GLOBALS['current_userid'] = bigintval($userid);
869
870         // Unset it to re-determine the actual state
871         unset($GLOBALS['is_userdata_valid'][$userid]);
872 }
873
874 // Getter for current userid
875 function getCurrentUserId () {
876         // Userid must be set before it can be used
877         if (!isCurrentUserIdSet()) {
878                 // Not set
879                 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
880         } // END - if
881
882         // Return the userid
883         return $GLOBALS['current_userid'];
884 }
885
886 // Checks if current userid is set
887 function isCurrentUserIdSet () {
888         return ((isset($GLOBALS['current_userid'])) && ($GLOBALS['current_userid'] > 0));
889 }
890
891 // Checks wether we are debugging template cache
892 function isDebuggingTemplateCache () {
893         // Do we have cache?
894         if (!isset($GLOBALS['debug_template_cache'])) {
895                 // Determine it
896                 $GLOBALS['debug_template_cache'] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
897         } // END - if
898
899         // Return cache
900         return $GLOBALS['debug_template_cache'];
901 }
902
903 // Wrapper for fetchUserData() and getUserData() calls
904 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
905         // Is it cached?
906         if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
907                 // Default is 'guest'
908                 $data = '{--USERNAME_GUEST--}';
909
910                 // Can we fetch the user data?
911                 if (($userid > 0) && (fetchUserData($userid, $keyColumn))) {
912                         // Now get the data back
913                         $data = getUserData($valueColumn);
914                 } // END - if
915
916                 // Cache it
917                 $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data;
918         } // END - if
919
920         // Return it
921         return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn];
922 }
923
924 // Wrapper for strpos() to ease porting from deprecated ereg() function
925 function isInString ($needle, $haystack) {
926         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
927         return (strpos($haystack, $needle) !== false);
928 }
929
930 // Wrapper for strpos() to ease porting from deprecated eregi() function
931 // This function is case-insensitive
932 function isInStringIgnoreCase ($needle, $haystack) {
933         return (isInString(strtolower($needle), strtolower($haystack)));
934 }
935
936 // Wrapper to check for if fatal errors where detected
937 function ifFatalErrorsDetected () {
938         // Just call the inner function
939         return (getTotalFatalErrors() > 0);
940 }
941
942 // Setter for HTTP status
943 function setHttpStatus ($status) {
944         $GLOBALS['http_status'] = (string) $status;
945 }
946
947 // Getter for HTTP status
948 function getHttpStatus () {
949         return $GLOBALS['http_status'];
950 }
951
952 /**
953  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
954  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
955  *
956  * ----------------------------------------------------------------------------
957  * If you want to redirect, please use redirectToUrl(); instead
958  * ----------------------------------------------------------------------------
959  *
960  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
961  *
962  * @link    http://support.microsoft.com/kb/q176113/
963  * @author  Andreas Gohr <andi@splitbrain.org>
964  * @access  private
965  */
966 function sendRawRedirect ($url) {
967         // always close the session
968         session_write_close();
969
970         // Revert entity &amp;
971         $url = str_replace('&amp;', '&', $url);
972
973         // check if running on IIS < 6 with CGI-PHP
974         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
975                 (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) &&
976                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
977                 ($matches[1] < 6)) {
978                 // Send the IIS header
979                 sendHeader('Refresh: 0;url=' . $url);
980         } else {
981                 // Send generic header
982                 sendHeader('Location: ' . $url);
983         }
984
985         // Shutdown here
986         shutdown();
987 }
988
989 // Determines the country of the given user id
990 function determineCountry ($userid) {
991         // Default is 'invalid'
992         $country = 'invalid';
993
994         // Is extension country active?
995         if (isExtensionActive('country')) {
996                 // Determine the right country code through the country id
997                 $id = getUserData('country_code');
998
999                 // Then handle it over
1000                 $country = generateCountryInfo($id);
1001         } else {
1002                 // Get raw code from user data
1003                 $country = getUserData('country');
1004         }
1005
1006         // Return it
1007         return $country;
1008 }
1009
1010 // "Getter" for total confirmed user accounts
1011 function getTotalConfirmedUser () {
1012         // Is it cached?
1013         if (!isset($GLOBALS['total_confirmed_users'])) {
1014                 // Then do it
1015                 $GLOBALS['total_confirmed_users'] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1016         } // END - if
1017
1018         // Return cached value
1019         return $GLOBALS['total_confirmed_users'];
1020 }
1021
1022 // Is given userid valid?
1023 function isValidUserId ($userid) {
1024         // Do we have cache?
1025         if (!isset($GLOBALS['is_valid_userid'][$userid])) {
1026                 // Check it out
1027                 $GLOBALS['is_valid_userid'][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1028         } // END - if
1029
1030         // Return cache
1031         return $GLOBALS['is_valid_userid'][$userid];
1032 }
1033
1034 // Encodes entities
1035 function encodeEntities ($str) {
1036         // Secure it first
1037         $str = secureString($str);
1038
1039         // Encode dollar sign as well
1040         $str = str_replace('$', '&#36;', $str);
1041
1042         // Return it
1043         return $str;
1044 }
1045
1046 // "Getter" for date from patch_ctime
1047 function getDateFromPatchTime () {
1048         // Is it cached?
1049         if (!isset($GLOBALS[__FUNCTION__])) {
1050                 // Then set it
1051                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1052         } // END - if
1053
1054         // Return cache
1055         return $GLOBALS[__FUNCTION__];
1056 }
1057
1058 // Getter for current year (default)
1059 function getYear ($timestamp = null) {
1060         // Is it cached?
1061         if (!isset($GLOBALS['year'][$timestamp])) {
1062                 // null is time()
1063                 if (is_null($timestamp)) $timestamp = time();
1064
1065                 // Then create it
1066                 $GLOBALS['year'][$timestamp] = date('Y', $timestamp);
1067         } // END - if
1068
1069         // Return cache
1070         return $GLOBALS['year'][$timestamp];
1071 }
1072
1073 // Getter for current month (default)
1074 function getMonth ($timestamp = null) {
1075         // Is it cached?
1076         if (!isset($GLOBALS['month'][$timestamp])) {
1077                 // null is time()
1078                 if (is_null($timestamp)) $timestamp = time();
1079
1080                 // Then create it
1081                 $GLOBALS['month'][$timestamp] = date('m', $timestamp);
1082         } // END - if
1083
1084         // Return cache
1085         return $GLOBALS['month'][$timestamp];
1086 }
1087
1088 // Getter for current day (default)
1089 function getDay ($timestamp = null) {
1090         // Is it cached?
1091         if (!isset($GLOBALS['day'][$timestamp])) {
1092                 // null is time()
1093                 if (is_null($timestamp)) $timestamp = time();
1094
1095                 // Then create it
1096                 $GLOBALS['day'][$timestamp] = date('d', $timestamp);
1097         } // END - if
1098
1099         // Return cache
1100         return $GLOBALS['day'][$timestamp];
1101 }
1102
1103 // Getter for current week (default)
1104 function getWeek ($timestamp = null) {
1105         // Is it cached?
1106         if (!isset($GLOBALS['week'][$timestamp])) {
1107                 // null is time()
1108                 if (is_null($timestamp)) $timestamp = time();
1109
1110                 // Then create it
1111                 $GLOBALS['week'][$timestamp] = date('W', $timestamp);
1112         } // END - if
1113
1114         // Return cache
1115         return $GLOBALS['week'][$timestamp];
1116 }
1117
1118 // Getter for current short_hour (default)
1119 function getShortHour ($timestamp = null) {
1120         // Is it cached?
1121         if (!isset($GLOBALS['short_hour'][$timestamp])) {
1122                 // null is time()
1123                 if (is_null($timestamp)) $timestamp = time();
1124
1125                 // Then create it
1126                 $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp);
1127         } // END - if
1128
1129         // Return cache
1130         return $GLOBALS['short_hour'][$timestamp];
1131 }
1132
1133 // Getter for current long_hour (default)
1134 function getLongHour ($timestamp = null) {
1135         // Is it cached?
1136         if (!isset($GLOBALS['long_hour'][$timestamp])) {
1137                 // null is time()
1138                 if (is_null($timestamp)) $timestamp = time();
1139
1140                 // Then create it
1141                 $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp);
1142         } // END - if
1143
1144         // Return cache
1145         return $GLOBALS['long_hour'][$timestamp];
1146 }
1147
1148 // Getter for current second (default)
1149 function getSecond ($timestamp = null) {
1150         // Is it cached?
1151         if (!isset($GLOBALS['second'][$timestamp])) {
1152                 // null is time()
1153                 if (is_null($timestamp)) $timestamp = time();
1154
1155                 // Then create it
1156                 $GLOBALS['second'][$timestamp] = date('s', $timestamp);
1157         } // END - if
1158
1159         // Return cache
1160         return $GLOBALS['second'][$timestamp];
1161 }
1162
1163 // Getter for current minute (default)
1164 function getMinute ($timestamp = null) {
1165         // Is it cached?
1166         if (!isset($GLOBALS['minute'][$timestamp])) {
1167                 // null is time()
1168                 if (is_null($timestamp)) $timestamp = time();
1169
1170                 // Then create it
1171                 $GLOBALS['minute'][$timestamp] = date('i', $timestamp);
1172         } // END - if
1173
1174         // Return cache
1175         return $GLOBALS['minute'][$timestamp];
1176 }
1177
1178 // Checks wether the title decoration is enabled
1179 function isTitleDecorationEnabled () {
1180         // Do we have cache?
1181         if (!isset($GLOBALS['title_deco_enabled'])) {
1182                 // Just check it
1183                 $GLOBALS['title_deco_enabled'] = (getConfig('enable_title_deco') == 'Y');
1184         } // END - if
1185
1186         // Return cache
1187         return $GLOBALS['title_deco_enabled'];
1188 }
1189
1190 // Checks wether filter usage updates are enabled (expensive queries!)
1191 function isFilterUsageUpdateEnabled () {
1192         // Do we have cache?
1193         if (!isset($GLOBALS['filter_usage_updates'])) {
1194                 // Determine it
1195                 $GLOBALS['filter_usage_updates'] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1196         } // END - if
1197
1198         // Return cache
1199         return $GLOBALS['filter_usage_updates'];
1200 }
1201
1202 // Checks wether debugging of weekly resets is enabled
1203 function isWeeklyResetDebugEnabled () {
1204         // Do we have cache?
1205         if (!isset($GLOBALS['weekly_reset_debug'])) {
1206                 // Determine it
1207                 $GLOBALS['weekly_reset_debug'] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1208         } // END - if
1209
1210         // Return cache
1211         return $GLOBALS['weekly_reset_debug'];
1212 }
1213
1214 // Checks wether debugging of monthly resets is enabled
1215 function isMonthlyResetDebugEnabled () {
1216         // Do we have cache?
1217         if (!isset($GLOBALS['monthly_reset_debug'])) {
1218                 // Determine it
1219                 $GLOBALS['monthly_reset_debug'] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1220         } // END - if
1221
1222         // Return cache
1223         return $GLOBALS['monthly_reset_debug'];
1224 }
1225
1226 // Checks wether displaying of debug SQLs are enabled
1227 function isDisplayDebugSqlEnabled () {
1228         // Do we have cache?
1229         if (!isset($GLOBALS['display_debug_sql'])) {
1230                 // Determine it
1231                 $GLOBALS['display_debug_sql'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1232         } // END - if
1233
1234         // Return cache
1235         return $GLOBALS['display_debug_sql'];
1236 }
1237
1238 // Checks wether module title is enabled
1239 function isModuleTitleEnabled () {
1240         // Do we have cache?
1241         if (!isset($GLOBALS['mod_title_enabled'])) {
1242                 // Determine it
1243                 $GLOBALS['mod_title_enabled'] = (getConfig('enable_mod_title') == 'Y');
1244         } // END - if
1245
1246         // Return cache
1247         return $GLOBALS['mod_title_enabled'];
1248 }
1249
1250 // Checks wether what title is enabled
1251 function isWhatTitleEnabled () {
1252         // Do we have cache?
1253         if (!isset($GLOBALS['mod_title_enabled'])) {
1254                 // Determine it
1255                 $GLOBALS['mod_title_enabled'] = (getConfig('enable_what_title') == 'Y');
1256         } // END - if
1257
1258         // Return cache
1259         return $GLOBALS['mod_title_enabled'];
1260 }
1261
1262 // Checks wether stats are enabled
1263 function ifStatsAreEnabled () {
1264         // Do we have cache?
1265         if (!isset($GLOBALS['stats_enabled'])) {
1266                 // Then determine it
1267                 $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y');
1268         } // END - if
1269
1270         // Return cached value
1271         return $GLOBALS['stats_enabled'];
1272 }
1273
1274 // Checks wether admin-notification of certain user actions is enabled
1275 function isAdminNotificationEnabled () {
1276         // Do we have cache?
1277         if (!isset($GLOBALS['admin_notification_enabled'])) {
1278                 // Determine it
1279                 $GLOBALS['admin_notification_enabled'] = (getConfig('admin_notify') == 'Y');
1280         } // END - if
1281
1282         // Return cache
1283         return $GLOBALS['admin_notification_enabled'];
1284 }
1285
1286 // Checks wether random referal id selection is enabled
1287 function isRandomReferalIdEnabled () {
1288         // Do we have cache?
1289         if (!isset($GLOBALS['select_user_zero_refid'])) {
1290                 // Determine it
1291                 $GLOBALS['select_user_zero_refid'] = (getConfig('select_user_zero_refid') == 'Y');
1292         } // END - if
1293
1294         // Return cache
1295         return $GLOBALS['select_user_zero_refid'];
1296 }
1297
1298 // "Getter" for default language
1299 function getDefaultLanguage () {
1300         // Do we have cache?
1301         if (!isset($GLOBALS['default_language'])) {
1302                 // Determine it
1303                 $GLOBALS['default_language'] = getConfig('DEFAULT_LANG');
1304         } // END - if
1305
1306         // Return cache
1307         return $GLOBALS['default_language'];
1308 }
1309
1310 // "Getter" for path
1311 function getPath () {
1312         // Do we have cache?
1313         if (!isset($GLOBALS['path'])) {
1314                 // Determine it
1315                 $GLOBALS['path'] = getConfig('PATH');
1316         } // END - if
1317
1318         // Return cache
1319         return $GLOBALS['path'];
1320 }
1321
1322 // "Getter" for url
1323 function getUrl () {
1324         // Do we have cache?
1325         if (!isset($GLOBALS['url'])) {
1326                 // Determine it
1327                 $GLOBALS['url'] = getConfig('URL');
1328         } // END - if
1329
1330         // Return cache
1331         return $GLOBALS['url'];
1332 }
1333
1334 // "Getter" for cache_path
1335 function getCachePath () {
1336         // Do we have cache?
1337         if (!isset($GLOBALS['cache_path'])) {
1338                 // Determine it
1339                 $GLOBALS['cache_path'] = getConfig('CACHE_PATH');
1340         } // END - if
1341
1342         // Return cache
1343         return $GLOBALS['cache_path'];
1344 }
1345
1346 // "Getter" for secret_key
1347 function getSecretKey () {
1348         // Do we have cache?
1349         if (!isset($GLOBALS['secret_key'])) {
1350                 // Determine it
1351                 $GLOBALS['secret_key'] = getConfig('secret_key');
1352         } // END - if
1353
1354         // Return cache
1355         return $GLOBALS['secret_key'];
1356 }
1357
1358 // "Getter" for master_salt
1359 function getMasterSalt () {
1360         // Do we have cache?
1361         if (!isset($GLOBALS['master_salt'])) {
1362                 // Determine it
1363                 $GLOBALS['master_salt'] = getConfig('master_salt');
1364         } // END - if
1365
1366         // Return cache
1367         return $GLOBALS['master_salt'];
1368 }
1369
1370 // "Getter" for prime
1371 function getPrime () {
1372         // Do we have cache?
1373         if (!isset($GLOBALS['prime'])) {
1374                 // Determine it
1375                 $GLOBALS['prime'] = getConfig('_PRIME');
1376         } // END - if
1377
1378         // Return cache
1379         return $GLOBALS['prime'];
1380 }
1381
1382 // "Getter" for encrypt_seperator
1383 function getEncryptSeperator () {
1384         // Do we have cache?
1385         if (!isset($GLOBALS['encrypt_seperator'])) {
1386                 // Determine it
1387                 $GLOBALS['encrypt_seperator'] = getConfig('ENCRYPT_SEPERATOR');
1388         } // END - if
1389
1390         // Return cache
1391         return $GLOBALS['encrypt_seperator'];
1392 }
1393
1394 // "Getter" for mysql_prefix
1395 function getMysqlPrefix () {
1396         // Do we have cache?
1397         if (!isset($GLOBALS['mysql_prefix'])) {
1398                 // Determine it
1399                 $GLOBALS['mysql_prefix'] = getConfig('_MYSQL_PREFIX');
1400         } // END - if
1401
1402         // Return cache
1403         return $GLOBALS['mysql_prefix'];
1404 }
1405
1406 // "Getter" for salt_length
1407 function getSaltLength () {
1408         // Do we have cache?
1409         if (!isset($GLOBALS['salt_length'])) {
1410                 // Determine it
1411                 $GLOBALS['salt_length'] = getConfig('salt_length');
1412         } // END - if
1413
1414         // Return cache
1415         return $GLOBALS['salt_length'];
1416 }
1417
1418 // "Getter" for output_mode
1419 function getCachedOutputMode () {
1420         // Do we have cache?
1421         if (!isset($GLOBALS['cached_output_mode'])) {
1422                 // Determine it
1423                 $GLOBALS['cached_output_mode'] = getConfig('OUTPUT_MODE');
1424         } // END - if
1425
1426         // Return cache
1427         return $GLOBALS['cached_output_mode'];
1428 }
1429
1430 // "Getter" for full_version
1431 function getFullVersion () {
1432         // Do we have cache?
1433         if (!isset($GLOBALS['full_version'])) {
1434                 // Determine it
1435                 $GLOBALS['full_version'] = getConfig('FULL_VERSION');
1436         } // END - if
1437
1438         // Return cache
1439         return $GLOBALS['full_version'];
1440 }
1441
1442 // "Getter" for title
1443 function getTitle () {
1444         // Do we have cache?
1445         if (!isset($GLOBALS['title'])) {
1446                 // Determine it
1447                 $GLOBALS['title'] = getConfig('TITLE');
1448         } // END - if
1449
1450         // Return cache
1451         return $GLOBALS['title'];
1452 }
1453
1454 // "Getter" for curr_svn_revision
1455 function getCurrSvnRevision () {
1456         // Do we have cache?
1457         if (!isset($GLOBALS['curr_svn_revision'])) {
1458                 // Determine it
1459                 $GLOBALS['curr_svn_revision'] = getConfig('CURR_SVN_REVISION');
1460         } // END - if
1461
1462         // Return cache
1463         return $GLOBALS['curr_svn_revision'];
1464 }
1465
1466 // "Getter" for server_url
1467 function getServerUrl () {
1468         // Do we have cache?
1469         if (!isset($GLOBALS['server_url'])) {
1470                 // Determine it
1471                 $GLOBALS['server_url'] = getConfig('SERVER_URL');
1472         } // END - if
1473
1474         // Return cache
1475         return $GLOBALS['server_url'];
1476 }
1477
1478 // "Getter" for mt_word
1479 function getMtWord () {
1480         // Do we have cache?
1481         if (!isset($GLOBALS['mt_word'])) {
1482                 // Determine it
1483                 $GLOBALS['mt_word'] = getConfig('mt_word');
1484         } // END - if
1485
1486         // Return cache
1487         return $GLOBALS['mt_word'];
1488 }
1489
1490 // "Getter" for main_title
1491 function getMainTitle () {
1492         // Do we have cache?
1493         if (!isset($GLOBALS['main_title'])) {
1494                 // Determine it
1495                 $GLOBALS['main_title'] = getConfig('MAIN_TITLE');
1496         } // END - if
1497
1498         // Return cache
1499         return $GLOBALS['main_title'];
1500 }
1501
1502 // "Getter" for file_hash
1503 function getFileHash () {
1504         // Do we have cache?
1505         if (!isset($GLOBALS['file_hash'])) {
1506                 // Determine it
1507                 $GLOBALS['file_hash'] = getConfig('file_hash');
1508         } // END - if
1509
1510         // Return cache
1511         return $GLOBALS['file_hash'];
1512 }
1513
1514 // "Getter" for pass_scramble
1515 function getPassScramble () {
1516         // Do we have cache?
1517         if (!isset($GLOBALS['pass_scramble'])) {
1518                 // Determine it
1519                 $GLOBALS['pass_scramble'] = getConfig('pass_scramble');
1520         } // END - if
1521
1522         // Return cache
1523         return $GLOBALS['pass_scramble'];
1524 }
1525
1526 // "Getter" for ap_inactive_since
1527 function getApInactiveSince () {
1528         // Do we have cache?
1529         if (!isset($GLOBALS['ap_inactive_since'])) {
1530                 // Determine it
1531                 $GLOBALS['ap_inactive_since'] = getConfig('ap_inactive_since');
1532         } // END - if
1533
1534         // Return cache
1535         return $GLOBALS['ap_inactive_since'];
1536 }
1537
1538 // [EOF]
1539 ?>