From 62a83b3bd5813885d964d9fd1509d52bb9c4f12c Mon Sep 17 00:00:00 2001 From: thomascube Date: Wed, 12 Jan 2011 15:47:44 +0000 Subject: Copying plugins to release branch --- 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