7004cc32 |
1 | <?php |
ea5f4b8e |
2 | /** |
fb579f0b |
3 | * Administrator plugin - Authentication routines |
4 | * |
5 | * This function tell other modules what users have access |
6 | * to the plugin. |
7 | * |
0df03ce7 |
8 | * @version $Id$ |
fb579f0b |
9 | * @author Philippe Mingo |
10 | * @copyright (c) 1999-2004 The SquirrelMail Project Team |
11 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
ea5f4b8e |
12 | * @package plugins |
13 | * @subpackage administrator |
2d977280 |
14 | */ |
7004cc32 |
15 | |
ea5f4b8e |
16 | /** |
0df03ce7 |
17 | * Check if user has access to administrative functions |
18 | * |
19 | * @return boolean |
20 | * @access private |
21 | */ |
52a6105d |
22 | function adm_check_user() { |
a28a56da |
23 | global $PHP_SELF; |
4cd8ae7d |
24 | require_once(SM_PATH . 'functions/global.php'); |
91e0dccc |
25 | |
4cd8ae7d |
26 | if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) { |
27 | $username = ''; |
28 | } |
29 | |
a28a56da |
30 | /* This needs to be first, for all non_options pages */ |
52a6105d |
31 | if (strpos('options.php', $PHP_SELF)) { |
71bf4974 |
32 | $auth = FALSE; |
52a6105d |
33 | } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) { |
34 | $auths = file(SM_PATH . 'plugins/administrator/admins'); |
35 | $auth = in_array("$username\n", $auths); |
36 | } else if (file_exists(SM_PATH . 'config/admins')) { |
37 | $auths = file(SM_PATH . 'config/admins'); |
38 | $auth = in_array("$username\n", $auths); |
a9ccc40c |
39 | } else if ($adm_id = fileowner(SM_PATH . 'config/config.php') && |
40 | function_exists('posix_getpwuid')) { |
7004cc32 |
41 | $adm = posix_getpwuid( $adm_id ); |
52a6105d |
42 | $auth = ($username == $adm['name']); |
43 | } else { |
a82293f6 |
44 | $auth = FALSE; |
45 | } |
7004cc32 |
46 | |
52a6105d |
47 | return ($auth); |
7004cc32 |
48 | } |
49 | |
0df03ce7 |
50 | ?> |