ipsets.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
  3. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
  4. if (getPOST("create") !== null) {
  5. $fname = trim(getPOST("newipset", null, ''));
  6. if ($fname !== '') {
  7. $new_id = insert_record($db_link, "ipset_list", ['name' => $fname]);
  8. if ($new_id) {
  9. header("Location: editipset.php?id=$new_id");
  10. exit;
  11. }
  12. }
  13. header("Location: " . $_SERVER["REQUEST_URI"]);
  14. exit;
  15. }
  16. if (getPOST("remove") !== null) {
  17. $fgid = getPOST("fid", null, []);
  18. if (!empty($fgid) && is_array($fgid)) {
  19. foreach ($fgid as $val) {
  20. $val = trim($val);
  21. if ($val === '') continue;
  22. delete_records($db_link, "ipset_members", "ipset_id = ?", [$val]);
  23. update_records($db_link, "filter_list", "ipset_id = ?", [ 'ipset_id'=>0, 'dst'=>'' ], [$val]);
  24. delete_records($db_link, "ipset_list", "id = ?", [$val]);
  25. }
  26. }
  27. header("Location: " . $_SERVER["REQUEST_URI"]);
  28. exit;
  29. }
  30. unset($_POST);
  31. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  32. print_filters_submenu($page_url);
  33. ?>
  34. <div id="cont">
  35. <form name="def" action="ipsets.php" method="post">
  36. <table class="data">
  37. <tr align="center">
  38. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  39. <td><b>Id</b></td>
  40. <td width=200><b><?php echo WEB_cell_name; ?></b></td>
  41. <td width=200><b><?php echo WEB_cell_description; ?></b></td>
  42. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
  43. </tr>
  44. <?php
  45. $ipsets = get_records_sql($db_link, 'SELECT * FROM ipset_list ORDER BY id');
  46. foreach ($ipsets as $row) {
  47. print "<tr align=center>\n";
  48. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row["id"] . "></td>\n";
  49. print "<td class=\"data\" ><input type=\"hidden\" name=\"" . $row["id"] . "\" value=" . $row["id"] . ">" . $row["id"] . "</td>\n";
  50. print "<td class=\"data\"><a href=editipset.php?id=" . $row["id"] . ">" . $row["name"] . "</a></td>\n";
  51. print "<td class=\"data\">" . $row["description"] . "</td>\n";
  52. print "<td></td></tr>";
  53. }
  54. ?>
  55. </table>
  56. <div>
  57. <?php echo WEB_cell_name; ?><input type=text name=newipset value="Unknown">
  58. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  59. </div>
  60. </form>
  61. <?php
  62. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
  63. ?>