Skip to content

Commit 8918268

Browse files
Aggiunta modalità manutenzione e blocco hooks e cron
1 parent ad5b45a commit 8918268

5 files changed

Lines changed: 79 additions & 13 deletions

File tree

‎config.example.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343
// Permette di eseguire il cron anche se OSM è installato su localhost
4444
$forza_cron_localhost = false;
4545

46+
// Permette di disabilitare i cron e gli hooks
47+
$disable_cron = false;
48+
$disable_hooks = false;
49+
50+
// Permette di accedere solo con un ip (da utilizzare per manutenzione)
51+
$maintenance_ip = '';
52+
4653
// Personalizzazione dei gestori dei tag personalizzati
4754
$HTMLWrapper = null;
4855
$HTMLHandlers = [];

‎core.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169

170170
/* ACCESSO E INSTALLAZIONE */
171171
// Controllo sulla presenza dei permessi di accesso basilari
172-
$continue = $dbo->isInstalled() && !Update::isUpdateAvailable() && (Auth::check() || API\Response::isAPIRequest());
172+
$continue = $dbo->isInstalled() && !Update::isUpdateAvailable() && (Auth::check() || API\Response::isAPIRequest()) && (empty($config['maintenance_ip']) || $config['maintenance_ip'] == $_SERVER['REMOTE_ADDR']);
173173

174174
if (!empty($skip_permissions)) {
175175
Permissions::skip();

‎include/bottom.php‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,29 @@
6565
<style>'.$custom_css.'</style>';
6666
}
6767

68-
// Hooks
69-
echo '
68+
// Hooks
69+
echo '
7070
<script>
71-
$(document).ready(function() {
72-
// Toast
73-
alertPush();
71+
$(document).ready(function() {
72+
// Toast
73+
alertPush();
7474
75-
// Orologio
76-
clock();
75+
// Orologio
76+
clock();';
7777

78-
// Hooks
79-
setTimeout("startHooks();", 1000);
78+
// Hooks
79+
if (!$config['disable_hooks']) {
80+
echo '
81+
setTimeout("startHooks();", 1000);';
82+
}
8083

81-
// Abilitazione del cron autonoma
82-
$.get(globals.rootdir + "/cron.php");
83-
});
84+
// Abilitazione del cron autonoma
85+
if (!$config['disable_cron']) {
86+
echo '
87+
$.get(globals.rootdir + "/cron.php");';
88+
}
89+
echo '
90+
});
8491
</script>';
8592
}
8693

‎include/init/maintenance.php‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
22+
if ($config['maintenance_ip'] != $_SERVER['REMOTE_ADDR']) {
23+
include_once App::filepath('include|custom|', 'top.php');
24+
$img = App::getPaths()['img'];
25+
26+
echo '
27+
<div class="box box-center-large box-danger">
28+
<div class="box-header with-border text-center">
29+
<img src="'.$img.'/logo_completo.png" width="300" alt="'.tr('OSM Logo').'">
30+
</div>
31+
32+
<div class="box-body">
33+
<div class="box box-center box-danger box-solid text-center">
34+
<div class="box-header with-border">
35+
<h3 class="box-title">'.tr('Manutenzione in corso!').'</h3>
36+
</div>
37+
<div class="box-body">
38+
<p>'.tr('Il software si trova attualmente in modalità manutenzione, siete pregati di attendere sino alla conclusione dell\'intervento').'.</p>
39+
</div>
40+
</div>
41+
</div>
42+
</div>';
43+
44+
include_once App::filepath('include|custom|', 'bottom.php');
45+
46+
exit();
47+
}

‎index.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
exit();
7777
}
7878

79+
// Modalità manutenzione
80+
if (!empty($config['maintenance_ip'])) {
81+
include_once base_dir().'/include/init/maintenance.php';
82+
}
83+
7984
// Procedura di installazione
8085
include_once base_dir().'/include/init/configuration.php';
8186

0 commit comments

Comments
 (0)