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
| <?php
if(isset($_SESSION['user']) && isset($_SESSION['pass'])){
?><div id="msg">
<?php
if($_GET['new_email'] && $_GET['new_email']!=NULL)
{
$log = $_SESSION['user'];
$new_email = replace($_GET['new_email']);
$cod = replace($_GET['cod']);
if($new_email !=NULL && $cod!=NULL)
{
$chk = mysql_query("Select * from account.account where new_email_change='$new_email' and new_email_change2='$cod'");
// Verific daca emailul si codul sunt bune
if(mysql_num_rows($chk)==1)
{
$old = mysql_fetch_object($chk);
mysql_query("Update account.account set email='$new_email',new_email_change2='1' where login='$log'");
echo succes("Votre adresse a été modifié avec succès ".$new_email."");
}
else
{
echo error("Lien incorrect.");
}
}
}
else {
if($_GET['email']!=NULL && $_GET['cod'] !=NULL)
{
$log = $_SESSION['user'];
$cod = replace($_GET['cod']);
$email = replace($_GET['email']);
if($cod != NULL && $email != NULL)
{
$cods = mysql_query("Select * from account.account where email='$email' AND emailchange_token='$cod'");
if(mysql_num_rows($cods) == 0)
{
echo error("Lien incorrect.");
}
else
{
$ch = mysql_fetch_object($cods);
$cod = md5(rand(999,999999));
mysql_query("Update account.account set emailchange_token='1',new_email_change2='$cod' where login='$log'") or die(mysql_error());
$email = $ch->new_email_change;
$to = $email;
$subject = 'Confirmer le changement par Email!';
$message = "Pour confirmer le changement, cliquer sur le lien ci dessous ". "\r\n" ."http://www.naecyth-mt2.fr/index.php?page=schimbare-email&new_email=".$email."&cod=".$cod."";
new mail($to, $subject, $message);
echo succes("Un mail a été envoyé à* l'adresse.");
}
}
}
else {
$oldemail = replace($_POST['oldEmail']);
$newemail = replace($_POST['newEmail']);
$log = $_SESSION['user'];
if($oldemail !=NULL && $newemail !=NULL)
{
if($oldemail!=$newemail)
{
$ch1 = mysql_query("Select * from account.account where login='$log' and email='$oldemail'");
$ch2 = mysql_query("Select * from account.account where email='$newemail'");
if(mysql_num_rows($ch2) == 0) // Verific daca emailul nou nu exista deja
{
if(mysql_num_rows($ch1) == 1) // Emailul vechi este al meu
{
$cod = md5(rand(999,999999));
mysql_query("Update account.account set emailchange_token='$cod',new_email_change='$newemail' where login='$log'"); // Generez cod si inserez codul si adresa noua in db
$email = $oldemail;
$to = $email;
$subject = 'Confirmer par Mail!';
$message = "Pour confirmer le changement, cliquez sur le lien ci-dessous ". "\r\n" ."http://www.naecyth-mt2.fr/index.php?page=schimbare-email&email=".$oldemail."&cod=".$cod."
";
new mail($to, $subject, $message);
echo succes("Il faut confirmer par mail. Etape obligatoire pour continuer");// Trimit codul pe emailul vechi.
}
else
{
echo error("L'email ne correspond pas");
}
}
else
{
echo error("Noul email exista deja in baza de date.Alegeti altul");
}
}
else { echo error("Les deux adresses mail sont identiques ... Je me demande parfois si tu as un cerveau :p"); }
} } }
?></div>
<h4>Changer son adresse mail :</h4>
<form name="emailChangeForm" id="emailChangeForm" method="POST" action="">
<table width="100%" border="0">
<tr>
<td width="25%">Adresse actuelle : </td>
<td width="75%"><input type="text" id="oldEmail" name="oldEmail" title="" value="" maxlength="64" class="iRg_input"/></td>
</tr>
<tr>
<td>Nouvelle adresse : </td>
<td><input type="text" id="newEmail" name="newEmail" title="" value="" maxlength="64" class="iRg_input"/></td>
</tr>
<tr>
<td> </td>
<td><input id="submitBtn" type="submit" name="SubmitEmailChange" value="Confirmer" class="buton"/></td>
</tr>
</table></form>
<?php } else {echo "Acces restrictionat!";}?> |
Partager