Added new function:
[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 require_once(SM_PATH . 'functions/global.php');
15
16 if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) {
17 $username = '';
18 }
19
20 /* This needs to be first, for all non_options pages */
21 if (strpos('options.php', $PHP_SELF)) {
22 $auth = FALSE;
23 } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
24 $auths = file(SM_PATH . 'plugins/administrator/admins');
25 $auth = in_array("$username\n", $auths);
26 } else if (file_exists(SM_PATH . 'config/admins')) {
27 $auths = file(SM_PATH . 'config/admins');
28 $auth = in_array("$username\n", $auths);
29 } else if ($adm_id = fileowner(SM_PATH . 'config/config.php')) {
30 $adm = posix_getpwuid( $adm_id );
31 $auth = ($username == $adm['name']);
32 } else {
33 $auth = FALSE;
34 }
35
36 return ($auth);
37 }
38
39 ?>