fixes for the admin plugin for 1.4.0 RC1
[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 * $Id$
10 */
11
12 function adm_check_user() {
13 global $PHP_SELF;
14
15 $username = ( !isset($_SESSION['username']) ? '' : $_SESSION['username'] );
16 /* This needs to be first, for all non_options pages */
17 if (strpos('options.php', $PHP_SELF)) {
18 $auth = FALSE;
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')) {
26 $adm = posix_getpwuid( $adm_id );
27 $auth = ($username == $adm['name']);
28 } else {
29 $auth = FALSE;
30 }
31
32 return ($auth);
33 }
34
35 ?>