From 22274b2b11ef9a08a3063d4a8bcd3738ced99d91 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Mon, 31 Dec 2012 12:58:57 +0200 Subject: [PATCH] switched roundcube driver to sockets --- install/0.9.7/rhel/roundcube-driver.php | 40 ++++++++++++++----------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/install/0.9.7/rhel/roundcube-driver.php b/install/0.9.7/rhel/roundcube-driver.php index 22877047..0fb2c4be 100644 --- a/install/0.9.7/rhel/roundcube-driver.php +++ b/install/0.9.7/rhel/roundcube-driver.php @@ -25,25 +25,31 @@ class rcube_vesta_password $vesta_port = '8083'; } - $request = 'email='.$_SESSION['username'].'&'; - $request .= 'password='.$curpass.'&'; - $request .= 'new='.$passwd.'&'; + $postvars = array( + 'email' => $_SESSION['username'], + 'password' => $curpass, + 'new' => $passwd + ); + + $postdata = http_build_query($postvars); + + $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL; + $send .= 'Host: ' . $vesta_host . PHP_EOL; + $send .= 'User-Agent: PHP Script' . PHP_EOL; + $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL; + $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL; + $send .= 'Connection: close' . PHP_EOL; + $send .= PHP_EOL; + $send .= $postdata . PHP_EOL . PHP_EOL; + + $fp = fsockopen('ssl://' . $vesta_host, $vesta_port); + fputs($fp, $send); + $result = fread($fp, 2048); + fclose($fp); - $context = stream_context_create(array( - 'http' => array( - 'method' => 'POST', - 'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL, - 'content' => $request, - ), - )); - - $result = file_get_contents( - $file = "https://".$vesta_host.":".$vesta_port."/reset/mail/?", - $use_include_path = false, - $context); - - if ($result == 'ok'){ + if(strpos($result, 'ok') && !strpos($html, 'error')) + { return PASSWORD_SUCCESS; } else {