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