add_firewall_ipset.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/firewall/ipset/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. </div>
  9. <div class="toolbar-buttons">
  10. <button type="submit" class="button" form="main-form">
  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="main-form" name="v_add_ipset" method="post">
  19. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  20. <input type="hidden" name="ok" value="Add">
  21. <?php
  22. $country = [
  23. "br" => "Brazil",
  24. "ca" => "Canada",
  25. "cn" => "China",
  26. "fr" => "French",
  27. "de" => "Germany",
  28. "in" => "India",
  29. "id" => "Indonesia",
  30. "nl" => "Netherlands",
  31. "ro" => "Romania",
  32. "ru" => "Russia",
  33. "es" => "Spain",
  34. "ch" => "Switzerland",
  35. "tr" => "Turkey",
  36. "ua" => "Ukraine",
  37. "gb" => "United Kingdom",
  38. "us" => "United States",
  39. ];
  40. function generate_iplist($country, $type) {
  41. $iplist = [];
  42. $lowercaseType = strtolower($type);
  43. foreach ($country as $iso => $name) {
  44. $iplist[] = [
  45. "name" => "[$type] " . _("Country") . " - $name",
  46. "source" => "https://raw.githubusercontent.com/ipverse/rir-ip/master/country/$iso/$lowercaseType-aggregated.txt",
  47. ];
  48. }
  49. return $iplist;
  50. }
  51. $country_iplists = generate_iplist($country, "IPv4");
  52. // Uncomment below for IPv6
  53. // $country_ipv6lists = generate_iplist($country, 'IPv6');
  54. $blacklist_iplists = [
  55. ["name" => "[IPv4] " . _("Block Malicious IPs"), "source" => "script:/usr/local/hestia/install/common/firewall/ipset/blacklist.sh"],
  56. // Uncomment below for IPv6
  57. // array('name' => "[IPv6] " . _("Block Malicious IPs"), 'source' => "script:/usr/local/hestia/install/common/firewall/ipset/blacklist.ipv6.sh"),
  58. ];
  59. ?>
  60. <div class="form-container">
  61. <h1 class="u-mb20"><?= _("Add IPset IP List for Firewall") ?></h1>
  62. <?php show_alert_message($_SESSION); ?>
  63. <div class="u-mb10">
  64. <label for="v_ipname" class="form-label"><?= _("IP List Name") ?></label>
  65. <input type="text" class="form-control" name="v_ipname" id="v_ipname" maxlength="255" value="<?= htmlentities(trim($v_ipname, "'")) ?>">
  66. </div>
  67. <div class="u-mb10">
  68. <label for="v_datasource" class="form-label">
  69. <?= _("Data Source") ?> <span class="optional">(<?= _("url, script or file") ?>)</span>
  70. </label>
  71. <div class="u-pos-relative">
  72. <select
  73. class="form-select js-datasource-select"
  74. tabindex="-1"
  75. onchange="this.nextElementSibling.value=this.value"
  76. data-country-iplists="<?= htmlspecialchars(json_encode($country_iplists), ENT_QUOTES, "UTF-8") ?>"
  77. data-blacklist-iplists="<?= htmlspecialchars(json_encode($blacklist_iplists), ENT_QUOTES, "UTF-8") ?>"
  78. >
  79. <option value=""><?= _("Clear") ?></option>
  80. </select>
  81. <input type="text" class="form-control list-editor" name="v_datasource" id="v_datasource" maxlength="255" value="<?= htmlentities(trim($v_datasource, "'")) ?>">
  82. </div>
  83. </div>
  84. <div class="u-mb10">
  85. <label for="v_ipver" class="form-label"><?= _("IP Version") ?></label>
  86. <select class="form-select" name="v_ipver" id="v_ipver">
  87. <option value="v4" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v4'" )) echo 'selected'?>>IPv4</option>
  88. <option value="v6" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v6'" )) echo 'selected'?>>IPv6</option>
  89. </select>
  90. </div>
  91. <div class="u-mb10">
  92. <label for="v_autoupdate" class="form-label"><?= _("Auto Update") ?></label>
  93. <select class="form-select" name="v_autoupdate" id="v_autoupdate">
  94. <option value="yes" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'yes'" )) echo 'selected'?>><?= _("Yes") ?></option>
  95. <option value="no" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'no'" )) echo 'selected'?>><?= _("No") ?></option>
  96. </select>
  97. </div>
  98. </div>
  99. </form>
  100. </div>