1
0

index.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
  3. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
  4. // Создание нового фильтра
  5. if (getPOST("create") !== null) {
  6. $fname = trim(getPOST("newfilter", null, ''));
  7. $ftype = (int)getPOST("filter_type", null, 0);
  8. if ($fname !== '') {
  9. $new_id = insert_record($db_link, "filter_list", [
  10. 'name' => $fname,
  11. 'filter_type' => $ftype
  12. ]);
  13. if ($new_id) {
  14. header("Location: editfilter.php?id=$new_id");
  15. exit;
  16. }
  17. }
  18. header("Location: " . $_SERVER["REQUEST_URI"]);
  19. exit;
  20. }
  21. // Удаление фильтров
  22. if (getPOST("remove") !== null) {
  23. $fid = getPOST("fid", null, []);
  24. if (!empty($fid) && is_array($fid)) {
  25. foreach ($fid as $val) {
  26. $val = trim($val);
  27. if ($val === '') continue;
  28. // Удаляем из связей
  29. delete_records($db_link, "group_filters", "filter_id = ?", [(int)$val]);
  30. // Удаляем сам фильтр
  31. delete_record($db_link, "filter_list", "id = ?", [(int)$val]);
  32. }
  33. }
  34. header("Location: " . $_SERVER["REQUEST_URI"]);
  35. exit;
  36. }
  37. unset($_POST);
  38. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  39. print_filters_submenu($page_url);
  40. ?>
  41. <div id="cont">
  42. <form name="def" action="index.php" method="post">
  43. <table class="data">
  44. <tr align="center">
  45. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  46. <td><b>id</b></td>
  47. <td><b><?php echo WEB_cell_forename; ?></b></td>
  48. <td><b><?php echo WEB_cell_type; ?></b></td>
  49. <td><b><?php echo WEB_traffic_proto; ?></b></td>
  50. <td><b><?php echo WEB_traffic_dest_address; ?></b></td>
  51. <td><b><?php echo WEB_traffic_dst_port; ?></b></td>
  52. <td><b><?php echo WEB_traffic_src_port; ?></b></td>
  53. <td><b><?php echo WEB_cell_description; ?></b></td>
  54. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
  55. </tr>
  56. <?php
  57. $filters = get_records_sql($db_link, 'SELECT * FROM filter_list ORDER BY name');
  58. foreach ($filters as $row) {
  59. print "<tr align=center>\n";
  60. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row['id'] . "></td>\n";
  61. print "<td class=\"data\" ><input type=hidden name=\"id\" value=" . $row['id'] . ">" . $row['id'] . "</td>\n";
  62. print "<td class=\"data\" align=left><a href=editfilter.php?id=" . $row['id'] . ">" . $row['name'] . "</a></td>\n";
  63. if (empty($row['description'])) {
  64. $row['description'] = '';
  65. }
  66. if (empty($row['proto'])) {
  67. $row['proto'] = '';
  68. }
  69. if (empty($row['dst'])) {
  70. $row['dst'] = '';
  71. }
  72. if (empty($row['dstport'])) {
  73. $row['dstport'] = '';
  74. }
  75. if (empty($row['srcport'])) {
  76. $row['srcport'] = '';
  77. }
  78. if ($row['filter_type'] == 0) {
  79. print "<td class=\"data\">IP фильтр</td>\n";
  80. print "<td class=\"data\">" . $row['proto'] . "</td>\n";
  81. print "<td class=\"data\">" . $row['dst'] . "</td>\n";
  82. print "<td class=\"data\">" . $row['dstport'] . "</td>\n";
  83. print "<td class=\"data\">" . $row['srcport'] . "</td>\n";
  84. print "<td class=\"data\">" . $row['description'] . "</td>\n";
  85. } else {
  86. print "<td class=\"data\">Name фильтр</td>\n";
  87. print "<td class=\"data\"></td>\n";
  88. print "<td class=\"data\">" . $row['dst'] . "</td>\n";
  89. print "<td class=\"data\"></td>\n";
  90. print "<td class=\"data\"></td>\n";
  91. print "<td class=\"data\">" . $row['description'] . "</td>\n";
  92. }
  93. print "<td></td></tr>";
  94. }
  95. ?>
  96. </table>
  97. <div>
  98. <?php echo WEB_cell_name; ?>
  99. <input type=text name=newfilter value="Unknown">
  100. <?php echo Web_filter_type; ?>
  101. <select name="filter_type" disabled=true>
  102. <option value=0 selected>IP фильтр</option>
  103. <option value=1>Name фильтр</option>
  104. </select>
  105. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  106. </form>
  107. <?php
  108. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
  109. ?>