auth.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Administrator plugin - Authentication routines
  4. *
  5. * This function tell other modules what users have access
  6. * to the plugin.
  7. *
  8. * @version $Id$
  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
  12. * @package plugins
  13. * @subpackage administrator
  14. */
  15. /**
  16. * Check if user has access to administrative functions
  17. *
  18. * @return boolean
  19. * @access private
  20. */
  21. function adm_check_user() {
  22. global $PHP_SELF;
  23. require_once(SM_PATH . 'functions/global.php');
  24. if ( !sqgetGlobalVar('username',$username,SQ_SESSION) ) {
  25. $username = '';
  26. }
  27. /* This needs to be first, for all non_options pages */
  28. if (strpos('options.php', $PHP_SELF)) {
  29. $auth = FALSE;
  30. } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
  31. $auths = file(SM_PATH . 'plugins/administrator/admins');
  32. $auth = in_array("$username\n", $auths);
  33. } else if (file_exists(SM_PATH . 'config/admins')) {
  34. $auths = file(SM_PATH . 'config/admins');
  35. $auth = in_array("$username\n", $auths);
  36. } else if ($adm_id = fileowner(SM_PATH . 'config/config.php')) {
  37. $adm = posix_getpwuid( $adm_id );
  38. $auth = ($username == $adm['name']);
  39. } else {
  40. $auth = FALSE;
  41. }
  42. return ($auth);
  43. }
  44. ?>