list_firewall.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary button-back js-button-back" href="/list/server/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. <a href="/add/firewall/" class="button button-secondary js-button-create">
  9. <i class="fas fa-circle-plus icon-green"></i><?= _("Add Rule") ?>
  10. </a>
  11. <?php if (!empty($_SESSION["FIREWALL_EXTENSION"])): ?>
  12. <a class="button button-secondary" href="/list/firewall/banlist/">
  13. <i class="fas fa-eye icon-red"></i><?= _("Fail2ban Banlists") ?>
  14. </a>
  15. <?php endif; ?>
  16. <a class="button button-secondary" href="/list/firewall/ipset/">
  17. <i class="fas fa-list icon-blue"></i><?= _("IPset IP Lists") ?>
  18. </a>
  19. </div>
  20. <div class="toolbar-right">
  21. <div class="toolbar-sorting">
  22. <button class="toolbar-sorting-toggle js-toggle-sorting-menu" type="button" title="<?= _("Sort items") ?>">
  23. <?= _("Sort by") ?>:
  24. <span class="u-text-bold">
  25. <?= _("Action") ?> <i class="fas fa-arrow-up-a-z"></i>
  26. </span>
  27. </button>
  28. <ul class="toolbar-sorting-menu animate__animated animate__fadeIn js-sorting-menu u-hidden">
  29. <li data-entity="sort-action">
  30. <span class="name"><?= _("Action") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up active"><i class="fas fa-arrow-up-a-z"></i></span>
  31. </li>
  32. <li data-entity="sort-protocol">
  33. <span class="name"><?= _("Protocol") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  34. </li>
  35. <li data-entity="sort-port">
  36. <span class="name"><?= _("Port") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  37. </li>
  38. <li data-entity="sort-ip" data-sort-as-int="1">
  39. <span class="name"><?= _("IP Address") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  40. </li>
  41. <li data-entity="sort-comment">
  42. <span class="name"><?= _("Comment") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  43. </li>
  44. </ul>
  45. <form x-data x-bind="BulkEdit" action="/bulk/firewall/" method="post">
  46. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  47. <select class="form-select" name="action">
  48. <option value=""><?= _("Apply to selected") ?></option>
  49. <option value="delete"><?= _("Delete") ?></option>
  50. </select>
  51. <button type="submit" class="toolbar-input-submit" title="<?= _("Apply to selected") ?>">
  52. <i class="fas fa-arrow-right"></i>
  53. </button>
  54. </form>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <!-- End toolbar -->
  60. <div class="container">
  61. <h1 class="u-text-center u-hide-desktop u-mt20 u-pr30 u-mb20 u-pl30"><?= _("Firewall Rules") ?></h1>
  62. <div class="units-table js-units-container">
  63. <div class="units-table-header">
  64. <div class="units-table-cell">
  65. <input type="checkbox" class="js-toggle-all-checkbox" title="<?= _("Select all") ?>">
  66. </div>
  67. <div class="units-table-cell"><?= _("Action") ?></div>
  68. <div class="units-table-cell"></div>
  69. <div class="units-table-cell"><?= _("Comment") ?></div>
  70. <div class="units-table-cell u-text-center"><?= _("Protocol") ?></div>
  71. <div class="units-table-cell u-text-center"><?= _("Port") ?></div>
  72. <div class="units-table-cell u-text-center"><?= _("IP Address") ?></div>
  73. </div>
  74. <!-- Begin firewall chain/action list item loop -->
  75. <?php
  76. foreach ($data as $key => $value) {
  77. ++$i;
  78. if ($data[$key]['SUSPENDED'] == 'yes') {
  79. $status = 'suspended';
  80. $spnd_action = 'unsuspend';
  81. $spnd_action_title = _('Unsuspend');
  82. $spnd_icon = 'fa-play';
  83. $spnd_icon_class = 'icon-green';
  84. $spnd_confirmation = _('Are you sure you want to unsuspend rule #%s?') ;
  85. } else {
  86. $status = 'active';
  87. $spnd_action = 'suspend';
  88. $spnd_action_title = _('Suspend');
  89. $spnd_icon = 'fa-pause';
  90. $spnd_icon_class = 'icon-highlight';
  91. $spnd_confirmation = _('Are you sure you want to suspend rule #%s?') ;
  92. }
  93. ?>
  94. <div class="units-table-row <?php if ($status == 'suspended') echo 'disabled'; ?> animate__animated animate__fadeIn js-unit"
  95. data-sort-action="<?= $data[$key]['ACTION'] ?>"
  96. data-sort-protocol="<?= $data[$key]['PROTOCOL'] ?>"
  97. data-sort-port="<?= $data[$key]['PORT'] ?>"
  98. data-sort-ip="<?= str_replace('.', '', $data[$key]['IP']) ?>"
  99. data-sort-comment="<?= $data[$key]['COMMENT'] ?>">
  100. <div class="units-table-cell">
  101. <div>
  102. <input id="check<?= $i ?>" class="js-unit-checkbox" type="checkbox" title="<?= _("Select") ?>" name="rule[]" value="<?= $key ?>">
  103. <label for="check<?= $i ?>" class="u-hide-desktop"><?= _("Select") ?></label>
  104. </div>
  105. </div>
  106. <div class="units-table-cell units-table-heading-cell u-text-bold">
  107. <span class="u-hide-desktop"><?= _("Action") ?>:</span>
  108. <a href="/edit/firewall/?rule=<?= $key ?>&token=<?= $_SESSION["token"] ?>" title="<?= _("Edit Firewall Rule") ?>">
  109. <?php
  110. $suspended = $data[$key]["SUSPENDED"] == "no";
  111. $action = $data[$key]["ACTION"];
  112. $iconClass = $action == "DROP" ? "fa-circle-minus" : "fa-circle-check";
  113. $colorClass = $action == "DROP" ? "icon-red" : "icon-green";
  114. ?>
  115. <i class="fas <?= $iconClass ?> u-mr5 <?= $suspended ? $colorClass : "" ?>"></i> <?= $action ?>
  116. </a>
  117. </div>
  118. <div class="units-table-cell">
  119. <ul class="units-table-row-actions">
  120. <li class="units-table-row-action shortcut-enter" data-key-action="href">
  121. <a
  122. class="units-table-row-action-link"
  123. href="/edit/firewall/?rule=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  124. title="<?= _("Edit Firewall Rule") ?>"
  125. >
  126. <i class="fas fa-pencil icon-orange"></i>
  127. <span class="u-hide-desktop"><?= _("Edit Firewall Rule") ?></span>
  128. </a>
  129. </li>
  130. <li class="units-table-row-action shortcut-s" data-key-action="js">
  131. <a
  132. class="units-table-row-action-link data-controls js-confirm-action"
  133. href="/<?= $spnd_action ?>/firewall/?rule=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  134. title="<?= $spnd_action_title ?>"
  135. data-confirm-title="<?= $spnd_action_title ?>"
  136. data-confirm-message="<?= sprintf($spnd_confirmation, $key) ?>"
  137. >
  138. <i class="fas <?= $spnd_icon ?> <?= $spnd_icon_class ?>"></i>
  139. <span class="u-hide-desktop"><?= $spnd_action_title ?></span>
  140. </a>
  141. </li>
  142. <li class="units-table-row-action shortcut-delete" data-key-action="js">
  143. <a
  144. class="units-table-row-action-link data-controls js-confirm-action"
  145. href="/delete/firewall/?rule=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  146. title="<?= _("Delete") ?>"
  147. data-confirm-title="<?= _("Delete") ?>"
  148. data-confirm-message="<?= sprintf(_("Are you sure you want to delete rule %s"), $key) ?>"
  149. >
  150. <i class="fas fa-trash icon-red"></i>
  151. <span class="u-hide-desktop"><?= _("Delete") ?></span>
  152. </a>
  153. </li>
  154. </ul>
  155. </div>
  156. <div class="units-table-cell u-text-bold">
  157. <span class="u-hide-desktop"><?= _("Comment") ?>:</span>
  158. <?php if (!empty($data[$key]['COMMENT'])) echo '' . $data[$key]['COMMENT']; else echo "&nbsp;"; ?>
  159. </div>
  160. <div class="units-table-cell u-text-center-desktop">
  161. <span class="u-hide-desktop u-text-bold"><?= _("Protocol") ?>:</span>
  162. <?= _($data[$key]["PROTOCOL"]) ?>
  163. </div>
  164. <div class="units-table-cell u-text-bold u-text-center-desktop">
  165. <span class="u-hide-desktop"><?= _("Port") ?>:</span>
  166. <?= $data[$key]["PORT"] ?>
  167. </div>
  168. <div class="units-table-cell u-text-center-desktop">
  169. <span class="u-hide-desktop u-text-bold"><?= _("IP Address") ?>:</span>
  170. <?= $data[$key]["IP"] ?>
  171. </div>
  172. </div>
  173. <?php } ?>
  174. </div>
  175. </div>
  176. <footer class="app-footer">
  177. <div class="container app-footer-inner">
  178. <p>
  179. <?php printf(ngettext("%d firewall rule", "%d firewall rules", $i), $i); ?>
  180. </p>
  181. </div>
  182. </footer>