| | |
| | | * |
| | | * Driver to change passwords via Poppassd/Courierpassd |
| | | * |
| | | * @version 1.0 |
| | | * @version 2.0 |
| | | * @author Philip Weir |
| | | * |
| | | */ |
| | | |
| | | function password_save($curpass, $passwd) |
| | | class rcube_poppassd_password |
| | | { |
| | | $rcmail = rcmail::get_instance(); |
| | | // include('Net/Socket.php'); |
| | | $poppassd = new Net_Socket(); |
| | | |
| | | if (PEAR::isError($poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null))) { |
| | | return PASSWORD_CONNECT_ERROR; |
| | | function format_error_result($code, $line) |
| | | { |
| | | if (preg_match('/^\d\d\d\s+(\S.*)\s*$/', $line, $matches)) { |
| | | return array('code' => $code, 'message' => $matches[1]); |
| | | } else { |
| | | return $code; |
| | | } |
| | | } |
| | | else { |
| | | $result = $poppassd->readLine(); |
| | | if(!preg_match('/^2\d\d/', $result)) { |
| | | $poppassd->disconnect(); |
| | | return PASSWORD_ERROR; |
| | | |
| | | function save($curpass, $passwd) |
| | | { |
| | | $rcmail = rcmail::get_instance(); |
| | | // include('Net/Socket.php'); |
| | | $poppassd = new Net_Socket(); |
| | | |
| | | $result = $poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null); |
| | | if (PEAR::isError($result)) { |
| | | return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage()); |
| | | } |
| | | else { |
| | | $poppassd->writeLine("user ". $_SESSION['username']); |
| | | $result = $poppassd->readLine(); |
| | | if(!preg_match('/^[23]\d\d/', $result) ) { |
| | | if(!preg_match('/^2\d\d/', $result)) { |
| | | $poppassd->disconnect(); |
| | | return PASSWORD_CONNECT_ERROR; |
| | | return $this->format_error_result(PASSWORD_ERROR, $result); |
| | | } |
| | | else { |
| | | $poppassd->writeLine("pass ". $curpass); |
| | | $poppassd->writeLine("user ". $_SESSION['username']); |
| | | $result = $poppassd->readLine(); |
| | | if(!preg_match('/^[23]\d\d/', $result) ) { |
| | | $poppassd->disconnect(); |
| | | return PASSWORD_ERROR; |
| | | return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result); |
| | | } |
| | | else { |
| | | $poppassd->writeLine("newpass ". $passwd); |
| | | $poppassd->writeLine("pass ". $curpass); |
| | | $result = $poppassd->readLine(); |
| | | $poppassd->disconnect(); |
| | | if (!preg_match('/^2\d\d/', $result)) |
| | | return PASSWORD_ERROR; |
| | | else |
| | | return PASSWORD_SUCCESS; |
| | | if(!preg_match('/^[23]\d\d/', $result) ) { |
| | | $poppassd->disconnect(); |
| | | return $this->format_error_result(PASSWORD_ERROR, $result); |
| | | } |
| | | else { |
| | | $poppassd->writeLine("newpass ". $passwd); |
| | | $result = $poppassd->readLine(); |
| | | $poppassd->disconnect(); |
| | | if (!preg_match('/^2\d\d/', $result)) |
| | | return $this->format_error_result(PASSWORD_ERROR, $result); |
| | | else |
| | | return PASSWORD_SUCCESS; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | ?> |