We're living in 2004 now... perl is your friend for these kinds of things :)
[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 * @package plugins
11 * @subpackage administrator
12 */
13
14 /**
15 *
16 */
17 function adm_check_user() {
18 global $PHP_SELF;
19 require_once(SM_PATH . 'functions/global.php');
20
21 if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) {
22 $username = '';
23 }
24
25 /* This needs to be first, for all non_options pages */
26 if (strpos('options.php', $PHP_SELF)) {
27 $auth = FALSE;
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')) {
35 $adm = posix_getpwuid( $adm_id );
36 $auth = ($username == $adm['name']);
37 } else {
38 $auth = FALSE;
39 }
40
41 return ($auth);
42 }
43
44 ?>