source: subversion/trunk/plugins/password/drivers/domainfactory.php @ 5974

Last change on this file since 5974 was 5974, checked in by alec, 16 months ago
File size: 1.7 KB
Line 
1<?php
2
3/**
4 * domainFACTORY Password Driver
5 *
6 * Driver to change passwords with the hosting provider domainFACTORY.
7 * See: http://www.df.eu/
8 *
9 * @version 2.0
10 * @author Till KrÃŒss <me@tillkruess.com>
11 * @link http://tillkruess.com/projects/roundcube/
12 *
13 */
14
15class rcube_domainfactory_password
16{
17    function save($curpass, $passwd)
18    {
19            $rcmail = rcmail::get_instance();
20
21            if (is_null($curpass)) {
22                    $curpass = $rcmail->decrypt($_SESSION['password']);
23            }
24
25        if ($ch = curl_init()) {
26                // initial login
27                curl_setopt_array($ch, array(
28                        CURLOPT_RETURNTRANSFER => true,
29                        CURLOPT_URL => 'https://ssl.df.eu/chmail.php',
30                        CURLOPT_POST => true,
31                        CURLOPT_POSTFIELDS => array(
32                                'login' => $rcmail->user->get_username(),
33                                    'pwd' => $curpass,
34                                'action' => 'change'
35                        )
36                    ));
37
38                if ($result = curl_exec($ch)) {
39                        // login successful, get token!
40                        $postfields = array(
41                                'pwd1' => $passwd,
42                                'pwd2' => $passwd,
43                                    'action[update]' => 'Speichern'
44                        );
45
46                        preg_match_all('~<input name="(.+?)" type="hidden" value="(.+?)">~i', $result, $fields);
47                        foreach ($fields[1] as $field_key => $field_name) {
48                                $postfields[$field_name] = $fields[2][$field_key];
49                            }
50
51                        // change password
52                        $ch = curl_copy_handle($ch);
53                        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
54                            if ($result = curl_exec($ch)) {
55                                if (strpos($result, 'Einstellungen erfolgreich') !== false) {
56                                        return PASSWORD_SUCCESS;
57                                }
58                        } else {
59                                return PASSWORD_CONNECT_ERROR;
60                        }
61                } else {
62                        return PASSWORD_CONNECT_ERROR;
63                    }
64        } else {
65                return PASSWORD_CONNECT_ERROR;
66            }
67
68        return PASSWORD_ERROR;
69    }
70}
Note: See TracBrowser for help on using the repository browser.