firewall gui change

This commit is contained in:
Devdatt Bhatt 2026-05-17 16:27:08 +00:00
parent f01c24255d
commit 23a13ccf06
1 changed files with 18 additions and 17 deletions

View File

@ -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,6 +133,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
window.onload = attachValidation; window.onload = attachValidation;
</script> </script>
<div class="containerindex"> <div class="containerindex">
<div class="grid">
<div class="card wide">
<!-- Firewall Status Toggle (Left Aligned & Modernized) --> <!-- Firewall Status Toggle (Left Aligned & Modernized) -->
<div style="display: flex; justify-content: flex-start; margin-bottom: 20px;"> <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);"> <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);">
@ -146,9 +150,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</form> </form>
</div> </div>
</div> </div>
<div class="grid">
<div class="card wide">
<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">