summaryrefslogtreecommitdiff
path: root/plugins/password/drivers/ximss.php
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-10-19 15:28:11 +0000
committerthomascube <thomas@roundcube.net>2011-10-19 15:28:11 +0000
commit5da48a95224e925f4b070f2581a121516df33829 (patch)
treefadc87888faae54cdb1efc6f7b73fbfce79e0fe7 /plugins/password/drivers/ximss.php
parentb03854de3a36a322bf98c733ed9b75d996694e38 (diff)
Copy plugins to release branch
Diffstat (limited to 'plugins/password/drivers/ximss.php')
-rw-r--r--plugins/password/drivers/ximss.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/plugins/password/drivers/ximss.php b/plugins/password/drivers/ximss.php
new file mode 100644
index 000000000..94aba1874
--- /dev/null
+++ b/plugins/password/drivers/ximss.php
@@ -0,0 +1,81 @@
+<?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 1
+ * @author Erik Meitner <erik wanderings.us>
+ */
+
+function password_save($pass, $newpass)
+{
+
+ $rcmail = rcmail::get_instance();
+
+ $sock = stream_socket_client("tcp://".$rcmail->config->get('password_ximss_host').":".$rcmail->config->get('password_ximss_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;
+
+}
+
+?> \ No newline at end of file