Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple website to handle email passwords
- Loading branch information
0 parents
commit 1ce2d92
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a small script to setup on your OVH mutualisated server to manage email passwords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
$nic = "xxxxx-ovh"; // Votre nic ovh | ||
$pass = "********"; // Votre mot de passe ovh | ||
$domain = "yourdomaine.tld"; // your domain name | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
require_once(dirname(__FILE__).'/config.php'); | ||
?> | ||
<html> | ||
<title>Login to change email password</title> | ||
<body> | ||
<h3>Login to change email password</h3> | ||
<form action="modmail.php" method="post"> | ||
Your email : <input type="text" name="email">@<?php echo $domain; ?><br /> | ||
Your current password : <input type="password" name="passwordmail" /><br /> | ||
<input type="submit" value="Valider" /> | ||
</form> | ||
</html></body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
require_once(dirname(__FILE__).'/config.php'); | ||
|
||
$passwordmail = $_POST[passwordmail] ; | ||
$email = $_POST[$email] ; | ||
$dom = "@". $domaine; | ||
$serveur="pop3.". $domaine; | ||
$identifiant= $email . $dom; | ||
$mbox = @imap_open('{'.$serveur.':143}INBOX', "$identifiant", "$passwordmail"); | ||
if (!$mbox) { | ||
echo "Authentication error<br /><a href='index.php'>Back</a>"; | ||
exit; | ||
} | ||
imap_close($mbox); | ||
|
||
// Filtrage des données | ||
|
||
foreach ($_REQUEST as $key => $val) { | ||
$val = preg_replace("/[^_A-Za-z0-9-\.&=]/i",'', $val); | ||
$_REQUEST[$key] = $val; | ||
} | ||
$newpass = preg_replace("/[^_A-Za-z0-9-\.]/i",'', $_POST["newpass"]); | ||
$newpass2 = preg_replace("/[^_A-Za-z0-9-\.]/i",'', $_POST["newpass2"]); | ||
|
||
$errors[] = array(); | ||
$success = ''; | ||
|
||
if (strlen($newpass) > 8 && $newpass == $newpass2) { | ||
// 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 : ".$fault; | ||
} | ||
//popModifyPassword | ||
try { | ||
$result = $soap->popModifyPassword($session, $domaine, $email, $newpass, false); | ||
$success .= "popModifyPassword successfull<br/>"; | ||
$success .= print_r($result); | ||
$success .= "<br/>"; | ||
$success .= "<h3>Merci.<br />Mot de passe modifié.</h3>"; | ||
$success .= "<h3>Il sera pris en compte d'ici une quinzaine de minutes</h3>"; | ||
} catch(SoapFault $fault) { | ||
$errors[] = "Error : ".$fault; | ||
} | ||
//logout | ||
try { | ||
$result = $soap->logout($session); | ||
$success .= "logout successfull<br/>"; | ||
} catch(SoapFault $fault) { | ||
$errors[] = "Error : ".$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."; | ||
} | ||
|
||
$error_text = ''; | ||
if (!empty($errors)) { | ||
$error_text .= '<ul class="error-list">'; | ||
foreach($errors as $err) { | ||
$error_text .= '<li>'.$err.'</li>'; | ||
} | ||
$error_text .= '</ul>'; | ||
} | ||
?> | ||
<html> | ||
<title>Change the password of your email account</title> | ||
<body> | ||
|
||
<?php | ||
if ($success && empty($error)) { | ||
print $success; | ||
} else { ?> | ||
|
||
<h3>Change the password of your email account</h3> | ||
<?php echo $error_text; ?> | ||
<form action="modmail.php" method="post"> | ||
Your account: <? echo $identifiant; ?><br /><br /> | ||
Your new password: <br /> | ||
<input type="password" name="newpass" size="30" maxlength="50" id="newpass" value=""> | ||
(minimum 8 characters)<br /><br /> | ||
Confirm new password: <br /> | ||
<input type="password" name="newpass2" size="30" maxlength="20" id="newpass2" value=""> | ||
<br /><br /> | ||
<input type="submit" value="Send" /> | ||
<input type="hidden" name="passwordmail" value="<? echo $passwordmail; ?>"> | ||
<input type="hidden" name="email" value="<? echo $email; ?>"> | ||
</form> | ||
</html></body> | ||
|
||
<?php } | ||
?> |