Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ximss.php 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. class rcube_ximss_password
  33. {
  34. function save($pass, $newpass)
  35. {
  36. $rcmail = rcmail::get_instance();
  37. $host = $rcmail->config->get('password_ximss_host');
  38. $port = $rcmail->config->get('password_ximss_port');
  39. $sock = stream_socket_client("tcp://$host:$port", $errno, $errstr, 30);
  40. if ($sock === FALSE) {
  41. return PASSWORD_CONNECT_ERROR;
  42. }
  43. // send all requests at once(pipelined)
  44. fwrite( $sock, '<login id="A001" authData="'.$_SESSION['username'].'" password="'.$pass.'" />'."\0");
  45. fwrite( $sock, '<passwordModify id="A002" oldPassword="'.$pass.'" newPassword="'.$newpass.'" />'."\0");
  46. fwrite( $sock, '<bye id="A003" />'."\0");
  47. //example responses
  48. // <session id="A001" urlID="4815-vN2Txjkggy7gjHRD10jw" userName="user@example.com"/>\0
  49. // <response id="A001"/>\0
  50. // <response id="A002"/>\0
  51. // <response id="A003"/>\0
  52. // or an error:
  53. // <response id="A001" errorText="incorrect password or account name" errorNum="515"/>\0
  54. $responseblob = '';
  55. while (!feof($sock)) {
  56. $responseblob .= fgets($sock, 1024);
  57. }
  58. fclose($sock);
  59. foreach( explode( "\0",$responseblob) as $response ) {
  60. $resp = simplexml_load_string("<xml>".$response."</xml>");
  61. if( $resp->response[0]['id'] == 'A001' ) {
  62. if( isset( $resp->response[0]['errorNum'] ) ) {
  63. return PASSWORD_CONNECT_ERROR;
  64. }
  65. }
  66. else if( $resp->response[0]['id'] == 'A002' ) {
  67. if( isset( $resp->response[0]['errorNum'] )) {
  68. return PASSWORD_ERROR;
  69. }
  70. }
  71. else if( $resp->response[0]['id'] == 'A003' ) {
  72. if( isset($resp->response[0]['errorNum'] )) {
  73. //There was a problem during logout(This is probably harmless)
  74. }
  75. }
  76. } //foreach
  77. return PASSWORD_SUCCESS;
  78. }
  79. }