blob: 8a54fb7d9d55744e5b6ef22da0f1a6739ed42b2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
}
}
}
}
}
?>
|