diff options
author | thomascube <thomas@roundcube.net> | 2012-03-03 14:23:04 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2012-03-03 14:23:04 +0000 |
commit | 884add1419729cb8eb5ed8fb47ea68e5f6ce6682 (patch) | |
tree | 183fdf813b3d84475e01d08abbe6d3511b2dd389 /plugins/password/drivers/ximss.php | |
parent | 10ac35625a04074467f002c283d65db24a0508de (diff) |
Tagging plugins for 0.8-betav0.8-beta
Diffstat (limited to 'plugins/password/drivers/ximss.php')
-rw-r--r-- | plugins/password/drivers/ximss.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/plugins/password/drivers/ximss.php b/plugins/password/drivers/ximss.php new file mode 100644 index 000000000..3b5286a27 --- /dev/null +++ b/plugins/password/drivers/ximss.php @@ -0,0 +1,76 @@ +<?php +/** + * Communigate driver for the Password Plugin for Roundcube + * + * Tested with Communigate Pro 5.1.2 + * + * Configuration options: + * password_ximss_host - Host name of Communigate server + * password_ximss_port - XIMSS port on Communigate server + * + * + * References: + * http://www.communigate.com/WebGuide/XMLAPI.html + * + * @version 2.0 + * @author Erik Meitner <erik wanderings.us> + */ + +class rcube_ximss_password +{ + function save($pass, $newpass) + { + $rcmail = rcmail::get_instance(); + + $host = $rcmail->config->get('password_ximss_host'); + $port = $rcmail->config->get('password_ximss_port'); + $sock = stream_socket_client("tcp://$host:$port", $errno, $errstr, 30); + + if ($sock === FALSE) { + return PASSWORD_CONNECT_ERROR; + } + + // send all requests at once(pipelined) + fwrite( $sock, '<login id="A001" authData="'.$_SESSION['username'].'" password="'.$pass.'" />'."\0"); + fwrite( $sock, '<passwordModify id="A002" oldPassword="'.$pass.'" newPassword="'.$newpass.'" />'."\0"); + fwrite( $sock, '<bye id="A003" />'."\0"); + + //example responses + // <session id="A001" urlID="4815-vN2Txjkggy7gjHRD10jw" userName="user@example.com"/>\0 + // <response id="A001"/>\0 + // <response id="A002"/>\0 + // <response id="A003"/>\0 + // or an error: + // <response id="A001" errorText="incorrect password or account name" errorNum="515"/>\0 + + $responseblob = ''; + while (!feof($sock)) { + $responseblob .= fgets($sock, 1024); + } + + fclose($sock); + + foreach( explode( "\0",$responseblob) as $response ) { + $resp = simplexml_load_string("<xml>".$response."</xml>"); + + if( $resp->response[0]['id'] == 'A001' ) { + if( isset( $resp->response[0]['errorNum'] ) ) { + return PASSWORD_CONNECT_ERROR; + } + } + else if( $resp->response[0]['id'] == 'A002' ) { + if( isset( $resp->response[0]['errorNum'] )) { + return PASSWORD_ERROR; + } + } + else if( $resp->response[0]['id'] == 'A003' ) { + if( isset($resp->response[0]['errorNum'] )) { + //There was a problem during logout(This is probably harmless) + } + } + } //foreach + + return PASSWORD_SUCCESS; + + } +} |