bc89dfc63f560e1c950c87ad75646ade19ef57ad
[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__, __LINE__, '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__, __LINE__, '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         // Is the cache there
503         if (!isset($GLOBALS['is_nickname_used'][$userid])) {
504                 // Determine it
505                 $GLOBALS['is_nickname_used'][$userid] = (('' . round($userid) . '') != $userid);
506         } // END - if
507
508         // Return the result
509         return $GLOBALS['is_nickname_used'][$userid];
510 }
511
512 // Getter for 'what' value
513 function getWhat () {
514         // Default is null
515         $what = null;
516
517         // Is the value set?
518         if (isWhatSet(true)) {
519                 // Then use it
520                 $what = $GLOBALS['what'];
521         } // END - if
522
523         // Return it
524         return $what;
525 }
526
527 // Setter for 'what' value
528 function setWhat ($newWhat) {
529         $GLOBALS['what'] = SQL_ESCAPE($newWhat);
530 }
531
532 // Setter for 'what' from configuration
533 function setWhatFromConfig ($configEntry) {
534         // Get 'what' from config
535         $what = getConfig($configEntry);
536
537         // Set it
538         setWhat($what);
539 }
540
541 // Checks wether what is set and optionally aborts on miss
542 function isWhatSet ($strict =  false) {
543         // Check for it
544         $isset = isset($GLOBALS['what']);
545
546         // Should we abort here?
547         if (($strict === true) && ($isset === false)) {
548                 // Output backtrace
549                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
550         } // END - if
551
552         // Return it
553         return $isset;
554 }
555
556 // Getter for 'action' value
557 function getAction ($strict = true) {
558         // Default is null
559         $action = null;
560
561         // Is the value set?
562         if (isActionSet(($strict) && (getScriptOutputMode() == 0))) {
563                 // Then use it
564                 $action = $GLOBALS['action'];
565         } // END - if
566
567         // Return it
568         return $action;
569 }
570
571 // Setter for 'action' value
572 function setAction ($newAction) {
573         $GLOBALS['action'] = SQL_ESCAPE($newAction);
574 }
575
576 // Checks wether action is set and optionally aborts on miss
577 function isActionSet ($strict =  false) {
578         // Check for it
579         $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
580
581         // Should we abort here?
582         if (($strict === true) && ($isset === false)) {
583                 // Output backtrace
584                 debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
585         } // END - if
586
587         // Return it
588         return $isset;
589 }
590
591 // Getter for 'module' value
592 function getModule ($strict = true) {
593         // Default is null
594         $module = null;
595
596         // Is the value set?
597         if (isModuleSet($strict)) {
598                 // Then use it
599                 $module = $GLOBALS['module'];
600         } // END - if
601
602         // Return it
603         return $module;
604 }
605
606 // Setter for 'module' value
607 function setModule ($newModule) {
608         // Secure it and make all modules lower-case
609         $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
610 }
611
612 // Checks wether module is set and optionally aborts on miss
613 function isModuleSet ($strict =  false) {
614         // Check for it
615         $isset = (!empty($GLOBALS['module']));
616
617         // Should we abort here?
618         if (($strict === true) && ($isset === false)) {
619                 // Output backtrace
620                 debug_report_bug(__FUNCTION__, __LINE__, 'module is empty.');
621         } // END - if
622
623         // Return it
624         return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
625 }
626
627 // Getter for 'output_mode' value
628 function getScriptOutputMode () {
629         // Default is null
630         $output_mode = null;
631
632         // Is the value set?
633         if (isOutputModeSet(true)) {
634                 // Then use it
635                 $output_mode = $GLOBALS['output_mode'];
636         } // END - if
637
638         // Return it
639         return $output_mode;
640 }
641
642 // Setter for 'output_mode' value
643 function setOutputMode ($newOutputMode) {
644         $GLOBALS['output_mode'] = (int) $newOutputMode;
645 }
646
647 // Checks wether output_mode is set and optionally aborts on miss
648 function isOutputModeSet ($strict =  false) {
649         // Check for it
650         $isset = (isset($GLOBALS['output_mode']));
651
652         // Should we abort here?
653         if (($strict === true) && ($isset === false)) {
654                 // Output backtrace
655                 debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
656         } // END - if
657
658         // Return it
659         return $isset;
660 }
661
662 // Enables block-mode
663 function enableBlockMode ($enabled = true) {
664         $GLOBALS['block_mode'] = $enabled;
665 }
666
667 // Checks wether block-mode is enabled
668 function isBlockModeEnabled () {
669         // Abort if not set
670         if (!isset($GLOBALS['block_mode'])) {
671                 // Needs to be fixed
672                 debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
673         } // END - if
674
675         // Return it
676         return $GLOBALS['block_mode'];
677 }
678
679 // Wrapper function for addPointsThroughReferalSystem()
680 function addPointsDirectly ($subject, $userid, $points) {
681         // Reset level here
682         unset($GLOBALS['ref_level']);
683
684         // Call more complicated method (due to more parameters)
685         return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, false, 'direct');
686 }
687
688 // Wrapper for redirectToUrl but URL comes from a configuration entry
689 function redirectToConfiguredUrl ($configEntry) {
690         // Load the URL
691         redirectToUrl(getConfig($configEntry));
692 }
693
694 // Wrapper function to redirect from member-only modules to index
695 function redirectToIndexMemberOnlyModule () {
696         // Do the redirect here
697         redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
698 }
699
700 // Wrapper function to redirect to current URL
701 function redirectToRequestUri () {
702         redirectToUrl(basename(detectRequestUri()));
703 }
704
705 // Wrapper function to redirect to de-refered URL
706 function redirectToDereferedUrl ($URL) {
707         // Redirect to to
708         redirectToUrl(generateDerefererUrl($URL));
709 }
710
711 // Wrapper function for checking if extension is installed and newer or same version
712 function isExtensionInstalledAndNewer ($ext_name, $version) {
713         // Is an cache entry found?
714         if (!isset($GLOBALS['ext_installed_newer'][$ext_name][$version])) {
715                 $GLOBALS['ext_installed_newer'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
716         } else {
717                 // Cache hits should be incremented twice
718                 incrementStatsEntry('cache_hits', 2);
719         }
720
721         // Return it
722         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]));
723         return $GLOBALS['ext_installed_newer'][$ext_name][$version];
724 }
725
726 // Wrapper function for checking if extension is installed and older than given version
727 function isExtensionInstalledAndOlder ($ext_name, $version) {
728         // Is an cache entry found?
729         if (!isset($GLOBALS['ext_installed_older'][$ext_name][$version])) {
730                 $GLOBALS['ext_installed_older'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
731         } else {
732                 // Cache hits should be incremented twice
733                 incrementStatsEntry('cache_hits', 2);
734         }
735
736         // Return it
737         //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]));
738         return $GLOBALS['ext_installed_older'][$ext_name][$version];
739 }
740
741 // Set username
742 function setUsername ($userName) {
743         $GLOBALS['username'] = (string) $userName;
744 }
745
746 // Get username
747 function getUsername () {
748         // User name set?
749         if (!isset($GLOBALS['username'])) {
750                 // No, so it has to be a guest
751                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
752         } // END - if
753
754         // Return it
755         return $GLOBALS['username'];
756 }
757
758 // Wrapper function for installation phase
759 function isInstallationPhase () {
760         // Do we have cache?
761         if (!isset($GLOBALS['installation_phase'])) {
762                 // Determine it
763                 $GLOBALS['installation_phase'] = ((!isInstalled()) || (isInstalling()));
764         } // END - if
765
766         // Return result
767         return $GLOBALS['installation_phase'];
768 }
769
770 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
771 function isDemoModeActive () {
772         // Is cache set?
773         if (!isset($GLOBALS['demo_mode_active'])) {
774                 // Simply check it
775                 $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
776         } // END - if
777
778         // Return it
779         return $GLOBALS['demo_mode_active'];
780 }
781
782 // Getter for PHP caching value
783 function getPhpCaching () {
784         return $GLOBALS['php_caching'];
785 }
786
787 // Checks wether the admin hash is set
788 function isAdminHashSet ($adminId) {
789         // Is the array there?
790         if (!isset($GLOBALS['cache_array']['admin'])) {
791                 // Missing array should be reported
792                 debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
793         } // END - if
794
795         // Check for admin hash
796         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
797 }
798
799 // Setter for admin hash
800 function setAdminHash ($adminId, $hash) {
801         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
802 }
803
804 // Init user data array
805 function initUserData () {
806         // User id should not be zero
807         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
808
809         // Init the user
810         $GLOBALS['user_data'][getCurrentUserId()] = array();
811 }
812
813 // Getter for user data
814 function getUserData ($column) {
815         // User id should not be zero
816         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
817
818         // Return the value
819         return $GLOBALS['user_data'][getCurrentUserId()][$column];
820 }
821
822 // Geter for whole user data array
823 function getUserDataArray () {
824         // Get user id
825         $uid = getCurrentUserId();
826
827         // User id should not be zero
828         if ($uid < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
829
830         // Get the whole array if found
831         if (isset($GLOBALS['user_data'][$uid])) {
832                 // Found, so return it
833                 return $GLOBALS['user_data'][$uid];
834         } else {
835                 // Return empty array
836                 return array();
837         }
838 }
839
840 // Checks if the user data is valid, this may indicate that the user has logged
841 // in, but you should use isMember() if you want to find that out.
842 function isUserDataValid () {
843         // User id should not be zero so abort here
844         if (!isCurrentUserIdSet()) return false;
845
846         // Is it cached?
847         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
848                 // Determine it
849                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
850         } // END - if
851
852         // Return the result
853         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
854 }
855
856 // Setter for current userid
857 function setCurrentUserId ($userid) {
858         // Set userid
859         $GLOBALS['current_userid'] = bigintval($userid);
860
861         // Unset it to re-determine the actual state
862         unset($GLOBALS['is_userdata_valid'][$userid]);
863 }
864
865 // Getter for current userid
866 function getCurrentUserId () {
867         // Userid must be set before it can be used
868         if (!isCurrentUserIdSet()) {
869                 // Not set
870                 debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
871         } // END - if
872
873         // Return the userid
874         return $GLOBALS['current_userid'];
875 }
876
877 // Checks if current userid is set
878 function isCurrentUserIdSet () {
879         return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
880 }
881
882 // Checks wether we are debugging template cache
883 function isDebuggingTemplateCache () {
884         // Do we have cache?
885         if (!isset($GLOBALS['debug_template_cache'])) {
886                 // Determine it
887                 $GLOBALS['debug_template_cache'] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
888         } // END - if
889
890         // Return cache
891         return $GLOBALS['debug_template_cache'];
892 }
893
894 // Wrapper for fetchUserData() and getUserData() calls
895 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
896         // Is it cached?
897         if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
898                 // Default is 'guest'
899                 $data = '{--USERNAME_GUEST--}';
900
901                 // Can we fetch the user data?
902                 if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
903                         // Now get the data back
904                         $data = getUserData($valueColumn);
905                 } // END - if
906
907                 // Cache it
908                 $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data;
909         } // END - if
910
911         // Return it
912         return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn];
913 }
914
915 // Wrapper for strpos() to ease porting from deprecated ereg() function
916 function isInString ($needle, $haystack) {
917         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false));
918         return (strpos($haystack, $needle) !== false);
919 }
920
921 // Wrapper for strpos() to ease porting from deprecated eregi() function
922 // This function is case-insensitive
923 function isInStringIgnoreCase ($needle, $haystack) {
924         return (isInString(strtolower($needle), strtolower($haystack)));
925 }
926
927 // Wrapper to check for if fatal errors where detected
928 function ifFatalErrorsDetected () {
929         // Just call the inner function
930         return (getTotalFatalErrors() > 0);
931 }
932
933 // Setter for HTTP status
934 function setHttpStatus ($status) {
935         $GLOBALS['http_status'] = (string) $status;
936 }
937
938 // Getter for HTTP status
939 function getHttpStatus () {
940         return $GLOBALS['http_status'];
941 }
942
943 /**
944  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
945  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
946  *
947  * ----------------------------------------------------------------------------
948  * If you want to redirect, please use redirectToUrl(); instead
949  * ----------------------------------------------------------------------------
950  *
951  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
952  *
953  * @link    http://support.microsoft.com/kb/q176113/
954  * @author  Andreas Gohr <andi@splitbrain.org>
955  * @access  private
956  */
957 function sendRawRedirect ($url) {
958         // always close the session
959         session_write_close();
960
961         // Revert entity &amp;
962         $url = str_replace('&amp;', '&', $url);
963
964         // check if running on IIS < 6 with CGI-PHP
965         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
966                 (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) &&
967                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
968                 ($matches[1] < 6)) {
969                 // Send the IIS header
970                 sendHeader('Refresh: 0;url=' . $url);
971         } else {
972                 // Send generic header
973                 sendHeader('Location: ' . $url);
974         }
975
976         // Shutdown here
977         shutdown();
978 }
979
980 // Determines the country of the given user id
981 function determineCountry ($userid) {
982         // Default is 'invalid'
983         $country = 'invalid';
984
985         // Is extension country active?
986         if (isExtensionActive('country')) {
987                 // Determine the right country code through the country id
988                 $id = getUserData('country_code');
989
990                 // Then handle it over
991                 $country = generateCountryInfo($id);
992         } else {
993                 // Get raw code from user data
994                 $country = getUserData('country');
995         }
996
997         // Return it
998         return $country;
999 }
1000
1001 // "Getter" for total confirmed user accounts
1002 function getTotalConfirmedUser () {
1003         // Is it cached?
1004         if (!isset($GLOBALS['total_confirmed_users'])) {
1005                 // Then do it
1006                 $GLOBALS['total_confirmed_users'] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
1007         } // END - if
1008
1009         // Return cached value
1010         return $GLOBALS['total_confirmed_users'];
1011 }
1012
1013 // "Getter" for total unconfirmed user accounts
1014 function getTotalUnconfirmedUser () {
1015         // Is it cached?
1016         if (!isset($GLOBALS['total_unconfirmed_users'])) {
1017                 // Then do it
1018                 $GLOBALS['total_unconfirmed_users'] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
1019         } // END - if
1020
1021         // Return cached value
1022         return $GLOBALS['total_unconfirmed_users'];
1023 }
1024
1025 // "Getter" for total locked user accounts
1026 function getTotalLockedUser () {
1027         // Is it cached?
1028         if (!isset($GLOBALS['total_locked_users'])) {
1029                 // Then do it
1030                 $GLOBALS['total_locked_users'] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
1031         } // END - if
1032
1033         // Return cached value
1034         return $GLOBALS['total_locked_users'];
1035 }
1036
1037 // Is given userid valid?
1038 function isValidUserId ($userid) {
1039         // Do we have cache?
1040         if (!isset($GLOBALS['is_valid_userid'][$userid])) {
1041                 // Check it out
1042                 $GLOBALS['is_valid_userid'][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
1043         } // END - if
1044
1045         // Return cache
1046         return $GLOBALS['is_valid_userid'][$userid];
1047 }
1048
1049 // Encodes entities
1050 function encodeEntities ($str) {
1051         // Secure it first
1052         $str = secureString($str);
1053
1054         // Encode dollar sign as well
1055         $str = str_replace('$', '&#36;', $str);
1056
1057         // Return it
1058         return $str;
1059 }
1060
1061 // "Getter" for date from patch_ctime
1062 function getDateFromPatchTime () {
1063         // Is it cached?
1064         if (!isset($GLOBALS[__FUNCTION__])) {
1065                 // Then set it
1066                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
1067         } // END - if
1068
1069         // Return cache
1070         return $GLOBALS[__FUNCTION__];
1071 }
1072
1073 // Getter for current year (default)
1074 function getYear ($timestamp = null) {
1075         // Is it cached?
1076         if (!isset($GLOBALS['year'][$timestamp])) {
1077                 // null is time()
1078                 if (is_null($timestamp)) $timestamp = time();
1079
1080                 // Then create it
1081                 $GLOBALS['year'][$timestamp] = date('Y', $timestamp);
1082         } // END - if
1083
1084         // Return cache
1085         return $GLOBALS['year'][$timestamp];
1086 }
1087
1088 // Getter for current month (default)
1089 function getMonth ($timestamp = null) {
1090         // Is it cached?
1091         if (!isset($GLOBALS['month'][$timestamp])) {
1092                 // null is time()
1093                 if (is_null($timestamp)) $timestamp = time();
1094
1095                 // Then create it
1096                 $GLOBALS['month'][$timestamp] = date('m', $timestamp);
1097         } // END - if
1098
1099         // Return cache
1100         return $GLOBALS['month'][$timestamp];
1101 }
1102
1103 // Getter for current day (default)
1104 function getDay ($timestamp = null) {
1105         // Is it cached?
1106         if (!isset($GLOBALS['day'][$timestamp])) {
1107                 // null is time()
1108                 if (is_null($timestamp)) $timestamp = time();
1109
1110                 // Then create it
1111                 $GLOBALS['day'][$timestamp] = date('d', $timestamp);
1112         } // END - if
1113
1114         // Return cache
1115         return $GLOBALS['day'][$timestamp];
1116 }
1117
1118 // Getter for current week (default)
1119 function getWeek ($timestamp = null) {
1120         // Is it cached?
1121         if (!isset($GLOBALS['week'][$timestamp])) {
1122                 // null is time()
1123                 if (is_null($timestamp)) $timestamp = time();
1124
1125                 // Then create it
1126                 $GLOBALS['week'][$timestamp] = date('W', $timestamp);
1127         } // END - if
1128
1129         // Return cache
1130         return $GLOBALS['week'][$timestamp];
1131 }
1132
1133 // Getter for current short_hour (default)
1134 function getShortHour ($timestamp = null) {
1135         // Is it cached?
1136         if (!isset($GLOBALS['short_hour'][$timestamp])) {
1137                 // null is time()
1138                 if (is_null($timestamp)) $timestamp = time();
1139
1140                 // Then create it
1141                 $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp);
1142         } // END - if
1143
1144         // Return cache
1145         return $GLOBALS['short_hour'][$timestamp];
1146 }
1147
1148 // Getter for current long_hour (default)
1149 function getLongHour ($timestamp = null) {
1150         // Is it cached?
1151         if (!isset($GLOBALS['long_hour'][$timestamp])) {
1152                 // null is time()
1153                 if (is_null($timestamp)) $timestamp = time();
1154
1155                 // Then create it
1156                 $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp);
1157         } // END - if
1158
1159         // Return cache
1160         return $GLOBALS['long_hour'][$timestamp];
1161 }
1162
1163 // Getter for current second (default)
1164 function getSecond ($timestamp = null) {
1165         // Is it cached?
1166         if (!isset($GLOBALS['second'][$timestamp])) {
1167                 // null is time()
1168                 if (is_null($timestamp)) $timestamp = time();
1169
1170                 // Then create it
1171                 $GLOBALS['second'][$timestamp] = date('s', $timestamp);
1172         } // END - if
1173
1174         // Return cache
1175         return $GLOBALS['second'][$timestamp];
1176 }
1177
1178 // Getter for current minute (default)
1179 function getMinute ($timestamp = null) {
1180         // Is it cached?
1181         if (!isset($GLOBALS['minute'][$timestamp])) {
1182                 // null is time()
1183                 if (is_null($timestamp)) $timestamp = time();
1184
1185                 // Then create it
1186                 $GLOBALS['minute'][$timestamp] = date('i', $timestamp);
1187         } // END - if
1188
1189         // Return cache
1190         return $GLOBALS['minute'][$timestamp];
1191 }
1192
1193 // Checks wether the title decoration is enabled
1194 function isTitleDecorationEnabled () {
1195         // Do we have cache?
1196         if (!isset($GLOBALS['title_deco_enabled'])) {
1197                 // Just check it
1198                 $GLOBALS['title_deco_enabled'] = (getConfig('enable_title_deco') == 'Y');
1199         } // END - if
1200
1201         // Return cache
1202         return $GLOBALS['title_deco_enabled'];
1203 }
1204
1205 // Checks wether filter usage updates are enabled (expensive queries!)
1206 function isFilterUsageUpdateEnabled () {
1207         // Do we have cache?
1208         if (!isset($GLOBALS['filter_usage_updates'])) {
1209                 // Determine it
1210                 $GLOBALS['filter_usage_updates'] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1211         } // END - if
1212
1213         // Return cache
1214         return $GLOBALS['filter_usage_updates'];
1215 }
1216
1217 // Checks wether debugging of weekly resets is enabled
1218 function isWeeklyResetDebugEnabled () {
1219         // Do we have cache?
1220         if (!isset($GLOBALS['weekly_reset_debug'])) {
1221                 // Determine it
1222                 $GLOBALS['weekly_reset_debug'] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1223         } // END - if
1224
1225         // Return cache
1226         return $GLOBALS['weekly_reset_debug'];
1227 }
1228
1229 // Checks wether debugging of monthly resets is enabled
1230 function isMonthlyResetDebugEnabled () {
1231         // Do we have cache?
1232         if (!isset($GLOBALS['monthly_reset_debug'])) {
1233                 // Determine it
1234                 $GLOBALS['monthly_reset_debug'] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1235         } // END - if
1236
1237         // Return cache
1238         return $GLOBALS['monthly_reset_debug'];
1239 }
1240
1241 // Checks wether displaying of debug SQLs are enabled
1242 function isDisplayDebugSqlEnabled () {
1243         // Do we have cache?
1244         if (!isset($GLOBALS['display_debug_sql'])) {
1245                 // Determine it
1246                 $GLOBALS['display_debug_sql'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
1247         } // END - if
1248
1249         // Return cache
1250         return $GLOBALS['display_debug_sql'];
1251 }
1252
1253 // Checks wether module title is enabled
1254 function isModuleTitleEnabled () {
1255         // Do we have cache?
1256         if (!isset($GLOBALS['mod_title_enabled'])) {
1257                 // Determine it
1258                 $GLOBALS['mod_title_enabled'] = (getConfig('enable_mod_title') == 'Y');
1259         } // END - if
1260
1261         // Return cache
1262         return $GLOBALS['mod_title_enabled'];
1263 }
1264
1265 // Checks wether what title is enabled
1266 function isWhatTitleEnabled () {
1267         // Do we have cache?
1268         if (!isset($GLOBALS['mod_title_enabled'])) {
1269                 // Determine it
1270                 $GLOBALS['mod_title_enabled'] = (getConfig('enable_what_title') == 'Y');
1271         } // END - if
1272
1273         // Return cache
1274         return $GLOBALS['mod_title_enabled'];
1275 }
1276
1277 // Checks wether stats are enabled
1278 function ifStatsAreEnabled () {
1279         // Do we have cache?
1280         if (!isset($GLOBALS['stats_enabled'])) {
1281                 // Then determine it
1282                 $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y');
1283         } // END - if
1284
1285         // Return cached value
1286         return $GLOBALS['stats_enabled'];
1287 }
1288
1289 // Checks wether admin-notification of certain user actions is enabled
1290 function isAdminNotificationEnabled () {
1291         // Do we have cache?
1292         if (!isset($GLOBALS['admin_notification_enabled'])) {
1293                 // Determine it
1294                 $GLOBALS['admin_notification_enabled'] = (getConfig('admin_notify') == 'Y');
1295         } // END - if
1296
1297         // Return cache
1298         return $GLOBALS['admin_notification_enabled'];
1299 }
1300
1301 // Checks wether random referal id selection is enabled
1302 function isRandomReferalIdEnabled () {
1303         // Do we have cache?
1304         if (!isset($GLOBALS['select_user_zero_refid'])) {
1305                 // Determine it
1306                 $GLOBALS['select_user_zero_refid'] = (getConfig('select_user_zero_refid') == 'Y');
1307         } // END - if
1308
1309         // Return cache
1310         return $GLOBALS['select_user_zero_refid'];
1311 }
1312
1313 // "Getter" for default language
1314 function getDefaultLanguage () {
1315         // Do we have cache?
1316         if (!isset($GLOBALS['default_language'])) {
1317                 // Determine it
1318                 $GLOBALS['default_language'] = getConfig('DEFAULT_LANG');
1319         } // END - if
1320
1321         // Return cache
1322         return $GLOBALS['default_language'];
1323 }
1324
1325 // "Getter" for path
1326 function getPath () {
1327         // Do we have cache?
1328         if (!isset($GLOBALS['path'])) {
1329                 // Determine it
1330                 $GLOBALS['path'] = getConfig('PATH');
1331         } // END - if
1332
1333         // Return cache
1334         return $GLOBALS['path'];
1335 }
1336
1337 // "Getter" for url
1338 function getUrl () {
1339         // Do we have cache?
1340         if (!isset($GLOBALS['url'])) {
1341                 // Determine it
1342                 $GLOBALS['url'] = getConfig('URL');
1343         } // END - if
1344
1345         // Return cache
1346         return $GLOBALS['url'];
1347 }
1348
1349 // "Getter" for cache_path
1350 function getCachePath () {
1351         // Do we have cache?
1352         if (!isset($GLOBALS['cache_path'])) {
1353                 // Determine it
1354                 $GLOBALS['cache_path'] = getConfig('CACHE_PATH');
1355         } // END - if
1356
1357         // Return cache
1358         return $GLOBALS['cache_path'];
1359 }
1360
1361 // "Getter" for secret_key
1362 function getSecretKey () {
1363         // Do we have cache?
1364         if (!isset($GLOBALS['secret_key'])) {
1365                 // Determine it
1366                 $GLOBALS['secret_key'] = getConfig('secret_key');
1367         } // END - if
1368
1369         // Return cache
1370         return $GLOBALS['secret_key'];
1371 }
1372
1373 // "Getter" for master_salt
1374 function getMasterSalt () {
1375         // Do we have cache?
1376         if (!isset($GLOBALS['master_salt'])) {
1377                 // Determine it
1378                 $GLOBALS['master_salt'] = getConfig('master_salt');
1379         } // END - if
1380
1381         // Return cache
1382         return $GLOBALS['master_salt'];
1383 }
1384
1385 // "Getter" for prime
1386 function getPrime () {
1387         // Do we have cache?
1388         if (!isset($GLOBALS['prime'])) {
1389                 // Determine it
1390                 $GLOBALS['prime'] = getConfig('_PRIME');
1391         } // END - if
1392
1393         // Return cache
1394         return $GLOBALS['prime'];
1395 }
1396
1397 // "Getter" for encrypt_seperator
1398 function getEncryptSeperator () {
1399         // Do we have cache?
1400         if (!isset($GLOBALS['encrypt_seperator'])) {
1401                 // Determine it
1402                 $GLOBALS['encrypt_seperator'] = getConfig('ENCRYPT_SEPERATOR');
1403         } // END - if
1404
1405         // Return cache
1406         return $GLOBALS['encrypt_seperator'];
1407 }
1408
1409 // "Getter" for mysql_prefix
1410 function getMysqlPrefix () {
1411         // Do we have cache?
1412         if (!isset($GLOBALS['mysql_prefix'])) {
1413                 // Determine it
1414                 $GLOBALS['mysql_prefix'] = getConfig('_MYSQL_PREFIX');
1415         } // END - if
1416
1417         // Return cache
1418         return $GLOBALS['mysql_prefix'];
1419 }
1420
1421 // "Getter" for table_type
1422 function getTableType () {
1423         // Do we have cache?
1424         if (!isset($GLOBALS['table_type'])) {
1425                 // Determine it
1426                 $GLOBALS['table_type'] = getConfig('_TABLE_TYPE');
1427         } // END - if
1428
1429         // Return cache
1430         return $GLOBALS['table_type'];
1431 }
1432
1433 // "Getter" for salt_length
1434 function getSaltLength () {
1435         // Do we have cache?
1436         if (!isset($GLOBALS['salt_length'])) {
1437                 // Determine it
1438                 $GLOBALS['salt_length'] = getConfig('salt_length');
1439         } // END - if
1440
1441         // Return cache
1442         return $GLOBALS['salt_length'];
1443 }
1444
1445 // "Getter" for output_mode
1446 function getOutputMode () {
1447         // Do we have cache?
1448         if (!isset($GLOBALS['cached_output_mode'])) {
1449                 // Determine it
1450                 $GLOBALS['cached_output_mode'] = getConfig('OUTPUT_MODE');
1451         } // END - if
1452
1453         // Return cache
1454         return $GLOBALS['cached_output_mode'];
1455 }
1456
1457 // "Getter" for full_version
1458 function getFullVersion () {
1459         // Do we have cache?
1460         if (!isset($GLOBALS['full_version'])) {
1461                 // Determine it
1462                 $GLOBALS['full_version'] = getConfig('FULL_VERSION');
1463         } // END - if
1464
1465         // Return cache
1466         return $GLOBALS['full_version'];
1467 }
1468
1469 // "Getter" for title
1470 function getTitle () {
1471         // Do we have cache?
1472         if (!isset($GLOBALS['title'])) {
1473                 // Determine it
1474                 $GLOBALS['title'] = getConfig('TITLE');
1475         } // END - if
1476
1477         // Return cache
1478         return $GLOBALS['title'];
1479 }
1480
1481 // "Getter" for curr_svn_revision
1482 function getCurrSvnRevision () {
1483         // Do we have cache?
1484         if (!isset($GLOBALS['curr_svn_revision'])) {
1485                 // Determine it
1486                 $GLOBALS['curr_svn_revision'] = getConfig('CURR_SVN_REVISION');
1487         } // END - if
1488
1489         // Return cache
1490         return $GLOBALS['curr_svn_revision'];
1491 }
1492
1493 // "Getter" for server_url
1494 function getServerUrl () {
1495         // Do we have cache?
1496         if (!isset($GLOBALS['server_url'])) {
1497                 // Determine it
1498                 $GLOBALS['server_url'] = getConfig('SERVER_URL');
1499         } // END - if
1500
1501         // Return cache
1502         return $GLOBALS['server_url'];
1503 }
1504
1505 // "Getter" for mt_word
1506 function getMtWord () {
1507         // Do we have cache?
1508         if (!isset($GLOBALS['mt_word'])) {
1509                 // Determine it
1510                 $GLOBALS['mt_word'] = getConfig('mt_word');
1511         } // END - if
1512
1513         // Return cache
1514         return $GLOBALS['mt_word'];
1515 }
1516
1517 // "Getter" for main_title
1518 function getMainTitle () {
1519         // Do we have cache?
1520         if (!isset($GLOBALS['main_title'])) {
1521                 // Determine it
1522                 $GLOBALS['main_title'] = getConfig('MAIN_TITLE');
1523         } // END - if
1524
1525         // Return cache
1526         return $GLOBALS['main_title'];
1527 }
1528
1529 // "Getter" for file_hash
1530 function getFileHash () {
1531         // Do we have cache?
1532         if (!isset($GLOBALS['file_hash'])) {
1533                 // Determine it
1534                 $GLOBALS['file_hash'] = getConfig('file_hash');
1535         } // END - if
1536
1537         // Return cache
1538         return $GLOBALS['file_hash'];
1539 }
1540
1541 // "Getter" for pass_scramble
1542 function getPassScramble () {
1543         // Do we have cache?
1544         if (!isset($GLOBALS['pass_scramble'])) {
1545                 // Determine it
1546                 $GLOBALS['pass_scramble'] = getConfig('pass_scramble');
1547         } // END - if
1548
1549         // Return cache
1550         return $GLOBALS['pass_scramble'];
1551 }
1552
1553 // "Getter" for ap_inactive_since
1554 function getApInactiveSince () {
1555         // Do we have cache?
1556         if (!isset($GLOBALS['ap_inactive_since'])) {
1557                 // Determine it
1558                 $GLOBALS['ap_inactive_since'] = getConfig('ap_inactive_since');
1559         } // END - if
1560
1561         // Return cache
1562         return $GLOBALS['ap_inactive_since'];
1563 }
1564
1565 // "Getter" for user_min_confirmed
1566 function getUserMinConfirmed () {
1567         // Do we have cache?
1568         if (!isset($GLOBALS['user_min_confirmed'])) {
1569                 // Determine it
1570                 $GLOBALS['user_min_confirmed'] = getConfig('user_min_confirmed');
1571         } // END - if
1572
1573         // Return cache
1574         return $GLOBALS['user_min_confirmed'];
1575 }
1576
1577 // "Getter" for auto_purge
1578 function getAutoPurge () {
1579         // Do we have cache?
1580         if (!isset($GLOBALS['auto_purge'])) {
1581                 // Determine it
1582                 $GLOBALS['auto_purge'] = getConfig('auto_purge');
1583         } // END - if
1584
1585         // Return cache
1586         return $GLOBALS['auto_purge'];
1587 }
1588
1589 // "Getter" for bonus_userid
1590 function getBonusUserid () {
1591         // Do we have cache?
1592         if (!isset($GLOBALS['bonus_userid'])) {
1593                 // Determine it
1594                 $GLOBALS['bonus_userid'] = getConfig('bonus_userid');
1595         } // END - if
1596
1597         // Return cache
1598         return $GLOBALS['bonus_userid'];
1599 }
1600
1601 // "Getter" for ap_inactive_time
1602 function getApInactiveTime () {
1603         // Do we have cache?
1604         if (!isset($GLOBALS['ap_inactive_time'])) {
1605                 // Determine it
1606                 $GLOBALS['ap_inactive_time'] = getConfig('ap_inactive_time');
1607         } // END - if
1608
1609         // Return cache
1610         return $GLOBALS['ap_inactive_time'];
1611 }
1612
1613 // "Getter" for ap_dm_timeout
1614 function getApDmTimeout () {
1615         // Do we have cache?
1616         if (!isset($GLOBALS['ap_dm_timeout'])) {
1617                 // Determine it
1618                 $GLOBALS['ap_dm_timeout'] = getConfig('ap_dm_timeout');
1619         } // END - if
1620
1621         // Return cache
1622         return $GLOBALS['ap_dm_timeout'];
1623 }
1624
1625 // "Getter" for ap_tasks_time
1626 function getApTasksTime () {
1627         // Do we have cache?
1628         if (!isset($GLOBALS['ap_tasks_time'])) {
1629                 // Determine it
1630                 $GLOBALS['ap_tasks_time'] = getConfig('ap_tasks_time');
1631         } // END - if
1632
1633         // Return cache
1634         return $GLOBALS['ap_tasks_time'];
1635 }
1636
1637 // "Getter" for ap_unconfirmed_time
1638 function getApUnconfirmedTime () {
1639         // Do we have cache?
1640         if (!isset($GLOBALS['ap_unconfirmed_time'])) {
1641                 // Determine it
1642                 $GLOBALS['ap_unconfirmed_time'] = getConfig('ap_unconfirmed_time');
1643         } // END - if
1644
1645         // Return cache
1646         return $GLOBALS['ap_unconfirmed_time'];
1647 }
1648
1649 // "Getter" for points
1650 function getPoints () {
1651         // Do we have cache?
1652         if (!isset($GLOBALS['points'])) {
1653                 // Determine it
1654                 $GLOBALS['points'] = getConfig('POINTS');
1655         } // END - if
1656
1657         // Return cache
1658         return $GLOBALS['points'];
1659 }
1660
1661 // "Getter" for slogan
1662 function getSlogan () {
1663         // Do we have cache?
1664         if (!isset($GLOBALS['slogan'])) {
1665                 // Determine it
1666                 $GLOBALS['slogan'] = getConfig('SLOGAN');
1667         } // END - if
1668
1669         // Return cache
1670         return $GLOBALS['slogan'];
1671 }
1672
1673 // "Getter" for copy
1674 function getCopy () {
1675         // Do we have cache?
1676         if (!isset($GLOBALS['copy'])) {
1677                 // Determine it
1678                 $GLOBALS['copy'] = getConfig('COPY');
1679         } // END - if
1680
1681         // Return cache
1682         return $GLOBALS['copy'];
1683 }
1684
1685 // "Getter" for webmaster
1686 function getWebmaster () {
1687         // Do we have cache?
1688         if (!isset($GLOBALS['webmaster'])) {
1689                 // Determine it
1690                 $GLOBALS['webmaster'] = getConfig('WEBMASTER');
1691         } // END - if
1692
1693         // Return cache
1694         return $GLOBALS['webmaster'];
1695 }
1696
1697 // "Getter" for sql_count
1698 function getSqlCount () {
1699         // Do we have cache?
1700         if (!isset($GLOBALS['sql_count'])) {
1701                 // Determine it
1702                 $GLOBALS['sql_count'] = getConfig('sql_count');
1703         } // END - if
1704
1705         // Return cache
1706         return $GLOBALS['sql_count'];
1707 }
1708
1709 // "Getter" for num_templates
1710 function getNumTemplates () {
1711         // Do we have cache?
1712         if (!isset($GLOBALS['num_templates'])) {
1713                 // Determine it
1714                 $GLOBALS['num_templates'] = getConfig('num_templates');
1715         } // END - if
1716
1717         // Return cache
1718         return $GLOBALS['num_templates'];
1719 }
1720
1721 // "Getter" for dns_cache_timeout
1722 function getDnsCacheTimeout () {
1723         // Do we have cache?
1724         if (!isset($GLOBALS['dns_cache_timeout'])) {
1725                 // Determine it
1726                 $GLOBALS['dns_cache_timeout'] = getConfig('dns_cache_timeout');
1727         } // END - if
1728
1729         // Return cache
1730         return $GLOBALS['dns_cache_timeout'];
1731 }
1732
1733 // "Getter" for menu_blur_spacer
1734 function getMenuBlurSpacer () {
1735         // Do we have cache?
1736         if (!isset($GLOBALS['menu_blur_spacer'])) {
1737                 // Determine it
1738                 $GLOBALS['menu_blur_spacer'] = getConfig('menu_blur_spacer');
1739         } // END - if
1740
1741         // Return cache
1742         return $GLOBALS['menu_blur_spacer'];
1743 }
1744
1745 // "Getter" for points_register
1746 function getPointsRegister () {
1747         // Do we have cache?
1748         if (!isset($GLOBALS['points_register'])) {
1749                 // Determine it
1750                 $GLOBALS['points_register'] = getConfig('points_register');
1751         } // END - if
1752
1753         // Return cache
1754         return $GLOBALS['points_register'];
1755 }
1756
1757 // "Getter" for points_ref
1758 function getPointsRef () {
1759         // Do we have cache?
1760         if (!isset($GLOBALS['points_ref'])) {
1761                 // Determine it
1762                 $GLOBALS['points_ref'] = getConfig('points_ref');
1763         } // END - if
1764
1765         // Return cache
1766         return $GLOBALS['points_ref'];
1767 }
1768
1769 // "Getter" for ref_payout
1770 function getRefPayout () {
1771         // Do we have cache?
1772         if (!isset($GLOBALS['ref_payout'])) {
1773                 // Determine it
1774                 $GLOBALS['ref_payout'] = getConfig('ref_payout');
1775         } // END - if
1776
1777         // Return cache
1778         return $GLOBALS['ref_payout'];
1779 }
1780
1781 // "Getter" for online_timeout
1782 function getOnlineTimeout () {
1783         // Do we have cache?
1784         if (!isset($GLOBALS['online_timeout'])) {
1785                 // Determine it
1786                 $GLOBALS['online_timeout'] = getConfig('online_timeout');
1787         } // END - if
1788
1789         // Return cache
1790         return $GLOBALS['online_timeout'];
1791 }
1792
1793 // Checks wether proxy configuration is used
1794 function isProxyUsed () {
1795         // Do we have cache?
1796         if (!isset($GLOBALS['is_proxy_used'])) {
1797                 // Determine it
1798                 $GLOBALS['is_proxy_used'] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
1799         } // END - if
1800
1801         // Return cache
1802         return $GLOBALS['is_proxy_used'];
1803 }
1804
1805 // Checks wether POST data contains selections
1806 function ifPostContainsSelections ($element = 'sel') {
1807         // Do we have cache?
1808         if (!isset($GLOBALS['post_contains_selections'][$element])) {
1809                 // Determine it
1810                 $GLOBALS['post_contains_selections'][$element] = (countPostSelection($element) > 0);
1811         } // END - if
1812
1813         // Return cache
1814         return $GLOBALS['post_contains_selections'][$element];
1815 }
1816
1817 // Checks wether verbose_sql is Y and returns true/false if so
1818 function isVerboseSqlEnabled () {
1819         // Do we have cache?
1820         if (!isset($GLOBALS['is_verbose_sql_enabled'])) {
1821                 // Determine it
1822                 $GLOBALS['is_verbose_sql_enabled'] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
1823         } // END - if
1824
1825         // Return cache
1826         return $GLOBALS['is_verbose_sql_enabled'];
1827 }
1828
1829 // [EOF]
1830 ?>