2017-08-04 16:28:16 +02:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$skip_permissions = true;
|
|
|
|
|
include_once __DIR__.'/core.php';
|
|
|
|
|
|
|
|
|
|
$op = filter('op');
|
|
|
|
|
|
|
|
|
|
// LOGIN
|
|
|
|
|
switch ($op) {
|
|
|
|
|
case 'login':
|
2017-09-12 09:57:02 +02:00
|
|
|
|
$username = post('username');
|
|
|
|
|
$password = post('password');
|
2018-03-03 15:03:28 +01:00
|
|
|
|
|
2018-09-20 12:05:22 +02:00
|
|
|
|
if ($dbo->isConnected() && $dbo->isInstalled() && auth()->attempt($username, $password)) {
|
2019-08-28 09:28:08 +02:00
|
|
|
|
$_SESSION['keep_alive'] = true;
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
2019-08-29 11:25:13 +02:00
|
|
|
|
// Rimozione log vecchi
|
2019-08-28 16:58:47 +02:00
|
|
|
|
//$dbo->query('DELETE FROM `zz_operations` WHERE DATE_ADD(`created_at`, INTERVAL 30*24*60*60 SECOND) <= NOW()');
|
2018-07-08 16:18:44 +02:00
|
|
|
|
} else {
|
2018-09-20 12:05:22 +02:00
|
|
|
|
$status = auth()->getCurrentStatus();
|
2018-07-08 16:18:44 +02:00
|
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
|
flash()->error(Auth::getStatus()[$status]['message']);
|
2018-07-08 16:18:44 +02:00
|
|
|
|
|
|
|
|
|
redirect(ROOTDIR.'/index.php');
|
|
|
|
|
exit();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
}
|
2018-03-03 15:03:28 +01:00
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'logout':
|
|
|
|
|
Auth::logout();
|
|
|
|
|
|
|
|
|
|
redirect(ROOTDIR.'/index.php');
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Auth::check() && isset($dbo) && $dbo->isConnected() && $dbo->isInstalled()) {
|
2017-08-07 13:07:18 +02:00
|
|
|
|
$module = Auth::firstModule();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
|
|
if (!empty($module)) {
|
2018-07-09 11:11:54 +02:00
|
|
|
|
redirect(ROOTDIR.'/controller.php?id_module='.$module);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
} else {
|
|
|
|
|
redirect(ROOTDIR.'/index.php?op=logout');
|
|
|
|
|
}
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-03 15:03:28 +01:00
|
|
|
|
// Procedura di installazione
|
2018-07-03 11:12:32 +02:00
|
|
|
|
include_once $docroot.'/include/init/configuration.php';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
2018-03-03 15:03:28 +01:00
|
|
|
|
// Procedura di aggiornamento
|
2018-07-03 11:12:32 +02:00
|
|
|
|
include_once $docroot.'/include/init/update.php';
|
|
|
|
|
|
|
|
|
|
// Procedura di inizializzazione
|
|
|
|
|
include_once $docroot.'/include/init/init.php';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$pageTitle = tr('Login');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
2018-06-26 09:41:43 +02:00
|
|
|
|
include_once App::filepath('include|custom|', 'top.php');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
|
|
// Controllo se è una beta e in caso mostro un warning
|
2018-09-04 12:30:22 +02:00
|
|
|
|
if (Update::isBeta()) {
|
2017-08-04 16:28:16 +02:00
|
|
|
|
echo '
|
2018-04-13 17:46:13 +02:00
|
|
|
|
<div class="clearfix"> </div>
|
2018-04-06 17:39:56 +02:00
|
|
|
|
<div class="alert alert-warning alert-dismissable col-md-6 col-md-push-3 text-center fade in">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<i class="fa fa-warning"></i> <b>'.tr('Attenzione!').'</b> '.tr('Stai utilizzando una versione <b>non stabile</b> di OSM.').'
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
|
|
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
|
|
|
|
|
</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-04 10:24:44 +02:00
|
|
|
|
// Controllo se è una beta e in caso mostro un warning
|
|
|
|
|
if (Auth::isBrute()) {
|
|
|
|
|
echo '
|
|
|
|
|
<div class="box box-danger box-center" id="brute">
|
|
|
|
|
<div class="box-header with-border text-center">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<h3 class="box-title">'.tr('Attenzione').'</h3>
|
2017-09-04 10:24:44 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="box-body text-center">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<p>'.tr('Sono stati effettuati troppi tentativi di accesso consecutivi!').'</p>
|
|
|
|
|
<p>'.tr('Tempo rimanente (in secondi)').': <span id="brute-timeout">'.(Auth::getBruteTimeout() + 1).'</span></p>
|
2017-09-04 10:24:44 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<script>
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
$(".login-box").fadeOut();
|
|
|
|
|
brute();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function brute() {
|
|
|
|
|
var value = parseFloat($("#brute-timeout").html()) - 1;
|
|
|
|
|
$("#brute-timeout").html(value);
|
|
|
|
|
|
|
|
|
|
if(value > 0){
|
|
|
|
|
setTimeout("brute()", 1000);
|
|
|
|
|
} else{
|
|
|
|
|
$("#brute").fadeOut();
|
|
|
|
|
$(".login-box").fadeIn();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>';
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
|
if (!empty(flash()->getMessage('error'))) {
|
2017-08-04 16:28:16 +02:00
|
|
|
|
echo '
|
|
|
|
|
<script>
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
$(".login-box").effect("shake");
|
|
|
|
|
});
|
|
|
|
|
</script>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo '
|
2019-07-25 14:49:24 +02:00
|
|
|
|
<form action="?op=login" method="post" class="login-box box" autocomplete="off" >
|
2017-08-04 16:28:16 +02:00
|
|
|
|
<div class="box-header with-border text-center">
|
2019-08-02 10:38:55 +02:00
|
|
|
|
<img src="'.App::getPaths()['img'].'/logo.png" class="logo-image" alt="'.tr('OSM Logo').'">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<h3 class="box-title">'.tr('OpenSTAManager').'</h3>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
2018-04-13 17:46:13 +02:00
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
|
<div class="login-box-body box-body">
|
|
|
|
|
<div class="form-group input-group">
|
2018-12-14 11:14:52 +01:00
|
|
|
|
<span class="input-group-addon before"><i class="fa fa-user"></i> </span>
|
2019-04-04 10:50:29 +02:00
|
|
|
|
<input type="text" name="username" autocomplete="username" class="form-control" placeholder="'.tr('Nome utente').'"';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
if (isset($username)) {
|
|
|
|
|
echo ' value="'.$username.'"';
|
|
|
|
|
}
|
2019-09-20 17:59:27 +02:00
|
|
|
|
echo' required>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
2019-07-16 15:43:15 +02:00
|
|
|
|
|
|
|
|
|
{[ "type": "password", "name": "password", "autocomplete": "current-password", "placeholder": "'.tr('Password').'", "icon-before": "<i class=\"fa fa-lock\"></i>" ]}
|
2019-08-28 09:28:08 +02:00
|
|
|
|
|
|
|
|
|
<div class="text-right">
|
2019-07-16 15:43:15 +02:00
|
|
|
|
<a href="'.ROOTDIR.'/reset.php">'.tr('Dimenticata la password?').'</a>
|
|
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
2019-07-16 15:43:15 +02:00
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
|
<!-- /.box-body -->
|
|
|
|
|
<div class="box-footer">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<button type="submit" id="login" class="btn btn-danger btn-block">'.tr('Accedi').'</button>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
|
|
|
|
<!-- box-footer -->
|
|
|
|
|
</form>
|
|
|
|
|
<!-- /.box -->
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
$(document).ready( function(){
|
|
|
|
|
$("#login").click(function(){
|
2019-08-26 18:02:05 +02:00
|
|
|
|
$("#login").text("'.tr('Autenticazione').'...");
|
2017-08-04 16:28:16 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if( $("input[name=username]").val() == ""){
|
|
|
|
|
$("input[name=username]").focus();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$("input[name=password]").focus();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>';
|
|
|
|
|
|
2018-06-26 09:41:43 +02:00
|
|
|
|
include_once App::filepath('include|custom|', 'bottom.php');
|