You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vpopmaild.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * vpopmail Password Driver
  4. *
  5. * Driver to change passwords via vpopmaild
  6. *
  7. * @version 2.0
  8. * @author Johannes Hessellund
  9. *
  10. * Copyright (C) 2005-2013, The Roundcube Dev Team
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see http://www.gnu.org/licenses/.
  24. */
  25. class rcube_vpopmaild_password
  26. {
  27. function save($curpass, $passwd)
  28. {
  29. $rcmail = rcmail::get_instance();
  30. $vpopmaild = new Net_Socket();
  31. $host = $rcmail->config->get('password_vpopmaild_host');
  32. $port = $rcmail->config->get('password_vpopmaild_port');
  33. $result = $vpopmaild->connect($host, $port, null);
  34. if (is_a($result, 'PEAR_Error')) {
  35. return PASSWORD_CONNECT_ERROR;
  36. }
  37. $vpopmaild->setTimeout($rcmail->config->get('password_vpopmaild_timeout'),0);
  38. $result = $vpopmaild->readLine();
  39. if(!preg_match('/^\+OK/', $result)) {
  40. $vpopmaild->disconnect();
  41. return PASSWORD_CONNECT_ERROR;
  42. }
  43. $vpopmaild->writeLine("slogin ". $_SESSION['username'] . " " . $curpass);
  44. $result = $vpopmaild->readLine();
  45. if(!preg_match('/^\+OK/', $result) ) {
  46. $vpopmaild->writeLine("quit");
  47. $vpopmaild->disconnect();
  48. return PASSWORD_ERROR;
  49. }
  50. $vpopmaild->writeLine("mod_user ". $_SESSION['username']);
  51. $vpopmaild->writeLine("clear_text_password ". $passwd);
  52. $vpopmaild->writeLine(".");
  53. $result = $vpopmaild->readLine();
  54. $vpopmaild->writeLine("quit");
  55. $vpopmaild->disconnect();
  56. if (!preg_match('/^\+OK/', $result)) {
  57. return PASSWORD_ERROR;
  58. }
  59. return PASSWORD_SUCCESS;
  60. }
  61. }