Mercurial > hg > rc1
comparison plugins/password/drivers/ximss.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 <?php | |
2 /** | |
3 * Communigate driver for the Password Plugin for Roundcube | |
4 * | |
5 * Tested with Communigate Pro 5.1.2 | |
6 * | |
7 * Configuration options: | |
8 * password_ximss_host - Host name of Communigate server | |
9 * password_ximss_port - XIMSS port on Communigate server | |
10 * | |
11 * References: | |
12 * http://www.communigate.com/WebGuide/XMLAPI.html | |
13 * | |
14 * @version 2.0 | |
15 * @author Erik Meitner <erik wanderings.us> | |
16 * | |
17 * Copyright (C) 2005-2013, The Roundcube Dev Team | |
18 * | |
19 * This program is free software: you can redistribute it and/or modify | |
20 * it under the terms of the GNU General Public License as published by | |
21 * the Free Software Foundation, either version 3 of the License, or | |
22 * (at your option) any later version. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, | |
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 * GNU General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see http://www.gnu.org/licenses/. | |
31 */ | |
32 | |
33 class rcube_ximss_password | |
34 { | |
35 function save($pass, $newpass) | |
36 { | |
37 $rcmail = rcmail::get_instance(); | |
38 | |
39 $host = $rcmail->config->get('password_ximss_host'); | |
40 $port = $rcmail->config->get('password_ximss_port'); | |
41 $sock = stream_socket_client("tcp://$host:$port", $errno, $errstr, 30); | |
42 | |
43 if ($sock === FALSE) { | |
44 return PASSWORD_CONNECT_ERROR; | |
45 } | |
46 | |
47 // send all requests at once(pipelined) | |
48 fwrite( $sock, '<login id="A001" authData="'.$_SESSION['username'].'" password="'.$pass.'" />'."\0"); | |
49 fwrite( $sock, '<passwordModify id="A002" oldPassword="'.$pass.'" newPassword="'.$newpass.'" />'."\0"); | |
50 fwrite( $sock, '<bye id="A003" />'."\0"); | |
51 | |
52 //example responses | |
53 // <session id="A001" urlID="4815-vN2Txjkggy7gjHRD10jw" userName="user@example.com"/>\0 | |
54 // <response id="A001"/>\0 | |
55 // <response id="A002"/>\0 | |
56 // <response id="A003"/>\0 | |
57 // or an error: | |
58 // <response id="A001" errorText="incorrect password or account name" errorNum="515"/>\0 | |
59 | |
60 $responseblob = ''; | |
61 while (!feof($sock)) { | |
62 $responseblob .= fgets($sock, 1024); | |
63 } | |
64 | |
65 fclose($sock); | |
66 | |
67 foreach (explode( "\0",$responseblob) as $response) { | |
68 $resp = simplexml_load_string("<xml>".$response."</xml>"); | |
69 | |
70 if( $resp->response[0]['id'] == 'A001' ) { | |
71 if( isset( $resp->response[0]['errorNum'] ) ) { | |
72 return PASSWORD_CONNECT_ERROR; | |
73 } | |
74 } | |
75 else if( $resp->response[0]['id'] == 'A002' ) { | |
76 if( isset( $resp->response[0]['errorNum'] )) { | |
77 return PASSWORD_ERROR; | |
78 } | |
79 } | |
80 else if( $resp->response[0]['id'] == 'A003' ) { | |
81 if( isset($resp->response[0]['errorNum'] )) { | |
82 //There was a problem during logout(This is probably harmless) | |
83 } | |
84 } | |
85 } //foreach | |
86 | |
87 return PASSWORD_SUCCESS; | |
88 } | |
89 } |