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 *
0df03ce7 9 * @version $Id$
ea5f4b8e 10 * @package plugins
11 * @subpackage administrator
2d977280 12 */
7004cc32 13
ea5f4b8e 14/**
0df03ce7 15 * Check if user has access to administrative functions
16 *
17 * @return boolean
18 * @access private
19 */
52a6105d 20function adm_check_user() {
a28a56da 21 global $PHP_SELF;
4cd8ae7d 22 require_once(SM_PATH . 'functions/global.php');
a28a56da 23
4cd8ae7d 24 if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) {
25 $username = '';
26 }
27
a28a56da 28 /* This needs to be first, for all non_options pages */
52a6105d 29 if (strpos('options.php', $PHP_SELF)) {
71bf4974 30 $auth = FALSE;
52a6105d 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')) {
7004cc32 38 $adm = posix_getpwuid( $adm_id );
52a6105d 39 $auth = ($username == $adm['name']);
40 } else {
a82293f6 41 $auth = FALSE;
42 }
7004cc32 43
52a6105d 44 return ($auth);
7004cc32 45}
46
0df03ce7 47?>