[Svn] r2973 - in trunk/roundcubemail/plugins/password: . drivers

trac at roundcube.net trac at roundcube.net
Sun Sep 20 12:14:04 CEST 2009


Author: netbit
Date: 2009-09-20 05:14:04 -0500 (Sun, 20 Sep 2009)
New Revision: 2973

Added:
   trunk/roundcubemail/plugins/password/drivers/vpopmaild.php
Modified:
   trunk/roundcubemail/plugins/password/config.inc.php.dist
Log:
 - Password plugin: added vpopmaild driver

Modified: trunk/roundcubemail/plugins/password/config.inc.php.dist
===================================================================
--- trunk/roundcubemail/plugins/password/config.inc.php.dist	2009-09-20 09:09:36 UTC (rev 2972)
+++ trunk/roundcubemail/plugins/password/config.inc.php.dist	2009-09-20 10:14:04 UTC (rev 2973)
@@ -3,6 +3,7 @@
 // Password Plugin options
 // -----------------------
 // A driver to use for password change. Default: "sql".
+// Current possibilities: 'directadmin', 'ldap', 'poppassd', 'sasl', 'sql', 'vpopmaild'
 $rcmail_config['password_driver'] = 'sql';
 
 // Determine whether current password is required to change password.
@@ -148,4 +149,13 @@
 // TCP port used for DirectAdmin connections
 $rcmail_config['password_directadmin_port'] = 2222;
 
+
+// vpopmaild Driver options
+// -----------------------
+// The host which changes the password
+$rcmail_config['password_vpopmaild_host'] = 'localhost';
+
+// TCP port used for vpopmaild connections
+$rcmail_config['password_vpopmaild_port'] = 89;
+
 ?>

Added: trunk/roundcubemail/plugins/password/drivers/vpopmaild.php
===================================================================
--- trunk/roundcubemail/plugins/password/drivers/vpopmaild.php	                        (rev 0)
+++ trunk/roundcubemail/plugins/password/drivers/vpopmaild.php	2009-09-20 10:14:04 UTC (rev 2973)
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * vpopmail Password Driver
+ *
+ * Driver to change passwords via vpopmaild
+ *
+ * @version 1.0
+ * @author Johannes Hessellund
+ *
+ */
+
+function password_save($curpass, $passwd)
+{
+    $rcmail = rcmail::get_instance();
+//    include('Net/Socket.php');
+    $vpopmaild = new Net_Socket();
+
+    if (PEAR::isError($vpopmaild->connect($rcmail->config->get('password_vpopmaild_host'), $rcmail->config->get('password_vpopmaild_port'), null))) {
+        return PASSWORD_CONNECT_ERROR;
+    }
+    else {
+        $result = $vpopmaild->readLine();
+        if(!preg_match('/^\+OK/', $result)) {
+            $vpopmaild->disconnect();
+            return PASSWORD_CONNECT_ERROR;
+        }
+        else {
+            $vpopmaild->writeLine("slogin ". $_SESSION['username'] . " " . $curpass);
+            $result = $vpopmaild->readLine();
+            if(!preg_match('/^\+OK/', $result) ) {
+                $vpopmaild->disconnect();
+                return PASSWORD_ERROR;
+            }
+            else {
+                $vpopmaild->writeLine("mod_user ". $_SESSION['username']);
+                $result = $vpopmaild->readLine();
+                if(!preg_match('/^\+OK/', $result) ) {
+                    $vpopmaild->disconnect();
+                    return PASSWORD_ERROR;
+                }
+                else {
+                    $vpopmaild->writeLine("clear_text_password ". $passwd);
+                    $vpopmaild->writeLine(".");
+                    $result = $vpopmaild->readLine();
+                    $vpopmaild->disconnect();
+                    if (!preg_match('/^\+OK/', $result))
+                        return PASSWORD_ERROR;
+                    else
+                        return PASSWORD_SUCCESS;
+                }
+            }
+        }
+    }
+}
+
+?>

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list