Opps :(
[mailer.git] / inc / wrapper-functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/04/2009 *
4  * ===================                          Last change: 04/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : wrapper-functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Wrapper functions                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Wrapper-Funktionen                               *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         exit();
41 } // END - if
42
43 // Read a given file
44 function readFromFile ($FQFN) {
45         // Sanity-check if file is there (should be there, but just to make it sure)
46         if (!isFileReadable($FQFN)) {
47                 // This should not happen
48                 reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
49         } // END - if
50
51         // Load the file
52         if (function_exists('file_get_contents')) {
53                 // Use new function
54                 $fileContent = file_get_contents($FQFN);
55         } else {
56                 // Fall-back to implode-file chain
57                 $fileContent = implode('', file($FQFN));
58         }
59
60         // Return the content
61         return $fileContent;
62 }
63
64 // Writes content to a file
65 function writeToFile ($FQFN, $content, $aquireLock = FALSE) {
66         // Is the file writeable?
67         if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
68                 // Not writeable!
69                 logDebugMessage(__FUNCTION__, __LINE__, sprintf('File %s not writeable or cannot change CHMOD to 0644.', basename($FQFN)));
70
71                 // Failed! :(
72                 return FALSE;
73         } // END - if
74
75         // By default all is failed...
76         $GLOBALS['file_readable'][$FQFN] = FALSE;
77         $return = FALSE;
78
79         // Is the function there?
80         if (function_exists('file_put_contents')) {
81                 // With lock?
82                 if ($aquireLock === TRUE) {
83                         // Write it directly with lock
84                         $return = file_put_contents($FQFN, $content, LOCK_EX);
85                 } else {
86                         // Write it directly
87                         $return = file_put_contents($FQFN, $content);
88                 }
89         } else {
90                 // Write it with fopen
91                 $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
92
93                 // Aquire a lock?
94                 if ($aquireLock === TRUE) {
95                         // Aquire a lock.
96                         flock($fp, LOCK_EX);
97                 } // END - if
98
99                 // Write content
100                 $return = fwrite($fp, $content);
101
102                 // Close stream
103                 fclose($fp);
104         }
105
106         // Was something written?
107         if ($return !== FALSE) {
108                 // Mark it as readable
109                 $GLOBALS['file_readable'][$FQFN] = TRUE;
110         } // END - if
111
112         // Return status
113         return (($return !== FALSE) && (changeMode($FQFN, 0644)));
114 }
115
116 // Clears the output buffer. This function does *NOT* backup sent content.
117 function clearOutputBuffer () {
118         // Make sure this function is not called twice (no double-cleaning!)
119         if (isset($GLOBALS[__FUNCTION__])) {
120                 // This function is called twice
121                 reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
122         } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
123                 // Failed!
124                 reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
125         } // END - if
126
127         // Mark this function as called
128         $GLOBALS[__FUNCTION__] = TRUE;
129 }
130
131 // Encode strings
132 function encodeString ($str) {
133         $str = urlencode(base64_encode(compileUriCode($str)));
134         return $str;
135 }
136
137 // Decode strings encoded with encodeString()
138 function decodeString ($str) {
139         $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
140         return $str;
141 }
142
143 // Decode entities in a nicer way
144 function decodeEntities ($str, $quote = ENT_NOQUOTES) {
145         // Decode the entities to UTF-8 now
146         $decodedString = html_entity_decode($str, $quote, 'UTF-8');
147
148         // Return decoded string
149         return $decodedString;
150 }
151
152 // Merges an array together but only if both are arrays
153 function merge_array ($array1, $array2, $keepIndex = FALSE) {
154         // Are both an array?
155         if ((!is_array($array1)) && (!is_array($array2))) {
156                 // Both are not arrays
157                 reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
158         } elseif (!is_array($array1)) {
159                 // Left one is not an array
160                 reportBug(__FUNCTION__, __LINE__, sprintf('array1 is not an array. array != %s', gettype($array1)));
161         } elseif (!is_array($array2)) {
162                 // Right one is not an array
163                 reportBug(__FUNCTION__, __LINE__, sprintf('array2 is not an array. array != %s', gettype($array2)));
164         }
165
166         // Maintain index of array2?
167         if ($keepIndex === TRUE) {
168                 // Keep index of array2, array_merge() rewrites e.g. $key=1 to $key=0, $key=2 to $key=1 ! :(
169                 foreach ($array2 as $key => $value) {
170                         // Add it
171                         $array1[$key] = $value;
172                 } // END - foreach
173
174                 // Return it
175                 return $array1;
176         } else {
177                 // Merge both together normally
178                 return array_merge($array1, $array2);
179         }
180 }
181
182 // Check if given FQFN is a readable file
183 function isFileReadable ($FQFN) {
184         // Is there cache?
185         if (!isset($GLOBALS['file_readable'][$FQFN])) {
186                 // Check all...
187                 $GLOBALS['file_readable'][$FQFN] = ((is_file($FQFN)) && (file_exists($FQFN)) && (is_readable($FQFN)));
188         } // END - if
189
190         // Return result
191         return $GLOBALS['file_readable'][$FQFN];
192 }
193
194 // Checks whether the given FQFN is a directory and not ., .. or .svn
195 function isDirectory ($FQFN) {
196         // Is there cache?
197         if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
198                 // Generate baseName
199                 $baseName = basename($FQFN);
200
201                 // Check it
202                 $GLOBALS[__FUNCTION__][$FQFN] = ((is_dir($FQFN)) && (!in_array($baseName, array('.', '..', '.svn'))));
203         } // END - if
204
205         // Return the result
206         return $GLOBALS[__FUNCTION__][$FQFN];
207 }
208
209 // "Getter" for the real remote IP number
210 function detectRealIpAddress ($alwaysReal = FALSE) {
211         // Get remote ip from environment
212         $remoteAddr = determineRealRemoteAddress();
213
214         // Is removeip installed?
215         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
216                 // Then anonymize it
217                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
218         } // END - if
219
220         // Return it
221         return $remoteAddr;
222 }
223
224 // "Getter" for remote IP number
225 function detectRemoteAddr ($alwaysReal = FALSE) {
226         // Get remote ip from environment
227         $remoteAddr = determineRealRemoteAddress(TRUE);
228
229         // Is removeip installed?
230         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
231                 // Then anonymize it
232                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
233         } // END - if
234
235         // Return it
236         return $remoteAddr;
237 }
238
239 // "Getter" for remote hostname
240 function detectRemoteHostname ($alwaysReal = FALSE) {
241         // Get remote ip from environment
242         $remoteHost = getenv('REMOTE_HOST');
243
244         // Is removeip installed?
245         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
246                 // Then anonymize it
247                 $remoteHost = getAnonymousRemoteHost($remoteHost);
248         } // END - if
249
250         // Return it
251         return $remoteHost;
252 }
253
254 // "Getter" for user agent
255 function detectUserAgent ($alwaysReal = FALSE) {
256         // Get remote ip from environment
257         $userAgent = getenv('HTTP_USER_AGENT');
258
259         // Is removeip installed?
260         if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
261                 // Then anonymize it
262                 $userAgent = getAnonymousUserAgent($userAgent);
263         } // END - if
264
265         // Return it
266         return $userAgent;
267 }
268
269 // "Getter" for referer
270 function detectReferer ($alwaysReal = FALSE) {
271         // Get remote ip from environment
272         $referer = getenv('HTTP_REFERER');
273
274         // Is removeip installed?
275         if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
276                 // Then anonymize it
277                 $referer = getAnonymousReferer($referer);
278         } // END - if
279
280         // Return it
281         return $referer;
282 }
283
284 // "Getter" for request URI
285 function detectRequestUri () {
286         // Return it
287         return (getenv('REQUEST_URI'));
288 }
289
290 // "Getter" for query string
291 function detectQueryString () {
292         return str_replace('&', '&amp;', (getenv('QUERY_STRING')));
293 }
294
295 // "Getter" for SERVER_NAME
296 function detectServerName () {
297         // Return it
298         return (getenv('SERVER_NAME'));
299 }
300
301 // Removes any  existing www. from SERVER_NAME. This is very silly but enough
302 // for our purpose here.
303 function detectDomainName () {
304         // Is there cache?
305         if (!isset($GLOBALS[__FUNCTION__])) {
306                 // Get server name
307                 $domainName = detectServerName();
308
309                 // Is there any www. ?
310                 if (substr($domainName, 0, 4) == 'www.') {
311                         // Remove it
312                         $domainName = substr($domainName, 4);
313                 } // END - if
314
315                 // Set cache
316                 $GLOBALS[__FUNCTION__] = $domainName;
317         } // END - if
318
319         // Return cache
320         return $GLOBALS[__FUNCTION__];
321 }
322
323 // Check whether we are installing
324 function isInstalling () {
325         // Determine whether we are installing
326         if (!isset($GLOBALS['__mailer_installing'])) {
327                 // Check URL (css.php/js.php need this)
328                 $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isAjaxOutputMode()) && (isGetRequestElementSet('level')) && (getRequestElement('level') == 'install')));
329         } // END - if
330
331         // Return result
332         return $GLOBALS['__mailer_installing'];
333 }
334
335 // Check whether this script is installed
336 function isInstalled () {
337         // Is there cache?
338         if (!isset($GLOBALS[__FUNCTION__])) {
339                 // Determine whether this script is installed
340                 $GLOBALS[__FUNCTION__] = (
341                 (
342                         // First is config
343                         (
344                                 (
345                                         isConfigEntrySet('MAILER_INSTALLED')
346                                 ) && (
347                                         getConfig('MAILER_INSTALLED') == 'Y'
348                                 )
349                         )
350                 ) || (
351                         // New config file found and loaded
352                         isIncludeReadable(getCachePath() . 'config-local.php')
353                 ) || (
354                         (
355                                 // New config file found, but not yet read
356                                 isIncludeReadable(getCachePath() . 'config-local.php')
357                         ) && (
358                                 (
359                                         // Only new config file is found
360                                         !isIncludeReadable('inc/config.php')
361                                 ) || (
362                                         // Is installation mode
363                                         !isInstalling()
364                                 )
365                         )
366                 ));
367         } // END - if
368
369         // Then use the cache
370         return $GLOBALS[__FUNCTION__];
371 }
372
373 // Check whether an admin is registered
374 function isAdminRegistered () {
375         // Is cache set?
376         if (!isset($GLOBALS[__FUNCTION__])) {
377                 // Simply check it
378                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
379         } // END - if
380
381         // Return it
382         return $GLOBALS[__FUNCTION__];
383 }
384
385 // Checks whether the hourly reset mode is active
386 function isHourlyResetEnabled () {
387         // Now simply check it
388         return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE));
389 }
390
391 // Checks whether the daily reset mode is active
392 function isDailyResetEnabled () {
393         // Now simply check it
394         return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE));
395 }
396
397 // Checks whether the weekly reset mode is active
398 function isWeeklyResetEnabled () {
399         // Now simply check it
400         return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE));
401 }
402
403 // Checks whether the monthly reset mode is active
404 function isMonthlyResetEnabled () {
405         // Now simply check it
406         return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE));
407 }
408
409 // Checks whether the yearly reset mode is active
410 function isYearlyResetEnabled () {
411         // Now simply check it
412         return ((isset($GLOBALS['yearly_enabled'])) && ($GLOBALS['yearly_enabled'] === TRUE));
413 }
414
415 // Checks whether one of the reset modes is enabled
416 function isResetModeEnabled () {
417         // Now simply check it
418         return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled()) || (isYearlyResetEnabled()));
419 }
420
421 // Checks whether the debug mode is enabled
422 function isDebugModeEnabled () {
423         // Is cache set?
424         if (!isset($GLOBALS[__FUNCTION__])) {
425                 // Simply check it
426                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
427         } // END - if
428
429         // Return it
430         return $GLOBALS[__FUNCTION__];
431 }
432
433 // Checks whether the debug hourly is enabled
434 function isDebugHourlyEnabled () {
435         // Is cache set?
436         if (!isset($GLOBALS[__FUNCTION__])) {
437                 // Simply check it
438                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
439         } // END - if
440
441         // Return it
442         return $GLOBALS[__FUNCTION__];
443 }
444
445 // Checks whether the debug daily is enabled
446 function isDebugDailyEnabled () {
447         // Is cache set?
448         if (!isset($GLOBALS[__FUNCTION__])) {
449                 // Simply check it
450                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y'));
451         } // END - if
452
453         // Return it
454         return $GLOBALS[__FUNCTION__];
455 }
456
457 // Checks whether the debug weekly is enabled
458 function isDebugWeeklyEnabled () {
459         // Is cache set?
460         if (!isset($GLOBALS[__FUNCTION__])) {
461                 // Simply check it
462                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
463         } // END - if
464
465         // Return it
466         return $GLOBALS[__FUNCTION__];
467 }
468
469 // Checks whether the debug monthly is enabled
470 function isDebugMonthlyEnabled () {
471         // Is cache set?
472         if (!isset($GLOBALS[__FUNCTION__])) {
473                 // Simply check it
474                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
475         } // END - if
476
477         // Return it
478         return $GLOBALS[__FUNCTION__];
479 }
480
481 // Checks whether the debug yearly is enabled
482 function isDebugYearlyEnabled () {
483         // Is cache set?
484         if (!isset($GLOBALS[__FUNCTION__])) {
485                 // Simply check it
486                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
487         } // END - if
488
489         // Return it
490         return $GLOBALS[__FUNCTION__];
491 }
492
493 // Checks whether SQL debugging is enabled
494 function isSqlDebuggingEnabled () {
495         // Is cache set?
496         if (!isset($GLOBALS[__FUNCTION__])) {
497                 // Determine if SQL debugging is enabled
498                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y'));
499         } // END - if
500
501         // Return it
502         return $GLOBALS[__FUNCTION__];
503 }
504
505 // Checks whether we shall debug regular expressions
506 function isDebugRegularExpressionEnabled () {
507         // Is cache set?
508         if (!isset($GLOBALS[__FUNCTION__])) {
509                 // Simply check it
510                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
511         } // END - if
512
513         // Return it
514         return $GLOBALS[__FUNCTION__];
515 }
516
517 // Checks whether debugging of build mails is enabled
518 function isDebugBuildMailsEnabled () {
519         // Is cache set?
520         if (!isset($GLOBALS[__FUNCTION__])) {
521                 // Simply check it
522                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
523         } // END - if
524
525         // Return it
526         return $GLOBALS[__FUNCTION__];
527 }
528
529 // Checks whether the cache instance is valid
530 function isValidCacheInstance () {
531         // Is there cache?
532         if (!isset($GLOBALS[__FUNCTION__])) {
533                 // Determine it
534                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
535         } // END - if
536
537         // Return cache
538         return $GLOBALS[__FUNCTION__];
539 }
540
541 // Copies a file from source to destination and verifies if that goes fine.
542 // This function should wrap the copy() command and make a nicer debug backtrace
543 // even if there is no xdebug extension installed.
544 function copyFileVerified ($source, $dest, $chmod = '') {
545         // Failed is the default
546         $status = FALSE;
547
548         // Is the source file there?
549         if (!isFileReadable($source)) {
550                 // Then abort here
551                 reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
552         } // END - if
553
554         // Is the target directory there?
555         if (!isDirectory(dirname($dest))) {
556                 // Then abort here
557                 reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
558         } // END - if
559
560         // Now try to copy it
561         if (!copy($source, $dest)) {
562                 // Something went wrong
563                 reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
564         } else {
565                 // Reset cache
566                 $GLOBALS['file_readable'][$dest] = TRUE;
567         }
568
569         // All fine by default
570         $status = TRUE;
571
572         // If there are chmod rights set, apply them
573         if (!empty($chmod)) {
574                 // Try to apply them
575                 $status = changeMode($dest, $chmod);
576         } // END - if
577
578         // All fine
579         return $status;
580 }
581
582 // Wrapper function for chmod()
583 // @TODO Do some more sanity check here
584 function changeMode ($FQFN, $mode) {
585         // Is the file/directory there?
586         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
587                 // Neither, so abort here
588                 reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
589         } // END - if
590
591         // Try to set them
592         return chmod($FQFN, $mode);
593 }
594
595 // Wrapper for unlink()
596 function removeFile ($FQFN) {
597         // Is the file there?
598         if (isFileReadable($FQFN)) {
599                 // Reset cache first
600                 $GLOBALS['file_readable'][$FQFN] = FALSE;
601
602                 // Yes, so remove it
603                 return unlink($FQFN);
604         } // END - if
605
606         // All fine if no file was removed. If we change this to 'false' or rewrite
607         // above if() block it would be to restrictive.
608         return TRUE;
609 }
610
611 // Wrapper for $_POST['sel']
612 function countPostSelection ($element = 'sel') {
613         // Is there cache?
614         if (!isset($GLOBALS[__FUNCTION__][$element])) {
615                 // Default is zero
616                 $GLOBALS[__FUNCTION__][$element] = '0';
617
618                 // Is it set?
619                 if (isPostRequestElementSet($element)) {
620                         // Return counted elements
621                         $GLOBALS[__FUNCTION__][$element] = countSelection(postRequestElement($element));
622                 } // END - if
623         } // END - if
624
625         // Return cached value
626         return $GLOBALS[__FUNCTION__][$element];
627 }
628
629 // Checks whether the config-local.php is loaded
630 function isConfigLocalLoaded () {
631         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === TRUE));
632 }
633
634 // Checks whether a nickname or userid was entered and caches the result
635 function isNicknameUsed ($userid) {
636         // Is the cache there
637         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
638                 // Determine it
639                 $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, TRUE, FALSE) . '') != $userid) && ($userid != 'NULL'));
640         } // END - if
641
642         // Return the result
643         return $GLOBALS[__FUNCTION__][$userid];
644 }
645
646 // Getter for 'what' value
647 function getWhat ($strict = TRUE) {
648         // Default is null
649         $what = NULL;
650
651         // Is the value set?
652         if (isWhatSet($strict)) {
653                 // Then use it
654                 $what = $GLOBALS['__what'];
655         } // END - if
656
657         // Return it
658         return $what;
659 }
660
661 // Setter for 'what' value
662 function setWhat ($newWhat) {
663         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
664         $GLOBALS['__what'] = $newWhat;
665 }
666
667 // Setter for 'what' from configuration
668 function setWhatFromConfig ($configEntry) {
669         // Get 'what' from config
670         $what = getConfig($configEntry);
671
672         // Set it
673         setWhat($what);
674 }
675
676 // Checks whether what is set and optionally aborts on miss
677 function isWhatSet ($strict = FALSE) {
678         // Check for it
679         $isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
680
681         // Should we abort here?
682         if (($strict === TRUE) && ($isset === FALSE)) {
683                 // Output backtrace
684                 debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.');
685         } // END - if
686
687         // Return it
688         return $isset;
689 }
690
691 // Getter for 'action' value
692 function getAction ($strict = TRUE) {
693         // Default is null
694         $action = NULL;
695
696         // Is the value set?
697         if (isActionSet(($strict) && (isHtmlOutputMode()))) {
698                 // Then use it
699                 $action = $GLOBALS['__action'];
700         } // END - if
701
702         // Return it
703         return $action;
704 }
705
706 // Setter for 'action' value
707 function setAction ($newAction) {
708         $GLOBALS['__action'] = $newAction;
709 }
710
711 // Checks whether action is set and optionally aborts on miss
712 function isActionSet ($strict = FALSE) {
713         // Check for it
714         $isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
715
716         // Should we abort here?
717         if (($strict === TRUE) && ($isset === FALSE)) {
718                 // Output backtrace
719                 reportBug(__FUNCTION__, __LINE__, 'action is empty.');
720         } // END - if
721
722         // Return it
723         return $isset;
724 }
725
726 // Getter for 'module' value
727 function getModule ($strict = TRUE) {
728         // Default is null
729         $module = NULL;
730
731         // Is the value set?
732         if (isModuleSet($strict)) {
733                 // Then use it
734                 $module = $GLOBALS['__module'];
735         } // END - if
736
737         // Return it
738         return $module;
739 }
740
741 // Setter for 'module' value
742 function setModule ($newModule) {
743         // Secure it and make all modules lower-case
744         $GLOBALS['__module'] = strtolower($newModule);
745 }
746
747 // Wrapper to get extra module names
748 function getExtraModule () {
749         // Default is 'NULL'
750         $extra = 'NULL';
751
752         // Is 'tab/step' set?
753         if (isPostRequestElementSet('tab')) {
754                 // Use this
755                 $extra = 'tab=' . postRequestElement('tab');
756         } elseif (isPostRequestElementSet('step')) {
757                 // Use this
758                 $extra = 'step=' . postRequestElement('step');
759         } elseif ((isActionSet()) && (isWhatSet())) {
760                 // Use 'action/what'
761                 $extra = 'action=' . getAction() . ':what=' . getWhat();
762         }
763
764         // Return it
765         return $extra;
766 }
767
768 // Checks whether module is set and optionally aborts on miss
769 function isModuleSet ($strict = FALSE) {
770         // Check for it
771         $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
772
773         // Should we abort here?
774         if (($strict === TRUE) && ($isset === FALSE)) {
775                 // Output backtrace
776                 reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
777         } // END - if
778
779         // Return it
780         return (($isset === TRUE) && ($GLOBALS['__module'] != 'unknown')) ;
781 }
782
783 // Getter for 'output_mode' value
784 function getScriptOutputMode () {
785         // Is cache set?
786         if (!isset($GLOBALS[__FUNCTION__])) {
787                 // Is the output mode set?
788                 if (!isOutputModeSet()) {
789                         // No, then abort here
790                         reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
791                 } // END - if
792
793                 // Set it in cache
794                 $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
795         } // END - if
796
797         // Return cache
798         return $GLOBALS[__FUNCTION__];
799 }
800
801 // Setter for 'output_mode' value
802 function setScriptOutputMode ($newOutputMode) {
803         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
804         $GLOBALS['__output_mode'] = (int) $newOutputMode;
805 }
806
807 // Checks whether output_mode is set and optionally aborts on miss
808 function isOutputModeSet ($strict = FALSE) {
809         // Check for it
810         $isset = (isset($GLOBALS['__output_mode']));
811
812         // Should we abort here?
813         if (($strict === TRUE) && ($isset === FALSE)) {
814                 // Output backtrace
815                 reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
816         } // END - if
817
818         // Return it
819         return $isset;
820 }
821
822 // Enables block-mode
823 function enableBlockMode ($enabled = TRUE) {
824         $GLOBALS['__block_mode'] = $enabled;
825 }
826
827 // Checks whether block-mode is enabled
828 function isBlockModeEnabled () {
829         // Abort if not set
830         if (!isset($GLOBALS['__block_mode'])) {
831                 // Needs to be fixed
832                 reportBug(__FUNCTION__, __LINE__, '__block_mode is not set.');
833         } // END - if
834
835         // Return it
836         return $GLOBALS['__block_mode'];
837 }
838
839 // Wrapper for redirectToUrl but URL comes from a configuration entry
840 function redirectToConfiguredUrl ($configEntry) {
841         // Load the URL
842         redirectToUrl(getConfig($configEntry));
843 }
844
845 // Wrapper function to redirect from member-only modules to index
846 function redirectToIndexMemberOnlyModule () {
847         // Do the redirect here
848         redirectToUrl('modules.php?module=index&amp;code=' . getCode('MODULE_MEMBER_ONLY') . '&amp;mod=' . getModule());
849 }
850
851 // Wrapper function to redirect to current URL
852 function redirectToRequestUri () {
853         redirectToUrl(basename(detectRequestUri()));
854 }
855
856 // Wrapper function to redirect to de-refered URL
857 function redirectToDereferedUrl ($url) {
858         // Redirect to to
859         redirectToUrl(generateDereferrerUrl($url));
860 }
861
862 // Wrapper function for checking if extension is installed and newer or same version
863 function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
864         // Is an cache entry found?
865         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
866                 // Determine it
867                 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
868         } else {
869                 // Cache hits should be incremented twice
870                 incrementStatsEntry('cache_hits', 2);
871         }
872
873         // Return it
874         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=&gt;' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
875         return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
876 }
877
878 // Wrapper function for checking if extension is installed and older than given version
879 function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
880         // Is an cache entry found?
881         if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
882                 // Determine it
883                 $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
884         } else {
885                 // Cache hits should be incremented twice
886                 incrementStatsEntry('cache_hits', 2);
887         }
888
889         // Return it
890         //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '&lt;' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
891         return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
892 }
893
894 // Set username
895 function setUsername ($userName) {
896         $GLOBALS['username'] = (string) $userName;
897 }
898
899 // Get username
900 function getUsername () {
901         // User name set?
902         if (!isset($GLOBALS['username'])) {
903                 // No, so it has to be a guest
904                 $GLOBALS['username'] = '{--USERNAME_GUEST--}';
905         } // END - if
906
907         // Return it
908         return $GLOBALS['username'];
909 }
910
911 // Wrapper function for installation phase
912 function isInstaller () {
913         // Is there cache?
914         if (!isset($GLOBALS[__FUNCTION__])) {
915                 // Determine it
916                 $GLOBALS[__FUNCTION__] = ((!isInstalled()) || (isInstalling()));
917         } // END - if
918
919         // Return result
920         return $GLOBALS[__FUNCTION__];
921 }
922
923 // Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
924 function isDemoModeActive () {
925         // Is cache set?
926         if (!isset($GLOBALS[__FUNCTION__])) {
927                 // Simply check it
928                 $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
929         } // END - if
930
931         // Return it
932         return $GLOBALS[__FUNCTION__];
933 }
934
935 // Getter for PHP caching value
936 function getPhpCaching () {
937         return $GLOBALS['php_caching'];
938 }
939
940 // Checks whether the admin hash is set
941 function isAdminHashSet ($adminId) {
942         // Is the array there?
943         if (!isset($GLOBALS['cache_array']['admin'])) {
944                 // Missing array should be reported
945                 reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
946         } // END - if
947
948         // Check for admin hash
949         return isset($GLOBALS['cache_array']['admin']['password'][$adminId]);
950 }
951
952 // Setter for admin hash
953 function setAdminHash ($adminId, $hash) {
954         $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
955 }
956
957 // Getter for current admin login
958 function getCurrentAdminLogin () {
959         // Log debug message
960         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
961
962         // Is there cache?
963         if (!isset($GLOBALS[__FUNCTION__])) {
964                 // Determine it
965                 $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
966         } // END - if
967
968         // Return it
969         return $GLOBALS[__FUNCTION__];
970 }
971
972 // Setter for admin id (and current)
973 function setAdminId ($adminId) {
974         // Log debug message
975         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
976
977         // Set session
978         $status = setSession('admin_id', bigintval($adminId));
979
980         // Set current id
981         setCurrentAdminId($adminId);
982
983         // Return status
984         return $status;
985 }
986
987 // Setter for admin_last
988 function setAdminLast ($adminLast) {
989         // Log debug message
990         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
991
992         // Set session
993         $status = setSession('admin_last', $adminLast);
994
995         // Return status
996         return $status;
997 }
998
999 // Setter for admin_md5
1000 function setAdminMd5 ($adminMd5) {
1001         // Log debug message
1002         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
1003
1004         // Set session
1005         $status = setSession('admin_md5', $adminMd5);
1006
1007         // Return status
1008         return $status;
1009 }
1010
1011 // Getter for admin_md5
1012 function getAdminMd5 () {
1013         // Log debug message
1014         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
1015
1016         // Get session
1017         return getSession('admin_md5');
1018 }
1019
1020 // Init user data array
1021 function initUserData () {
1022         // User id should not be zero
1023         if (!isValidId(getCurrentUserId())) {
1024                 // Should be always valid
1025                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1026         } // END - if
1027
1028         // Init the user
1029         unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
1030         $GLOBALS['user_data'][getCurrentUserId()] = array();
1031 }
1032
1033 // Getter for user data
1034 function getUserData ($column) {
1035         // User id should not be zero
1036         if (!isValidId(getCurrentUserId())) {
1037                 // Should be always valid
1038                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
1039         } // END - if
1040
1041         // Default is empty
1042         $data = NULL;
1043
1044         if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) {
1045                 // Return the value
1046                 $data = $GLOBALS['user_data'][getCurrentUserId()][$column];
1047         } // END - if
1048
1049         // Return it
1050         return $data;
1051 }
1052
1053 // Checks whether given user data is set to 'Y'
1054 function isUserDataEnabled ($column) {
1055         // Is there cache?
1056         if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
1057                 // Determine it
1058                 $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y');
1059         } // END - if
1060
1061         // Return cache
1062         return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column];
1063 }
1064
1065 // Geter for whole user data array
1066 function getUserDataArray () {
1067         // Get user id
1068         $userid = getCurrentUserId();
1069
1070         // Is the current userid valid?
1071         if (!isValidId($userid)) {
1072                 // Should be always valid
1073                 reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
1074         } // END - if
1075
1076         // Get the whole array if found
1077         if (isset($GLOBALS['user_data'][$userid])) {
1078                 // Found, so return it
1079                 return $GLOBALS['user_data'][$userid];
1080         } else {
1081                 // Return empty array
1082                 return array();
1083         }
1084 }
1085
1086 // Checks if the user data is valid, this may indicate that the user has logged
1087 // in, but you should use isMember() if you want to find that out.
1088 function isValidUserData () {
1089         // User id should not be zero so abort here
1090         if (!isCurrentUserIdSet()) {
1091                 // Debug message, may be noisy
1092                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
1093
1094                 // Abort here
1095                 return FALSE;
1096         } // END - if
1097
1098         // Is it cached?
1099         if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) {
1100                 // Determine it
1101                 $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
1102         } // END - if
1103
1104         // Return the result
1105         return $GLOBALS['is_userdata_valid'][getCurrentUserId()];
1106 }
1107
1108 // Setter for current userid
1109 function setCurrentUserId ($userid) {
1110         // Debug message
1111         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
1112
1113         // Is the cache from below functions different?
1114         if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
1115                 // Then unset both
1116                 unsetCurrentUserId();
1117         } // END - if
1118
1119         // Set userid
1120         $GLOBALS['current_userid'] = bigintval($userid);
1121
1122         // Unset it to re-determine the actual state
1123         unset($GLOBALS['is_userdata_valid'][$userid]);
1124
1125         // Debug message
1126         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
1127 }
1128
1129 // Getter for current userid
1130 function getCurrentUserId () {
1131         // Is cache set?
1132         if (!isset($GLOBALS[__FUNCTION__])) {
1133                 // Userid must be set before it can be used
1134                 if (!isCurrentUserIdSet()) {
1135                         // Not set
1136                         reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
1137                 } // END - if
1138
1139                 // Set userid in cache
1140                 $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
1141         } // END - if
1142
1143         // Return cache
1144         return $GLOBALS[__FUNCTION__];
1145 }
1146
1147 // Checks if current userid is set
1148 function isCurrentUserIdSet () {
1149         // Is there cache?
1150         if (!isset($GLOBALS[__FUNCTION__])) {
1151                 // Determine it
1152                 $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid'])));
1153         } // END - if
1154
1155         // Return cache
1156         return $GLOBALS[__FUNCTION__];
1157 }
1158
1159 // Unsets current userid
1160 function unsetCurrentUserId () {
1161         // Is it set?
1162         if (isset($GLOBALS['current_userid'])) {
1163                 // Unset this, too
1164                 unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]);
1165         } // END - if
1166
1167         // Unset all cache entries
1168         unset($GLOBALS['current_userid']);
1169         unset($GLOBALS['getCurrentUserId']);
1170         unset($GLOBALS['isCurrentUserIdSet']);
1171 }
1172
1173 // Checks whether we are debugging template cache
1174 function isDebugTemplateCacheEnabled () {
1175         // Is there cache?
1176         if (!isset($GLOBALS[__FUNCTION__])) {
1177                 // Determine it
1178                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_TEMPLATE_CACHE')) && (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'));
1179         } // END - if
1180
1181         // Return cache
1182         return $GLOBALS[__FUNCTION__];
1183 }
1184
1185 // Wrapper for fetchUserData() and getUserData() calls
1186 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
1187         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
1188         // Is it cached?
1189         if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
1190                 // Default is NULL
1191                 $data = NULL;
1192
1193                 // Can we fetch the user data?
1194                 if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) {
1195                         // Now get the data back
1196                         $data = getUserData($valueColumn);
1197                 } // END - if
1198
1199                 // Cache it
1200                 $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] = $data;
1201         } // END - if
1202
1203         // Return it
1204         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
1205         return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
1206 }
1207
1208 // Wrapper for strpos() to ease porting from deprecated ereg() function
1209 function isInString ($needle, $haystack) {
1210         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== FALSE));
1211         return (strpos($haystack, $needle) !== FALSE);
1212 }
1213
1214 // Wrapper for strpos() to ease porting from deprecated eregi() function
1215 // This function is case-insensitive
1216 function isInStringIgnoreCase ($needle, $haystack) {
1217         return (isInString(strtolower($needle), strtolower($haystack)));
1218 }
1219
1220 // Wrapper to check for if fatal errors where detected
1221 function ifFatalErrorsDetected () {
1222         // Just call the inner function
1223         return (getTotalFatalErrors() > 0);
1224 }
1225
1226 // Checks whether a HTTP status has been set
1227 function isHttpStatusSet () {
1228         // Is it set and not empty?
1229         return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
1230 }
1231
1232 // Setter for HTTP status
1233 function setHttpStatus ($status) {
1234         $GLOBALS['http_status'] = (string) $status;
1235 }
1236
1237 // Getter for HTTP status
1238 function getHttpStatus () {
1239         // Is the status set?
1240         if (!isHttpStatusSet()) {
1241                 // Abort here
1242                 reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
1243         } // END - if
1244
1245         // Return it
1246         return $GLOBALS['http_status'];
1247 }
1248
1249 /**
1250  * Send a HTTP redirect to the browser. This function was taken from DokuWiki
1251  * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
1252  *
1253  * ----------------------------------------------------------------------------
1254  * If you want to redirect, please use redirectToUrl(); instead
1255  * ----------------------------------------------------------------------------
1256  *
1257  * Works arround Microsoft IIS cookie sending bug. Does exit the script.
1258  *
1259  * @link    http://support.microsoft.com/kb/q176113/
1260  * @author  Andreas Gohr <andi@splitbrain.org>
1261  * @access  private
1262  */
1263 function sendRawRedirect ($url) {
1264         // Clear output buffer
1265         clearOutputBuffer();
1266
1267         // Clear own output buffer
1268         $GLOBALS['__output'] = '';
1269
1270         // To make redirects working (no content type), output mode must be raw
1271         setScriptOutputMode(-1);
1272
1273         // Send helping header
1274         setHttpStatus('302 Found');
1275
1276         // always close the session
1277         session_write_close();
1278
1279         // Revert entity &amp;
1280         $url = str_replace('&amp;', '&', $url);
1281
1282         // check if running on IIS < 6 with CGI-PHP
1283         if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
1284                 (isInString('CGI', $_SERVER['GATEWAY_INTERFACE'])) &&
1285                 (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
1286                 ($matches[1] < 6)) {
1287                 // Send the IIS header
1288                 addHttpHeader('Refresh: 0;url=' . $url);
1289         } else {
1290                 // Send generic header
1291                 addHttpHeader('Location: ' . $url);
1292         }
1293
1294         // Shutdown here
1295         doShutdown();
1296 }
1297
1298 // Determines the country of the given user id
1299 function determineCountry ($userid) {
1300         // Is there cache?
1301         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
1302                 // Default is 'invalid'
1303                 $GLOBALS[__FUNCTION__][$userid] = 'invalid';
1304
1305                 // Is extension country active?
1306                 if (isExtensionActive('country')) {
1307                         // Determine the right country code through the country id
1308                         $id = getUserData('country_code');
1309
1310                         // Then handle it over
1311                         $GLOBALS[__FUNCTION__][$userid] = generateCountryInfo($id);
1312                 } else {
1313                         // Get raw code from user data
1314                         $GLOBALS[__FUNCTION__][$userid] = getUserData('country');
1315                 }
1316         } // END - if
1317
1318         // Return cache
1319         return $GLOBALS[__FUNCTION__][$userid];
1320 }
1321
1322 // "Getter" for total confirmed user accounts
1323 function getTotalConfirmedUser () {
1324         // Is it cached?
1325         if (!isset($GLOBALS[__FUNCTION__])) {
1326                 // Then do it
1327                 if (isExtensionActive('user')) {
1328                         $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1329                 } else {
1330                         $GLOBALS[__FUNCTION__] = 0;
1331                 }
1332         } // END - if
1333
1334         // Return cached value
1335         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1336         return $GLOBALS[__FUNCTION__];
1337 }
1338
1339 // "Getter" for total unconfirmed user accounts
1340 function getTotalUnconfirmedUser () {
1341         // Is it cached?
1342         if (!isset($GLOBALS[__FUNCTION__])) {
1343                 // Then do it
1344                 if (isExtensionActive('user')) {
1345                         $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1346                 } else {
1347                         $GLOBALS[__FUNCTION__] = 0;
1348                 }
1349         } // END - if
1350
1351         // Return cached value
1352         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1353         return $GLOBALS[__FUNCTION__];
1354 }
1355
1356 // "Getter" for total locked user accounts
1357 function getTotalLockedUser () {
1358         // Is it cached?
1359         if (!isset($GLOBALS[__FUNCTION__])) {
1360                 // Then do it
1361                 if (isExtensionActive('user')) {
1362                         $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' '));
1363                 } else {
1364                         $GLOBALS[__FUNCTION__] = 0;
1365                 }
1366         } // END - if
1367
1368         // Return cached value
1369         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1370         return $GLOBALS[__FUNCTION__];
1371 }
1372
1373 // "Getter" for total locked user accounts
1374 function getTotalRandomRefidUser () {
1375         // Is it cached?
1376         if (!isset($GLOBALS[__FUNCTION__])) {
1377                 // Then do it
1378                 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
1379                         $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', TRUE, runFilterChain('user_exclusion_sql', ' '), '>=');
1380                 } else {
1381                         $GLOBALS[__FUNCTION__] = 0;
1382                 }
1383         } // END - if
1384
1385         // Return cached value
1386         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, __FUNCTION__ . '()=' . $GLOBALS[__FUNCTION__]);
1387         return $GLOBALS[__FUNCTION__];
1388 }
1389
1390 // Is given id number valid?
1391 function isValidId ($id) {
1392         // Debug message
1393         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id);
1394
1395         // Is there cache?
1396         if (!isset($GLOBALS[__FUNCTION__][$id])) {
1397                 // Check it out
1398                 $GLOBALS[__FUNCTION__][$id] = ((isValidNumber($id)) && (!is_bool($id)) && ($id != '00000') && ($id > 0));
1399         } // END - if
1400
1401         // Return cache
1402         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id]));
1403         return $GLOBALS[__FUNCTION__][$id];
1404 }
1405
1406 // Checks whether a valid number is given
1407 function isValidNumber ($num) {
1408         // Determine it
1409         return ((!is_null($num)) && (!empty($num)) && ('*' . bigintval($num, TRUE, FALSE) . '*' == '*' . $num . '*'));
1410 }
1411
1412 // Encodes entities
1413 function encodeEntities ($str) {
1414         // Secure it first
1415         $str = secureString($str, TRUE, TRUE);
1416
1417         // Encode dollar sign as well
1418         $str = str_replace('$', '&#36;', $str);
1419
1420         // Return it
1421         return $str;
1422 }
1423
1424 // "Getter" for date from patch_ctime
1425 function getDateFromRepository () {
1426         // Is it cached?
1427         if (!isset($GLOBALS[__FUNCTION__])) {
1428                 // Then set it
1429                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '5');
1430         } // END - if
1431
1432         // Return cache
1433         return $GLOBALS[__FUNCTION__];
1434 }
1435
1436 // "Getter" for date/time from patch_ctime
1437 function getDateTimeFromRepository () {
1438         // Is it cached?
1439         if (!isset($GLOBALS[__FUNCTION__])) {
1440                 // Then set it
1441                 $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('CURRENT_REPOSITORY_DATE'), '2');
1442         } // END - if
1443
1444         // Return cache
1445         return $GLOBALS[__FUNCTION__];
1446 }
1447
1448 // Getter for current year (default)
1449 function getYear ($timestamp = NULL) {
1450         // Is it cached?
1451         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1452                 // If NULL is set, use time()
1453                 if (is_null($timestamp)) {
1454                         $timestamp = time();
1455                 } // END - if
1456
1457                 // Then create it
1458                 $GLOBALS[__FUNCTION__][$timestamp] = date('Y', $timestamp);
1459         } // END - if
1460
1461         // Return cache
1462         return $GLOBALS[__FUNCTION__][$timestamp];
1463 }
1464
1465 // Getter for current month (default)
1466 function getMonth ($timestamp = NULL) {
1467         // Is it cached?
1468         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1469                 // If NULL is set, use time()
1470                 if (is_null($timestamp)) {
1471                         // Use time() which is current timestamp
1472                         $timestamp = time();
1473                 } // END - if
1474
1475                 // Then create it
1476                 $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
1477         } // END - if
1478
1479         // Return cache
1480         return $GLOBALS[__FUNCTION__][$timestamp];
1481 }
1482
1483 // Getter for current hour (default)
1484 function getHour ($timestamp = NULL) {
1485         // Is it cached?
1486         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1487                 // null is time()
1488                 if (is_null($timestamp)) {
1489                         $timestamp = time();
1490                 } // END - if
1491
1492                 // Then create it
1493                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1494         } // END - if
1495
1496         // Return cache
1497         return $GLOBALS[__FUNCTION__][$timestamp];
1498 }
1499
1500 // Getter for current day (default)
1501 function getDay ($timestamp = NULL) {
1502         // Is it cached?
1503         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1504                 // null is time()
1505                 if (is_null($timestamp)) {
1506                         $timestamp = time();
1507                 } // END - if
1508
1509                 // Then create it
1510                 $GLOBALS[__FUNCTION__][$timestamp] = date('d', $timestamp);
1511         } // END - if
1512
1513         // Return cache
1514         return $GLOBALS[__FUNCTION__][$timestamp];
1515 }
1516
1517 // Getter for current week (default)
1518 function getWeek ($timestamp = NULL) {
1519         // Is it cached?
1520         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1521                 // null is time()
1522                 if (is_null($timestamp)) $timestamp = time();
1523
1524                 // Then create it
1525                 $GLOBALS[__FUNCTION__][$timestamp] = date('W', $timestamp);
1526         } // END - if
1527
1528         // Return cache
1529         return $GLOBALS[__FUNCTION__][$timestamp];
1530 }
1531
1532 // Getter for current short_hour (default)
1533 function getShortHour ($timestamp = NULL) {
1534         // Is it cached?
1535         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1536                 // null is time()
1537                 if (is_null($timestamp)) $timestamp = time();
1538
1539                 // Then create it
1540                 $GLOBALS[__FUNCTION__][$timestamp] = date('G', $timestamp);
1541         } // END - if
1542
1543         // Return cache
1544         return $GLOBALS[__FUNCTION__][$timestamp];
1545 }
1546
1547 // Getter for current long_hour (default)
1548 function getLongHour ($timestamp = NULL) {
1549         // Is it cached?
1550         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1551                 // null is time()
1552                 if (is_null($timestamp)) $timestamp = time();
1553
1554                 // Then create it
1555                 $GLOBALS[__FUNCTION__][$timestamp] = date('H', $timestamp);
1556         } // END - if
1557
1558         // Return cache
1559         return $GLOBALS[__FUNCTION__][$timestamp];
1560 }
1561
1562 // Getter for current second (default)
1563 function getSecond ($timestamp = NULL) {
1564         // Is it cached?
1565         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1566                 // null is time()
1567                 if (is_null($timestamp)) $timestamp = time();
1568
1569                 // Then create it
1570                 $GLOBALS[__FUNCTION__][$timestamp] = date('s', $timestamp);
1571         } // END - if
1572
1573         // Return cache
1574         return $GLOBALS[__FUNCTION__][$timestamp];
1575 }
1576
1577 // Getter for current minute (default)
1578 function getMinute ($timestamp = NULL) {
1579         // Is it cached?
1580         if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
1581                 // null is time()
1582                 if (is_null($timestamp)) $timestamp = time();
1583
1584                 // Then create it
1585                 $GLOBALS[__FUNCTION__][$timestamp] = date('i', $timestamp);
1586         } // END - if
1587
1588         // Return cache
1589         return $GLOBALS[__FUNCTION__][$timestamp];
1590 }
1591
1592 // Checks whether the title decoration is enabled
1593 function isTitleDecorationEnabled () {
1594         // Is there cache?
1595         if (!isset($GLOBALS[__FUNCTION__])) {
1596                 // Just check it
1597                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_title_deco')) && (getConfig('enable_title_deco') == 'Y'));
1598         } // END - if
1599
1600         // Return cache
1601         return $GLOBALS[__FUNCTION__];
1602 }
1603
1604 // Checks whether filter usage updates are enabled (expensive queries!)
1605 function isFilterUsageUpdateEnabled () {
1606         // Is there cache?
1607         if (!isset($GLOBALS[__FUNCTION__])) {
1608                 // Determine it
1609                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y'));
1610         } // END - if
1611
1612         // Return cache
1613         return $GLOBALS[__FUNCTION__];
1614 }
1615
1616 // Checks whether debugging of weekly resets is enabled
1617 function isWeeklyResetDebugEnabled () {
1618         // Is there cache?
1619         if (!isset($GLOBALS[__FUNCTION__])) {
1620                 // Determine it
1621                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'));
1622         } // END - if
1623
1624         // Return cache
1625         return $GLOBALS[__FUNCTION__];
1626 }
1627
1628 // Checks whether debugging of monthly resets is enabled
1629 function isMonthlyResetDebugEnabled () {
1630         // Is there cache?
1631         if (!isset($GLOBALS[__FUNCTION__])) {
1632                 // Determine it
1633                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'));
1634         } // END - if
1635
1636         // Return cache
1637         return $GLOBALS[__FUNCTION__];
1638 }
1639
1640 // Checks whether debugging of yearly resets is enabled
1641 function isYearlyResetDebugEnabled () {
1642         // Is there cache?
1643         if (!isset($GLOBALS[__FUNCTION__])) {
1644                 // Determine it
1645                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_YEARLY')) && (getConfig('DEBUG_YEARLY') == 'Y'));
1646         } // END - if
1647
1648         // Return cache
1649         return $GLOBALS[__FUNCTION__];
1650 }
1651
1652 // Checks whether displaying of debug SQLs are enabled
1653 function isDisplayDebugSqlEnabled () {
1654         // Is there cache?
1655         if (!isset($GLOBALS[__FUNCTION__])) {
1656                 // Determine it
1657                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (isConfigEntrySet('display_debug_sql')) && (getDisplayDebugSqls() == 'Y'));
1658         } // END - if
1659
1660         // Return cache
1661         return $GLOBALS[__FUNCTION__];
1662 }
1663
1664 // Checks whether module title is enabled
1665 function isModuleTitleEnabled () {
1666         // Is there cache?
1667         if (!isset($GLOBALS[__FUNCTION__])) {
1668                 // Determine it
1669                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_mod_title')) && (getConfig('enable_mod_title') == 'Y'));
1670         } // END - if
1671
1672         // Return cache
1673         return $GLOBALS[__FUNCTION__];
1674 }
1675
1676 // Checks whether what title is enabled
1677 function isWhatTitleEnabled () {
1678         // Is there cache?
1679         if (!isset($GLOBALS[__FUNCTION__])) {
1680                 // Determine it
1681                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.1.6')) && (isConfigEntrySet('enable_what_title')) && (getConfig('enable_what_title') == 'Y'));
1682         } // END - if
1683
1684         // Return cache
1685         return $GLOBALS[__FUNCTION__];
1686 }
1687
1688 // "Getter" for internal_stats
1689 function getInternalStats () {
1690         // Is there cache?
1691         if (!isset($GLOBALS[__FUNCTION__])) {
1692                 // Determine it
1693                 $GLOBALS[__FUNCTION__] = getConfig('internal_stats');
1694         } // END - if
1695
1696         // Return cache
1697         return $GLOBALS[__FUNCTION__];
1698 }
1699
1700 // Checks whether stats are enabled
1701 function ifInternalStatsEnabled () {
1702         // Is there cache?
1703         if (!isset($GLOBALS[__FUNCTION__])) {
1704                 // Then determine it, do not add isExtensionInstalledAndNewer() here as it breaks very first SQL query
1705                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('internal_stats')) && (getInternalStats() == 'Y'));
1706         } // END - if
1707
1708         // Return cached value
1709         return $GLOBALS[__FUNCTION__];
1710 }
1711
1712 // Checks whether admin-notification of certain user actions is enabled
1713 function isAdminNotificationEnabled () {
1714         // Is there cache?
1715         if (!isset($GLOBALS[__FUNCTION__])) {
1716                 // Determine it
1717                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isConfigEntrySet('admin_notify')) && (getAdminNotify() == 'Y'));
1718         } // END - if
1719
1720         // Return cache
1721         return $GLOBALS[__FUNCTION__];
1722 }
1723
1724 // Checks whether random referral id selection is enabled
1725 function isRandomReferralIdEnabled () {
1726         // Is there cache?
1727         if (!isset($GLOBALS[__FUNCTION__])) {
1728                 // Determine it
1729                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isConfigEntrySet('select_user_zero_refid')) && (getSelectUserZeroRefid() == 'Y'));
1730         } // END - if
1731
1732         // Return cache
1733         return $GLOBALS[__FUNCTION__];
1734 }
1735
1736 // "Getter" for default language
1737 function getDefaultLanguage () {
1738         // Is there cache?
1739         if (!isset($GLOBALS[__FUNCTION__])) {
1740                 // Determine it
1741                 $GLOBALS[__FUNCTION__] = getConfig('DEFAULT_LANG');
1742         } // END - if
1743
1744         // Return cache
1745         return $GLOBALS[__FUNCTION__];
1746 }
1747
1748 // "Getter" for default referral id
1749 function getDefRefid () {
1750         // Is there cache?
1751         if (!isset($GLOBALS[__FUNCTION__])) {
1752                 // Determine it
1753                 $GLOBALS[__FUNCTION__] = getConfig('def_refid');
1754         } // END - if
1755
1756         // Return cache
1757         return $GLOBALS[__FUNCTION__];
1758 }
1759
1760 // "Getter" for path
1761 function getPath () {
1762         // Is there cache?
1763         if (!isset($GLOBALS[__FUNCTION__])) {
1764                 // Determine it
1765                 $GLOBALS[__FUNCTION__] = getConfig('PATH');
1766         } // END - if
1767
1768         // Return cache
1769         return $GLOBALS[__FUNCTION__];
1770 }
1771
1772 // "Getter" for url
1773 function getUrl () {
1774         // Is there cache?
1775         if (!isset($GLOBALS[__FUNCTION__])) {
1776                 // Determine it
1777                 $GLOBALS[__FUNCTION__] = getConfig('URL');
1778         } // END - if
1779
1780         // Return cache
1781         return $GLOBALS[__FUNCTION__];
1782 }
1783
1784 // "Getter" for cache_path
1785 function getCachePath () {
1786         // Is there cache?
1787         if (!isset($GLOBALS[__FUNCTION__])) {
1788                 // Determine it
1789                 $GLOBALS[__FUNCTION__] = getConfig('CACHE_PATH');
1790         } // END - if
1791
1792         // Return cache
1793         return $GLOBALS[__FUNCTION__];
1794 }
1795
1796 // "Getter" for WRITE_FOOTER
1797 function getWriteFooter () {
1798         // Is there cache?
1799         if (!isset($GLOBALS[__FUNCTION__])) {
1800                 // Determine it
1801                 $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER');
1802         } // END - if
1803
1804         // Return cache
1805         return $GLOBALS[__FUNCTION__];
1806 }
1807
1808 // "Getter" for secret_key
1809 function getSecretKey () {
1810         // Is there cache?
1811         if (!isset($GLOBALS[__FUNCTION__])) {
1812                 // Determine it
1813                 $GLOBALS[__FUNCTION__] = getConfig('secret_key');
1814         } // END - if
1815
1816         // Return cache
1817         return $GLOBALS[__FUNCTION__];
1818 }
1819
1820 // "Getter" for SITE_KEY
1821 function getSiteKey () {
1822         // Is there cache?
1823         if (!isset($GLOBALS[__FUNCTION__])) {
1824                 // Determine it
1825                 $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
1826         } // END - if
1827
1828         // Return cache
1829         return $GLOBALS[__FUNCTION__];
1830 }
1831
1832 // "Getter" for DATE_KEY
1833 function getDateKey () {
1834         // Is there cache?
1835         if (!isset($GLOBALS[__FUNCTION__])) {
1836                 // Determine it
1837                 $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
1838         } // END - if
1839
1840         // Return cache
1841         return $GLOBALS[__FUNCTION__];
1842 }
1843
1844 // "Getter" for master_salt
1845 function getMasterSalt () {
1846         // Is there cache?
1847         if (!isset($GLOBALS[__FUNCTION__])) {
1848                 // Determine it
1849                 $GLOBALS[__FUNCTION__] = getConfig('master_salt');
1850         } // END - if
1851
1852         // Return cache
1853         return $GLOBALS[__FUNCTION__];
1854 }
1855
1856 // "Getter" for prime
1857 function getPrime () {
1858         // Is there cache?
1859         if (!isset($GLOBALS[__FUNCTION__])) {
1860                 // Determine it
1861                 $GLOBALS[__FUNCTION__] = getConfig('_PRIME');
1862         } // END - if
1863
1864         // Return cache
1865         return $GLOBALS[__FUNCTION__];
1866 }
1867
1868 // "Getter" for encrypt_separator
1869 function getEncryptSeparator () {
1870         // Is there cache?
1871         if (!isset($GLOBALS[__FUNCTION__])) {
1872                 // Determine it
1873                 $GLOBALS[__FUNCTION__] = getConfig('ENCRYPT_SEPARATOR');
1874         } // END - if
1875
1876         // Return cache
1877         return $GLOBALS[__FUNCTION__];
1878 }
1879
1880 // "Getter" for mysql_prefix
1881 function getMysqlPrefix () {
1882         // Is there cache?
1883         if (!isset($GLOBALS[__FUNCTION__])) {
1884                 // Determine it
1885                 $GLOBALS[__FUNCTION__] = getConfig('_MYSQL_PREFIX');
1886         } // END - if
1887
1888         // Return cache
1889         return $GLOBALS[__FUNCTION__];
1890 }
1891
1892 // "Getter" for table_type
1893 function getTableType () {
1894         // Is there cache?
1895         if (!isset($GLOBALS[__FUNCTION__])) {
1896                 // Determine it
1897                 $GLOBALS[__FUNCTION__] = getConfig('_TABLE_TYPE');
1898         } // END - if
1899
1900         // Return cache
1901         return $GLOBALS[__FUNCTION__];
1902 }
1903
1904 // "Getter" for salt_length
1905 function getSaltLength () {
1906         // Is there cache?
1907         if (!isset($GLOBALS[__FUNCTION__])) {
1908                 // Determine it
1909                 $GLOBALS[__FUNCTION__] = getConfig('salt_length');
1910         } // END - if
1911
1912         // Return cache
1913         return $GLOBALS[__FUNCTION__];
1914 }
1915
1916 // "Getter" for output_mode
1917 function getOutputMode () {
1918         // Is there cache?
1919         if (!isset($GLOBALS[__FUNCTION__])) {
1920                 // Determine it
1921                 $GLOBALS[__FUNCTION__] = getConfig('OUTPUT_MODE');
1922         } // END - if
1923
1924         // Return cache
1925         return $GLOBALS[__FUNCTION__];
1926 }
1927
1928 // "Getter" for full_version
1929 function getFullVersion () {
1930         // Is there cache?
1931         if (!isset($GLOBALS[__FUNCTION__])) {
1932                 // Determine it
1933                 $GLOBALS[__FUNCTION__] = getConfig('FULL_VERSION');
1934         } // END - if
1935
1936         // Return cache
1937         return $GLOBALS[__FUNCTION__];
1938 }
1939
1940 // "Getter" for title
1941 function getTitle () {
1942         // Is there cache?
1943         if (!isset($GLOBALS[__FUNCTION__])) {
1944                 // Determine it
1945                 $GLOBALS[__FUNCTION__] = getConfig('TITLE');
1946         } // END - if
1947
1948         // Return cache
1949         return $GLOBALS[__FUNCTION__];
1950 }
1951
1952 // "Getter" for curr_svn_revision
1953 function getCurrentRepositoryRevision () {
1954         // Is there cache?
1955         if (!isset($GLOBALS[__FUNCTION__])) {
1956                 // Determine it
1957                 $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
1958         } // END - if
1959
1960         // Return cache
1961         return $GLOBALS[__FUNCTION__];
1962 }
1963
1964 // "Getter" for server_url
1965 function getServerUrl () {
1966         // Is there cache?
1967         if (!isset($GLOBALS[__FUNCTION__])) {
1968                 // Determine it
1969                 $GLOBALS[__FUNCTION__] = getConfig('SERVER_URL');
1970         } // END - if
1971
1972         // Return cache
1973         return $GLOBALS[__FUNCTION__];
1974 }
1975
1976 // "Getter" for mt_word
1977 function getMtWord () {
1978         // Is there cache?
1979         if (!isset($GLOBALS[__FUNCTION__])) {
1980                 // Determine it
1981                 $GLOBALS[__FUNCTION__] = getConfig('mt_word');
1982         } // END - if
1983
1984         // Return cache
1985         return $GLOBALS[__FUNCTION__];
1986 }
1987
1988 // "Getter" for mt_word2
1989 function getMtWord2 () {
1990         // Is there cache?
1991         if (!isset($GLOBALS[__FUNCTION__])) {
1992                 // Determine it
1993                 $GLOBALS[__FUNCTION__] = getConfig('mt_word2');
1994         } // END - if
1995
1996         // Return cache
1997         return $GLOBALS[__FUNCTION__];
1998 }
1999
2000 // "Getter" for mt_word3
2001 function getMtWord3 () {
2002         // Is there cache?
2003         if (!isset($GLOBALS[__FUNCTION__])) {
2004                 // Determine it
2005                 $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
2006         } // END - if
2007
2008         // Return cache
2009         return $GLOBALS[__FUNCTION__];
2010 }
2011
2012 // "Getter" for START_TDAY
2013 function getStartTday () {
2014         // Is there cache?
2015         if (!isset($GLOBALS[__FUNCTION__])) {
2016                 // Determine it
2017                 $GLOBALS[__FUNCTION__] = getConfig('START_TDAY');
2018         } // END - if
2019
2020         // Return cache
2021         return $GLOBALS[__FUNCTION__];
2022 }
2023
2024 // "Getter" for START_YDAY
2025 function getStartYday () {
2026         // Is there cache?
2027         if (!isset($GLOBALS[__FUNCTION__])) {
2028                 // Determine it
2029                 $GLOBALS[__FUNCTION__] = getConfig('START_YDAY');
2030         } // END - if
2031
2032         // Return cache
2033         return $GLOBALS[__FUNCTION__];
2034 }
2035
2036 // "Getter" for main_title
2037 function getMainTitle () {
2038         // Is there cache?
2039         if (!isset($GLOBALS[__FUNCTION__])) {
2040                 // Determine it
2041                 $GLOBALS[__FUNCTION__] = getConfig('MAIN_TITLE');
2042         } // END - if
2043
2044         // Return cache
2045         return $GLOBALS[__FUNCTION__];
2046 }
2047
2048 // "Getter" for file_hash
2049 function getFileHash () {
2050         // Is there cache?
2051         if (!isset($GLOBALS[__FUNCTION__])) {
2052                 // Determine it
2053                 $GLOBALS[__FUNCTION__] = getConfig('file_hash');
2054         } // END - if
2055
2056         // Return cache
2057         return $GLOBALS[__FUNCTION__];
2058 }
2059
2060 // "Getter" for pass_scramble
2061 function getPassScramble () {
2062         // Is there cache?
2063         if (!isset($GLOBALS[__FUNCTION__])) {
2064                 // Determine it
2065                 $GLOBALS[__FUNCTION__] = getConfig('pass_scramble');
2066         } // END - if
2067
2068         // Return cache
2069         return $GLOBALS[__FUNCTION__];
2070 }
2071
2072 // "Getter" for ap_inactive_since
2073 function getApInactiveSince () {
2074         // Is there cache?
2075         if (!isset($GLOBALS[__FUNCTION__])) {
2076                 // Determine it
2077                 $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_since');
2078         } // END - if
2079
2080         // Return cache
2081         return $GLOBALS[__FUNCTION__];
2082 }
2083
2084 // "Getter" for user_min_confirmed
2085 function getUserMinConfirmed () {
2086         // Is there cache?
2087         if (!isset($GLOBALS[__FUNCTION__])) {
2088                 // Determine it
2089                 $GLOBALS[__FUNCTION__] = getConfig('user_min_confirmed');
2090         } // END - if
2091
2092         // Return cache
2093         return $GLOBALS[__FUNCTION__];
2094 }
2095 // "Getter" for points
2096 function getPoints () {
2097         // Is there cache?
2098         if (!isset($GLOBALS[__FUNCTION__])) {
2099                 // Determine it
2100                 $GLOBALS[__FUNCTION__] = getConfig('POINTS');
2101         } // END - if
2102
2103         // Return cache
2104         return $GLOBALS[__FUNCTION__];
2105 }
2106
2107 // "Getter" for slogan
2108 function getSlogan () {
2109         // Is there cache?
2110         if (!isset($GLOBALS[__FUNCTION__])) {
2111                 // Determine it
2112                 $GLOBALS[__FUNCTION__] = getConfig('SLOGAN');
2113         } // END - if
2114
2115         // Return cache
2116         return $GLOBALS[__FUNCTION__];
2117 }
2118
2119 // "Getter" for copy
2120 function getCopy () {
2121         // Is there cache?
2122         if (!isset($GLOBALS[__FUNCTION__])) {
2123                 // Determine it
2124                 $GLOBALS[__FUNCTION__] = getConfig('COPY');
2125         } // END - if
2126
2127         // Return cache
2128         return $GLOBALS[__FUNCTION__];
2129 }
2130
2131 // "Getter" for webmaster
2132 function getWebmaster () {
2133         // Is there cache?
2134         if (!isset($GLOBALS[__FUNCTION__])) {
2135                 // Determine it
2136                 $GLOBALS[__FUNCTION__] = getConfig('WEBMASTER');
2137         } // END - if
2138
2139         // Return cache
2140         return $GLOBALS[__FUNCTION__];
2141 }
2142
2143 // "Getter" for sql_count
2144 function getSqlCount () {
2145         // Is there cache?
2146         if (!isset($GLOBALS[__FUNCTION__])) {
2147                 // Determine it
2148                 $GLOBALS[__FUNCTION__] = getConfig('sql_count');
2149         } // END - if
2150
2151         // Return cache
2152         return $GLOBALS[__FUNCTION__];
2153 }
2154
2155 // "Getter" for num_templates
2156 function getNumTemplates () {
2157         // Is there cache?
2158         if (!isset($GLOBALS[__FUNCTION__])) {
2159                 // Determine it
2160                 $GLOBALS[__FUNCTION__] = getConfig('num_templates');
2161         } // END - if
2162
2163         // Return cache
2164         return $GLOBALS[__FUNCTION__];
2165 }
2166
2167 // "Getter" for dns_cache_timeout
2168 function getDnsCacheTimeout () {
2169         // Is there cache?
2170         if (!isset($GLOBALS[__FUNCTION__])) {
2171                 // Determine it
2172                 $GLOBALS[__FUNCTION__] = getConfig('dns_cache_timeout');
2173         } // END - if
2174
2175         // Return cache
2176         return $GLOBALS[__FUNCTION__];
2177 }
2178
2179 // "Getter" for menu_blur_spacer
2180 function getMenuBlurSpacer () {
2181         // Is there cache?
2182         if (!isset($GLOBALS[__FUNCTION__])) {
2183                 // Determine it
2184                 $GLOBALS[__FUNCTION__] = getConfig('menu_blur_spacer');
2185         } // END - if
2186
2187         // Return cache
2188         return $GLOBALS[__FUNCTION__];
2189 }
2190
2191 // "Getter" for points_register
2192 function getPointsRegister () {
2193         // Is there cache?
2194         if (!isset($GLOBALS[__FUNCTION__])) {
2195                 // Determine it
2196                 $GLOBALS[__FUNCTION__] = getConfig('points_register');
2197         } // END - if
2198
2199         // Return cache
2200         return $GLOBALS[__FUNCTION__];
2201 }
2202
2203 // "Getter" for points_ref
2204 function getPointsRef () {
2205         // Is there cache?
2206         if (!isset($GLOBALS[__FUNCTION__])) {
2207                 // Determine it
2208                 $GLOBALS[__FUNCTION__] = getConfig('points_ref');
2209         } // END - if
2210
2211         // Return cache
2212         return $GLOBALS[__FUNCTION__];
2213 }
2214
2215 // "Getter" for ref_payout
2216 function getRefPayout () {
2217         // Is there cache?
2218         if (!isset($GLOBALS[__FUNCTION__])) {
2219                 // Determine it
2220                 $GLOBALS[__FUNCTION__] = getConfig('ref_payout');
2221         } // END - if
2222
2223         // Return cache
2224         return $GLOBALS[__FUNCTION__];
2225 }
2226
2227 // "Getter" for online_timeout
2228 function getOnlineTimeout () {
2229         // Is there cache?
2230         if (!isset($GLOBALS[__FUNCTION__])) {
2231                 // Determine it
2232                 $GLOBALS[__FUNCTION__] = getConfig('online_timeout');
2233         } // END - if
2234
2235         // Return cache
2236         return $GLOBALS[__FUNCTION__];
2237 }
2238
2239 // "Getter" for index_home
2240 function getIndexHome () {
2241         // Is there cache?
2242         if (!isset($GLOBALS[__FUNCTION__])) {
2243                 // Determine it
2244                 $GLOBALS[__FUNCTION__] = getConfig('index_home');
2245         } // END - if
2246
2247         // Return cache
2248         return $GLOBALS[__FUNCTION__];
2249 }
2250
2251 // "Getter" for one_day
2252 function getOneDay () {
2253         // Is there cache?
2254         if (!isset($GLOBALS[__FUNCTION__])) {
2255                 // Determine it
2256                 $GLOBALS[__FUNCTION__] = getConfig('ONE_DAY');
2257         } // END - if
2258
2259         // Return cache
2260         return $GLOBALS[__FUNCTION__];
2261 }
2262
2263 // "Getter" for img_type
2264 function getImgType () {
2265         // Is there cache?
2266         if (!isset($GLOBALS[__FUNCTION__])) {
2267                 // Determine it
2268                 $GLOBALS[__FUNCTION__] = getConfig('img_type');
2269         } // END - if
2270
2271         // Return cache
2272         return $GLOBALS[__FUNCTION__];
2273 }
2274
2275 // "Getter" for code_length
2276 function getCodeLength () {
2277         // Is there cache?
2278         if (!isset($GLOBALS[__FUNCTION__])) {
2279                 // Determine it
2280                 $GLOBALS[__FUNCTION__] = getConfig('code_length');
2281         } // END - if
2282
2283         // Return cache
2284         return $GLOBALS[__FUNCTION__];
2285 }
2286
2287 // "Getter" for min_password_length
2288 function getMinPasswordLength () {
2289         // Is there cache?
2290         if (!isset($GLOBALS[__FUNCTION__])) {
2291                 // Determine it
2292                 $GLOBALS[__FUNCTION__] = getConfig('min_password_length');
2293         } // END - if
2294
2295         // Return cache
2296         return $GLOBALS[__FUNCTION__];
2297 }
2298
2299 // "Getter" for min_password_score
2300 function getMinPasswordScore () {
2301         // Is there cache?
2302         if (!isset($GLOBALS[__FUNCTION__])) {
2303                 // Determine it
2304                 $GLOBALS[__FUNCTION__] = getConfig('min_password_score');
2305         } // END - if
2306
2307         // Return cache
2308         return $GLOBALS[__FUNCTION__];
2309 }
2310
2311 // "Getter" for admin_menu
2312 function getAdminMenu () {
2313         // Is there cache?
2314         if (!isset($GLOBALS[__FUNCTION__])) {
2315                 // Determine it
2316                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
2317         } // END - if
2318
2319         // Return cache
2320         return $GLOBALS[__FUNCTION__];
2321 }
2322
2323 // "Getter" for last_hourly
2324 function getLastHourly () {
2325         // Is there cache?
2326         if (!isset($GLOBALS[__FUNCTION__])) {
2327                 // Determine it
2328                 $GLOBALS[__FUNCTION__] = getConfig('last_hourly');
2329         } // END - if
2330
2331         // Return cache
2332         return $GLOBALS[__FUNCTION__];
2333 }
2334
2335 // "Getter" for last_daily
2336 function getLastDaily () {
2337         // Is there cache?
2338         if (!isset($GLOBALS[__FUNCTION__])) {
2339                 // Determine it
2340                 $GLOBALS[__FUNCTION__] = getConfig('last_daily');
2341         } // END - if
2342
2343         // Return cache
2344         return $GLOBALS[__FUNCTION__];
2345 }
2346
2347 // "Getter" for last_weekly
2348 function getLastWeekly () {
2349         // Is there cache?
2350         if (!isset($GLOBALS[__FUNCTION__])) {
2351                 // Determine it
2352                 $GLOBALS[__FUNCTION__] = getConfig('last_weekly');
2353         } // END - if
2354
2355         // Return cache
2356         return $GLOBALS[__FUNCTION__];
2357 }
2358
2359 // "Getter" for last_monthly
2360 function getLastMonthly () {
2361         // Is there cache?
2362         if (!isset($GLOBALS[__FUNCTION__])) {
2363                 // Determine it
2364                 $GLOBALS[__FUNCTION__] = getConfig('last_monthly');
2365         } // END - if
2366
2367         // Return cache
2368         return $GLOBALS[__FUNCTION__];
2369 }
2370
2371 // "Getter" for last_yearly
2372 function getLastYearly () {
2373         // Is there cache?
2374         if (!isset($GLOBALS[__FUNCTION__])) {
2375                 // Determine it
2376                 $GLOBALS[__FUNCTION__] = getConfig('last_yearly');
2377         } // END - if
2378
2379         // Return cache
2380         return $GLOBALS[__FUNCTION__];
2381 }
2382
2383 // "Getter" for mails_page
2384 function getMailsPage () {
2385         // Is there cache?
2386         if (!isset($GLOBALS[__FUNCTION__])) {
2387                 // Determine it
2388                 $GLOBALS[__FUNCTION__] = getConfig('mails_page');
2389         } // END - if
2390
2391         // Return cache
2392         return $GLOBALS[__FUNCTION__];
2393 }
2394
2395 // "Getter" for rand_no
2396 function getRandNo () {
2397         // Is there cache?
2398         if (!isset($GLOBALS[__FUNCTION__])) {
2399                 // Determine it
2400                 $GLOBALS[__FUNCTION__] = getConfig('rand_no');
2401         } // END - if
2402
2403         // Return cache
2404         return $GLOBALS[__FUNCTION__];
2405 }
2406
2407 // "Getter" for __DB_NAME
2408 function getDbName () {
2409         // Is there cache?
2410         if (!isset($GLOBALS[__FUNCTION__])) {
2411                 // Determine it
2412                 $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
2413         } // END - if
2414
2415         // Return cache
2416         return $GLOBALS[__FUNCTION__];
2417 }
2418
2419 // "Getter" for DOMAIN
2420 function getDomain () {
2421         // Is there cache?
2422         if (!isset($GLOBALS[__FUNCTION__])) {
2423                 // Determine it
2424                 $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
2425         } // END - if
2426
2427         // Return cache
2428         return $GLOBALS[__FUNCTION__];
2429 }
2430
2431 // "Getter" for proxy_username
2432 function getProxyUsername () {
2433         // Is there cache?
2434         if (!isset($GLOBALS[__FUNCTION__])) {
2435                 // Determine it
2436                 $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
2437         } // END - if
2438
2439         // Return cache
2440         return $GLOBALS[__FUNCTION__];
2441 }
2442
2443 // "Getter" for proxy_password
2444 function getProxyPassword () {
2445         // Is there cache?
2446         if (!isset($GLOBALS[__FUNCTION__])) {
2447                 // Determine it
2448                 $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
2449         } // END - if
2450
2451         // Return cache
2452         return $GLOBALS[__FUNCTION__];
2453 }
2454
2455 // "Getter" for proxy_host
2456 function getProxyHost () {
2457         // Is there cache?
2458         if (!isset($GLOBALS[__FUNCTION__])) {
2459                 // Determine it
2460                 $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
2461         } // END - if
2462
2463         // Return cache
2464         return $GLOBALS[__FUNCTION__];
2465 }
2466
2467 // "Getter" for proxy_port
2468 function getProxyPort () {
2469         // Is there cache?
2470         if (!isset($GLOBALS[__FUNCTION__])) {
2471                 // Determine it
2472                 $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
2473         } // END - if
2474
2475         // Return cache
2476         return $GLOBALS[__FUNCTION__];
2477 }
2478
2479 // "Getter" for SMTP_HOSTNAME
2480 function getSmtpHostname () {
2481         // Is there cache?
2482         if (!isset($GLOBALS[__FUNCTION__])) {
2483                 // Determine it
2484                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
2485         } // END - if
2486
2487         // Return cache
2488         return $GLOBALS[__FUNCTION__];
2489 }
2490
2491 // "Getter" for SMTP_USER
2492 function getSmtpUser () {
2493         // Is there cache?
2494         if (!isset($GLOBALS[__FUNCTION__])) {
2495                 // Determine it
2496                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
2497         } // END - if
2498
2499         // Return cache
2500         return $GLOBALS[__FUNCTION__];
2501 }
2502
2503 // "Getter" for SMTP_PASSWORD
2504 function getSmtpPassword () {
2505         // Is there cache?
2506         if (!isset($GLOBALS[__FUNCTION__])) {
2507                 // Determine it
2508                 $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
2509         } // END - if
2510
2511         // Return cache
2512         return $GLOBALS[__FUNCTION__];
2513 }
2514
2515 // "Getter" for points_word
2516 function getPointsWord () {
2517         // Is there cache?
2518         if (!isset($GLOBALS[__FUNCTION__])) {
2519                 // Determine it
2520                 $GLOBALS[__FUNCTION__] = getConfig('points_word');
2521         } // END - if
2522
2523         // Return cache
2524         return $GLOBALS[__FUNCTION__];
2525 }
2526
2527 // "Getter" for profile_lock
2528 function getProfileLock () {
2529         // Is there cache?
2530         if (!isset($GLOBALS[__FUNCTION__])) {
2531                 // Determine it
2532                 $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
2533         } // END - if
2534
2535         // Return cache
2536         return $GLOBALS[__FUNCTION__];
2537 }
2538
2539 // "Getter" for url_tlock
2540 function getUrlTlock () {
2541         // Is there cache?
2542         if (!isset($GLOBALS[__FUNCTION__])) {
2543                 // Determine it
2544                 $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
2545         } // END - if
2546
2547         // Return cache
2548         return $GLOBALS[__FUNCTION__];
2549 }
2550
2551 // "Getter" for title_left
2552 function getTitleLeft () {
2553         // Is there cache?
2554         if (!isset($GLOBALS[__FUNCTION__])) {
2555                 // Determine it
2556                 $GLOBALS[__FUNCTION__] = getConfig('title_left');
2557         } // END - if
2558
2559         // Return cache
2560         return $GLOBALS[__FUNCTION__];
2561 }
2562
2563 // "Getter" for title_right
2564 function getTitleRight () {
2565         // Is there cache?
2566         if (!isset($GLOBALS[__FUNCTION__])) {
2567                 // Determine it
2568                 $GLOBALS[__FUNCTION__] = getConfig('title_right');
2569         } // END - if
2570
2571         // Return cache
2572         return $GLOBALS[__FUNCTION__];
2573 }
2574
2575 // "Getter" for title_middle
2576 function getTitleMiddle () {
2577         // Is there cache?
2578         if (!isset($GLOBALS[__FUNCTION__])) {
2579                 // Determine it
2580                 $GLOBALS[__FUNCTION__] = getConfig('title_middle');
2581         } // END - if
2582
2583         // Return cache
2584         return $GLOBALS[__FUNCTION__];
2585 }
2586
2587 // Getter for 'display_home_in_index'
2588 function getDisplayHomeInIndex () {
2589         // Is the cache entry set?
2590         if (!isset($GLOBALS[__FUNCTION__])) {
2591                 // No, so determine it
2592                 $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index');
2593         } // END - if
2594
2595         // Return cached entry
2596         return $GLOBALS[__FUNCTION__];
2597 }
2598
2599 // Checks whether 'display_home_in_index' is 'Y'
2600 function isDisplayHomeInIndexEnabled () {
2601         // Is the cache entry set?
2602         if (!isset($GLOBALS[__FUNCTION__])) {
2603                 // No, so determine it
2604                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isConfigEntrySet('display_home_in_index')) && (getDisplayHomeInIndex() == 'Y'));
2605         } // END - if
2606
2607         // Return cached entry
2608         return $GLOBALS[__FUNCTION__];
2609 }
2610
2611 // Getter for 'show_points_unconfirmed'
2612 function getShowPointsUnconfirmed () {
2613         // Is the cache entry set?
2614         if (!isset($GLOBALS[__FUNCTION__])) {
2615                 // No, so determine it
2616                 $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed');
2617         } // END - if
2618
2619         // Return cached entry
2620         return $GLOBALS[__FUNCTION__];
2621 }
2622
2623 // Checks whether 'show_points_unconfirmed' is 'Y'
2624 function isShowPointsUnconfirmedEnabled () {
2625         // Is the cache entry set?
2626         if (!isset($GLOBALS[__FUNCTION__])) {
2627                 // No, so determine it
2628                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.5.5')) && (isConfigEntrySet('show_points_unconfirmed')) && (getShowPointsUnconfirmed() == 'Y'));
2629         } // END - if
2630
2631         // Return cached entry
2632         return $GLOBALS[__FUNCTION__];
2633 }
2634
2635 // Getter for 'youre_here'
2636 function getYoureHere () {
2637         // Is the cache entry set?
2638         if (!isset($GLOBALS[__FUNCTION__])) {
2639                 // No, so determine it
2640                 $GLOBALS[__FUNCTION__] = getConfig('youre_here');
2641         } // END - if
2642
2643         // Return cached entry
2644         return $GLOBALS[__FUNCTION__];
2645 }
2646
2647 // Checks whether 'show_timings' is 'Y'
2648 function isYoureHereEnabled () {
2649         // Is the cache entry set?
2650         if (!isset($GLOBALS[__FUNCTION__])) {
2651                 // No, so determine it
2652                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (isConfigEntrySet('youre_here')) && (getYoureHere() == 'Y'));
2653         } // END - if
2654
2655         // Return cached entry
2656         return $GLOBALS[__FUNCTION__];
2657 }
2658
2659 // Getter for 'show_timings'
2660 function getShowTimings () {
2661         // Is the cache entry set?
2662         if (!isset($GLOBALS[__FUNCTION__])) {
2663                 // No, so determine it
2664                 $GLOBALS[__FUNCTION__] = getConfig('show_timings');
2665         } // END - if
2666
2667         // Return cached entry
2668         return $GLOBALS[__FUNCTION__];
2669 }
2670
2671 // Checks whether 'show_timings' is 'Y'
2672 function isShowTimingsEnabled () {
2673         // Is the cache entry set?
2674         if (!isset($GLOBALS[__FUNCTION__])) {
2675                 // No, so determine it
2676                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isConfigEntrySet('show_timings')) && (getShowTimings() == 'Y'));
2677         } // END - if
2678
2679         // Return cached entry
2680         return $GLOBALS[__FUNCTION__];
2681 }
2682
2683 // Getter for 'ap_server_name_since'
2684 function getApServerNameSince () {
2685         // Is the cache entry set?
2686         if (!isset($GLOBALS[__FUNCTION__])) {
2687                 // No, so determine it
2688                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
2689         } // END - if
2690
2691         // Return cached entry
2692         return $GLOBALS[__FUNCTION__];
2693 }
2694
2695 // Getter for 'ap_server_name'
2696 function getApServerName () {
2697         // Is the cache entry set?
2698         if (!isset($GLOBALS[__FUNCTION__])) {
2699                 // No, so determine it
2700                 $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
2701         } // END - if
2702
2703         // Return cached entry
2704         return $GLOBALS[__FUNCTION__];
2705 }
2706
2707 // Getter for 'index_delay'
2708 function getIndexDelay () {
2709         // Is the cache entry set?
2710         if (!isset($GLOBALS[__FUNCTION__])) {
2711                 // No, so determine it
2712                 $GLOBALS[__FUNCTION__] = getConfig('index_delay');
2713         } // END - if
2714
2715         // Return cached entry
2716         return $GLOBALS[__FUNCTION__];
2717 }
2718
2719 // Checks whether 'ap_server_name' is 'Y'
2720 function isApServerNameEnabled () {
2721         // Is the cache entry set?
2722         if (!isset($GLOBALS[__FUNCTION__])) {
2723                 // No, so determine it
2724                 $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
2725         } // END - if
2726
2727         // Return cached entry
2728         return $GLOBALS[__FUNCTION__];
2729 }
2730
2731 // Getter for 'admin_menu_javascript'
2732 function getAdminMenuJavascript () {
2733         // Is the cache entry set?
2734         if (!isset($GLOBALS[__FUNCTION__])) {
2735                 // No, so determine it
2736                 $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
2737         } // END - if
2738
2739         // Return cached entry
2740         return $GLOBALS[__FUNCTION__];
2741 }
2742
2743 // Getter for 'points_remove_account'
2744 function getPointsRemoveAccount () {
2745         // Is the cache entry set?
2746         if (!isset($GLOBALS[__FUNCTION__])) {
2747                 // No, so determine it
2748                 $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
2749         } // END - if
2750
2751         // Return cached entry
2752         return $GLOBALS[__FUNCTION__];
2753 }
2754
2755 // Getter for 'css_php'
2756 function getCssPhp () {
2757         // Is the cache entry set?
2758         if (!isset($GLOBALS[__FUNCTION__])) {
2759                 // No, so determine it
2760                 $GLOBALS[__FUNCTION__] = getConfig('css_php');
2761         } // END - if
2762
2763         // Return cached entry
2764         return $GLOBALS[__FUNCTION__];
2765 }
2766
2767 // Getter for 'guest_menu'
2768 function getGuestMenu () {
2769         // Is the cache entry set?
2770         if (!isset($GLOBALS[__FUNCTION__])) {
2771                 // No, so determine it
2772                 $GLOBALS[__FUNCTION__] = getConfig('guest_menu');
2773         } // END - if
2774
2775         // Return cached entry
2776         return $GLOBALS[__FUNCTION__];
2777 }
2778
2779 // Checks if guest menu is enabled
2780 function isGuestMenuEnabled () {
2781         // Is the cache entry set?
2782         if (!isset($GLOBALS[__FUNCTION__])) {
2783                 // No, so determine it
2784                 $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y');
2785         } // END - if
2786
2787         // Return cached entry
2788         return $GLOBALS[__FUNCTION__];
2789 }
2790
2791 // Getter for 'member_menu'
2792 function getMemberMenu () {
2793         // Is the cache entry set?
2794         if (!isset($GLOBALS[__FUNCTION__])) {
2795                 // No, so determine it
2796                 $GLOBALS[__FUNCTION__] = getConfig('member_menu');
2797         } // END - if
2798
2799         // Return cached entry
2800         return $GLOBALS[__FUNCTION__];
2801 }
2802
2803 // Checks if member menu is enabled
2804 function isMemberMenuEnabled () {
2805         // Is the cache entry set?
2806         if (!isset($GLOBALS[__FUNCTION__])) {
2807                 // No, so determine it
2808                 $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y');
2809         } // END - if
2810
2811         // Return cached entry
2812         return $GLOBALS[__FUNCTION__];
2813 }
2814
2815 // Getter for 'word_wrap'
2816 function getWordWrap () {
2817         // Is the cache entry set?
2818         if (!isset($GLOBALS[__FUNCTION__])) {
2819                 // Construct config entry name
2820                 $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat();
2821
2822                 // Is a special config entry found or ext-sql_patches updated?
2823                 if (isConfigEntrySet($configEntry)) {
2824                         // A special config entry has been found, then use it
2825                         $GLOBALS[__FUNCTION__] = getConfig($configEntry);
2826                 } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) {
2827                         // No special config entry found, then use it as "fall-back"
2828                         $GLOBALS[__FUNCTION__] = getConfig('word_wrap');
2829                 } else {
2830                         // No, use default (15 characters)
2831                         $GLOBALS[__FUNCTION__] = 15;
2832                 }
2833         } // END - if
2834
2835         // Return cached entry
2836         return $GLOBALS[__FUNCTION__];
2837 }
2838
2839 // Checks whether proxy configuration is used
2840 function isProxyUsed () {
2841         // Is there cache?
2842         if (!isset($GLOBALS[__FUNCTION__])) {
2843                 // Determine it
2844                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (isValidNumber(getConfig('proxy_port'))));
2845         } // END - if
2846
2847         // Return cache
2848         return $GLOBALS[__FUNCTION__];
2849 }
2850
2851 // Checks whether POST data contains selections
2852 function ifPostContainsSelections ($element = 'sel') {
2853         // Is there cache?
2854         if (!isset($GLOBALS[__FUNCTION__][$element])) {
2855                 // Determine it
2856                 $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
2857         } // END - if
2858
2859         // Return cache
2860         return $GLOBALS[__FUNCTION__][$element];
2861 }
2862
2863 // Checks whether verbose_sql is Y and returns true/false if so
2864 function isVerboseSqlEnabled () {
2865         // Is there cache?
2866         if (!isset($GLOBALS[__FUNCTION__])) {
2867                 // Determine it
2868                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
2869         } // END - if
2870
2871         // Return cache
2872         return $GLOBALS[__FUNCTION__];
2873 }
2874
2875 // "Getter" for total user points
2876 function getTotalPoints ($userid) {
2877         // Is there cache?
2878         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2879                 // Init array for filter chain
2880                 $data = array(
2881                         'userid' => $userid,
2882                         'points' => 0
2883                 );
2884
2885                 // Run filter chain for getting more point values
2886                 $data = runFilterChain('get_total_points', $data);
2887
2888                 // Determine it
2889                 $GLOBALS[__FUNCTION__][$userid] = $data['points']  - getUserUsedPoints($userid);
2890         } // END - if
2891
2892         // Return cache
2893         return $GLOBALS[__FUNCTION__][$userid];
2894 }
2895
2896 // Wrapper to get used points for given userid
2897 function getUserUsedPoints ($userid) {
2898         // Is there cache?
2899         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
2900                 // Determine it
2901                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
2902         } // END - if
2903
2904         // Return cache
2905         return $GLOBALS[__FUNCTION__][$userid];
2906 }
2907
2908 // Checks whether direct payment is allowed in configuration
2909 function isDirectPaymentEnabled () {
2910         // Is there cache?
2911         if (!isset($GLOBALS[__FUNCTION__])) {
2912                 // Determine it
2913                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('allow_direct_pay')) && (getConfig('allow_direct_pay') == 'Y'));
2914         } // END - if
2915
2916         // Return cache
2917         return $GLOBALS[__FUNCTION__];
2918 }
2919
2920 // Checks whether JavaScript-based admin menu is enabled
2921 function isAdminMenuJavascriptEnabled () {
2922         // Is there cache?
2923         if (!isset($GLOBALS[__FUNCTION__])) {
2924                 // Determine it
2925                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (isConfigEntrySet('admin_menu_javascript')) && (getAdminMenuJavaScript() == 'Y'));
2926         } // END - if
2927
2928         // Return cache
2929         return $GLOBALS[__FUNCTION__];
2930 }
2931
2932 // Wrapper to check if current task is for extension (not update)
2933 function isExtensionTask ($content) {
2934         // Is there cache?
2935         if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
2936                 // Determine it
2937                 $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
2938         } // END - if
2939
2940         // Return cache
2941         return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']];
2942 }
2943
2944 // Checks whether ALLOW_TESTER_ACCOUNTS is set
2945 function ifTesterAccountsAllowed () {
2946         // Is the cache entry set?
2947         if (!isset($GLOBALS[__FUNCTION__])) {
2948                 // No, so determine it
2949                 $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
2950         } // END - if
2951
2952         // Return cached entry
2953         return $GLOBALS[__FUNCTION__];
2954 }
2955
2956 // Wrapper to check if output mode is CSS
2957 function isCssOutputMode () {
2958         // Is cache set?
2959         if (!isset($GLOBALS[__FUNCTION__])) {
2960                 // Determine it
2961                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2962                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
2963         } // END - if
2964
2965         // Return cache
2966         return $GLOBALS[__FUNCTION__];
2967 }
2968
2969 // Wrapper to check if output mode is HTML
2970 function isHtmlOutputMode () {
2971         // Is cache set?
2972         if (!isset($GLOBALS[__FUNCTION__])) {
2973                 // Determine it
2974                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2975                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
2976         } // END - if
2977
2978         // Return cache
2979         return $GLOBALS[__FUNCTION__];
2980 }
2981
2982 // Wrapper to check if output mode is RAW
2983 function isRawOutputMode () {
2984         // Is cache set?
2985         if (!isset($GLOBALS[__FUNCTION__])) {
2986                 // Determine it
2987                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
2988                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
2989         } // END - if
2990
2991         // Return cache
2992         return $GLOBALS[__FUNCTION__];
2993 }
2994
2995 // Wrapper to check if output mode is AJAX
2996 function isAjaxOutputMode () {
2997         // Is cache set?
2998         if (!isset($GLOBALS[__FUNCTION__])) {
2999                 // Determine it
3000                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
3001                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
3002         } // END - if
3003
3004         // Return cache
3005         return $GLOBALS[__FUNCTION__];
3006 }
3007
3008 // Wrapper to check if output mode is image
3009 function isImageOutputMode () {
3010         // Is cache set?
3011         if (!isset($GLOBALS[__FUNCTION__])) {
3012                 // Determine it
3013                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
3014                 $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
3015         } // END - if
3016
3017         // Return cache
3018         return $GLOBALS[__FUNCTION__];
3019 }
3020
3021 // Wrapper to generate a user email link
3022 function generateWrappedUserEmailLink ($email) {
3023         // Just call the inner function
3024         return generateEmailLink($email, 'user_data');
3025 }
3026
3027 // Wrapper to check if user points are locked
3028 function ifUserPointsLocked ($userid) {
3029         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
3030         // Is there cache?
3031         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3032                 // Determine it
3033                 $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
3034         } // END - if
3035
3036         // Return cache
3037         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
3038         return $GLOBALS[__FUNCTION__][$userid];
3039 }
3040
3041 // Appends a line to an existing file or creates it instantly with given content.
3042 // This function does always add a new-line character to every line.
3043 function appendLineToFile ($file, $line) {
3044         $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
3045         fwrite($fp, $line . PHP_EOL);
3046         fclose($fp);
3047 }
3048
3049 // Wrapper for changeDataInFile() but with full path added
3050 function changeDataInInclude ($inc, $comment, $prefix, $suffix, $inserted, $seek=0) {
3051         // Add full path
3052         $FQFN = getPath() . $inc;
3053
3054         // Call inner function
3055         return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
3056 }
3057
3058 // Wrapper for changing entries in config-local.php
3059 function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
3060         // Call the inner function
3061         return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
3062 }
3063
3064 // Shortens ucfirst(strtolower()) calls
3065 function firstCharUpperCase ($str) {
3066         return ucfirst(strtolower($str));
3067 }
3068
3069 // Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
3070 function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
3071         // Get the configuration entry
3072         $configValue = getConfig($configEntry);
3073
3074         // Call inner method
3075         return createTimeSelections($configValue, $configEntry, $stamps, $align);
3076 }
3077
3078 // Shortens converting of German comma to Computer's version in POST data
3079 function convertCommaToDotInPostData ($postEntry) {
3080         // Read and convert given entry
3081         $postValue = convertCommaToDot(postRequestElement($postEntry));
3082
3083         // Log message
3084         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue);
3085
3086         // ... and set it again
3087         setPostRequestElement($postEntry, $postValue);
3088 }
3089
3090 // Converts German commas to Computer's version in all entries
3091 function convertCommaToDotInPostDataArray ($postEntries) {
3092         // Replace german decimal comma with computer decimal dot
3093         foreach ($postEntries as $entry) {
3094                 // Is the entry there?
3095                 if (isPostRequestElementSet($entry)) {
3096                         // Then convert it
3097                         convertCommaToDotInPostData($entry);
3098                 } // END - if
3099         } // END - foreach
3100 }
3101
3102 /**
3103  * Parses a string into a US formated float variable, taken from user comments
3104  * from PHP documentation website.
3105  *
3106  * @param       $floatString    A string holding a float expression
3107  * @return      $float                  Corresponding float variable
3108  * @author      chris<at>georgakopoulos<dot>com
3109  * @link        http://de.php.net/manual/en/function.floatval.php#92563
3110  */
3111 function parseFloat ($floatString){
3112         // Load locale info
3113         $LocaleInfo = localeconv();
3114
3115         // Remove thousand separators
3116         $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
3117
3118         // Convert decimal point
3119         $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
3120
3121         // Return float value of converted string
3122         return floatval($floatString);
3123 }
3124
3125 /**
3126  * Searches a multi-dimensional array (as used in many places) for given
3127  * key/value pair as taken from user comments from PHP documentation website.
3128  *
3129  * @param       $array                  An array with one or more dimensions
3130  * @param       $key                    Key to look for
3131  * @param       $value                  Value to look for
3132  * @param       $parentIndex    Parent index (ONLY INTERNAL USE!)
3133  * @return      $results                Resulted array or empty array if $array is no array
3134  * @author      sunelbe<at>gmail<dot>com
3135  * @link        http://de.php.net/manual/en/function.array-search.php#110120
3136  */
3137 function search_array ($array, $key, $value, $parentIndex = NULL) {
3138         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!');
3139         // Init array result
3140         $results = array();
3141
3142         // Is $array really an array?
3143         if (is_array($array)) {
3144                 // Search for whole array
3145                 foreach ($array as $idx => $dummy) {
3146                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex);
3147                         //* DEBUG: */ print 'idx=' . $idx . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',key=' . $key . ',value=' . $value . ',array=<pre>'.print_r($array, TRUE).'</pre>';
3148                         // Is dummy an array?
3149                         if ((is_array($dummy)) && ((is_null($parentIndex)) || ($parentIndex === $value))) {
3150                                 // Then search again
3151                                 $subResult = search_array($dummy, $key, $value, $idx);
3152                                 //* DEBUG: */ print 'subResult=<pre>' . print_r($subResult, TRUE).'</pre>';
3153
3154                                 // And merge both
3155                                 $results = merge_array($results, $subResult, TRUE);
3156                         } elseif (($key == $idx) && (isset($array[$key])) && ($array[$key] === $value)) {
3157                                 // Is found, so add it
3158                                 $results[$parentIndex] = $array;
3159                                 //* DEBUG: */ print 'ARRAY: key=' . $key . ',idx=' . $idx . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . ']=' . $parentIndex . ',array=<pre>' . print_r($array, TRUE).'</pre>';
3160                         }
3161                 } // END - foreach
3162         } // END - if
3163
3164         // Return resulting array
3165         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!');
3166         return $results;
3167 }
3168
3169 // Generates a YES/NO option list from given default
3170 function generateYesNoOptions ($defaultValue = '') {
3171         // Generate it
3172         return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
3173 }
3174
3175 // "Getter" for total available receivers
3176 function getTotalReceivers ($mode = 'normal') {
3177         // Get num rows
3178         $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', TRUE, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
3179
3180         // Return value
3181         return $numRows;
3182 }
3183
3184 // Wrapper "getter" to get total unconfirmed mails for given userid
3185 function getTotalUnconfirmedMails ($userid) {
3186         // Is there cache?
3187         if (!isset($GLOBALS[__FUNCTION__][$userid])) {
3188                 // Determine it
3189                 $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', TRUE);
3190         } // END - if
3191
3192         // Return cache
3193         return $GLOBALS[__FUNCTION__][$userid];
3194 }
3195
3196 // Checks whether 'mailer_theme' was found in session
3197 function isMailerThemeSet () {
3198         // Is cache set?
3199         if (!isset($GLOBALS[__FUNCTION__])) {
3200                 // Determine it
3201                 $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
3202         } // END - if
3203
3204         // Return cache
3205         return $GLOBALS[__FUNCTION__];
3206 }
3207
3208 /**
3209  * Setter for theme in session (This setter does return the success of
3210  * setSession() which is required e.g. for destroySponsorSession().
3211  */
3212 function setMailerTheme ($newTheme) {
3213         // Set it in session
3214         return setSession('mailer_theme', $newTheme);
3215 }
3216
3217 /**
3218  * Getter for theme from session (This getter does return 'mailer_theme' from
3219  * session data or throws an error if not possible
3220  */
3221 function getMailerTheme () {
3222         // Is cache set?
3223         if (!isset($GLOBALS[__FUNCTION__])) {
3224                 // Is 'mailer_theme' set?
3225                 if (!isMailerThemeSet()) {
3226                         // No, then abort here
3227                         reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
3228                 } // END - if
3229
3230                 // Get it and store it in cache
3231                 $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
3232         } // END - if
3233
3234         // Return cache
3235         return $GLOBALS[__FUNCTION__];
3236 }
3237
3238 // "Getter" for last_module/last_what depending on ext-user version
3239 function getUserLastWhatName () {
3240         // Default is old one: last_module
3241         $columnName = 'last_module';
3242
3243         // Is ext-user up-to-date?
3244         if (isExtensionInstalledAndNewer('user', '0.4.9')) {
3245                 // Yes, then use new one
3246                 $columnName = 'last_what';
3247         } // END - if
3248
3249         // Return it
3250         return $columnName;
3251 }
3252
3253 // "Getter" for all columns for given alias and separator
3254 function getAllPointColumns ($alias = NULL, $separator = ',') {
3255         // Prepare the filter array
3256         $filterData = array(
3257                 'columns'   => '',
3258                 'alias'     => $alias,
3259                 'separator' => $separator
3260         );
3261
3262         // Run the filter
3263         $filterData = runFilterChain('get_all_point_columns', $filterData);
3264
3265         // Return the columns
3266         return $filterData['columns'];
3267 }
3268
3269 // Checks whether the copyright footer (which breaks framesets) is enabled
3270 function ifCopyrightFooterEnabled () {
3271         // Is not unset and not 'N'?
3272         return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
3273 }
3274
3275 /**
3276  * Wrapper to check whether we have a "full page". This means that the actual
3277  * content is not delivered in any frame of a frameset.
3278  */
3279 function isFullPage () {
3280         /*
3281          * The parameter 'frame' is generic and always indicates that this content
3282          * will be output into a frame. Furthermore, if a frameset is reported or
3283          * the copyright line is explicitly deactivated, this cannot be a "full
3284          * page" again.
3285          */
3286         // @TODO Find a way to not use direct module comparison
3287         $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
3288
3289         // Return it
3290         return $isFullPage;
3291 }
3292
3293 // Checks whether frameset_mode is set to true
3294 function isFramesetModeEnabled () {
3295         // Check it
3296         return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === TRUE));
3297 }
3298
3299 // Function to determine correct 'what' value
3300 function determineWhat ($module = NULL) {
3301         // Init default 'what'
3302         $what = 'welcome';
3303
3304         // Is module NULL?
3305         if (is_null($module)) {
3306                 // Then use default
3307                 $module = getModule();
3308         } // END - if
3309
3310         // Is what set?
3311         if (isWhatSet()) {
3312                 // Then use it
3313                 $what = getWhat();
3314         } else {
3315                 // Else try to get it from current module
3316                 $what = getWhatFromModule($module);
3317         }
3318         //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
3319
3320         // Remove any spaces from variable
3321         $what = trim($what);
3322
3323         // Is it empty?
3324         if (empty($what)) {
3325                 // Default action for non-admin menus
3326                 $what = 'welcome';
3327         } else {
3328                 // Secure it
3329                 $what = secureString($what);
3330         }
3331
3332         // Return what
3333         return $what;
3334 }
3335
3336 // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
3337 function prependZeros ($str, $length = 2) {
3338         // Return prepended string
3339         return sprintf('%0' . (int) $length . 's', $str);
3340 }
3341
3342 // Wraps convertSelectionsToEpocheTime()
3343 function convertSelectionsToEpocheTimeInPostData ($id) {
3344         // Init variables
3345         $content = array();
3346         $skip = FALSE;
3347
3348         // Get all POST data
3349         $postData = postRequestArray();
3350
3351         // Convert given selection id
3352         convertSelectionsToEpocheTime($postData, $content, $id, $skip);
3353
3354         // Set the POST array back
3355         setPostRequestArray($postData);
3356 }
3357
3358 // Wraps checking if given points account type matches with given in POST data
3359 function ifPointsAccountTypeMatchesPost ($type) {
3360         // Check condition
3361         exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
3362 }
3363
3364 // Gets given user's total referral
3365 function getUsersTotalReferrals ($userid, $level = NULL) {
3366         // Is there cache?
3367         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3368                 // Is the level NULL?
3369                 if (is_null($level)) {
3370                         // Get total amount (all levels)
3371                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE);
3372                 } else {
3373                         // Get it from user refs
3374                         $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', TRUE, ' AND `level`=' . bigintval($level));
3375                 }
3376         } // END - if
3377
3378         // Return it
3379         return $GLOBALS[__FUNCTION__][$userid][$level];
3380 }
3381
3382 // Gets given user's total referral
3383 function getUsersTotalLockedReferrals ($userid, $level = NULL) {
3384         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
3385         // Is there cache?
3386         if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
3387                 // Default is all refs
3388                 $add = '';
3389
3390                 // Is the not level NULL?
3391                 if (!is_null($level)) {
3392                         // Then add referral level
3393                         $add = ' AND `r`.`level`=' . bigintval($level);
3394                 } // END - if
3395
3396                 // Check for all referrals
3397                 $result = sqlQueryEscaped("SELECT
3398         COUNT(`d`.`userid`) AS `cnt`
3399 FROM
3400         `{?_MYSQL_PREFIX?}_user_data` AS `d`
3401 INNER JOIN
3402         `{?_MYSQL_PREFIX?}_user_refs` AS `r`
3403 ON
3404         `d`.`userid`=`r`.`refid`
3405 WHERE
3406         `d`.`status` != 'CONFIRMED' AND
3407         `r`.`userid`=%s
3408         " . $add . "
3409 ORDER BY
3410         `d`.`userid` ASC
3411 LIMIT 1",
3412                         array(
3413                                 $userid
3414                         ), __FUNCTION__, __LINE__);
3415
3416                 // Load count
3417                 list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
3418
3419                 // Free result
3420                 sqlFreeResult($result);
3421         } // END - if
3422
3423         // Return it
3424         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
3425         return $GLOBALS[__FUNCTION__][$userid][$level];
3426 }
3427
3428 // Converts, if found, dollar data to get element
3429 function convertDollarDataToGetElement ($data) {
3430         // Is first char a dollar?
3431         if (substr($data, 0, 1) == chr(36)) {
3432                 // Use last part for getRequestElement()
3433                 $data = getRequestElement(substr($data, 1));
3434         } // END - if
3435
3436         // Return it
3437         return $data;
3438 }
3439
3440 // Wrapper function for SQL layer to speed-up things
3441 function isSqlDebugEnabled () {
3442         // Is there cache?
3443         if (!isset($GLOBALS[__FUNCTION__])) {
3444                 // Determine it
3445                 $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
3446         } // END - if
3447
3448         // Return cache
3449         return $GLOBALS[__FUNCTION__];
3450 }
3451
3452 // Wrapper function to wrap call of wordwrap()
3453 function wrapWords ($text) {
3454         // Wrap words
3455         $wrapped = wordwrap($test, getWordWrap());
3456
3457         // Return it
3458         return $wrapped;
3459 }
3460
3461 // Encodes given data into a JSON object
3462 function encodeJson ($data) {
3463         // Encode it
3464         return json_encode($data, JSON_FORCE_OBJECT);
3465 }
3466
3467 // Get all extension files
3468 function loadAllExtensionsByTemplate () {
3469         // Get all
3470         $extensions = getArrayFromDirectory(
3471                 'templates/' . getLanguage() . '/html/ext/',
3472                 'ext_',
3473                 false,
3474                 false,
3475                 array(),
3476                 '.tpl',
3477                 '@(\.|\.\.)$@',
3478                 false
3479         );
3480
3481         // Return them
3482         return $extensions;
3483 }
3484
3485 // Wrapper function to allow full float values as supported by current database layout
3486 function translateFullComma ($dotted) {
3487         // Call inner function
3488         return translateComma($dotted, TRUE, 5);
3489 }
3490
3491 // Wrapper to check if the first element to be shifted is set to given value
3492 function shift_array (&$array, $value, $key = '0') {
3493         // Is the element set and value matches?
3494         assert(is_array($array));
3495         assert(isset($array[$key]));
3496         assert($array[$key] === $value);
3497
3498         // Shift it
3499         array_shift($array);
3500 }
3501
3502 // Wrapper for str_pad() with left padding zeros
3503 function padLeftZero ($str, $amount = 2) {
3504         // Is str_pad() there?
3505         if (!function_exists('str_pad')) {
3506                 // Use prependZeros()
3507                 return prependZeros($str, $amount);
3508         } else {
3509                 // Pad it
3510                 return str_pad($str, $amount, '0', STR_PAD_LEFT);
3511         }
3512 }
3513
3514 // Calculates percentage
3515 function calculatePercentageRate ($current, $total) {
3516         // Default is zero
3517         $rate = '0.0';
3518
3519         // Is sent larger zero? (Prevents division-by-zero)
3520         if ($total > 0) {
3521                 // Calculate it (it should be "translated" alter on)
3522                 $rate = ($current / $total * 100);
3523         } // END - if
3524
3525         // The should be a .0 at the end?
3526         if (strpos($rate, '.') === FALSE) {
3527                 // No, then add it
3528                 $rate .= '.0';
3529         } // END - if
3530
3531         // Return it
3532         return $rate;
3533 }
3534
3535 // Checks whether an array is filled with entries
3536 function isFilledArray ($array) {
3537         // Determine it
3538         return ((is_array($array)) && (count($array) > 0));
3539 }
3540
3541 // Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
3542 function isDeveloperSystem () {
3543         // Determine it
3544         return in_array(detectServerName(), array('localhost', '127.0.0.1'));
3545 }
3546
3547 // Checks whether given subject line has '_ref' suffix
3548 function ifSubjectHasReferralSuffix ($subject) {
3549         // Is there cache?
3550         if (!isset($GLOBALS[__FUNCTION__][$subject])) {
3551                 // Determine it
3552                 $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
3553         } // END - if
3554
3555         // Return cache
3556         return $GLOBALS[__FUNCTION__][$subject];
3557 }
3558
3559 // [EOF]
3560 ?>