0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 * domainFACTORY Password Driver
|
|
5 *
|
|
6 * Driver to change passwords with the hosting provider domainFACTORY.
|
|
7 * http://www.df.eu/
|
|
8 *
|
|
9 * @version 2.1
|
|
10 * @author Till Krüss <me@tillkruess.com>
|
|
11 * @link http://tillkruess.com/projects/roundcube/
|
|
12 *
|
|
13 * Copyright (C) 2005-2014, The Roundcube Dev Team
|
|
14 *
|
|
15 * This program is free software: you can redistribute it and/or modify
|
|
16 * it under the terms of the GNU General Public License as published by
|
|
17 * the Free Software Foundation, either version 3 of the License, or
|
|
18 * (at your option) any later version.
|
|
19 *
|
|
20 * This program is distributed in the hope that it will be useful,
|
|
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23 * GNU General Public License for more details.
|
|
24 *
|
|
25 * You should have received a copy of the GNU General Public License
|
|
26 * along with this program. If not, see http://www.gnu.org/licenses/.
|
|
27 */
|
|
28
|
|
29 class rcube_domainfactory_password
|
|
30 {
|
|
31 function save($curpass, $passwd)
|
|
32 {
|
|
33 $rcmail = rcmail::get_instance();
|
|
34
|
|
35 if (is_null($curpass)) {
|
|
36 $curpass = $rcmail->decrypt($_SESSION['password']);
|
|
37 }
|
|
38
|
|
39 if ($ch = curl_init()) {
|
|
40 // initial login
|
|
41 curl_setopt_array($ch, array(
|
|
42 CURLOPT_RETURNTRANSFER => true,
|
|
43 CURLOPT_URL => 'https://ssl.df.eu/chmail.php',
|
|
44 CURLOPT_POST => true,
|
|
45 CURLOPT_POSTFIELDS => http_build_query(array(
|
|
46 'login' => $rcmail->user->get_username(),
|
|
47 'pwd' => $curpass,
|
|
48 'action' => 'change'
|
|
49 ))
|
|
50 ));
|
|
51
|
|
52 if ($result = curl_exec($ch)) {
|
|
53 // login successful, get token!
|
|
54 $postfields = array(
|
|
55 'pwd1' => $passwd,
|
|
56 'pwd2' => $passwd,
|
|
57 'action[update]' => 'Speichern'
|
|
58 );
|
|
59
|
|
60 preg_match_all('~<input name="(.+?)" type="hidden" value="(.+?)">~i', $result, $fields);
|
|
61 foreach ($fields[1] as $field_key => $field_name) {
|
|
62 $postfields[$field_name] = $fields[2][$field_key];
|
|
63 }
|
|
64
|
|
65 // change password
|
|
66 $ch = curl_copy_handle($ch);
|
|
67 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
|
|
68 if ($result = curl_exec($ch)) {
|
|
69 // has the password been changed?
|
|
70 if (strpos($result, 'Einstellungen erfolgreich') !== false) {
|
|
71 return PASSWORD_SUCCESS;
|
|
72 }
|
|
73
|
|
74 // show error message(s) if possible
|
|
75 if (strpos($result, '<div class="d-msg-text">') !== false) {
|
|
76 preg_match_all('#<div class="d-msg-text">(.*?)</div>#s', $result, $errors);
|
|
77 if (isset($errors[1])) {
|
|
78 $error_message = '';
|
|
79 foreach ($errors[1] as $error) {
|
|
80 $error_message .= trim(mb_convert_encoding( $error, 'UTF-8', 'ISO-8859-15' )).' ';
|
|
81 }
|
|
82 return array('code' => PASSWORD_ERROR, 'message' => $error_message);
|
|
83 }
|
|
84 }
|
|
85 }
|
|
86 else {
|
|
87 return PASSWORD_CONNECT_ERROR;
|
|
88 }
|
|
89 }
|
|
90 else {
|
|
91 return PASSWORD_CONNECT_ERROR;
|
|
92 }
|
|
93 }
|
|
94 else {
|
|
95 return PASSWORD_CONNECT_ERROR;
|
|
96 }
|
|
97
|
|
98 return PASSWORD_ERROR;
|
|
99 }
|
|
100 }
|