3 * Communigate driver for the Password Plugin for Roundcube
5 * Tested with Communigate Pro 5.1.2
7 * Configuration options:
8 * password_ximss_host - Host name of Communigate server
9 * password_ximss_port - XIMSS port on Communigate server
13 * http://www.communigate.com/WebGuide/XMLAPI.html
16 * @author Erik Meitner <erik wanderings.us>
19 function password_save($pass, $newpass)
22 $rcmail = rcmail::get_instance();
24 $sock = stream_socket_client("tcp://".$rcmail->config->get('password_ximss_host').":".$rcmail->config->get('password_ximss_port'), $errno, $errstr, 30) ;
27 return PASSWORD_CONNECT_ERROR;
30 // send all requests at once(pipelined)
31 fwrite( $sock, '<login id="A001" authData="'.$_SESSION['username'].'" password="'.$pass.'" />'."\0");
32 fwrite( $sock, '<passwordModify id="A002" oldPassword="'.$pass.'" newPassword="'.$newpass.'" />'."\0");
33 fwrite( $sock, '<bye id="A003" />'."\0");
36 // <session id="A001" urlID="4815-vN2Txjkggy7gjHRD10jw" userName="user@example.com"/>\0
37 // <response id="A001"/>\0
38 // <response id="A002"/>\0
39 // <response id="A003"/>\0
41 // <response id="A001" errorText="incorrect password or account name" errorNum="515"/>\0
44 while (!feof($sock)) {
45 $responseblob .= fgets($sock, 1024);
50 foreach( explode( "\0",$responseblob) as $response )
52 $resp = simplexml_load_string("<xml>".$response."</xml>");
54 if( $resp->response[0]['id'] == 'A001' )
56 if( isset( $resp->response[0]['errorNum'] ) )
58 return PASSWORD_CONNECT_ERROR;
61 else if( $resp->response[0]['id'] == 'A002' )
63 if( isset( $resp->response[0]['errorNum'] ))
65 return PASSWORD_ERROR;
68 else if( $resp->response[0]['id'] == 'A003' )
70 if( isset($resp->response[0]['errorNum'] ))
72 //There was a problem during logout(This is probably harmless)
77 return PASSWORD_SUCCESS;