list_firewall.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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><?= tohtml( _("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><?= tohtml( _("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><?= tohtml( _("Banned IP Addresses")) ?>
  14. </a>
  15. <?php endif; ?>
  16. <a class="button button-secondary" href="/list/firewall/ipset/">
  17. <i class="fas fa-list icon-blue"></i><?= tohtml( _("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="<?= tohtml( _("Sort items")) ?>">
  23. <?= tohtml( _("Sort by")) ?>:
  24. <span class="u-text-bold">
  25. <?= tohtml( _("Action")) ?> <i class="fas fa-arrow-up-a-z"></i>
  26. </span>
  27. </button>
  28. <ul class="toolbar-sorting-menu js-sorting-menu u-hidden">
  29. <li data-entity="sort-action">
  30. <span class="name"><?= tohtml( _("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"><?= tohtml( _("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"><?= tohtml( _("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"><?= tohtml( _("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"><?= tohtml( _("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="<?= tohtml($_SESSION["token"]) ?>">
  47. <select class="form-select" name="action">
  48. <option value=""><?= tohtml( _("Apply to selected")) ?></option>
  49. <option value="delete"><?= tohtml( _("Delete")) ?></option>
  50. </select>
  51. <button type="submit" class="toolbar-input-submit" title="<?= tohtml( _("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"><?= tohtml( _("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="<?= tohtml( _("Select all")) ?>">
  66. </div>
  67. <div class="units-table-cell"><?= tohtml( _("Pos")) ?></div>
  68. <div class="units-table-cell"></div>
  69. <div class="units-table-cell"><?= tohtml( _("Action")) ?></div>
  70. <div class="units-table-cell"></div>
  71. <div class="units-table-cell"><?= tohtml( _("Comment")) ?></div>
  72. <div class="units-table-cell u-text-center"><?= tohtml( _("Protocol")) ?></div>
  73. <div class="units-table-cell u-text-center"><?= tohtml( _("Port")) ?></div>
  74. <div class="units-table-cell u-text-center"><?= tohtml( _("IP Address")) ?></div>
  75. </div>
  76. <!-- Begin firewall chain/action list item loop -->
  77. <?php
  78. foreach ($data as $key => $value) {
  79. ++$i;
  80. if ($i === 1) {
  81. $move_up_enabled = false;
  82. } elseif ($i == count($data)) {
  83. $move_up_enabled = true;
  84. $move_down_enabled = false;
  85. } else {
  86. $move_up_enabled = true;
  87. $move_down_enabled = true;
  88. }
  89. if ($data[$key]['SUSPENDED'] == 'yes') {
  90. $status = 'suspended';
  91. $spnd_action = 'unsuspend';
  92. $spnd_action_title = _('Unsuspend');
  93. $spnd_icon = 'fa-play';
  94. $spnd_icon_class = 'icon-green';
  95. $spnd_confirmation = _('Are you sure you want to unsuspend rule #%s?') ;
  96. } else {
  97. $status = 'active';
  98. $spnd_action = 'suspend';
  99. $spnd_action_title = _('Suspend');
  100. $spnd_icon = 'fa-pause';
  101. $spnd_icon_class = 'icon-highlight';
  102. $spnd_confirmation = _('Are you sure you want to suspend rule #%s?') ;
  103. }
  104. ?>
  105. <div class="units-table-row <?php if ($status == 'suspended') echo 'disabled'; ?> js-unit"
  106. data-sort-action="<?= tohtml($data[$key]['ACTION']) ?>"
  107. data-sort-protocol="<?= tohtml($data[$key]['PROTOCOL']) ?>"
  108. data-sort-port="<?= tohtml($data[$key]['PORT']) ?>"
  109. data-sort-ip="<?= tohtml(str_replace('.', '', $data[$key]['IP'])) ?>"
  110. data-sort-comment="<?= tohtml($data[$key]['COMMENT']) ?>">
  111. <div class="units-table-cell">
  112. <div>
  113. <input id="check<?= tohtml($i) ?>" class="js-unit-checkbox" type="checkbox" title="<?= tohtml( _("Select")) ?>" name="rule[]" value="<?= tohtml($key) ?>">
  114. <label for="check<?= tohtml($i) ?>" class="u-hide-desktop"><?= tohtml( _("Select")) ?></label>
  115. </div>
  116. </div>
  117. <div class="units-table-cell units-table-heading-cell u-text-bold">
  118. <span class="u-hide-desktop"><?= tohtml( _("Position")) ?>:</span>
  119. <a href="/edit/firewall/?<?= tohtml(http_build_query(["rule" => $key, "token" => $_SESSION["token"]])) ?>" title="<?= tohtml( _("Edit Firewall Rule")) ?>">
  120. <?php
  121. $rule = $key;
  122. ?>
  123. <?= tohtml($rule) ?>
  124. </a>
  125. </div>
  126. <div class="units-table-cell" style="padding-left: 0;padding-right: 0;">
  127. <ul class="units-table-row-actions">
  128. <li class="units-table-row-action shortcut-up" data-key-action="js">
  129. <a
  130. class="units-table-row-action-link data-controls js-confirm-action"
  131. style="<?= tohtml($move_up_enabled ? "display:block!important" : "display:none!important") ?>"
  132. href="/move/firewall/?<?= tohtml(http_build_query(["rule" => $key, "direction" => 'up', "token" => $_SESSION["token"]])) ?>"
  133. title="<?= tohtml( _("Move Firewall Rule Up")) ?>"
  134. data-confirm-title="<?= tohtml( _("Move Up")) ?>"
  135. data-confirm-message="<?= tohtml(sprintf(_("Are you sure you want to move rule #%s up?"), $key)) ?>">
  136. <i class="fas fa-arrow-up icon-blue"></i>
  137. <span class="u-hide-desktop"><?= tohtml( _("Move Firewall Rule Up")) ?></span>
  138. </a>
  139. </li>
  140. <li class="units-table-row-action shortcut-down" data-key-action="js">
  141. <a
  142. class="units-table-row-action-link data-controls js-confirm-action"
  143. style="<?= tohtml($move_down_enabled ? "" : "display:block!important") ?>"
  144. href="/move/firewall/?<?= tohtml(http_build_query(["rule" => $key, "direction" => 'down', "token" => $_SESSION["token"]])) ?>"
  145. title="<?= tohtml( _("Move Firewall Rule Down")) ?>"
  146. data-confirm-title="<?= tohtml( _("Move Down")) ?>"
  147. data-confirm-message="<?= tohtml(sprintf(_("Are you sure you want to move rule #%s down?"), $key)) ?>">
  148. <i class="fas fa-arrow-down icon-blue"></i>
  149. <span class="u-hide-desktop"><?= tohtml( _("Move Firewall Rule Down")) ?></span>
  150. </a>
  151. </li>
  152. </ul>
  153. </div>
  154. <div class="units-table-cell units-table-heading-cell u-text-bold">
  155. <span class="u-hide-desktop"><?= tohtml( _("Action")) ?>:</span>
  156. <a href="/edit/firewall/?<?= tohtml(http_build_query(["rule" => $key, "token" => $_SESSION["token"]])) ?>" title="<?= tohtml( _("Edit Firewall Rule")) ?>">
  157. <?php
  158. $suspended = $data[$key]["SUSPENDED"] == "no";
  159. $action = $data[$key]["ACTION"];
  160. $iconClass = $action == "DROP" ? "fa-circle-minus" : "fa-circle-check";
  161. $colorClass = $action == "DROP" ? "icon-red" : "icon-green";
  162. ?>
  163. <i class="fas <?= tohtml($iconClass) ?> u-mr5 <?= tohtml($suspended ? $colorClass : "") ?>"></i> <?= tohtml($action) ?>
  164. </a>
  165. </div>
  166. <div class="units-table-cell">
  167. <ul class="units-table-row-actions">
  168. <li class="units-table-row-action shortcut-enter" data-key-action="href">
  169. <a
  170. class="units-table-row-action-link"
  171. href="/edit/firewall/?<?= tohtml(http_build_query(["rule" => $key, "token" => $_SESSION["token"]])) ?>"
  172. title="<?= tohtml( _("Edit Firewall Rule")) ?>"
  173. >
  174. <i class="fas fa-pencil icon-orange"></i>
  175. <span class="u-hide-desktop"><?= tohtml( _("Edit Firewall Rule")) ?></span>
  176. </a>
  177. </li>
  178. <li class="units-table-row-action shortcut-s" data-key-action="js">
  179. <a
  180. class="units-table-row-action-link data-controls js-confirm-action"
  181. href="/<?= tohtml($spnd_action) ?>/firewall/?<?= tohtml(http_build_query(["rule" => $key, "token" => $_SESSION["token"]])) ?>"
  182. title="<?= tohtml($spnd_action_title) ?>"
  183. data-confirm-title="<?= tohtml($spnd_action_title) ?>"
  184. data-confirm-message="<?= tohtml(sprintf($spnd_confirmation, $key)) ?>"
  185. >
  186. <i class="fas <?= tohtml($spnd_icon) ?> <?= tohtml($spnd_icon_class) ?>"></i>
  187. <span class="u-hide-desktop"><?= tohtml($spnd_action_title) ?></span>
  188. </a>
  189. </li>
  190. <li class="units-table-row-action shortcut-delete" data-key-action="js">
  191. <a
  192. class="units-table-row-action-link data-controls js-confirm-action"
  193. href="/delete/firewall/?<?= tohtml(http_build_query(["rule" => $key, "token" => $_SESSION["token"]])) ?>"
  194. title="<?= tohtml( _("Delete")) ?>"
  195. data-confirm-title="<?= tohtml( _("Delete")) ?>"
  196. data-confirm-message="<?= tohtml(sprintf(_("Are you sure you want to delete rule #%s?"), $key)) ?>"
  197. >
  198. <i class="fas fa-trash icon-red"></i>
  199. <span class="u-hide-desktop"><?= tohtml( _("Delete")) ?></span>
  200. </a>
  201. </li>
  202. </ul>
  203. </div>
  204. <div class="units-table-cell u-text-bold">
  205. <span class="u-hide-desktop"><?= tohtml( _("Comment")) ?>:</span>
  206. <?php if (!empty($data[$key]['COMMENT'])) { echo $data[$key]['COMMENT']; } ?>
  207. </div>
  208. <div class="units-table-cell u-text-center-desktop">
  209. <span class="u-hide-desktop u-text-bold"><?= tohtml( _("Protocol")) ?>:</span>
  210. <?= tohtml( _($data[$key]["PROTOCOL"])) ?>
  211. </div>
  212. <div class="units-table-cell u-text-bold u-text-center-desktop">
  213. <span class="u-hide-desktop"><?= tohtml( _("Port")) ?>:</span>
  214. <?= tohtml($data[$key]["PORT"]) ?>
  215. </div>
  216. <div class="units-table-cell u-text-center-desktop">
  217. <span class="u-hide-desktop u-text-bold"><?= tohtml( _("IP Address")) ?>:</span>
  218. <?= tohtml($data[$key]["IP"]) ?>
  219. </div>
  220. </div>
  221. <?php } ?>
  222. </div>
  223. <div class="units-table-footer">
  224. <p>
  225. <?php printf(ngettext("%d firewall rule", "%d firewall rules", $i), $i); ?>
  226. </p>
  227. </div>
  228. </div>