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.
234 righe
10 KiB
234 righe
10 KiB
<? |
|
$pagina_login = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!$disableCaptcha) { |
|
$required_js[] = "https://www.google.com/recaptcha/api.js?render=6Lcj75wUAAAAAIwBGvI9-HkFD6gtKaSXq1Pihx1s"; |
|
} |
|
if (!isset($_SESSION["utente"]) && |
|
( |
|
(isset($_SESSION["id_sessione"]) && md5(session_id()) == $_SESSION["id_sessione"] && isset($_SESSION["ente"])) |
|
|| |
|
(isset($_SESSION["id_sessione-admin"]) && sha1(session_id()) == $_SESSION["id_sessione-admin"] && !isset($_SESSION["ente"])) |
|
) |
|
) { |
|
include($root."/layout/topLogin.php"); |
|
$form = true; |
|
if (!empty($_POST)) { |
|
if (tokenVerify() && (!empty($_POST["g-recaptcha-response"]) || $disableCaptcha)) { |
|
$score = 0; |
|
if ($disableCaptcha) { $score = 1; } |
|
if (!empty($_POST["g-recaptcha-response"])) { $score = verifyGoogleCaptchaV3($_POST["g-recaptcha-response"]); } |
|
if ((isset($_POST["g-recaptcha-response"]) && $score > 0 || $disableCaptcha) && (!empty($_POST["email"]) && !empty($_POST["password"]))) { |
|
$login = Utente::login($_POST["email"],$_POST["password"],(isset($_POST["force"]))?true:false); |
|
} |
|
} |
|
$soglia_bot = 0.3; |
|
$bot = false; |
|
if (isset($login) && is_a($login,"Utente")) { |
|
if ($score >= $soglia_bot || $login->botVerify == "N") { |
|
$_SESSION["utente"] = $login; |
|
if ($_SESSION["utente"]->gerarchia >= 100) { |
|
session_write_close(); |
|
echo '<meta http-equiv="refresh" content="0;URL=/index.php">'; |
|
die(); |
|
} else { |
|
session_write_close(); |
|
echo '<meta http-equiv="refresh" content="0;URL=/backend/index.php">'; |
|
die(); |
|
} |
|
} else { |
|
$bot = true; |
|
} |
|
} |
|
if (isset($login) && $login === -1) { |
|
$login_force = true; |
|
} else { |
|
$login_error = true; |
|
$form = false; |
|
$locked = false; |
|
$msg = ""; |
|
if ($bot) { |
|
$locked = true; |
|
} else if (!empty($login)) { |
|
$residui = 5 - $login["tentativi"] ; |
|
if ($residui <= 0 || $login["scaduto"]=="S") { |
|
$locked = true; |
|
} else { |
|
if ($residui != 5) { |
|
$msg = "<br>" . __('Tentativi residui:') . $residui; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
?> |
|
<div class="my-auto mb-auto px-sm-5"> |
|
<script> |
|
function sendCaptcha() { |
|
grecaptcha.execute('6Lcj75wUAAAAAIwBGvI9-HkFD6gtKaSXq1Pihx1s', {action: 'login'}).then(function(token) { |
|
$('#g-recaptcha-response').val(token) |
|
$("#login_form").submit(); |
|
}); |
|
return false; |
|
} |
|
function reset_pwd() { |
|
$("#reset_form").submit(); |
|
<? if (!$disableCaptcha) { ?>grecaptcha.reset();<? } ?> |
|
} |
|
function resend_confirm() { |
|
$("#resend_form").submit(); |
|
<? if (!$disableCaptcha) { ?>grecaptcha.reset();<? } ?> |
|
} |
|
function unlock() { |
|
$("#unlock_form").submit(); |
|
<? if (!$disableCaptcha) { ?>grecaptcha.reset();<? } ?> |
|
} |
|
</script> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<? |
|
if(isset($login_error)) { |
|
?> |
|
<div id="error-message" class="alert alert-danger text-center rounded-0 py-5"> |
|
<span class="d-block mb-3 fa fa-exclamation-triangle fa-3x"></span> |
|
<? |
|
if (isset($locked) && $locked) { |
|
$email = purify($_POST["email"]); |
|
$label = (!empty($login) && $login["scaduto"]=="S") ? __("Utenza bloccata per inutilizzo da più di 6 mesi") : __("Utenza bloccata per eccessivi tentativi errati"); |
|
?> |
|
<span class="d-block mb-2"><?= $label ?></span> |
|
<form action="/profilo/send-unlock.php" method="post" id="unlock_form"> |
|
<input type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<input type="hidden" name="email" value="<?= $email ?>"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<div class="form-group mt-4"> |
|
<button class="btn btn-danger" data-callback="unlock"><?= __("Sblocca") ?></button> |
|
</div> |
|
</form> |
|
<? |
|
} else { |
|
?> |
|
<p> |
|
<? |
|
echo __('Utente non riconosciuto'); |
|
if(! empty($msg)) { |
|
echo $msg; |
|
} |
|
?> |
|
</p> |
|
<a href="/accesso.php" class="btn btn-danger"><em class="fa fa-undo mr-2"></em><?= __("Riprova") ?></a> |
|
<? |
|
} |
|
?> |
|
</div> |
|
<? |
|
} |
|
?> |
|
<form id="login_form" action="/accesso.php" rel="validate" method="post" target="_self"> |
|
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response"> |
|
<input type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<? if ( ! empty($login_force)) { ?><input type="hidden" name="force" value="S"><? } ?> |
|
<? |
|
if(isset($login_force)) { |
|
?> |
|
<div id="warning-message" class="alert alert-info font-weight-bold text-center rounded-0"> |
|
<span class="d-block fa fa-exclamation-triangle fa-3x mb-2"></span> |
|
<?= __('Un altro utente sta usando queste credenziali. Ripeti il login per sbloccare la sessione, tutte le altre sessioni saranno disattivate') ?> |
|
</div> |
|
<? |
|
} |
|
if($form) { |
|
?> |
|
<div class="form-group"> |
|
<label for="login-email"><em class="fa fa-user mr-2"></em><?= __('Indirizzo e-mail') ?></label> |
|
<input type="text" name="email" id="login-email" class="form-control" placeholder="<?= __('Indirizzo e-mail') ?>" title="<?= __('Indirizzo e-mail') ?>" rel="S;5;0;E"> |
|
</div> |
|
<div class="form-group"> |
|
<label for="login-password"><em class="fa fa-lock mr-2"></em><?= __('Password') ?></label> |
|
<input type="password" name="password" id="login-password" class="form-control" placeholder="<?= __('Password') ?>" title="<?= __('Password') ?>" rel="S;8;32;A"> |
|
</div> |
|
<div class="form-group"> |
|
<button class="btn btn-block btn-primary" onClick="sendCaptcha(); return false;"><?= __("Accedi") ?></button> |
|
</div> |
|
<? |
|
if (isset($_SESSION["ente"])) { ?> |
|
<div class="form-group"> |
|
<a class="btn btn-warning btn-block" href="/register.php" role="button"><?= __('Registrati') ?></a> |
|
</div> |
|
<? |
|
} |
|
} |
|
?> |
|
<div class="text-right mb-2"> |
|
<span class="text-secondary"><?= __('non riesci ad accedere') ?></span><br> |
|
<a href="#" data-toggle="modal" class="mx-2" data-target="#recupera_password" title="<?= __('reset password') ?>"><?= __('Reset password') ?></a> |
|
<? if (isset($_SESSION["ente"])) { ?> |
|
<a href="#" data-toggle="modal" data-target="#resend-link" title="<?= __('Rigenera PEC di conferma') ?>"><?= __('Rigenera PEC di conferma') ?></a> |
|
<? } ?> |
|
</div> |
|
</form> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="modal fade" id="recupera_password"> |
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
|
<div class="modal-content rounded-0"> |
|
<form action="/profilo/send-reset.php" rel="validate" method="post" id="reset_form"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<div class="modal-header"> |
|
<h4 class="modal-title"><?= __('reset password') ?></h4> |
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|
<span aria-hidden="true">×</span> |
|
<span class="sr-only">Close</span> |
|
</button> |
|
</div> |
|
<div class="modal-body"> |
|
<div class="form-group text-left"> |
|
<label for="email"><?= __('indirizzo e-mail') ?></label> |
|
<input type="text" class="input-lg form-control" name="email" title="<?= __('indirizzo e-mail') ?>" rel="S;3;0;E"> |
|
</div> |
|
</div> |
|
<div class="modal-footer"> |
|
<button class="btn btn-primary" data-callback="reset_pwd"><?= __('reset password') ?></button> |
|
<button class="btn btn-secondary" data-dismiss="modal"><?= __('Chiudi') ?></button> |
|
</div> |
|
</form> |
|
</div><!-- /.modal-content --> |
|
</div><!-- /.modal-dialog --> |
|
</div><!-- /.modal --> |
|
<div class="modal fade" id="resend-link"> |
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
|
<div class="modal-content rounded-0"> |
|
<form action="/oe/reinvia_conferma.php" rel="validate" method="post" id="resend_form"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<div class="modal-header"> |
|
<h4 class="modal-title"><?= __('Reinvia conferma') ?></h4> |
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|
<span aria-hidden="true">×</span> |
|
<span class="sr-only">Close</span> |
|
</button> |
|
</div> |
|
<div class="modal-body"> |
|
<div class="form-group text-left"> |
|
<label for="email"><?= __('indirizzo PEC') ?></label> |
|
<input type="text" class="input-lg form-control" name="pec_recupero" title="<?= __('indirizzo PEC') ?>" rel="S;3;0;E"> |
|
</div> |
|
</div> |
|
<div class="modal-footer"> |
|
<button class="btn btn-primary" data-callback="resend_confirm"><?= __('Invia conferma') ?></button> |
|
<button class="btn btn-secondary" data-dismiss="modal"><?= __('Chiudi') ?></button> |
|
</div> |
|
</form> |
|
</div><!-- /.modal-content --> |
|
</div><!-- /.modal-dialog --> |
|
</div><!-- /.modal --> |
|
<? |
|
include($root."/layout/bottomLogin.php"); |
|
} else { |
|
echo "<h1>Accesso negato</h1>"; |
|
session_destroy(); |
|
echo '<meta http-equiv="refresh" content="0;URL=/index.php">'; |
|
die(); |
|
} |
|
?>
|