edit_firewall.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary" id="btn-back" href="/list/firewall/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. </div>
  9. <div class="toolbar-buttons">
  10. <button class="button" type="submit" form="vstobjects">
  11. <i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
  12. </button>
  13. </div>
  14. </div>
  15. </div>
  16. <!-- End toolbar -->
  17. <div class="container animate__animated animate__fadeIn">
  18. <form id="vstobjects" name="v_edit_firewall" method="post" class="<?= $v_status ?>">
  19. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  20. <input type="hidden" name="save" value="save">
  21. <div class="form-container">
  22. <h1 class="form-title"><?= _("Editing Firewall Rule") ?></h1>
  23. <?php show_alert_message($_SESSION); ?>
  24. <div class="u-mb10">
  25. <label for="v_action" class="form-label"><?= _("Action") ?></label>
  26. <select class="form-select" name="v_action" id="v_action">
  27. <option value="DROP" <?php if ((!empty($v_action)) && ( $v_action == "DROP" )) echo 'selected'?>><?= _("DROP") ?></option>
  28. <option value="ACCEPT" <?php if ((!empty($v_action)) && ( $v_action == "ACCEPT" )) echo 'selected'?>><?= _("ACCEPT") ?></option>
  29. </select>
  30. </div>
  31. <div class="u-mb10">
  32. <label for="v_protocol" class="form-label"><?= _("Protocol") ?></label>
  33. <select class="form-select" name="v_protocol" id="v_protocol">
  34. <option value="TCP" <?php if ((!empty($v_protocol)) && ( $v_protocol == "TCP" )) echo 'selected'?>><?= _("TCP") ?></option>
  35. <option value="UDP" <?php if ((!empty($v_protocol)) && ( $v_protocol == "UDP" )) echo 'selected'?>><?= _("UDP") ?></option>
  36. <option value="ICMP" <?php if ((!empty($v_protocol)) && ( $v_protocol == "ICMP" )) echo 'selected'?>><?= _("ICMP") ?></option>
  37. </select>
  38. </div>
  39. <div class="u-mb10">
  40. <label for="v_port" class="form-label">
  41. <?= _("Port") ?> <span class="optional">(<?= _("Ranges and Lists are acceptable") ?>)</span>
  42. </label>
  43. <input type="text" class="form-control" name="v_port" id="v_port" value="<?= htmlentities(trim($v_port, "'")) ?>" placeholder="<?= _("All ports: 0, Range: 80-82, List: 80,443,8080,8443") ?>">
  44. </div>
  45. <div class="u-mb10">
  46. <label for="v_ip" class="form-label">
  47. <?= _("IP address / IPset") ?> <span class="optional">(<?= _("CIDR format is supported") ?>)</span>
  48. </label>
  49. <div class="u-pos-relative">
  50. <select class="form-select" tabindex="-1" id="quickips_list" onchange="this.nextElementSibling.value=this.value">
  51. <option value="">&nbsp;</option>
  52. </select>
  53. <input type="text" class="form-control list-editor" name="v_ip" id="v_ip" value="<?= htmlentities(trim($v_ip, "'")) ?>">
  54. </div>
  55. </div>
  56. <div class="u-mb10">
  57. <label for="v_comment" class="form-label">
  58. <?= _("Comment") ?> <span class="optional">(<?= _("optional") ?>)</span>
  59. </label>
  60. <input type="text" class="form-control" name="v_comment" id="v_comment" maxlength="255" value="<?= htmlentities(trim($v_comment, "'")) ?>">
  61. </div>
  62. </div>
  63. </form>
  64. </div>
  65. <script>
  66. var ipLists = JSON.parse('<?= $ipset_lists_json ?>');
  67. ipLists.sort(function (a, b) {
  68. return a.name > b.name;
  69. });
  70. $(function () {
  71. var targetElement = document.getElementById('quickips_list');
  72. var newEl = document.createElement("option");
  73. newEl.text = "IP address lists:";
  74. newEl.disabled = true;
  75. targetElement.appendChild(newEl);
  76. ipLists.forEach(iplist => {
  77. var newEl = document.createElement("option");
  78. newEl.text = iplist.name;
  79. newEl.value = "ipset:" + iplist.name;
  80. targetElement.appendChild(newEl);
  81. });
  82. });
  83. </script>