3 * Administrator plugin - Authentication routines
5 * This function tell other modules what users have access
9 * @author Philippe Mingo
10 * @copyright (c) 1999-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @subpackage administrator
17 * Check if user has access to administrative functions
21 function adm_check_user() {
23 require_once(SM_PATH
. 'functions/global.php');
25 if ( !sqgetGlobalVar('username',$username,SQ_SESSION
) ) {
29 /* This needs to be first, for all non_options pages */
30 if (strpos('options.php', $PHP_SELF)) {
32 } else if (file_exists(SM_PATH
. 'plugins/administrator/admins')) {
33 $auths = file(SM_PATH
. 'plugins/administrator/admins');
34 array_walk($auths, 'adm_array_trim');
35 $auth = in_array($username, $auths);
36 } else if (file_exists(SM_PATH
. 'config/admins')) {
37 $auths = file(SM_PATH
. 'config/admins');
38 array_walk($auths, 'adm_array_trim');
39 $auth = in_array($username, $auths);
40 } else if (($adm_id = fileowner(SM_PATH
. 'config/config.php')) &&
41 function_exists('posix_getpwuid')) {
42 $adm = posix_getpwuid( $adm_id );
43 $auth = ($username == $adm['name']);
52 * Removes whitespace from array values
53 * @param string $value array value that has to be trimmed
54 * @param string $key array key
55 * @since 1.5.1 and 1.4.5
58 function adm_array_trim(&$value,$key) {