]> git.donarmstrong.com Git - roundcube.git/blob - plugins/password/drivers/vpopmaild.php
Imported Upstream version 0.3.1
[roundcube.git] / plugins / password / drivers / vpopmaild.php
1 <?php
2
3 /**
4  * vpopmail Password Driver
5  *
6  * Driver to change passwords via vpopmaild
7  *
8  * @version 1.0
9  * @author Johannes Hessellund
10  *
11  */
12
13 function password_save($curpass, $passwd)
14 {
15     $rcmail = rcmail::get_instance();
16 //    include('Net/Socket.php');
17     $vpopmaild = new Net_Socket();
18
19     if (PEAR::isError($vpopmaild->connect($rcmail->config->get('password_vpopmaild_host'), $rcmail->config->get('password_vpopmaild_port'), null))) {
20         return PASSWORD_CONNECT_ERROR;
21     }
22     else {
23         $result = $vpopmaild->readLine();
24         if(!preg_match('/^\+OK/', $result)) {
25             $vpopmaild->disconnect();
26             return PASSWORD_CONNECT_ERROR;
27         }
28         else {
29             $vpopmaild->writeLine("slogin ". $_SESSION['username'] . " " . $curpass);
30             $result = $vpopmaild->readLine();
31             if(!preg_match('/^\+OK/', $result) ) {
32                 $vpopmaild->writeLine("quit");
33                 $vpopmaild->disconnect();
34                 return PASSWORD_ERROR;
35             }
36             else {
37                 $vpopmaild->writeLine("mod_user ". $_SESSION['username']);
38                 $result = $vpopmaild->readLine();
39                 if(!preg_match('/^\+OK/', $result) ) {
40                     $vpopmaild->writeLine("quit");
41                     $vpopmaild->disconnect();
42                     return PASSWORD_ERROR;
43                 }
44                 else {
45                     $vpopmaild->writeLine("clear_text_password ". $passwd);
46                     $vpopmaild->writeLine(".");
47                     $result = $vpopmaild->readLine();
48                     $vpopmaild->writeLine("quit");
49                     $vpopmaild->disconnect();
50                     if (!preg_match('/^\+OK/', $result))
51                         return PASSWORD_ERROR;
52                     else
53                         return PASSWORD_SUCCESS;
54                 }
55             }
56         }
57     }
58 }
59
60 ?>