This commit is contained in:
devdatt 2025-12-27 12:58:10 +05:30
parent ab84ba9085
commit 0f7113e127
1 changed files with 35 additions and 15 deletions

View File

@ -1,13 +1,13 @@
<?php include 'header.php' ?> <?php include 'header.php' ?>
<?php <?php
$file = __DIR__ . '/firewall.json'; $file = __DIR__ . '/firewall.json';
$data = [ $data = [
'80' => '', '80' => '',
'443' => '', '443' => '',
'1935' => '', '1935' => '',
'1937' => '' '1937' => '',
'8080' => '',
]; ];
if (file_exists($jsonFile)) { if (file_exists($jsonFile)) {
@ -17,12 +17,12 @@ if (file_exists($jsonFile)) {
} }
} }
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
foreach ($data as $port => $val) { foreach ($data as $port => $val) {
$data[$port] = trim($_POST["port_$port"] ?? ''); $data[$port] = trim($_POST["port_$port"] ?? '');
} }
file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT)); file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT));
} }
@ -60,12 +60,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
input[type=text] { input[type=text] {
width: 100%; width: 100%;
padding: 10px; padding: 16px 14px;
border-radius: 6px; border-radius: 8px;
border: 1px solid #ccc; border: 1px solid #ccc;
font-size: 14px; font-size: 11px;
line-height: 1.4;
} }
textarea {
width: 100%;
padding: 14px;
border-radius: 8px;
border: 1px solid #ccc;
font-size: 17px;
line-height: 1.5;
resize: vertical;
}
input[type=text]:invalid { input[type=text]:invalid {
border-color: #d33; border-color: #d33;
} }
@ -74,6 +86,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
color: #666; color: #666;
} }
input[type=text]:focus {
outline: none;
border-color: #2563eb;
box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}
button { button {
margin-top: 20px; margin-top: 20px;
padding: 12px 18px; padding: 12px 18px;
@ -124,26 +142,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="containerindex"> <div class="containerindex">
<div class="grid"> <div class="grid">
<div class="card wide"> <div class="card wide">
<h2>Firewall Allowed IPs</h2> <h2>Limit Access</h2>
<form method="post"> <form method="post">
<?php foreach ($data as $port => $value): ?> <?php foreach ($data as $port => $value): ?>
<div class="row"> <div class="row">
<label>Port <?= htmlspecialchars($port) ?></label> <label>Port <?= htmlspecialchars($port) ?></label>
<input <textarea
type="text"
name="port_<?= $port ?>" name="port_<?= $port ?>"
value="<?= htmlspecialchars($value) ?>" rows="3"
placeholder="IPv4, IPv6 (comma separated)"> placeholder="IPv4, IPv6 (comma separated)"><?= htmlspecialchars($value) ?></textarea>
<small>Example: 192.168.1.10, 2001:db8::1</small>
<small>Example: 192.168.1.10/24, 2001:db8::1</small>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<button type="submit">Save Rules</button> <button type="submit">Limit Access</button>
<br>
<br>
<br>
<br>
</form> </form>
<br><br>
</div> </div>
</div> </div>
</div> </div>
<?php include 'footer.php' ?> <?php include 'footer.php' ?>