alecpl
2009-10-09 1904fa71046fd1782b9a3b61bd408cf779824500
- Added XIMSS (Communigate) driver for Password plugin


1 files added
3 files modified
107 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
plugins/password/README 16 ●●●● patch | view | raw | blame | history
plugins/password/config.inc.php.dist 9 ●●●●● patch | view | raw | blame | history
plugins/password/drivers/ximss.php 81 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Added XIMSS (Communigate) driver for Password plugin
- Fix newly attached files are not saved in drafts w/o editing any text (#1486202)
- Added attachment upload indicator with parallel upload (#1486058)
- Use default_charset for bodies of messages without charset definition (#1486187)
plugins/password/README
@@ -32,6 +32,7 @@
 2.4.    LDAP (ldap)
 2.5.    DirectAdmin Control Panel
 2.6.   cPanel
 2.7.   XIMSS (Communigate)
 3.    Driver API
@@ -157,8 +158,8 @@
 2.3. Poppassd/Courierpassd (poppassd)
 -------------------------------------
 You can specify which host to connect to via `password_pop_host` and
 what port via `password_pop_port`. See config.inc.php file for more info.
 You can specify which host to connect to via 'password_pop_host' and
 what port via 'password_pop_port'. See config.inc.php file for more info.
 2.4. LDAP (ldap)
@@ -170,8 +171,8 @@
 2.5. DirectAdmin Control Panel
 -------------------------------------
 You can specify which host to connect to via `password_directadmin_host`
 and what port via `password_direactadmin_port`. See config.inc.php file
 You can specify which host to connect to via 'password_directadmin_host'
 and what port via 'password_direactadmin_port'. See config.inc.php file
 for more info.
@@ -182,6 +183,13 @@
 interface. See config.inc.php file for more info.
 2.7. XIMSS (Communigate)
 -------------------------------------
 You can specify which host and port to connect to via 'password_ximss_host'
 and 'password_ximss_port'. See config.inc.php file for more info.
 3. Driver API
 -------------
plugins/password/config.inc.php.dist
@@ -179,4 +179,13 @@
// The cPanel theme in use
$rcmail_config['password_cpanel_theme'] = 'x';
// XIMSS (Communigate server) Driver options
// -----------------------------------------
// Host name of the Communigate server
$rcmail_config['password_ximss_host'] = 'mail.example.com';
// XIMSS port on Communigate server
$rcmail_config['password_ximss_port'] = 11024;
?>
plugins/password/drivers/ximss.php
New file
@@ -0,0 +1,81 @@
<?php
/**
 * Communigate driver for the Password Plugin for Roundcube
 *
 * Tested with Communigate Pro 5.1.2
 *
 * Configuration options:
 *   password_ximss_host - Host name of Communigate server
 *   password_ximss_port - XIMSS port on Communigate server
 *
 *
 * References:
 *   http://www.communigate.com/WebGuide/XMLAPI.html
 *
 * @version 1
 * @author Erik Meitner <erik wanderings.us>
 */
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, '<login id="A001" authData="'.$_SESSION['username'].'" password="'.$pass.'" />'."\0");
  fwrite( $sock, '<passwordModify id="A002" oldPassword="'.$pass.'" newPassword="'.$newpass.'"  />'."\0");
  fwrite( $sock, '<bye id="A003" />'."\0");
  //example responses
  //  <session id="A001" urlID="4815-vN2Txjkggy7gjHRD10jw" userName="user@example.com"/>\0
  //  <response id="A001"/>\0
  //  <response id="A002"/>\0
  //  <response id="A003"/>\0
  // or an error:
  //  <response id="A001" errorText="incorrect password or account name" errorNum="515"/>\0
  $responseblob = '';
  while (!feof($sock)) {
    $responseblob .= fgets($sock, 1024);
  }
  fclose($sock);
  foreach( explode( "\0",$responseblob) as $response )
  {
    $resp = simplexml_load_string("<xml>".$response."</xml>");
    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;
}
?>