firewall updtae
This commit is contained in:
parent
4c847a59c3
commit
d5bcde0fad
|
|
@ -28,8 +28,24 @@ if (is_file($jsonFile)) {
|
|||
}
|
||||
}
|
||||
|
||||
// Function to get UFW status
|
||||
function getUfwStatus() {
|
||||
$status = shell_exec("sudo ufw status");
|
||||
return (strpos($status, 'Status: active') !== false) ? 'enabled' : 'disabled';
|
||||
}
|
||||
|
||||
$currentStatus = getUfwStatus();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
if (isset($_POST['toggle_status'])) {
|
||||
if ($_POST['toggle_status'] === 'enable') {
|
||||
exec("sudo ufw --force enable");
|
||||
} else {
|
||||
exec("sudo ufw disable");
|
||||
}
|
||||
$currentStatus = getUfwStatus();
|
||||
} else {
|
||||
exec("echo y | sudo ufw reset");
|
||||
exec("sudo ufw default allow outgoing");
|
||||
exec("sudo ufw default deny incoming");
|
||||
|
|
@ -66,6 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
exec("sudo ufw --force enable");
|
||||
exec("sudo ufw reload");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
|
@ -102,7 +119,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
<div class="containerindex">
|
||||
<div class="grid">
|
||||
<div class="card wide">
|
||||
<h2>Limit Access</h2>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||
<h2 style="margin: 0;">Limit Access</h2>
|
||||
<div style="text-align: right;">
|
||||
<span style="padding: 5px 10px; border-radius: 4px; background: <?= $currentStatus === 'enabled' ? '#d4edda' : '#f8d7da' ?>; color: <?= $currentStatus === 'enabled' ? '#155724' : '#721c24' ?>; font-weight: bold; margin-right: 10px;">
|
||||
UFW: <?= ucfirst($currentStatus) ?>
|
||||
</span>
|
||||
<form method="post" style="display: inline;">
|
||||
<button type="submit" name="toggle_status" value="<?= $currentStatus === 'enabled' ? 'disable' : 'enable' ?>" style="background: <?= $currentStatus === 'enabled' ? '#dc3545' : '#28a745' ?>; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer;">
|
||||
<?= $currentStatus === 'enabled' ? 'Disable' : 'Enable' ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<?php foreach ($data as $port => $value): ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue