roundcube-driver.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <<<<<<< HEAD
  2. <?php
  3. /**
  4. * Vesta Control Panel Password Driver
  5. *
  6. * @version 1.0
  7. * @author Serghey Rodin <[email protected]>
  8. */
  9. class rcube_vesta_password
  10. {
  11. function save($curpass, $passwd)
  12. {
  13. $rcmail = rcmail::get_instance();
  14. $vesta_host = $rcmail->config->get('password_vesta_host');
  15. if (empty($vesta_host))
  16. {
  17. $vesta_host = 'localhost';
  18. }
  19. $vesta_port = $rcmail->config->get('password_vesta_port');
  20. if (empty($vesta_port))
  21. {
  22. $vesta_port = '8083';
  23. }
  24. $request = 'email='.$_SESSION['username'].'&';
  25. $request .= 'password='.$curpass.'&';
  26. $request .= 'new='.$passwd.'&';
  27. $context = stream_context_create(array(
  28. 'http' => array(
  29. 'method' => 'POST',
  30. 'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL,
  31. 'content' => $request,
  32. ),
  33. ));
  34. $result = file_get_contents(
  35. $file = "https://".$vesta_host.":".$vesta_port."/reset/mail/?",
  36. $use_include_path = false,
  37. $context);
  38. if ($result == 'ok'){
  39. return PASSWORD_SUCCESS;
  40. }
  41. else {
  42. return PASSWORD_ERROR;
  43. }
  44. }
  45. }
  46. =======
  47. <?php
  48. /**
  49. * Vesta Control Panel Password Driver
  50. *
  51. * @version 1.0
  52. * @author Serghey Rodin <[email protected]>
  53. */
  54. class rcube_vesta_password
  55. {
  56. function save($curpass, $passwd)
  57. {
  58. $rcmail = rcmail::get_instance();
  59. $vesta_host = $rcmail->config->get('password_vesta_host');
  60. if (empty($vesta_host))
  61. {
  62. $vesta_host = 'localhost';
  63. }
  64. $vesta_port = $rcmail->config->get('password_vesta_port');
  65. if (empty($vesta_port))
  66. {
  67. $vesta_port = '8083';
  68. }
  69. $postvars = array(
  70. 'email' => $_SESSION['username'],
  71. 'password' => $curpass,
  72. 'new' => $passwd
  73. );
  74. $postdata = http_build_query($postvars);
  75. $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL;
  76. $send .= 'Host: ' . $vesta_host . PHP_EOL;
  77. $send .= 'User-Agent: PHP Script' . PHP_EOL;
  78. $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL;
  79. $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL;
  80. $send .= 'Connection: close' . PHP_EOL;
  81. $send .= PHP_EOL;
  82. $send .= $postdata . PHP_EOL . PHP_EOL;
  83. $fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
  84. fputs($fp, $send);
  85. $result = fread($fp, 2048);
  86. fclose($fp);
  87. if(strpos($result, 'ok') && !strpos($html, 'error'))
  88. {
  89. return PASSWORD_SUCCESS;
  90. }
  91. else {
  92. return PASSWORD_ERROR;
  93. }
  94. }
  95. }
  96. >>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d