Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /*
  3. * $Id: OpenMediaVault.php 470 2012-10-24 21:43:25Z imooreyahoo@gmail.com $
  4. */
  5. /*
  6. * OMV Specific
  7. */
  8. try {
  9. // Must be made global or OMV breaks
  10. global $xmlConfig, $OMV_DEFAULT_FILE;
  11. require_once("openmediavault/globals.inc");
  12. require_once("openmediavault/session.inc");
  13. require_once("rpc/authentication.inc");
  14. } catch(Exception $e) {
  15. header("Content-Type: text/html");
  16. die("Error #".$e->getCode().":<br/>". str_replace("\n", "<br/>",$e->__toString()));
  17. }
  18. class phpvbAuthOpenMediaVault implements phpvbAuth {
  19. static $session = null;
  20. var $capabilities = array(
  21. 'canChangePassword' => false,
  22. 'sessionStart' => 'sessionStart',
  23. 'canLogout' => true
  24. );
  25. var $config = array(
  26. 'allowNonAdmin' => false
  27. );
  28. function __construct($userConfig = null) {
  29. if($userConfig) $this->config = array_merge($this->config,$userConfig);
  30. }
  31. function login($username, $password)
  32. {
  33. # Try / catch so that we don't expose
  34. # usernames / passwords
  35. require_once("rpc/authentication.inc");
  36. $a = new AuthenticationRpc();
  37. try {
  38. $auth = $a->login(array('username'=>$username,'password'=>$password));
  39. self::$session = &OMVSession::getInstance();
  40. if(@$auth["authenticated"] &&
  41. (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin'])) {
  42. $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER);
  43. $_SESSION['user'] = $_SESSION['username'];
  44. $_SESSION['valid'] = ($_SESSION['admin'] || $this->config['allowNonAdmin']);
  45. $_SESSION['authCheckHeartbeat'] = time();
  46. }
  47. if(!@$_SESSION['valid']) {
  48. return false;
  49. }
  50. return true;
  51. } catch (Exception $e) {
  52. return false;
  53. }
  54. return false;
  55. }
  56. function sessionStart($keepopen) {
  57. self::$session = &OMVSession::getInstance();
  58. self::$session->start();
  59. if (self::$session->isAuthenticated() && !self::$session->isTimeout()) {
  60. self::$session->validate();
  61. self::$session->updateLastAccess();
  62. $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER);
  63. $_SESSION['user'] = $_SESSION['username'];
  64. $_SESSION['valid'] = (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin']);
  65. } else {
  66. $_SESSION['admin'] = $_SESSION['user'] = $_SESSION['valid'] = null;
  67. }
  68. if(!$keepopen)
  69. session_write_close();
  70. }
  71. function logout(&$response)
  72. {
  73. require_once("rpc/authentication.inc");
  74. $a = new AuthenticationRpc();
  75. $a->logout();
  76. $response['data']['result'] = 1;
  77. }
  78. /* Defined for compatibility with implemented interface */
  79. function heartbeat($vbox){}
  80. function changePassword($old, $new){}
  81. function listUsers(){}
  82. function updateUser($vboxRequest, $skipExistCheck){}
  83. function deleteUser($user){}
  84. }