diff options
author | alecpl <alec@alec.pl> | 2009-06-20 13:21:10 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2009-06-20 13:21:10 +0000 |
commit | 4534ab8771aa563ba7628b78e2321a4322a13a9e (patch) | |
tree | abfdfa01fb22eb2a2c069169c6d9f9ff188e57df /plugins/password/drivers/poppassd.php | |
parent | 70306a4c75ddd70eb4886496df2bee63e0b09ac4 (diff) |
- Password plugin: added poppassd driver
Diffstat (limited to 'plugins/password/drivers/poppassd.php')
-rw-r--r-- | plugins/password/drivers/poppassd.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/password/drivers/poppassd.php b/plugins/password/drivers/poppassd.php new file mode 100644 index 000000000..8a54fb7d9 --- /dev/null +++ b/plugins/password/drivers/poppassd.php @@ -0,0 +1,56 @@ +<?php + +/** + * Poppassd Password Driver + * + * Driver to change passwords via Poppassd/Courierpassd + * + * @version 1.0 + * @author Philip Weir + * + */ + +function password_save($curpass, $passwd) +{ + $rcmail = rcmail::get_instance(); +// include('Net/Socket.php'); + $poppassd = new Net_Socket(); + + if (PEAR::isError($poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null))) { + return PASSWORD_CONNECT_ERROR; + } + else { + $result = $poppassd->readLine(); + if(!preg_match('/^2\d\d/', $result)) { + $poppassd->disconnect(); + return PASSWORD_ERROR; + } + else { + $poppassd->writeLine("user ". $_SESSION['username']); + $result = $poppassd->readLine(); + if(!preg_match('/^[23]\d\d/', $result) ) { + $poppassd->disconnect(); + return PASSWORD_CONNECT_ERROR; + } + else { + $poppassd->writeLine("pass ". $curpass); + $result = $poppassd->readLine(); + if(!preg_match('/^[23]\d\d/', $result) ) { + $poppassd->disconnect(); + return PASSWORD_ERROR; + } + else { + $poppassd->writeLine("newpass ". $passwd); + $result = $poppassd->readLine(); + $poppassd->disconnect(); + if (!preg_match('/^2\d\d/', $result)) + return PASSWORD_ERROR; + else + return PASSWORD_SUCCESS; + } + } + } + } +} + +?> |