7004cc32 |
1 | <?php |
2 | |
2d977280 |
3 | /* |
4 | * This function tell other modules what users have access |
5 | * to the plugin. |
6 | * |
7 | * Philippe Mingo |
8 | * |
9 | * $Id$ |
10 | */ |
7004cc32 |
11 | |
52a6105d |
12 | function adm_check_user() { |
a28a56da |
13 | global $PHP_SELF; |
4cd8ae7d |
14 | require_once(SM_PATH . 'functions/global.php'); |
a28a56da |
15 | |
4cd8ae7d |
16 | if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) { |
17 | $username = ''; |
18 | } |
19 | |
a28a56da |
20 | /* This needs to be first, for all non_options pages */ |
52a6105d |
21 | if (strpos('options.php', $PHP_SELF)) { |
71bf4974 |
22 | $auth = FALSE; |
52a6105d |
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')) { |
7004cc32 |
30 | $adm = posix_getpwuid( $adm_id ); |
52a6105d |
31 | $auth = ($username == $adm['name']); |
32 | } else { |
a82293f6 |
33 | $auth = FALSE; |
34 | } |
7004cc32 |
35 | |
52a6105d |
36 | return ($auth); |
7004cc32 |
37 | } |
38 | |
26cbaf02 |
39 | ?> |