106 lines
7.2 KiB
PHP
106 lines
7.2 KiB
PHP
<?php
|
|
include 'auth.php';
|
|
$page_title = bg_t('dashboard') . ' - BastionGuard WebUI';
|
|
$active_page = 'dashboard.php';
|
|
$catalog = bg_services_catalog();
|
|
$service_states = [];
|
|
foreach ($catalog as $key => $svc) {
|
|
$service_states[$key] = bg_service_status($svc['services'], $svc['user']);
|
|
}
|
|
$dashboardWidgets = bg_dashboard_widgets();
|
|
$diag = bg_user_services_diagnostics();
|
|
$versions = bg_clamdb_versions();
|
|
$paths = bg_clamd_paths();
|
|
$recent = bg_journal([
|
|
'clamav-clamonacc.service',
|
|
'clamonacc.service',
|
|
'BastionGuard-ransomware-realtime.service',
|
|
'BastionGuard-phishing-scanner.service',
|
|
'BastionGuard-mailproxy.service'
|
|
], 25);
|
|
include 'includes/header.php'; include 'includes/sidebar.php';
|
|
?>
|
|
<div class="page-title">
|
|
<div>
|
|
<h1><?= bg_e(bg_t('dashboard_title')) ?></h1>
|
|
<p><?= bg_e(bg_t('dashboard_subtitle')) ?></p>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<a class="btn btn-outline-secondary" href="dashboard.php"><i class="bi bi-arrow-clockwise"></i> <?= bg_e(bg_t('refresh_status')) ?></a>
|
|
<a class="btn btn-outline-primary" href="logs.php"><i class="bi bi-journal-text"></i> <?= bg_e(bg_t('open_log')) ?></a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if(!empty($dashboardWidgets['user_services'])): ?>
|
|
<?php if(!empty($diag['target_user'])): ?>
|
|
<div class="alert alert-light border d-flex flex-wrap gap-3 align-items-center mb-4">
|
|
<strong><?= bg_e(bg_t('user_services')) ?>:</strong>
|
|
<span><?= bg_e(bg_t('target_user')) ?> <code><?= bg_e($diag['target_user']) ?></code></span>
|
|
<span><?= bg_e(bg_t('uid')) ?> <code><?= bg_e($diag['uid']) ?></code></span>
|
|
<span><?= bg_e(bg_t('dbus')) ?> <?php if($diag['bus_exists']): ?><span class="badge text-bg-success"><?= bg_e(bg_t('present')) ?></span><?php else: ?><span class="badge text-bg-warning"><?= bg_e(bg_t('not_found')) ?></span><?php endif; ?></span>
|
|
<span><?= bg_e(bg_t('helper')) ?> <?php if($diag['helper_installed']): ?><span class="badge text-bg-success"><?= bg_e(bg_t('installed')) ?></span><?php else: ?><span class="badge text-bg-secondary"><?= bg_e(bg_t('not_installed')) ?></span><?php endif; ?></span>
|
|
<?php if(!$diag['helper_installed']): ?><span class="small-muted"><?= bg_e(bg_t('dashboard_helper_missing_hint')) ?></span><?php endif; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="alert alert-warning mb-4"><?= bg_e(bg_t('dashboard_desktop_user_missing')) ?> <a href="settings.php#opzioni"><?= bg_e(bg_t('open_settings')) ?></a>.</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<?php if(!empty($dashboardWidgets['service_cards'])): ?>
|
|
<div class="row g-3 mb-4">
|
|
<?php foreach ($catalog as $key => $svc): $st = $service_states[$key]; ?>
|
|
<div class="col-xl-3 col-lg-4 col-md-6">
|
|
<div class="card metric h-100">
|
|
<div class="card-body d-flex gap-3">
|
|
<div class="icon"><i class="bi bi-shield-check"></i></div>
|
|
<div class="min-w-0">
|
|
<h6 class="mb-1"><?= bg_e($svc['label']) ?></h6>
|
|
<?= bg_service_state_badge($st) ?>
|
|
<div class="small-muted mt-1 service-name"><?= bg_e($st['name'] ?: implode(', ', $svc['services'])) ?></div>
|
|
<div class="service-meta"><?= bg_e(bg_t('scope')) ?>: <?= bg_e(bg_service_scope_label($st)) ?> · <?= bg_e(bg_t('enabled')) ?>: <?= bg_e(bg_systemd_value_label($st['unit_file_state'])) ?></div><?php if(!empty($st['access_method'])): ?><div class="service-meta"><?= bg_e(bg_t('read')) ?>: <?= bg_e(bg_access_method_label($st['access_method'])) ?></div><?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if(!empty($dashboardWidgets['service_table'])): ?>
|
|
<div class="card mb-4">
|
|
<div class="card-body">
|
|
<div class="d-flex align-items-center justify-content-between gap-3 mb-2">
|
|
<div>
|
|
<h5 class="mb-1"><?= bg_e(bg_t('detected_services')) ?></h5>
|
|
<p class="small-muted mb-0"><?= bg_e(bg_t('dashboard_service_detection_hint')) ?></p>
|
|
</div>
|
|
<a class="btn btn-sm btn-outline-primary" href="settings.php#servizi"><?= bg_e(bg_t('manage_services')) ?></a>
|
|
</div>
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-service-status align-middle">
|
|
<thead><tr><th><?= bg_e(bg_t('module')) ?></th><th><?= bg_e(bg_t('unit')) ?></th><th><?= bg_e(bg_t('state')) ?></th><th><?= bg_e(bg_t('sub_state')) ?></th><th><?= bg_e(bg_t('enabled')) ?></th><th><?= bg_e(bg_t('pid')) ?></th><th><?= bg_e(bg_t('scope')) ?></th><th><?= bg_e(bg_t('reading')) ?></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($catalog as $key => $svc): $st = $service_states[$key]; ?>
|
|
<tr>
|
|
<td><?= bg_e($svc['label']) ?></td>
|
|
<td><span class="service-name"><?= bg_e($st['name'] ?: implode(', ', $svc['services'])) ?></span><?php if(!$st['exists']): ?><div class="service-meta"><?= bg_e(bg_t('unit_not_loaded_or_accessible')) ?></div><?php endif; ?></td>
|
|
<td><?= bg_service_state_badge($st) ?></td>
|
|
<td><?= bg_e(bg_systemd_value_label($st['sub_state'])) ?></td>
|
|
<td><?= bg_e(bg_systemd_value_label($st['unit_file_state'])) ?></td>
|
|
<td><?= $st['main_pid'] ? (int)$st['main_pid'] : '—' ?></td>
|
|
<td><?= bg_e(bg_service_scope_label($st)) ?></td><td><?= bg_e($st['access_method'] ? bg_access_method_label($st['access_method']) : '—') ?><?php if(!empty($st['process_detected'])): ?><div class="service-meta"><?= bg_e(bg_t('pid')) ?>: <?= bg_e($st['process_detected']) ?></div><?php endif; ?><?php if(!$st['exists'] && !empty($st['access_error'])): ?><div class="service-meta text-danger"><?= bg_e(substr($st['access_error'],0,120) . (strlen($st['access_error'])>120?'…':'')) ?></div><?php endif; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="row g-4">
|
|
<?php if(!empty($dashboardWidgets['clamav_db'])): ?><div class="col-lg-6"><div class="card section-card"><div class="card-body"><h5><?= bg_e(bg_t('clamav_db')) ?></h5><?php if ($versions): ?><div class="table-responsive"><table class="table table-sm"><thead><tr><th><?= bg_e(bg_t('file')) ?></th><th><?= bg_e(bg_t('version')) ?></th><th><?= bg_e(bg_t('size')) ?></th><th><?= bg_e(bg_t('modified')) ?></th></tr></thead><tbody><?php foreach($versions as $v): ?><tr><td><?= bg_e($v['name']) ?></td><td><?= bg_e($v['version']) ?></td><td><?= bg_e(bg_file_size($v['size'])) ?></td><td><?= bg_e(date('Y-m-d H:i', $v['mtime'])) ?></td></tr><?php endforeach; ?></tbody></table></div><?php else: ?><p class="text-muted"><?= bg_e(bg_t('clamav_db_not_found')) ?></p><?php endif; ?></div></div></div><?php endif; ?>
|
|
<?php if(!empty($dashboardWidgets['realtime_paths'])): ?><div class="col-lg-6"><div class="card section-card"><div class="card-body"><h5><?= bg_e(bg_t('realtime_paths')) ?></h5><?php if($paths): ?><ul class="list-group list-group-flush"><?php foreach($paths as $p): ?><li class="list-group-item px-0"><code><?= bg_e($p) ?></code></li><?php endforeach; ?></ul><?php else: ?><p class="text-muted"><?= bg_e(bg_t('onaccess_paths_not_found')) ?></p><?php endif; ?></div></div></div><?php endif; ?>
|
|
<?php if(!empty($dashboardWidgets['recent_events'])): ?><div class="col-12"><div class="card"><div class="card-body"><h5><?= bg_e(bg_t('recent_events')) ?></h5><?php bg_render_log($recent, bg_t('no_recent_events')); ?></div></div></div><?php endif; ?>
|
|
</div>
|
|
<?php include 'includes/footer.php'; ?>
|