79ae8599334f85226b33845f812037f57b539df9
4 * Administrator plugin - Authentication routines
6 * This function tell other modules what users have access
9 * @author Philippe Mingo
10 * @copyright © 1999-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * @subpackage administrator
18 * Check if user has access to administrative functions
22 function adm_check_user() {
23 global $PHP_SELF, $plugins;
24 require_once(SM_PATH
. 'functions/global.php');
26 /* fail if the plugin is not enabled */
27 if ( !in_array('administrator', $plugins) ) {
31 if ( !sqgetGlobalVar('username',$username,SQ_SESSION
) ) {
35 /* This needs to be first, for all non_options pages */
36 if (strpos('options.php', $PHP_SELF)) {
38 } else if (file_exists(SM_PATH
. 'plugins/administrator/admins')) {
39 $auths = file(SM_PATH
. 'plugins/administrator/admins');
40 array_walk($auths, 'adm_array_trim');
41 $auth = in_array($username, $auths);
42 } else if (file_exists(SM_PATH
. 'config/admins')) {
43 $auths = file(SM_PATH
. 'config/admins');
44 array_walk($auths, 'adm_array_trim');
45 $auth = in_array($username, $auths);
46 } else if (($adm_id = fileowner(SM_PATH
. 'config/config.php')) &&
47 function_exists('posix_getpwuid')) {
48 $adm = posix_getpwuid( $adm_id );
49 $auth = ($username == $adm['name']);
58 * Removes whitespace from array values
59 * @param string $value array value that has to be trimmed
60 * @param string $key array key
61 * @since 1.5.1 and 1.4.5
64 function adm_array_trim(&$value,$key) {