BastionGuard/webui/includes/sidebar.php
specialworld83 f0f913a209 Release 2.0
2026-07-15 10:52:22 +02:00

83 lines
5.3 KiB
PHP

<?php
require_once __DIR__ . '/functions.php';
$active_page = $active_page ?? basename($_SERVER['SCRIPT_NAME']);
function nav_active($file) { global $active_page; return $active_page === $file ? 'active' : ''; }
function nav_group_open($files) { global $active_page; return in_array($active_page, $files, true); }
function nav_item($file, $icon, $labelKey) {
echo '<a class="nav-link ' . bg_e(nav_active($file)) . '" href="' . bg_e($file) . '"><i class="bi ' . bg_e($icon) . '"></i><span>' . bg_e(bg_t($labelKey)) . '</span></a>';
}
$nav_groups = [
'protection' => [
'label' => 'protection', 'icon' => 'bi-shield-check', 'files' => ['scan.php','antiransomware.php','bank.php','samba.php'],
'items' => [
['scan.php','bi-shield-check','scan_realtime'],
['antiransomware.php','bi-lock','anti_ransomware'],
['bank.php','bi-bank','safe_banks'],
['samba.php','bi-hdd-network','samba'],
],
],
'security' => [
'label' => 'security', 'icon' => 'bi-shield-lock', 'files' => ['logs.php','quarantine.php','identityleak.php','update.php','phishing.php'],
'items' => [
['logs.php','bi-journal-text','logs'],
['quarantine.php','bi-bug','quarantine'],
['identityleak.php','bi-person-bounding-box','identity_leaks'],
['update.php','bi-arrow-repeat','updates'],
['phishing.php','bi-search','phishing_search'],
],
],
'system' => [
'label' => 'system', 'icon' => 'bi-gear', 'files' => ['wizard.php','config.php','prediction.php','settings.php','about.php','donate.php','web_users.php'],
'items' => [
['wizard.php','bi-magic','wizard'],
['config.php','bi-file-earmark-code','configurations'],
['prediction.php','bi-activity','prediction'],
['settings.php','bi-gear','settings'],
['about.php','bi-info-circle','about'],
['donate.php','bi-heart','donations'],
],
],
];
?>
<aside class="sidebar" id="bgSidebar" aria-label="BastionGuard sidebar">
<button type="button" class="sidebar-close" id="bgMobileMenuClose" aria-label="Close navigation"><i class="bi bi-x-lg"></i></button>
<div class="brand"><div class="brand-mark"><?= bg_logo_html('brand-logo') ?></div><div><strong>BastionGuard™</strong><small><?= bg_e(bg_webpanel_name()) ?></small></div></div>
<nav class="nav flex-column sidebar-nav" aria-label="BastionGuard navigation">
<?php nav_item('dashboard.php','bi-speedometer2','dashboard'); ?>
<?php foreach($nav_groups as $groupId=>$group): $open = nav_group_open($group['files']); ?>
<div class="nav-group" data-nav-group="<?= bg_e($groupId) ?>">
<button class="nav-section-toggle <?= $open ? '' : 'collapsed' ?>" type="button" data-bs-toggle="collapse" data-bs-target="#nav_<?= bg_e($groupId) ?>" aria-expanded="<?= $open ? 'true' : 'false' ?>" aria-controls="nav_<?= bg_e($groupId) ?>">
<span><i class="bi <?= bg_e($group['icon']) ?>"></i> <?= bg_e(bg_t($group['label'])) ?></span>
<i class="bi bi-chevron-down nav-chevron"></i>
</button>
<div id="nav_<?= bg_e($groupId) ?>" class="collapse nav-group-collapse <?= $open ? 'show' : '' ?>" data-group-id="<?= bg_e($groupId) ?>">
<?php foreach($group['items'] as $it) nav_item($it[0], $it[1], $it[2]); ?>
</div>
</div>
<?php endforeach; ?>
<a class="nav-link text-danger" href="logout.php"><i class="bi bi-box-arrow-right"></i><span><?= bg_e(bg_t('logout')) ?></span></a>
</nav>
<?php if (function_exists('bg_current_user_is_admin') && bg_current_user_is_admin()): ?>
<div class="sidebar-user-setup">
<a class="nav-link <?= bg_e(nav_active('web_users.php')) ?>" href="web_users.php"><i class="bi bi-people"></i><span><?= bg_e(bg_t('webpanel_users_setup')) ?></span></a>
</div>
<?php endif; ?>
<div class="sidebar-preferences" aria-label="BastionGuard interface preferences">
<div class="sidebar-pref-title"><?= bg_e(bg_t('theme_quick')) ?></div>
<div class="btn-group btn-group-sm w-100 mb-2" role="group" aria-label="<?= bg_e(bg_t('theme')) ?>">
<a class="btn <?= bg_theme()==='system'?'btn-primary':'btn-outline-light' ?>" href="?<?= bg_e(http_build_query(array_merge($_GET, ['bg_theme'=>'system']))) ?>"><i class="bi bi-circle-half"></i> <?= bg_e(bg_t('system_theme')) ?></a>
<a class="btn <?= bg_theme()==='light'?'btn-primary':'btn-outline-light' ?>" href="?<?= bg_e(http_build_query(array_merge($_GET, ['bg_theme'=>'light']))) ?>"><i class="bi bi-sun"></i> <?= bg_e(bg_t('light')) ?></a>
<a class="btn <?= bg_theme()==='dark'?'btn-primary':'btn-outline-light' ?>" href="?<?= bg_e(http_build_query(array_merge($_GET, ['bg_theme'=>'dark']))) ?>"><i class="bi bi-moon-stars"></i> <?= bg_e(bg_t('dark')) ?></a>
</div>
<div class="btn-group btn-group-sm w-100" role="group" aria-label="<?= bg_e(bg_t('language')) ?>">
<a class="btn <?= bg_language()==='en'?'btn-primary':'btn-outline-light' ?>" href="?<?= bg_e(http_build_query(array_merge($_GET, ['bg_lang'=>'en']))) ?>">EN</a>
<a class="btn <?= bg_language()==='it'?'btn-primary':'btn-outline-light' ?>" href="?<?= bg_e(http_build_query(array_merge($_GET, ['bg_lang'=>'it']))) ?>">IT</a>
</div>
</div>
</aside>
<main class="main-content">
<div class="content-inner">
<?php bg_render_flash(); ?>