-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.php
170 lines (156 loc) · 5.18 KB
/
index.php
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
// ovhmail-password - Manage your OVH mails
// Licence: http://www.opensource.org/licenses/zlib-license.php
// Requires: php 5
require_once(dirname(__FILE__).'/config.php');
$errors = array();
$passwordmail = '';
$email_name = '';
$email = '';
$need_login = false;
if (!empty($_POST) && isset($_POST['passwordmail']) && isset($_POST['email'])) {
$passwordmail = $_POST['passwordmail'] ;
$email_name = $_POST['email'];
} else {
$need_login = true;
}
$email = $email_name . $dom;
$mbox = @imap_open('{'.$serveur.':143}INBOX', "$email", "$passwordmail");
if (!$mbox) {
if (!empty($_POST)) {
$errors[] = "Authentication error";
}
$need_login = true;
} else {
imap_close($mbox);
// Filtrage des données
foreach ($_REQUEST as $key => $val) {
$val = preg_replace("/[\'\"\\\?\~]/i",'', $val);
$_REQUEST[$key] = $val;
}
$newpass = '';
$newpass2 = '';
if (isset($_POST['newpass'])) {
$newpass = preg_replace("/[[\'\"\\\?\~]/i",'', $_POST["newpass"]);
}
if (isset($_POST['newpass2'])) {
$newpass2 = preg_replace("/[[\'\"\\\?\~]/i",'', $_POST["newpass2"]);
}
$success = '';
if (strlen($newpass) >= 8 && $newpass == $newpass2 && $_POST["newpass"]==$newpass) {
// Vérification du bon nouveau mot de passe (avec les deux champs puis on valide si ok )
$soap = new SoapClient('https://www.ovh.com/soapi/soapi-1.2.wsdl');
//login
try {
$language = null;
$multisession = false;
$session = $soap->login($nic,$pass,$language,$multisession);
//$success .= "login successfull<br/>";
} catch(SoapFault $fault) {
$errors[] = "Error : login";//.$fault;
}
//popModifyPassword
try {
$result = $soap->popModifyPassword($session, $domain, $email_name, $newpass, false);
//$success .= "popModifyPassword successfull<br/>";
//$success .= print_r($result);
//$success .= "<br/>";
$success .= "<h3>Thank you.<br />Password has been modified.</h3>";
$success .= "<h3>The change will be visible maximally in 15 minutes.</h3>";
} catch(SoapFault $fault) {
$errors[] = "Error : popModifyPassword";//.$fault;.$fault;
}
//logout
try {
$result = $soap->logout($session);
//$success .= "logout successfull<br/>";
} catch(SoapFault $fault) {
$errors[] = "Error : logout";//.$fault;.$fault;
}
} elseif (strlen($newpass) > 0 && $newpass != $newpass2) {
// ici le cas ou le premier nouveau mot de passe ne correspond pas au second
$errors[] = "The two passwords are not equal, please check it";
} elseif (strlen($newpass) > 0 && strlen($newpass) < 8) {
// Si le mot de passe fait moins de 8 caractères on refuse
$errors[] = "Make sure your password has minimum 8 characters.";
} elseif ($_POST["newpass"]!=$newpass) {
// Si le mot de passe fait moins de 8 caractères on refuse
$errors[] = "Password contains one or more of invalid characters:<ul><li>\'</li><li>\"</li><li>\\</li><li>\?</li><li>\~</li></ul>";
}
}
$error_text = '';
if (!empty($errors)) {
$error_text .= '<ul class="error-list">';
foreach($errors as $err) {
$error_text .= '<li>'.$err.'</li>';
}
$error_text .= '</ul>';
}
if ($need_login) {
$title = "Welcome on OVH email management";
} else {
$title = "Change the password of your email account";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" title="normal" href="common.css">
<title>Change the password of your email account</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
</head>
<body>
<img id="logo" border="0" style="margin:0 11px" alt="OVH Mail" src="logo.jpg">
<div id="login-form">
<div class="boxtitle"><?php echo $title; ?></div>
<div class="boxcontent">
<?php echo $error_text; ?>
<?php
if ($need_login) { ?>
<form name="form" action="index.php" method="post">
<table summary="" border="0">
<tbody><tr><td class="title">
<label for="email">Your email</label>
</td>
<td><input name="email" id="email" type="text" value="" />@<?php echo $domain; ?></td>
</tr>
<tr><td class="title"><label for="password">Your current password</label>
</td>
<td><input name="passwordmail" id="password" type="password" /></td>
</tr>
</tbody>
</table>
<p style="text-align:center;"><input type="submit" class="button mainaction" value="Authentication" /></p>
</form>
<?php
} elseif (strlen($success) > 0 && empty($errors)) {
print $success;
} else { ?>
<form name="form "action="index.php" method="post">
<input type="hidden" name="passwordmail" value="<?php echo $passwordmail; ?>">
<input type="hidden" name="email" value="<?php echo $email_name; ?>">
<table summary="" border="0">
<tbody>
<tr><td colspan=2>
Your account: <?php echo $email; ?><br /><br />
</td></tr>
<tr><td class="title">
<label for="newpass">Your new password</label>
</td>
<td><input name="newpass" id="newpass" type="password" /></td>
</tr>
<tr><td class="title">
<label for="newpass2">Confirm new password</label>
</td>
<td><input name="newpass2" id="newpass2" type="password" /></td>
</tr>
</tbody>
</table>
<p style="text-align:center;"><input type="submit" class="button mainaction" value="Send" /></p>
</form>
<?php }
?>
</div>
</div>
</body>
</html>