From 121ae23a83555b34c28b9967113a0cdf1755387a Mon Sep 17 00:00:00 2001 From: alec Date: Fri, 24 Feb 2012 10:17:19 +0000 Subject: - Fixed drivers namespace issues git-svn-id: https://svn.roundcube.net/trunk@5902 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/password/drivers/ximss.php | 95 ++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 50 deletions(-) (limited to 'plugins/password/drivers/ximss.php') diff --git a/plugins/password/drivers/ximss.php b/plugins/password/drivers/ximss.php index 94aba1874..3b5286a27 100644 --- a/plugins/password/drivers/ximss.php +++ b/plugins/password/drivers/ximss.php @@ -12,25 +12,28 @@ * References: * http://www.communigate.com/WebGuide/XMLAPI.html * - * @version 1 + * @version 2.0 * @author Erik Meitner */ - -function password_save($pass, $newpass) + +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; + } - $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"); + // send all requests at once(pipelined) + fwrite( $sock, ''."\0"); + fwrite( $sock, ''."\0"); + fwrite( $sock, ''."\0"); //example responses // \0 @@ -40,42 +43,34 @@ function password_save($pass, $newpass) // or an error: // \0 - $responseblob = ''; - while (!feof($sock)) { - $responseblob .= fgets($sock, 1024); - } + $responseblob = ''; + while (!feof($sock)) { + $responseblob .= fgets($sock, 1024); + } - fclose($sock); - - foreach( explode( "\0",$responseblob) as $response ) - { - $resp = simplexml_load_string("".$response.""); + fclose($sock); - 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 + foreach( explode( "\0",$responseblob) as $response ) { + $resp = simplexml_load_string("".$response.""); - return PASSWORD_SUCCESS; - + 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