add_firewall_ipset.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <div class="l-center edit">
  2. <div class="l-sort clearfix">
  3. <div class="l-unit-toolbar__buttonstrip">
  4. <a class="ui-button cancel" id="btn-back" href="/list/firewall/ipset/"><i class="fas fa-arrow-left status-icon blue"></i> <?=_('Back')?></a>
  5. </div>
  6. <div class="l-unit-toolbar__buttonstrip float-right">
  7. <a href="#" class="ui-button" data-action="submit" data-id="vstobjects"><i class="fas fa-save status-icon purple"></i> <?=_('Save')?></a>
  8. </div>
  9. </div>
  10. </div>
  11. <div class="l-separator"></div>
  12. <div class="l-center animated fadeIn">
  13. <?php
  14. $back = $_SESSION['back'];
  15. if (empty($back)) {
  16. $back = "location.href='/list/firewall/ipset/'";
  17. } else {
  18. $back = "location.href='".$back."'";
  19. }
  20. ?>
  21. <form id="vstobjects" name="v_add_ipset" method="post">
  22. <input type="hidden" name="token" value="<?=$_SESSION['token']?>" />
  23. <input type="hidden" name="ok" value="Add" />
  24. <table class="data mode-add">
  25. <tr class="data-add">
  26. <td class="data-dotted">
  27. <table class="data-col1">
  28. <tr><td></td></tr>
  29. </table>
  30. </td>
  31. <td class="data-dotted">
  32. <table class="data-col2" width="600px">
  33. <tr>
  34. <td class="step-top">
  35. <span class="page-title"><?=_('Adding Firewall Ipset List')?></span>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td>
  40. <?php
  41. if (!empty($_SESSION['error_msg'])) {
  42. echo "<span class=\"vst-error\"> <i class=\"fas fa-exclamation-circle status-icon red\"></i> ".htmlentities($_SESSION['error_msg'])."</span>";
  43. } else {
  44. if (!empty($_SESSION['ok_msg'])) {
  45. echo "<span class=\"vst-ok\"> <i class=\"fas fa-check-circle status-icon green\"></i> ".$_SESSION['ok_msg']."</span>";
  46. }
  47. }
  48. ?>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="vst-text step-top">
  53. <?php print _('Ip List Name') ?>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td>
  58. <input type="text" size="20" class="vst-input" name="v_ipname" maxlength="255" value="<?=htmlentities(trim($v_ipname, "'"))?>">
  59. </td>
  60. </tr>
  61. <tr>
  62. <td class="vst-text step-top">
  63. <?php print _('Data Source') ?> <span class="optional">(<?php print _('url, script or file');?>)</span>
  64. </td>
  65. </tr>
  66. <tr>
  67. <td>
  68. <select class="vst-list" tabindex="-1" id="datasource_list" onchange="this.nextElementSibling.value=this.value">
  69. <option value="">clear</option>
  70. </select>
  71. <input type="text" size="20" class="vst-input vst-list-editor" name="v_datasource" maxlength="255" value="<?=htmlentities(trim($v_datasource, "'"))?>">
  72. </td>
  73. </tr>
  74. <tr>
  75. <td class="vst-text step-top">
  76. <?php print _('Ip Version') ?>
  77. </td>
  78. </tr>
  79. <tr>
  80. <td>
  81. <select class="vst-list" name="v_ipver">
  82. <option value="v4" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v4'" )) echo 'selected'?>><?=_('ip v4')?></option>
  83. <option value="v6" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v6'" )) echo 'selected'?>><?=_('ip v6')?></option>
  84. </select>
  85. </td>
  86. </tr>
  87. <tr>
  88. <td class="vst-text step-top">
  89. <?php print _('Autoupdate') ?>
  90. </td>
  91. </tr>
  92. <tr>
  93. <td>
  94. <select class="vst-list" name="v_autoupdate">
  95. <option value="yes" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'yes'" )) echo 'selected'?>><?=_('yes')?></option>
  96. <option value="no" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'no'" )) echo 'selected'?>><?=_('no')?></option>
  97. </select>
  98. </td>
  99. </tr>
  100. </table>
  101. <table class="data-col2"></table>
  102. </td>
  103. </tr>
  104. </table>
  105. </form>
  106. </div>
  107. <script>
  108. var country_iplists = [
  109. // Define IPv4 country lists
  110. {name: "[IPv4] Country - Canada", source:"http://ipverse.net/ipblocks/data/countries/ca.zone"},
  111. {name: "[IPv4] Country - China", source:"http://ipverse.net/ipblocks/data/countries/cn.zone"},
  112. {name: "[IPv4] Country - France", source:"http://ipverse.net/ipblocks/data/countries/fr.zone"},
  113. {name: "[IPv4] Country - Germany", source:"http://ipverse.net/ipblocks/data/countries/de.zone"},
  114. {name: "[IPv4] Country - India", source:"http://ipverse.net/ipblocks/data/countries/in.zone"},
  115. {name: "[IPv4] Country - Netherlands", source:"http://ipverse.net/ipblocks/data/countries/nl.zone"},
  116. {name: "[IPv4] Country - Romania", source:"http://ipverse.net/ipblocks/data/countries/ro.zone"},
  117. {name: "[IPv4] Country - Russia", source:"http://ipverse.net/ipblocks/data/countries/ru.zone"},
  118. {name: "[IPv4] Country - Spain", source:"http://ipverse.net/ipblocks/data/countries/es.zone"},
  119. {name: "[IPv4] Country - Switzerland", source:"http://ipverse.net/ipblocks/data/countries/ch.zone"},
  120. {name: "[IPv4] Country - Ukraine", source:"http://ipverse.net/ipblocks/data/countries/ua.zone"},
  121. {name: "[IPv4] Country - United Kingdom", source:"http://ipverse.net/ipblocks/data/countries/gb.zone"},
  122. {name: "[IPv4] Country - United States", source:"http://ipverse.net/ipblocks/data/countries/us.zone"},
  123. // Define IPv6 country lists
  124. /*
  125. {name: "[IPv6] Country - China", source:"http://ipverse.net/ipblocks/data/countries/cn-ipv6.zone"},
  126. {name: "[IPv6] Country - Canada", source:"http://ipverse.net/ipblocks/data/countries/ca-ipv6.zone"},
  127. {name: "[IPv6] Country - France", source:"http://ipverse.net/ipblocks/data/countries/fr-ipv6.zone"},
  128. {name: "[IPv6] Country - Germany", source:"http://ipverse.net/ipblocks/data/countries/de-ipv6.zone"},
  129. {name: "[IPv6] Country - India", source:"http://ipverse.net/ipblocks/data/countries/in-ipv6.zone"},
  130. {name: "[IPv6] Country - Netherlands", source:"http://ipverse.net/ipblocks/data/countries/nl-ipv6.zone"},
  131. {name: "[IPv6] Country - Romania", source:"http://ipverse.net/ipblocks/data/countries/ro-ipv6.zone"},
  132. {name: "[IPv6] Country - Russia", source:"http://ipverse.net/ipblocks/data/countries/ru-ipv6.zone"},
  133. {name: "[IPv6] Country - Spain", source:"http://ipverse.net/ipblocks/data/countries/es-ipv6.zone"},
  134. {name: "[IPv6] Country - Switzerland", source:"http://ipverse.net/ipblocks/data/countries/ch-ipv6.zone"},
  135. {name: "[IPv6] Country - Ukraine", source:"http://ipverse.net/ipblocks/data/countries/ua-ipv6.zone"},
  136. {name: "[IPv6] Country - United Kingdom", source:"http://ipverse.net/ipblocks/data/countries/gb-ipv6.zone"},
  137. {name: "[IPv6] Country - United States", source:"http://ipverse.net/ipblocks/data/countries/us-ipv6.zone"},
  138. */
  139. ];
  140. var blacklist_iplists = [
  141. {name: "[IPv4] Block Malicious IPs", source:"script:/usr/local/hestia/install/deb/firewall/ipset/blacklist.sh"},
  142. /*
  143. {name: "[IPv6] Block Malicious IPs", source:"script:/usr/local/hestia/install/deb/firewall/ipset/blacklist.ipv6.sh"},
  144. */
  145. ];
  146. country_iplists.sort(function (a, b) {
  147. return a.name > b.name;
  148. });
  149. blacklist_iplists.sort(function (a, b) {
  150. return a.name > b.name;
  151. });
  152. $(function() {
  153. var targetelement = document.getElementById('datasource_list');
  154. // Blacklist
  155. var newEl = document.createElement("option");
  156. newEl.text="<?php print _('BLACKLIST') ?>";
  157. newEl.disabled=true;
  158. targetelement.appendChild(newEl);
  159. blacklist_iplists.forEach(iplist => {
  160. var newEl = document.createElement("option");
  161. newEl.text=iplist.name;
  162. newEl.value=iplist.source;
  163. targetelement.appendChild(newEl);
  164. });
  165. // IPVERSE
  166. var newEl = document.createElement("option");
  167. newEl.text="<?php print _('IPVERSE') ?>";
  168. newEl.disabled=true;
  169. targetelement.appendChild(newEl);
  170. country_iplists.forEach(iplist => {
  171. var newEl = document.createElement("option");
  172. newEl.text=iplist.name;
  173. newEl.value=iplist.source;
  174. targetelement.appendChild(newEl);
  175. });
  176. });
  177. </script>