phpdoc blocks
[squirrelmail.git] / plugins / administrator / auth.php
1 <?php
2
3 /**
4 * This function tell other modules what users have access
5 * to the plugin.
6 *
7 * Philippe Mingo
8 *
9 * @version $Id$
10 * @package plugins
11 * @subpackage administrator
12 */
13
14 /**
15 * Check if user has access to administrative functions
16 *
17 * @return boolean
18 * @access private
19 */
20 function adm_check_user() {
21 global $PHP_SELF;
22 require_once(SM_PATH . 'functions/global.php');
23
24 if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) {
25 $username = '';
26 }
27
28 /* This needs to be first, for all non_options pages */
29 if (strpos('options.php', $PHP_SELF)) {
30 $auth = FALSE;
31 } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
32 $auths = file(SM_PATH . 'plugins/administrator/admins');
33 $auth = in_array("$username\n", $auths);
34 } else if (file_exists(SM_PATH . 'config/admins')) {
35 $auths = file(SM_PATH . 'config/admins');
36 $auth = in_array("$username\n", $auths);
37 } else if ($adm_id = fileowner(SM_PATH . 'config/config.php')) {
38 $adm = posix_getpwuid( $adm_id );
39 $auth = ($username == $adm['name']);
40 } else {
41 $auth = FALSE;
42 }
43
44 return ($auth);
45 }
46
47 ?>