]> git.mxchange.org Git - mailer.git/blob - inc/wrapper-functions.php
Some more rewrites and fix for countPostSelection()
[mailer.git] / inc / wrapper-functions.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 04/04/2009 *
4  * ===============                              Last change: 04/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : wrapper-functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Wrapper functions                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Wrapper-Funktionen                               *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Read a given file
45 function readFromFile ($FQFN, $sqlPrepare = false) {
46         // Sanity-check if file is there (should be there, but just to make it sure)
47         if (!isFileReadable($FQFN)) {
48                 // This should not happen
49                 debug_report_bug(__FUNCTION__.': File ' . basename($FQFN) . ' is not readable!');
50         } // END - if
51
52         // Load the file
53         if (function_exists('file_get_contents')) {
54                 // Use new function
55                 $content = file_get_contents($FQFN);
56         } else {
57                 // Fall-back to implode-file chain
58                 $content = implode('', file($FQFN));
59         }
60
61         // Prepare SQL queries?
62         if ($sqlPrepare === true) {
63                 // Remove some unwanted chars
64                 $content = str_replace("\r", '', $content);
65                 $content = str_replace("\n\n", "\n", $content);
66         } // END - if
67
68         // Return the content
69         return $content;
70 }
71
72 // Writes content to a file
73 function writeToFile ($FQFN, $content, $aquireLock = false) {
74         // Is the file writeable?
75         if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
76                 // Not writeable!
77                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
78
79                 // Failed! :(
80                 return false;
81         } // END - if
82
83         // By default all is failed...
84         $return = false;
85
86         // Is the function there?
87         if (function_exists('file_put_contents')) {
88                 // With lock?
89                 if ($aquireLock === true) {
90                         // Write it directly with lock
91                         $return = file_put_contents($FQFN, $content, LOCK_EX);
92                 } else {
93                         // Write it directly
94                         $return = file_put_contents($FQFN, $content);
95                 }
96         } else {
97                 // Write it with fopen
98                 $fp = fopen($FQFN, 'w') or app_die(__FUNCTION__, __LINE__, "Cannot write file ".basename($FQFN).'!');
99
100                 // Aquire lock
101                 if ($aquireLock === true) flock($fp, LOCK_EX);
102
103                 // Write content
104                 fwrite($fp, $content);
105
106                 // Close stream
107                 fclose($fp);
108         }
109
110         // Mark it as readable
111         $GLOBALS['file_readable'][$FQFN] = true;
112
113         // Return status
114         return changeMode($FQFN, 0644);
115 }
116
117 // Clears the output buffer. This function does *NOT* backup sent content.
118 function clearOutputBuffer () {
119         // Trigger an error on failure
120         if (!ob_end_clean()) {
121                 // Failed!
122                 debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
123         } // END - if
124 }
125
126 // Encode strings
127 // @TODO Implement $compress
128 function encodeString ($str, $compress = true) {
129         $str = urlencode(base64_encode(compileUriCode($str)));
130         return $str;
131 }
132
133 // Decode strings encoded with encodeString()
134 // @TODO Implement $decompress
135 function decodeString ($str, $decompress = true) {
136         $str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
137         return $str;
138 }
139
140 // Smartly adds slashes
141 function smartAddSlashes ($unquoted) {
142         // Do we have cache?
143         if (!isset($GLOBALS['smart_addslashes'][$unquoted])) {
144                 // Remove slashe
145                 $unquoted = str_replace("\\", '', $unquoted);
146
147                 // Put it in cache and add slashes
148                 $GLOBALS['smart_addslashes'][$unquoted] = addslashes($unquoted);
149         } // END - if
150
151         // Return result
152         return $GLOBALS['smart_addslashes'][$unquoted];
153 }
154
155 // Decode entities in a nicer way
156 function decodeEntities ($str) {
157         // Decode the entities to UTF-8 now
158         $decodedString = html_entity_decode($str, ENT_NOQUOTES, 'UTF-8');
159
160         // Return decoded string
161         return $decodedString;
162 }
163
164 // Merges an array together but only if both are arrays
165 function merge_array ($array1, $array2) {
166         // Are both an array?
167         if ((!is_array($array1)) && (!is_array($array2))) {
168                 // Both are not arrays
169                 debug_report_bug(__FUNCTION__ . ': No arrays provided!');
170         } elseif (!is_array($array1)) {
171                 // Left one is not an array
172                 debug_report_bug(sprintf("[%s:%s] array1 is not an array. array != %s", __FUNCTION__, __LINE__, gettype($array1)));
173         } elseif (!is_array($array2)) {
174                 // Right one is not an array
175                 debug_report_bug(sprintf("[%s:%s] array2 is not an array. array != %s", __FUNCTION__, __LINE__, gettype($array2)));
176         }
177
178         // Merge all together
179         return array_merge($array1, $array2);
180 }
181
182 // Check if given FQFN is a readable file
183 function isFileReadable ($FQFN) {
184         // Do we have cache?
185         if (!isset($GLOBALS['file_readable'][$FQFN])) {
186                 // Check all...
187                 $GLOBALS['file_readable'][$FQFN] = ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
188         } // END - if
189
190         // Return result
191         return $GLOBALS['file_readable'][$FQFN];
192 }
193
194 // Checks wether the given FQFN is a directory and not ., .. or .svn
195 function isDirectory ($FQFN) {
196         // Do we have cache?
197         if (!isset($GLOBALS['is_directory'][$FQFN])) {
198                 // Generate baseName
199                 $baseName = basename($FQFN);
200
201                 // Check it
202                 $GLOBALS['is_directory'][$FQFN] = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
203         } // END - if
204
205         // Return the result
206         return $GLOBALS['is_directory'][$FQFN];
207 }
208
209 // "Getter" for remote IP number
210 function detectRemoteAddr () {
211         // Get remote ip from environment
212         $remoteAddr = determineRealRemoteAddress();
213
214         // Is removeip installed?
215         if (isExtensionActive('removeip')) {
216                 // Then anonymize it
217                 $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
218         } // END - if
219
220         // Return it
221         return $remoteAddr;
222 }
223
224 // "Getter" for remote hostname
225 function detectRemoteHostname () {
226         // Get remote ip from environment
227         $remoteHost = getenv('REMOTE_HOST');
228
229         // Is removeip installed?
230         if (isExtensionActive('removeip')) {
231                 // Then anonymize it
232                 $remoteHost = getAnonymousRemoteHost($remoteHost);
233         } // END - if
234
235         // Return it
236         return $remoteHost;
237 }
238
239 // "Getter" for user agent
240 function detectUserAgent () {
241         // Get remote ip from environment
242         $userAgent = getenv('HTTP_USER_AGENT');
243
244         // Is removeip installed?
245         if (isExtensionActive('removeip')) {
246                 // Then anonymize it
247                 $userAgent = getAnonymousUserAgent($userAgent);
248         } // END - if
249
250         // Return it
251         return $userAgent;
252 }
253
254 // "Getter" for referer
255 function detectReferer () {
256         // Get remote ip from environment
257         $referer = getenv('HTTP_REFERER');
258
259         // Is removeip installed?
260         if (isExtensionActive('removeip')) {
261                 // Then anonymize it
262                 $referer = getAnonymousReferer($referer);
263         } // END - if
264
265         // Return it
266         return $referer;
267 }
268
269 // Check wether we are installing
270 function isInstalling () {
271         // Determine wether we are installing
272         if (!isset($GLOBALS['mxchange_installing'])) {
273                 // Check URL (css.php/js.php need this)
274                 $GLOBALS['mxchange_installing'] = isGetRequestElementSet('installing');
275         } // END - if
276
277         // Return result
278         return $GLOBALS['mxchange_installing'];
279 }
280
281 // Check wether this script is installed
282 function isInstalled () {
283         // Do we have cache?
284         if (!isset($GLOBALS['is_installed'])) {
285                 // Determine wether this script is installed
286                 $GLOBALS['is_installed'] = (
287                 (
288                         // First is config
289                         (
290                                 (
291                                         isConfigEntrySet('MXCHANGE_INSTALLED')
292                                 ) && (
293                                         getConfig('MXCHANGE_INSTALLED') == 'Y'
294                                 )
295                         )
296                 ) || (
297                         // New config file found and loaded
298                         isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')
299                 ) || (
300                         (
301                                 // New config file found, but not yet read
302                                 isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')
303                         ) && (
304                                 (
305                                         // Only new config file is found
306                                         !isIncludeReadable('inc/config.php')
307                                 ) || (
308                                         // Is installation mode
309                                         !isInstalling()
310                                 )
311                         )
312                 ));
313         } // END - if
314
315         // Then use the cache
316         return $GLOBALS['is_installed'];
317 }
318
319 // Check wether an admin is registered
320 function isAdminRegistered () {
321         return ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
322 }
323
324 // Checks wether the reset mode is active
325 function isResetModeEnabled () {
326         // Now simply check it
327         return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
328 }
329
330 // Checks wether the debug mode is enabled
331 function isDebugModeEnabled () {
332         // Simply check it
333         return ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
334 }
335
336 // Checks wether we shall debug regular expressions
337 function isDebugRegExpressionEnabled () {
338         // Simply check it
339         return ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
340 }
341
342 // Checks wether the cache instance is valid
343 function isCacheInstanceValid () {
344         return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
345 }
346
347 // Copies a file from source to destination and verifies if that goes fine.
348 // This function should wrap the copy() command and make a nicer debug backtrace
349 // even if there is no xdebug extension installed.
350 function copyFileVerified ($source, $dest, $chmod = '') {
351         // Failed is the default
352         $status = false;
353
354         // Is the source file there?
355         if (!isFileReadable($source)) {
356                 // Then abort here
357                 debug_report_bug('Cannot read from source file ' . basename($source) . '.');
358         } // END - if
359
360         // Is the target directory there?
361         if (!isDirectory(dirname($dest))) {
362                 // Then abort here
363                 debug_report_bug('Cannot find directory ' . str_replace(getConfig('PATH'), '', dirname($dest)) . '.');
364         } // END - if
365
366         // Now try to copy it
367         if (!copy($source, $dest)) {
368                 // Something went wrong
369                 debug_report_bug('copy() has failed to copy the file.');
370         } else {
371                 // Reset cache
372                 $GLOBALS['file_readable'][$dest] = true;
373         }
374
375         // If there are chmod rights set, apply them
376         if (!empty($chmod)) {
377                 // Try to apply them
378                 $status = changeMode($dest, $chmod);
379         } else {
380                 // All fine
381                 $status = true;
382         }
383
384         // All fine
385         return $status;
386 }
387
388 // Wrapper function for header()
389 // Send a header but checks before if we can do so
390 function sendHeader ($header) {
391         // Is the header already sent?
392         if (headers_sent()) {
393                 // Then abort here
394                 debug_report_bug('Headers already sent!');
395         } // END - if
396
397         // Send the header
398         header(trim($header));
399 }
400
401 // Wrapper function for chmod()
402 // @TODO Do some more sanity check here
403 function changeMode ($FQFN, $mode) {
404         // Is the file/directory there?
405         if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
406                 // Neither, so abort here
407                 debug_report_bug('Cannot chmod() on ' . basename($FQFN) . '.');
408         } // END - if
409
410         // Try to set them
411         chmod($FQFN, $mode);
412 }
413
414 // Wrapper for unlink()
415 function removeFile ($FQFN) {
416         // Is the file there?
417         if (isFileReadable($FQFN)) {
418                 // Reset cache first
419                 $GLOBALS['file_readable'][$FQFN] = false;
420
421                 // Yes, so remove it
422                 return unlink($FQFN);
423         } // END - if
424
425         // All fine if no file was removed. If we change this to 'false' or rewrite
426         // above if() block it would be to restrictive.
427         return true;
428 }
429
430 // Wrapper for $_POST['sel']
431 function countPostSelection ($element = 'sel') {
432         // Is it set?
433         if (isPostRequestElementSet($element)) {
434                 // Return counted elements
435                 return countSelection(postRequestElement($element));
436         } else {
437                 // Return zero if not found
438                 return 0;
439         }
440 }
441
442 // Checks wether the config-local.php is loaded
443 function isConfigLocalLoaded () {
444         return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
445 }
446
447 // Checks wether a nickname or userid was entered and caches the result
448 function isNicknameUsed ($userid) {
449         // Default is false
450         $isUsed = false;
451
452         // Is the cache there
453         if (isset($GLOBALS['is_nickname_used'][$userid])) {
454                 // Then use it
455                 $isUsed = $GLOBALS['is_nickname_used'][$userid];
456         } else {
457                 // Determine it
458                 $isUsed = ((isExtensionActive('nickname')) && (('' . round($userid) . '') != $userid));
459
460                 // And write it to the cache
461                 $GLOBALS['is_nickname_used'][$userid] = $isUsed;
462         }
463
464         // Return the result
465         return $isUsed;
466 }
467
468 // Getter for 'what' value
469 function getWhat () {
470         // Default is null
471         $what = null;
472
473         // Is the value set?
474         if (isWhatSet(true)) {
475                 // Then use it
476                 $what = $GLOBALS['what'];
477         } // END - if
478
479         // Return it
480         return $what;
481 }
482
483 // Setter for 'what' value
484 function setWhat ($newWhat) {
485         $GLOBALS['what'] = SQL_ESCAPE($newWhat);
486 }
487
488 // Setter for 'what' from configuration
489 function setWhatFromConfig ($configEntry) {
490         // Get 'what' from config
491         $what = getConfig($configEntry);
492
493         // Set it
494         setWhat($what);
495 }
496
497 // Checks wether what is set and optionally aborts on miss
498 function isWhatSet ($strict =  false) {
499         // Check for it
500         $isset = (isset($GLOBALS['what']));
501
502         // Should we abort here?
503         if (($strict === true) && ($isset === false)) {
504                 // Output backtrace
505                 debug_report_bug('what is empty.');
506         } // END - if
507
508         // Return it
509         return $isset;
510 }
511
512 // Getter for 'action' value
513 function getAction () {
514         // Default is null
515         $action = null;
516
517         // Is the value set?
518         if (isActionSet(true)) {
519                 // Then use it
520                 $action = $GLOBALS['action'];
521         } // END - if
522
523         // Return it
524         return $action;
525 }
526
527 // Setter for 'action' value
528 function setAction ($newAction) {
529         $GLOBALS['action'] = SQL_ESCAPE($newAction);
530 }
531
532 // Checks wether action is set and optionally aborts on miss
533 function isActionSet ($strict =  false) {
534         // Check for it
535         $isset = (isset($GLOBALS['action']));
536
537         // Should we abort here?
538         if (($strict === true) && ($isset === false)) {
539                 // Output backtrace
540                 debug_report_bug('action is empty.');
541         } // END - if
542
543         // Return it
544         return $isset;
545 }
546
547 // Getter for 'module' value
548 function getModule ($strict = true) {
549         // Default is null
550         $module = null;
551
552         // Is the value set?
553         if (isModuleSet($strict)) {
554                 // Then use it
555                 $module = $GLOBALS['module'];
556         } // END - if
557
558         // Return it
559         return $module;
560 }
561
562 // Setter for 'module' value
563 function setModule ($newModule) {
564         // Secure it and make all modules lower-case
565         $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule));
566 }
567
568 // Checks wether module is set and optionally aborts on miss
569 function isModuleSet ($strict =  false) {
570         // Check for it
571         $isset = (!empty($GLOBALS['module']));
572
573         // Should we abort here?
574         if (($strict === true) && ($isset === false)) {
575                 // Output backtrace
576                 print 'Module not set!<pre>';
577                 debug_print_backtrace();
578                 die('</pre');
579                 debug_report_bug('module is empty.');
580         } // END - if
581
582         // Return it
583         return $isset;
584 }
585
586 // Getter for 'output_mode' value
587 function getOutputMode () {
588         // Default is null
589         $output_mode = null;
590
591         // Is the value set?
592         if (isOutputModeSet(true)) {
593                 // Then use it
594                 $output_mode = $GLOBALS['output_mode'];
595         } // END - if
596
597         // Return it
598         return $output_mode;
599 }
600
601 // Setter for 'output_mode' value
602 function setOutputMode ($newOutputMode) {
603         $GLOBALS['output_mode'] = (int) $newOutputMode;
604 }
605
606 // Checks wether output_mode is set and optionally aborts on miss
607 function isOutputModeSet ($strict =  false) {
608         // Check for it
609         $isset = (isset($GLOBALS['output_mode']));
610
611         // Should we abort here?
612         if (($strict === true) && ($isset === false)) {
613                 // Output backtrace
614                 debug_report_bug('output_mode is empty.');
615         } // END - if
616
617         // Return it
618         return $isset;
619 }
620
621 // Enables block-mode
622 function enableBlockMode ($enabled = true) {
623         $GLOBALS['block_mode'] = $enabled;
624 }
625
626 // Checks wether block-mode is enabled
627 function isBlockModeEnabled () {
628         // Abort if not set
629         if (!isset($GLOBALS['block_mode'])) {
630                 // Needs to be fixed
631                 debug_report_bug(__FUNCTION__ . ': block_mode is not set.');
632         } // END - if
633
634         // Return it
635         return $GLOBALS['block_mode'];
636 }
637
638 // Wrapper function for addPointsThroughReferalSystem()
639 function addPointsDirectly ($subject, $userid, $points) {
640         // Reset level here
641         unset($GLOBALS['ref_level']);
642
643         // Call more complicated method (due to more parameters)
644         return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, false, 'direct');
645 }
646
647 // Wrapper function to redirect from member-only modules to index
648 function redirectToIndexMemberOnlyModule () {
649         // Do the redirect here
650         redirectToUrl('modules.php?module=index&amp;code=' . getCode('MODULE_MEM_ONLY') . '&amp;mod=' . getModule());
651 }
652
653 // Wrapper function for checking if extension is installed and newer or same version
654 function isExtensionInstalledAndNewer ($ext_name, $version) {
655         // Return it
656         //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=&gt;'.$version.'<br />';
657         return ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
658 }
659
660 // Wrapper function for checking if extension is installed and older than given version
661 function isExtensionInstalledAndOlder ($ext_name, $version) {
662         // Return it
663         //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'&lt;'.$version.'<br />';
664         return ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
665 }
666
667 // Set username
668 function setUsername ($userName) {
669         $GLOBALS['username'] = (string) $userName;
670 }
671
672 // Get username
673 function getUsername () {
674         return $GLOBALS['username'];
675 }
676
677 // Wrapper function for installation phase
678 function isInstallationPhase () {
679         // Do we have cache?
680         if (!isset($GLOBALS['installation_phase'])) {
681                 // Determine it
682                 $GLOBALS['installation_phase'] = ((!isInstalled()) || (isInstalling()));
683         } // END - if
684
685         // Return result
686         return $GLOBALS['installation_phase'];
687 }
688
689 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
690 function isDemoModeActive () {
691         return ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo'));
692 }
693
694 // Wrapper function to redirect to de-refered URL
695 function redirectToDereferedUrl ($URL) {
696         // De-refer the URL
697         $URL = generateDerefererUrl($URL);
698
699         // Redirect to to
700         redirectToUrl($URL);
701 }
702
703 // Getter for PHP caching value
704 function getPhpCaching () {
705         return $GLOBALS['php_caching'];
706 }
707
708 // Checks wether the admin hash is set
709 function isAdminHashSet ($admin) {
710         return isset($GLOBALS['cache_array']['admin']['password'][$admin]);
711 }
712
713 // Setter for admin hash
714 function setAdminHash ($admin, $hash) {
715         $GLOBALS['cache_array']['admin']['password'][$admin] = $hash;
716 }
717
718 // Init user data array
719 function initUserData () {
720         // User id should not be zero
721         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
722
723         // Init the user
724         $GLOBALS['user_data'][getCurrentUserId()] = array();
725 }
726
727 // Getter for user data
728 function getUserData ($column) {
729         // User id should not be zero
730         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
731
732         // Return the value
733         return $GLOBALS['user_data'][getCurrentUserId()][$column];
734 }
735
736 // Geter for whole user data array
737 function getUserDataArray () {
738         // User id should not be zero
739         if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__.': User id is zero.');
740
741         // Get the whole array
742         return $GLOBALS['user_data'][getCurrentUserId()];
743 }
744
745 // Checks if the user data is valid, this may indicate that the user has logged
746 // in, but you should use isMember() if you want to find that out.
747 function isUserDataValid () {
748         // User id should not be zero so abort here
749         if (!isCurrentUserIdSet()) return false;
750
751         // Is the array there and filled?
752         return ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1));
753 }
754
755 // Setter for current userid
756 function setCurrentUserId ($userid) {
757         $GLOBALS['current_userid'] = bigintval($userid);
758 }
759
760 // Getter for current userid
761 function getCurrentUserId () {
762         // Userid must be set before it can be used
763         if (!isCurrentUserIdSet()) {
764                 // Not set
765                 debug_report_bug('User id is not set.');
766         } // END - if
767
768         // Return the userid
769         return $GLOBALS['current_userid'];
770 }
771
772 // Checks if current userid is set
773 function isCurrentUserIdSet () {
774         return isset($GLOBALS['current_userid']);
775 }
776
777 // [EOF]
778 ?>