您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

kpasswd.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * kpasswd Driver
  4. *
  5. * Driver that adds functionality to change the systems user password via
  6. * the 'kpasswd' command.
  7. *
  8. * For installation instructions please read the README file.
  9. *
  10. * @version 1.0
  11. * @author Peter Allgeyer <peter.allgeyer@salzburgresearch.at>
  12. *
  13. * Based on chpasswd roundcubemail password driver by
  14. * @author Alex Cartwright <acartwright@mutinydesign.co.uk>
  15. */
  16. class rcube_kpasswd_password
  17. {
  18. public function save($currpass, $newpass)
  19. {
  20. $bin = rcmail::get_instance()->config->get('password_kpasswd_cmd', '/usr/bin/kpasswd');
  21. $username = $_SESSION['username'];
  22. $cmd = $bin . ' "' . $username . '" 2>&1';
  23. $handle = popen($cmd, "w");
  24. fwrite($handle, $currpass."\n");
  25. fwrite($handle, $newpass."\n");
  26. fwrite($handle, $newpass."\n");
  27. if (pclose($handle) == 0) {
  28. return PASSWORD_SUCCESS;
  29. }
  30. else {
  31. rcube::raise_error(array(
  32. 'code' => 600,
  33. 'type' => 'php',
  34. 'file' => __FILE__, 'line' => __LINE__,
  35. 'message' => "Password plugin: Unable to execute $cmd"
  36. ), true, false);
  37. }
  38. return PASSWORD_ERROR;
  39. }
  40. }