chpw/mail.php
2016-09-11 17:48:55 +02:00

61 lines
2 KiB
PHP

<?php
require_once('config/mail.php');
global $sock;
$sock=mysql_connect($host,$user,$passwd);
mysql_select_db($db);
//fine sql
$cosa="mail";
require_once('include/template.php');
require_once('include/strenght_box.php');
printHead($title_page);
printLangSelector($lang);
if ($_POST["ph"]==""){
printPasswordStrenght();
}
printTitle($title);
if ($_POST["ph"]=="") {
printForm($form_user, $cosa, $lang);
} elseif ($_POST["ph"]=="1" AND $_POST["npwd"]==$_POST["npwd2"]) {
// risposte dopo il form iniziale se le due password di verifica sono uguali
//printTitle();
$email = $_POST["user"];
$opwd = mysql_real_escape_string(md5($_POST["opwd"]),$sock);
$npwd = mysql_real_escape_string(md5($_POST["npwd"]),$sock);
if (CRYPT_MD5 == 1) {
$npwdsalt = mysql_real_escape_string(crypt($_POST["npwd"]),$sock);
}
$mai = explode("@",$email);
//estrae dominio
function dom($name) {
$zon=explode(".",$name);
return implode(".",array_slice($zon,-2));
}
$dominio = dom($mai[1]);
$tab = mysql_real_escape_string(str_replace(".","_",$dominio),$sock);
$tempo = mysql_real_escape_string(time(),$sock);
$mailEscape = mysql_real_escape_string($mai[0],$sock);
$mailDomEscape = mysql_real_escape_string($mai[1],$sock);
$query2 = "UPDATE `$tab` SET md5salt = '$npwdsalt', password = '$npwd', modified = '$tempo' WHERE password = '$opwd' AND user = '$mailEscape' AND domain = '$mailDomEscape' AND tipo = 'mbox'";
// $query2 = "UPDATE $tab SET md5salt = '$npwdsalt', password = '$npwd', modified = '$tempo' WHERE user = '$mailEscape' AND domain = '$mailDomEscape' AND tipo = 'mbox'";
mysql_query($query2);
if (mysql_affected_rows()==1) {
printMessage($msgPasswordChanged);
if (strlen($_POST["npwd"])<6) {
printMessage($msgShortPassword);
}
} else {
printMessage($msgPasswordNotChanged);
}
} elseif ($_POST["ph"]=="1" AND $_POST["npwd"]!==$_POST["npwd2"]) {
// risposta dopo il form iniziale se le due password di verifica sono diverse
//printTitle($title);
printMessage($msgFailedConfirm);
}
printFooter();
?>