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':
|
|
|
|
|
$username = filter('username');
|
|
|
|
|
$password = filter('password');
|
2017-08-07 13:07:18 +02:00
|
|
|
|
if ($dbo->isConnected() && $dbo->isInstalled() && Auth::getInstance()->attempt($username, $password)) {
|
2017-08-04 16:28:16 +02:00
|
|
|
|
$_SESSION['keep_alive'] = (filter('keep_alive') != null);
|
|
|
|
|
|
|
|
|
|
// Auto backup del database giornaliero
|
|
|
|
|
if (get_var('Backup automatico')) {
|
|
|
|
|
$folders = glob($backup_dir.'*');
|
|
|
|
|
$regexp = '/'.date('Y\-m\-d').'/';
|
|
|
|
|
|
|
|
|
|
// Controllo se esiste già un backup zip o folder creato per oggi
|
|
|
|
|
if (!empty($folders)) {
|
|
|
|
|
$found = false;
|
|
|
|
|
foreach ($folders as $folder) {
|
|
|
|
|
if (preg_match($regexp, $folder, $matches)) {
|
|
|
|
|
$found = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($found) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['infos'][] = tr('Backup saltato perché già esistente!');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
} elseif (do_backup()) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['infos'][] = tr('Backup automatico eseguito correttamente!');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
} elseif (empty($backup_dir)) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['errors'][] = tr('Non è possibile eseguire i backup poichè la cartella di backup non esiste!!!');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
} elseif (!file_exists($backup_dir)) {
|
|
|
|
|
if (mkdir($backup_dir)) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['infos'][] = tr('La cartella di backup è stata creata correttamente.');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
if (do_backup()) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['infos'][] = tr('Backup automatico eseguito correttamente!');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$_SESSION['errors'][] = tr('Non è stato possibile creare la cartella di backup!');
|
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)) {
|
|
|
|
|
redirect(ROOTDIR.'/controller.php?id_module='.$module, 'js');
|
|
|
|
|
} else {
|
|
|
|
|
redirect(ROOTDIR.'/index.php?op=logout');
|
|
|
|
|
}
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
include_once $docroot.'/include/configuration.php';
|
|
|
|
|
|
|
|
|
|
include_once $docroot.'/include/update.php';
|
|
|
|
|
|
2017-09-04 12:02:29 +02:00
|
|
|
|
$pageTitle = tr('Login');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
|
|
if (file_exists($docroot.'/include/custom/top.php')) {
|
|
|
|
|
include_once $docroot.'/include/custom/top.php';
|
|
|
|
|
} else {
|
|
|
|
|
include_once $docroot.'/include/top.php';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Controllo se è una beta e in caso mostro un warning
|
2017-08-28 15:29:03 +02:00
|
|
|
|
if (str_contains($version, 'beta')) {
|
2017-08-04 16:28:16 +02:00
|
|
|
|
echo '
|
|
|
|
|
<div class="alert alert-warning alert-dismissable pull-right 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>';
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
|
if (!empty($_SESSION['errors'])) {
|
|
|
|
|
echo '
|
|
|
|
|
<script>
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
$(".login-box").effect("shake");
|
|
|
|
|
});
|
|
|
|
|
</script>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
<form action="?op=login" method="post" class="login-box box">
|
|
|
|
|
<div class="box-header with-border text-center">
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<img src="'.$img.'/logo.png" alt="'.tr('OSM Logo').'">
|
|
|
|
|
<h3 class="box-title">'.tr('OpenSTAManager').'</h3>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
|
|
|
|
<!-- /.box-header -->
|
|
|
|
|
<div class="login-box-body box-body">
|
|
|
|
|
<div class="form-group input-group">
|
|
|
|
|
<span class="input-group-addon"><i class="fa fa-user"></i> </span>
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<input type="text" name="username" autocomplete="off" class="form-control" placeholder="'.tr('Nome utente').'"';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
if (isset($username)) {
|
|
|
|
|
echo ' value="'.$username.'"';
|
|
|
|
|
}
|
|
|
|
|
echo'>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group input-group">
|
|
|
|
|
<span class="input-group-addon"><i class="fa fa-lock"></i> </span>
|
2017-09-04 12:02:29 +02:00
|
|
|
|
<input type="password" name="password" autocomplete="off" class="form-control" placeholder="'.tr('Password').'">
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<input type="checkbox" name="keep_alive"';
|
|
|
|
|
if (filter('keep_alive') != null) {
|
|
|
|
|
echo ' checked';
|
|
|
|
|
}
|
2017-09-04 12:02:29 +02:00
|
|
|
|
echo '/> '.tr('Mantieni attiva la sessione').'
|
2017-08-04 16:28:16 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- /.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(){
|
|
|
|
|
$("#login").text("';
|
|
|
|
|
if ($dbo->isInstalled() && get_var('Backup automatico')) {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
echo tr('Backup automatico in corso');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
} else {
|
2017-09-04 12:02:29 +02:00
|
|
|
|
echo tr('Autenticazione');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
}
|
|
|
|
|
echo '...");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if( $("input[name=username]").val() == ""){
|
|
|
|
|
$("input[name=username]").focus();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$("input[name=password]").focus();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>';
|
|
|
|
|
|
|
|
|
|
if (file_exists($docroot.'/include/custom/bottom.php')) {
|
|
|
|
|
include_once $docroot.'/include/custom/bottom.php';
|
|
|
|
|
} else {
|
|
|
|
|
include_once $docroot.'/include/bottom.php';
|
|
|
|
|
}
|