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 |
6c84ba1e |
10 | * @copyright (c) 1999-2005 The SquirrelMail Project Team |
fb579f0b |
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 |
0df03ce7 |
20 | */ |
52a6105d |
21 | function adm_check_user() { |
a28a56da |
22 | global $PHP_SELF; |
4cd8ae7d |
23 | require_once(SM_PATH . 'functions/global.php'); |
91e0dccc |
24 | |
4cd8ae7d |
25 | if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) { |
26 | $username = ''; |
27 | } |
28 | |
a28a56da |
29 | /* This needs to be first, for all non_options pages */ |
52a6105d |
30 | if (strpos('options.php', $PHP_SELF)) { |
71bf4974 |
31 | $auth = FALSE; |
52a6105d |
32 | } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) { |
33 | $auths = file(SM_PATH . 'plugins/administrator/admins'); |
0a577181 |
34 | array_walk($auths, 'adm_array_trim'); |
daa192a8 |
35 | $auth = in_array($username, $auths); |
52a6105d |
36 | } else if (file_exists(SM_PATH . 'config/admins')) { |
37 | $auths = file(SM_PATH . 'config/admins'); |
0a577181 |
38 | array_walk($auths, 'adm_array_trim'); |
daa192a8 |
39 | $auth = in_array($username, $auths); |
ec4584f9 |
40 | } else if (($adm_id = fileowner(SM_PATH . 'config/config.php')) && |
a9ccc40c |
41 | function_exists('posix_getpwuid')) { |
7004cc32 |
42 | $adm = posix_getpwuid( $adm_id ); |
52a6105d |
43 | $auth = ($username == $adm['name']); |
44 | } else { |
a82293f6 |
45 | $auth = FALSE; |
46 | } |
7004cc32 |
47 | |
52a6105d |
48 | return ($auth); |
7004cc32 |
49 | } |
50 | |
0a577181 |
51 | /** |
52 | * Removes whitespace from array values |
53 | * @param string $value array value that has to be trimmed |
54 | * @param string $key array key |
63ed9ceb |
55 | * @since 1.5.1 and 1.4.5 |
56 | * @access private |
0a577181 |
57 | */ |
58 | function adm_array_trim(&$value,$key) { |
59 | $value=trim($value); |
60 | } |
61 | ?> |