*/
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;
}
?>