gestione gare pubbliche
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.
 
 
 
 
 

132 righe
5.7 KiB

<?
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
$tokenVerified = false;
if (!empty($_SESSION["utente"]) && is_a($_SESSION["utente"],"Utente")) {
if (!empty($_GET["expired"])) {
$tmp = array();
$tmp["codice"] = $_SESSION["utente"]->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) {
$_GET["email"] = base64_encode($_SESSION["utente"]->getInfo()["email"]);
$_GET["token"] = base64_encode($tmp["password_token"]);
}
} else {
unset($_SESSION["utente"]);
}
}
if (((!empty($_GET["email"]) || !empty($_POST["email"])) && (!empty($_GET["token"]) || !empty($_POST["token"])))) {
$change_pwd = true;
$hide_footer = $hide_menu = TRUE;
include_once ($root."/layout/topLogin.php");
$email = empty($_GET["email"]) ? $_POST["email"] : $_GET["email"];
$email = base64_decode($email);
$token = empty($_GET["token"]) ? $_POST["token"] : $_GET["token"];
$token = base64_decode($token);
$bind=array(":token"=>$token,":email"=>$email);
$sql = "SELECT codice, password FROM b_utenti WHERE attivo = 'S' AND email = :email AND password_token = :token AND DATE_ADD(password_request, INTERVAL 2 DAY) > curdate()";
$ris = $pdo->go($sql,$bind);
?>
<div class="mt-auto mb-auto px-sm-5 scrollable">
<?
if ($ris->rowCount() === 1) {
$record = $ris->fetch(PDO::FETCH_ASSOC);
$show_form = true;
if (!empty($_POST["email"]) && !empty($_POST["password"])) {
$cryptpassw = md5($_POST["password"]);
if (password_verify($cryptpassw,$record["password"])) {
$msg = "La password deve essere differente da quella già utilizzata";
} else {
$array = array();
$array["codice"] = $record["codice"];
$array["password"] = password_hash(md5($_POST["password"]), PASSWORD_BCRYPT);
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_utenti";
$salva->operazione = "UPDATE";
$salva->oggetto = $array;
if ($salva->save()) {
$pdo->go("DELETE FROM b_login_hash WHERE codice_utente = :codice_utente", [':codice_utente' => $record["codice"]]);
$show_form = false;
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_password_log";
$salva->operazione = "INSERT";
$salva->oggetto = array("codice_utente"=>$record["codice"]);
$salva->save();
?>
<div class="text-center text-success">
<h1>
<span class="fa fa-check fa-5x"></span><br>
<?= __("Operazione effettuata con successo") ?><br><br>
<a class="btn btn-success btn-lg" href="/accesso<?= (!empty($_SESSION["ente"])) ? "" : "-admin" ?>.php" title="<?= __("accedi") ?>"><span class="fa fa-user"></span> <?= __("accedi") ?></a>
</h1>
</div>
<?
if (!empty($_SESSION["utente"]) && is_a($_SESSION["utente"],"Utente")) {
$pdo->go("DELETE FROM b_login_hash WHERE codice_utente = :codice_utente", [':codice_utente' => $record["codice"]]);
session_destroy();
}
} else {
$msg = "Errore nella richiesta";
}
}
}
if ($show_form) {
?>
<h1 class="text-center mb-5"><i class="fa fa-lock mb-3"></i><br><?= __("Reset password") ?></h1>
<div class="row">
<div class="col-12">
<? if (!empty($_GET["expired"])) { ?>
<div class="alert alert-danger">
<?= __("Password scaduta") ?>
</div>
<? } ?>
<? if (!empty($msg)) { ?>
<div class="alert alert-danger">
<?= __($msg) ?>
</div>
<? } ?>
<form action="change_pwd.php" rel="validate" method="post" target="_self">
<input type="hidden" name="email" value="<?= base64_encode($email) ?>">
<input type="hidden" name="token" value="<?= base64_encode($token) ?>">
<div class="form-group">
<label for="password"><?= __('Password') ?></label>
<input type="password" name="password" id="login-password" class="form-control" placeholder="<?= __('Password') ?>" title="<?= __('Password') ?>" rel="S;8;32;P;check-password;=">
</div>
<div class="form-group">
<label for="password"><?= __('Ripeti') ?> <?= __('password') ?></label>
<input type="password" class="form-control" id="check-password" title="<?= __("Ripeti") ?> <?= __("password") ?>" rel="S;8;32;P">
</div>
<div class="form-group">
<button class="form-control button btn-warning"><?= __('reset password') ?></button>
</div>
</form>
</div>
</div>
<?
}
} else {
alertManager::printAlertBox(__("Richiesta scaduta"));
}
?>
</div>
<?
include_once ($root."/layout/bottomLogin.php");
} else {
header('HTTP/1.0 403 Forbidden');
die();
}
?>