Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
75 righe
3.0 KiB
75 righe
3.0 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
if ((!empty($_POST["email"]) && tokenVerify())||(!empty($_POST["codice"]) && !empty($_SESSION["utente"]) && $_SESSION["utente"]->permission("utenti",$_POST["codice"]))) { |
|
$bind = array(); |
|
$sql = "SELECT codice, email, attivo |
|
FROM b_utenti |
|
WHERE attivo = 'S' "; |
|
if (!empty($_POST["email"])) { |
|
$bind[":email"] = $_POST["email"]; |
|
$sql.=" AND email = :email "; |
|
} else { |
|
$bind[":codice"] = $_POST["codice"]; |
|
$sql.=" AND codice = :codice "; |
|
} |
|
$ris = $pdo->go($sql,$bind); |
|
if ($ris->rowCount()===1) { |
|
$record = $ris->fetch(PDO::FETCH_ASSOC); |
|
$tmp = array(); |
|
$tmp["codice"] = $record["codice"]; |
|
$tmp["password_request"] = date("Y-m-d H:m:i"); |
|
$tmp["password_token"] = tokenGen(); |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_utenti"; |
|
$salva->operazione = "UPDATE"; |
|
$salva->oggetto = $tmp; |
|
if ($salva->save() > 0) { |
|
$link_sito = $_SESSION["config"]["link_sito"]; |
|
$nome_sito = $_SESSION["config"]["nome_sito"]; |
|
$mailer = new Communicator(); |
|
if (empty($_SESSION["ente"]) && !empty($_POST["codice_ente"]) && !empty($_POST["codice"])) { |
|
$info = ente::getInfoFromID($_POST["codice_ente"]); |
|
if (!empty($info)) { |
|
$info = $info[0]; |
|
$mailer->codice_ente = $info["codice"]; |
|
if (!empty($info["dominio"])) { |
|
$link_sito = $config["protocollo"] . $info["dominio"]; |
|
} |
|
$nome_sito = $config["nome_sito"] . " - " . $info["denominazione"]; |
|
} |
|
} |
|
$link = $link_sito . "/profilo/change_pwd.php?email=" . base64_encode($record["email"]) . "&token=" . base64_encode($tmp["password_token"]); |
|
$link = "<a href='".$link."' target=\"_blank\" title=\"".__("Reset password")."\">".$link."</a>"; |
|
|
|
$oggetto = __("Reset password"); |
|
$messaggio = "<h1>" . $nome_sito . "</h1>"; |
|
$messaggio.= __("Hai richiesto il recupero della password per l'accesso ai servizi del portale") . "<br><br>"; |
|
$messaggio.= $link; |
|
$messaggio.= "<br><br>".__("Clicca o incolla il link nel browser per creare una nuova password. Il link sarà attivo per le prossime 48 ore") . "<br><br>"; |
|
$oggetto = "Cambio Password"; |
|
|
|
$mailer->oggetto = $oggetto; |
|
$mailer->corpo = $messaggio; |
|
$mailer->codice_pec = -3; |
|
$mailer->comunicazione = false; |
|
$mailer->coda = false; |
|
$mailer->destinatari = $record["email"]; |
|
$esito = $mailer->send(); |
|
if ($esito==true) { |
|
$error = false; |
|
?> |
|
swal({title:js_dict["success-msg"],text:"<?= __('Una mail è stata inviata all\'indirizzo indicato') ?>",type:"success"}).then(function(){ window.location.reload(); }); |
|
<? |
|
} |
|
} |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 400 Bad Request'); |
|
die(); |
|
} |
|
?>
|
|
|