From 1904fa71046fd1782b9a3b61bd408cf779824500 Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 9 Oct 2009 16:04:01 +0000 Subject: - Added XIMSS (Communigate) driver for Password plugin --- plugins/password/drivers/ximss.php | 81 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 plugins/password/drivers/ximss.php (limited to 'plugins/password/drivers/ximss.php') 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 @@ + + */ + +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, ''."\0"); + fwrite( $sock, ''."\0"); + fwrite( $sock, ''."\0"); + + //example responses + // \0 + // \0 + // \0 + // \0 + // or an error: + // \0 + + $responseblob = ''; + while (!feof($sock)) { + $responseblob .= fgets($sock, 1024); + } + + fclose($sock); + + foreach( explode( "\0",$responseblob) as $response ) + { + $resp = simplexml_load_string("".$response.""); + + 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 -- cgit v1.2.3