openstamanager/modules/aggiornamenti/edit.php

201 lines
6.2 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
// Personalizzazioni di codice
2018-12-23 14:01:59 +01:00
if (function_exists(custom)) {
$custom = custom();
$tables = customTables();
if (!empty($custom) || !empty($tables)) {
echo '
2018-12-21 16:54:34 +01:00
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title"><span class="tip" title="'.tr('Elenco delle personalizzazioni rilevabili dal gestionale').'.">
<i class="fa fa-edit"></i> '.tr('Personalizzazioni').'
</span></h3>
</div>
<div class="box-body">';
2018-12-23 14:01:59 +01:00
if (!empty($custom)) {
echo '
2018-12-21 16:54:34 +01:00
<table class="table table-hover table-striped">
<tr>
<th width="10%">'.tr('Percorso').'</th>
<th width="15%">'.tr('Cartella personalizzata').'</th>
<th width="15%">'.tr('Database personalizzato').'</th>
</tr>';
2018-12-23 14:01:59 +01:00
foreach ($custom as $element) {
echo '
2018-12-21 16:54:34 +01:00
<tr>
<td>'.$element['path'].'</td>
<td>'.($element['directory'] ? 'Si' : 'No').'</td>
<td>'.($element['database'] ? 'Si' : 'No').'</td>
</tr>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
echo '
2018-12-21 16:54:34 +01:00
</table>
<p><strong>'.tr("Si sconsiglia l'aggiornamento senza il supporto dell'assistenza ufficiale").'.</strong></p>';
2018-12-23 14:01:59 +01:00
} else {
echo '
2018-12-21 16:54:34 +01:00
<p>'.tr('Non ci sono strutture personalizzate').'.</p>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
if (!empty($tables)) {
echo '
2018-12-21 16:54:34 +01:00
<div class="alert alert-warning">
<i class="fa fa-warning"></i>
<b>Attenzione!</b> Ci sono delle tabelle non previste nella versione standard del gestionale: '.implode(', ', $tables).'.
</div>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
echo '
2018-12-21 16:54:34 +01:00
</div>
</div>';
2018-12-23 14:01:59 +01:00
}
}
// Aggiornamenti
2018-07-08 18:11:17 +02:00
if (setting('Attiva aggiornamenti')) {
$alerts = [];
if (!extension_loaded('zip')) {
$alerts[tr('Estensione ZIP')] = tr('da abilitare');
}
$upload_max_filesize = ini_get('upload_max_filesize');
$upload_max_filesize = str_replace(['k', 'M'], ['000', '000000'], $upload_max_filesize);
2019-05-24 21:50:59 +02:00
// Dimensione minima: 32MB
if ($upload_max_filesize < 32000000) {
2019-05-24 21:49:15 +02:00
$alerts['upload_max_filesize'] = '32MB';
}
$post_max_size = ini_get('post_max_size');
$post_max_size = str_replace(['k', 'M'], ['000', '000000'], $post_max_size);
2019-05-24 21:50:59 +02:00
// Dimensione minima: 32MB
if ($post_max_size < 32000000) {
2019-05-24 21:49:15 +02:00
$alerts['post_max_size'] = '32MB';
}
if (!empty($alerts)) {
echo '
<div class="alert alert-warning">
<p>'.tr('Devi modificare il seguenti parametri del file di configurazione PHP (_FILE_) per poter caricare gli aggiornamenti', [
'_FILE_' => '<b>php.ini</b>',
]).':<ul>';
foreach ($alerts as $key => $value) {
echo '
<li><b>'.$key.'</b> = '.$value.'</li>';
}
echo '
</ul></p>
</div>';
}
2018-09-19 17:15:01 +02:00
echo '
<script>
function update() {
if ($("#blob").val()) {
swal({
title: "'.tr('Avviare la procedura?').'",
type: "warning",
showCancelButton: true,
confirmButtonText: "'.tr('Sì').'"
}).then(function (result) {
$("#update").submit();
})
} else {
swal({
title: "'.tr('Selezionare un file!').'",
type: "error",
})
}
}
function search(button) {
buttonLoading(button);
$.ajax({
url: globals.rootdir + "/actions.php",
type: "post",
data: {
id_module: globals.id_module,
op: "check",
},
success: function(data){
if (data === "none" || !data) {
2018-12-28 00:04:41 +01:00
$("#update-search").html("'.tr('Nessun aggiornamento disponibile').'.");
2018-09-19 17:15:01 +02:00
} else {
let beta_warning = data.includes("beta") ? "<br><b>'.tr('Attenzione: la versione individuata è in fase sperimentale, e pertanto può presentare diversi bug e malfunzionamenti').'.</b>" : "";
$("#update-search").html("'.tr("E' stato individuato un nuovo aggiornamento").': " + data + "." + beta_warning + "<br>'.tr('Scaricalo ora: _LINK_', [
'_LINK_' => "<a target='_blank' href='https://github.com/devcode-it/openstamanager/releases'>https://github.com/devcode-it/openstamanager/releases</a>",
2018-09-19 17:15:01 +02:00
]).'");
}
}
});
}
</script>';
echo '
2018-09-19 09:51:36 +02:00
<div class="row">
<div class="col-md-8">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">
'.tr('Carica un aggiornamento').' <span class="tip" title="'.tr('Form di caricamento aggiornamenti del gestionale e innesti di moduli e plugin').'."><i class="fa fa-question-circle-o"></i></span>
2018-09-19 09:51:36 +02:00
</h3>
</div>
<div class="box-body">
2019-05-29 05:19:15 +02:00
<form action="'.ROOTDIR.'/controller.php?id_module='.$id_module.'" method="post" enctype="multipart/form-data" id="update">
2018-09-19 09:51:36 +02:00
<input type="hidden" name="op" value="upload">
2019-05-29 05:19:15 +02:00
{[ "type": "file", "name": "blob", "required": 1, "accept": ".zip" ]}
2018-09-19 17:15:01 +02:00
<button type="button" class="btn btn-primary pull-right" onclick="update()">
2018-12-19 23:53:02 +01:00
<i class="fa fa-upload"></i> '.tr('Carica').'
2018-09-19 09:51:36 +02:00
</button>
</form>
</div>
</div>
</div>';
echo '
2018-09-19 09:51:36 +02:00
<div class="col-md-4">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">
'.tr('Ricerca aggiornamenti').' <span class="tip" title="'.tr('Controllo automatico della presenza di aggiornamenti per il gestionale').'."><i class="fa fa-question-circle-o"></i></span>
2018-09-19 09:51:36 +02:00
</h3>
</div>
<div class="box-body" id="update-search">';
2018-11-30 16:10:15 +01:00
if (extension_loaded('curl')) {
echo' <button type="button" class="btn btn-info btn-block" onclick="search(this)">
2018-09-19 09:51:36 +02:00
<i class="fa fa-search"></i> '.tr('Ricerca').'
</button>';
2018-11-30 16:10:15 +01:00
} else {
echo' <button type="button" class="btn btn-warning btn-block disabled" >
<i class="fa fa-warning"></i> '.tr('Estensione curl non supportata').'.
2018-11-30 16:10:15 +01:00
</button>';
}
echo' </div>
2018-09-19 09:51:36 +02:00
</div>
2018-07-04 17:15:14 +02:00
</div>
</div>';
}
2018-10-05 11:53:11 +02:00
// Requisiti
echo '
<hr>
2018-12-14 13:01:13 +01:00
<div>
2018-10-05 11:53:11 +02:00
<h3>'.tr('Requisiti').'</h3>';
include DOCROOT.'/include/init/requirements.php';
echo '
</div>';