fixes for the admin plugin for 1.4.0 RC1
[squirrelmail.git] / plugins / administrator / auth.php
CommitLineData
7004cc32 1<?php
2
2d977280 3/*
4 * This function tell other modules what users have access
5 * to the plugin.
6 *
7 * Philippe Mingo
8 *
9 * $Id$
10 */
7004cc32 11
52a6105d 12function adm_check_user() {
a28a56da 13 global $PHP_SELF;
14
15 $username = ( !isset($_SESSION['username']) ? '' : $_SESSION['username'] );
16 /* This needs to be first, for all non_options pages */
52a6105d 17 if (strpos('options.php', $PHP_SELF)) {
71bf4974 18 $auth = FALSE;
52a6105d 19 } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
20 $auths = file(SM_PATH . 'plugins/administrator/admins');
21 $auth = in_array("$username\n", $auths);
22 } else if (file_exists(SM_PATH . 'config/admins')) {
23 $auths = file(SM_PATH . 'config/admins');
24 $auth = in_array("$username\n", $auths);
25 } else if ($adm_id = fileowner(SM_PATH . 'config/config.php')) {
7004cc32 26 $adm = posix_getpwuid( $adm_id );
52a6105d 27 $auth = ($username == $adm['name']);
28 } else {
a82293f6 29 $auth = FALSE;
30 }
7004cc32 31
52a6105d 32 return ($auth);
7004cc32 33}
34
26cbaf02 35?>