firewall gui change
This commit is contained in:
parent
f01c24255d
commit
23a13ccf06
|
|
@ -38,7 +38,8 @@ if (is_file($jsonFile)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get UFW status
|
// Function to get UFW status
|
||||||
function getUfwStatus() {
|
function getUfwStatus()
|
||||||
|
{
|
||||||
$status = shell_exec("sudo ufw status");
|
$status = shell_exec("sudo ufw status");
|
||||||
if ($status === null) return 'disabled';
|
if ($status === null) return 'disabled';
|
||||||
return (strpos($status, 'Status: active') !== false) ? 'enabled' : 'disabled';
|
return (strpos($status, 'Status: active') !== false) ? 'enabled' : 'disabled';
|
||||||
|
|
@ -86,7 +87,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
);
|
);
|
||||||
if (count($tmp_ips) > 0) {
|
if (count($tmp_ips) > 0) {
|
||||||
foreach ($tmp_ips as $ip) {
|
foreach ($tmp_ips as $ip) {
|
||||||
exec("sudo ufw allow from " . escapeshellarg($ip)." to any port " . escapeshellarg($port) . " proto tcp");
|
exec("sudo ufw allow from " . escapeshellarg($ip) . " to any port " . escapeshellarg($port) . " proto tcp");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
exec("sudo ufw allow " . escapeshellarg($port));
|
exec("sudo ufw allow " . escapeshellarg($port));
|
||||||
|
|
@ -132,23 +133,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
window.onload = attachValidation;
|
window.onload = attachValidation;
|
||||||
</script>
|
</script>
|
||||||
<div class="containerindex">
|
<div class="containerindex">
|
||||||
<!-- Firewall Status Toggle (Left Aligned & Modernized) -->
|
|
||||||
<div style="display: flex; justify-content: flex-start; margin-bottom: 20px;">
|
|
||||||
<div style="display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, 0.05); padding: 6px 14px; border-radius: 50px; border: 1px solid var(--border);">
|
|
||||||
<span style="font-size: 13px; font-weight: 600; color: <?= $currentStatus === 'enabled' ? '#4ade80' : '#f87171' ?>; text-transform: uppercase; letter-spacing: 0.5px;">
|
|
||||||
● <?= $currentStatus === 'enabled' ? 'Active' : 'Inactive' ?>
|
|
||||||
</span>
|
|
||||||
<div style="width: 1px; height: 18px; background: var(--border);"></div>
|
|
||||||
<form method="post" style="display: inline; margin: 0;">
|
|
||||||
<button type="submit" name="toggle_status" value="<?= $currentStatus === 'enabled' ? 'disable' : 'enable' ?>" style="background: transparent; color: var(--text); border: none; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;">
|
|
||||||
<?= $currentStatus === 'enabled' ? 'Disable Firewall' : 'Enable Firewall' ?>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="card wide">
|
<div class="card wide">
|
||||||
|
<!-- Firewall Status Toggle (Left Aligned & Modernized) -->
|
||||||
|
<div style="display: flex; justify-content: flex-start; margin-bottom: 20px;">
|
||||||
|
<div style="display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, 0.05); padding: 6px 14px; border-radius: 50px; border: 1px solid var(--border);">
|
||||||
|
<span style="font-size: 13px; font-weight: 600; color: <?= $currentStatus === 'enabled' ? '#4ade80' : '#f87171' ?>; text-transform: uppercase; letter-spacing: 0.5px;">
|
||||||
|
● <?= $currentStatus === 'enabled' ? 'Active' : 'Inactive' ?>
|
||||||
|
</span>
|
||||||
|
<div style="width: 1px; height: 18px; background: var(--border);"></div>
|
||||||
|
<form method="post" style="display: inline; margin: 0;">
|
||||||
|
<button type="submit" name="toggle_status" value="<?= $currentStatus === 'enabled' ? 'disable' : 'enable' ?>" style="background: transparent; color: var(--text); border: none; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;">
|
||||||
|
<?= $currentStatus === 'enabled' ? 'Disable Firewall' : 'Enable Firewall' ?>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<h2 style="margin: 0 0 20px 0;">Limit Access</h2>
|
<h2 style="margin: 0 0 20px 0;">Limit Access</h2>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue