1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-20 20:25:17 +01:00
openstamanager/include/init/requirements.php

191 lines
5.3 KiB
PHP
Raw Normal View History

2018-06-27 14:25:19 +02:00
<?php
// Apache
$modules = [
2018-09-17 18:11:39 +02:00
'mod_rewrite' => [
'server' => 'HTTP_MOD_REWRITE',
'description' => tr('Fornisce un sistema di riscrittura URL basato su regole predefinite'),
],
2018-06-27 14:25:19 +02:00
];
2018-09-17 18:11:39 +02:00
if (function_exists('apache_get_modules')) {
2018-09-14 11:13:38 +02:00
$available_modules = apache_get_modules();
}
2018-06-27 14:25:19 +02:00
$apache = [];
2018-09-17 18:11:39 +02:00
foreach ($modules as $name => $values) {
$description = $values['description'];
$status = isset($available_modules) ? in_array($name, $available_modules) : $_SERVER[$values['server']] == 'On';
2018-06-27 14:25:19 +02:00
$apache[] = [
'name' => $name,
'description' => $description,
'status' => $status,
'type' => tr('Modulo'),
];
}
// PHP
$settings = [
'zip' => [
'type' => 'ext',
'description' => tr('Permette di leggere e scrivere gli archivi compressi ZIP e i file al loro interno'),
],
'mbstring' => [
'type' => 'ext',
'description' => tr('Permette di gestire i caratteri dello standard UTF-8'),
],
2018-06-27 14:25:19 +02:00
'pdo_mysql' => [
'type' => 'ext',
'description' => tr('Permette di effettuare la connessione al database MySQL'),
],
2018-12-14 12:58:40 +01:00
'dom' => [
'type' => 'ext',
'description' => tr('Permette la gestione dei file standard per la Fatturazione Elettronica'),
],
'xsl' => [
'type' => 'ext',
'description' => tr('Permette di visualizzazione grafica della Fattura Elettronica'),
],
2018-06-27 14:25:19 +02:00
'openssl' => [
'type' => 'ext',
2018-12-14 12:58:40 +01:00
'description' => tr("Permette l'utilizzo di funzioni crittografiche simmetriche e asimmetriche"),
2018-06-27 14:25:19 +02:00
],
'intl' => [
'type' => 'ext',
2018-12-14 12:58:40 +01:00
'description' => tr("Permette l'automazione della conversione dei numeri"),
2018-06-27 14:25:19 +02:00
],
2018-12-14 12:58:40 +01:00
'curl' => [
2018-10-02 18:21:27 +02:00
'type' => 'ext',
2018-12-14 12:58:40 +01:00
'description' => tr('Permette la comunicazione con servizi esterni'),
2018-10-02 18:21:27 +02:00
],
2018-06-27 14:25:19 +02:00
'soap' => [
'type' => 'ext',
'description' => tr('Permette la comunicazione con servizi esterni, quali il database europeo delle Partite IVA (facoltativo)'),
],
2018-10-02 18:21:27 +02:00
//'display_errors' => [
// 'type' => 'value',
// 'description' => true,
//],
2018-06-27 14:25:19 +02:00
'upload_max_filesize' => [
'type' => 'value',
2019-05-24 21:49:15 +02:00
'description' => '>32M',
2018-06-27 14:25:19 +02:00
],
'post_max_size' => [
'type' => 'value',
2019-05-24 21:49:15 +02:00
'description' => '>32M',
2018-06-27 14:25:19 +02:00
],
];
$php = [];
foreach ($settings as $name => $values) {
$description = $values['description'];
if ($values['type'] == 'ext') {
$status = extension_loaded($name);
} else {
$ini = str_replace(['k', 'M'], ['000', '000000'], ini_get($name));
$real = str_replace(['k', 'M'], ['000', '000000'], $description);
if (starts_with($real, '>')) {
$status = $ini >= substr($real, 1);
} elseif (starts_with($real, '<')) {
$status = $ini <= substr($real, 1);
} else {
$status = ($real == $ini);
}
if (is_bool($description)) {
$description = !empty($description) ? 'On' : 'Off';
} else {
$description = str_replace(['>', '<'], '', $description);
}
2018-10-30 22:19:15 +01:00
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _INI_)', [
2018-06-27 14:25:19 +02:00
'_VALUE_' => $description,
2018-10-30 22:19:15 +01:00
'_INI_' => ini_get($name),
2018-06-27 14:25:19 +02:00
]);
}
$type = ($values['type'] == 'ext') ? tr('Estensione') : tr('Impostazione');
$php[] = [
'name' => $name,
'description' => $description,
'status' => $status,
'type' => $type,
];
}
// Percorsi di servizio
$dirs = [
'backup' => tr('Necessario per il salvataggio dei backup'),
'files' => tr('Necessario per il salvataggio di file inseriti dagli utenti'),
'logs' => tr('Necessario per la gestione dei file di log'),
];
$directories = [];
foreach ($dirs as $name => $description) {
$status = is_writable($docroot.DIRECTORY_SEPARATOR.$name);
$directories[] = [
'name' => $name,
'description' => $description,
'status' => $status,
'type' => tr('Cartella'),
];
}
$requirements = [
tr('Apache') => $apache,
tr('PHP (_VERSION_)', [
'_VERSION_' => phpversion(),
]) => $php,
tr('Percorsi di servizio') => $directories,
];
// Tabelle di riepilogo
foreach ($requirements as $key => $values) {
$statuses = array_column($values, 'status');
$general_status = true;
foreach ($statuses as $status) {
$general_status &= $status;
}
echo '
<div class="box box-'.($general_status ? 'success collapsed-box' : 'danger').'">
<div class="box-header with-border">
<h3 class="box-title">'.$key.'</h3>';
if ($general_status) {
echo '
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-plus"></i>
</button>
</div>';
}
echo '
</div>
<div class="box-body no-padding">
<table class="table">';
foreach ($values as $value) {
echo '
<tr class="'.($value['status'] ? 'success' : 'danger').'">
<td style="width: 10px"><i class="fa fa-'.($value['status'] ? 'check' : 'times').'"></i></td>
<td>'.$value['type'].'</td>
<td>'.$value['name'].'</td>
<td>'.$value['description'].'</td>
</tr>';
}
echo '
</table>
</div>
</div>';
}