index.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. if (isset($_POST["create"])) {
  5. $fname = $_POST["newfilter"];
  6. $ftype = 0;
  7. if (isset($_POST['filter_type'])) {
  8. $ftype = $_POST["filter_type"] * 1;
  9. }
  10. if (isset($fname)) {
  11. $new[Name] = $fname;
  12. $new[type] = $ftype;
  13. insert_record($db_link, "Filter_list", $new);
  14. $new_id=get_record_field($db_link,'Filter_list','id',"Name='".$fname."' and type=".$ftype." ORDER BY id DESC");
  15. header("Location: editfilter.php?id=$new_id");
  16. }
  17. }
  18. if (isset($_POST["remove"])) {
  19. $fid = $_POST["fid"];
  20. while (list ($key, $val) = @each($fid)) {
  21. if ($val) {
  22. delete_record($db_link, "Group_filters", "filter_id=$val");
  23. delete_record($db_link, "Filter_list", "id=$val");
  24. }
  25. }
  26. header("Location: " . $_SERVER["REQUEST_URI"]);
  27. }
  28. unset($_POST);
  29. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  30. print_filters_submenu($page_url);
  31. ?>
  32. <div id="cont">
  33. <form name="def" action="index.php" method="post">
  34. <table class="data">
  35. <tr align="center">
  36. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  37. <td><b>id</b></td>
  38. <td><b>Имя</b></td>
  39. <td><b>Тип</b></td>
  40. <td><b>Протокол</b></td>
  41. <td><b>Адрес назначения</b></td>
  42. <td><b>Порт</b></td>
  43. <td><b>Действие</b></td>
  44. </tr>
  45. <?
  46. $filters = get_records($db_link,'Filter_list','TRUE ORDER BY Name');
  47. foreach ($filters as $row) {
  48. print "<tr align=center>\n";
  49. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
  50. print "<td class=\"data\" ><input type=hidden name=\"id\" value=".$row['id'].">".$row['id']."</td>\n";
  51. print "<td class=\"data\" align=left><a href=editfilter.php?id=".$row['id'].">" . $row['Name'] . "</a></td>\n";
  52. if ($row['type'] == 0) {
  53. print "<td class=\"data\">IP фильтр</td>\n";
  54. print "<td class=\"data\">".$row['proto']."</td>\n";
  55. print "<td class=\"data\">".$row['dst']."</td>\n";
  56. print "<td class=\"data\">".$row['dstport']."</td>\n";
  57. print "<td class=\"data\">" . get_action($row['action']) . "</td>\n<tr>";
  58. } else {
  59. print "<td class=\"data\">Name фильтр</td>\n";
  60. print "<td class=\"data\"></td>\n";
  61. print "<td class=\"data\">".$row['dst']."</td>\n";
  62. print "<td class=\"data\"></td>\n";
  63. print "<td class=\"data\">" . get_action($row['action']) . "</td>\n<tr>";
  64. }
  65. }
  66. ?>
  67. </table>
  68. <table class="data">
  69. <tr align=left>
  70. <td>Название <input type=text name=newfilter value="Unknown"></td>
  71. <td>Тип фильтра <select name="filter_type" disabled=true>
  72. <option value=0 selected>IP фильтр</option>
  73. <option value=1>Name фильтр</option>
  74. </select>
  75. </td>
  76. <td><input type="submit" name="create" value="Добавить"></td>
  77. <td align="right"><input type="submit" name="remove" value="Удалить"></td>
  78. </tr>
  79. </table>
  80. </form>
  81. <?
  82. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  83. ?>