editgroup.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
  3. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
  4. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
  5. if (isset($_POST["editgroup"])) {
  6. $new['group_name'] = $_POST["f_group_name"];
  7. $new['instance_id'] = $_POST["f_instance_id"]*1;
  8. $new['comment'] = $_POST["f_group_comment"];
  9. update_record($db_link, "group_list", "id='$id'", $new);
  10. header("Location: " . $_SERVER["REQUEST_URI"]);
  11. exit;
  12. }
  13. if (isset($_POST["addfilter"])) {
  14. $filter_id = $_POST["newfilter"] * 1;
  15. $max_record = get_record_sql($db_link, "SELECT MAX(G.order) as morder FROM group_filters as G where G.group_id='$id'");
  16. if (empty($max_record)) {
  17. $forder = 1;
  18. } else {
  19. $forder = $max_record["morder"] * 1 + 1;
  20. }
  21. $new['group_id'] = $id;
  22. $new['filter_id'] = $filter_id;
  23. $new['order'] = $forder;
  24. $new['action'] = 1;
  25. insert_record($db_link, "group_filters", $new);
  26. header("Location: " . $_SERVER["REQUEST_URI"]);
  27. exit;
  28. }
  29. if (isset($_POST["removefilter"])) {
  30. $f_group_filter = $_POST["f_group_filter"];
  31. foreach ($f_group_filter as $key => $val) {
  32. if (!empty($val)) {
  33. delete_record($db_link, "group_filters", "id=" . $val * 1);
  34. }
  35. }
  36. header("Location: " . $_SERVER["REQUEST_URI"]);
  37. exit;
  38. }
  39. if (isset($_POST["updateFilters"])) {
  40. if (!empty($_POST["f_group_filter"])) {
  41. $f_group_filter = $_POST["f_group_filter"];
  42. LOG_DEBUG($db_link, "Update filters for group id: " . $id);
  43. for ($i = 0; $i < count($f_group_filter); ++$i) {
  44. $group_filter_id = $f_group_filter[$i];
  45. if (empty($_POST["f_ord"][$group_filter_id])) {
  46. $new['order'] = $i;
  47. } else {
  48. $new['order'] = $_POST["f_ord"][$group_filter_id] * 1;
  49. }
  50. if (empty($_POST["f_action"][$group_filter_id])) {
  51. $new['action'] = 0;
  52. } else {
  53. $new['action'] = $_POST["f_action"][$group_filter_id] * 1;
  54. }
  55. if (!empty($new)) {
  56. update_record($db_link, "group_filters", "id=" . $group_filter_id, $new);
  57. }
  58. }
  59. }
  60. header("Location: " . $_SERVER["REQUEST_URI"]);
  61. exit;
  62. }
  63. unset($_POST);
  64. $group = get_record_sql($db_link, "SELECT * FROM group_list WHERE id=" . $id);
  65. print_filters_submenu($page_url);
  66. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  67. ?>
  68. <div id="cont">
  69. <br> <b><?php echo WEB_title_group; ?></b> <br>
  70. <form name="def" action="editgroup.php?id=<?php echo $id; ?>" method="post">
  71. <input type="hidden" name="id" value=<?php echo $id; ?>>
  72. <table class="data">
  73. <tr>
  74. <td><?php echo WEB_cell_name; ?></td>
  75. <td class='data'><input type="text" name="f_group_name" value="<?php echo $group['group_name']; ?>"></td>
  76. <td class='data' align=right><input type="submit" name="editgroup" value="<?php echo WEB_btn_save; ?>"></td>
  77. </tr>
  78. <tr>
  79. <td><?php echo WEB_cell_comment; ?></td>
  80. <td class='data'><input type="text" name="f_group_comment" value="<?php echo $group['comment']; ?>"></td>
  81. <td class='data'></td>
  82. </tr>
  83. <tr>
  84. <td><?php echo WEB_submenu_filter_instance; ?></td>
  85. <td class='data'><?php print_instance_select($db_link,'f_instance_id',$group['instance_id']); ?></td>
  86. <td class='data'></td>
  87. </tr>
  88. </table>
  89. <br> <b><?php echo WEB_groups_filter_list; ?></b><br>
  90. <table class="data">
  91. <tr>
  92. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  93. <td><?php echo WEB_group_filter_order; ?></td>
  94. <td><?php echo WEB_group_filter_name; ?></td>
  95. <td><?php echo WEB_traffic_action; ?></td>
  96. <td class='up'><input type="submit" name="updateFilters" value="<?php echo WEB_btn_save_filters; ?>"></td>
  97. <td class='warn'><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete_filter; ?>?')" name="removefilter" value="<?php echo WEB_btn_delete; ?>"></td>
  98. </tr>
  99. <?php
  100. $sSQL = "SELECT G.id, G.filter_id, F.name, G.order, G.action, F.comment FROM group_filters G, filter_list F WHERE F.id=G.filter_id and group_id=$id Order by G.order";
  101. $flist = get_records_sql($db_link, $sSQL);
  102. foreach ($flist as $row) {
  103. print "<tr align=center>\n";
  104. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_group_filter[] value=" . $row['id'] . "></td>\n";
  105. print "<td class=\"data\" align=left><input type=text name=f_ord[" . $row['id'] . "] value=" . $row['order'] . " size=4 ></td>\n";
  106. print "<td class=\"data\" align=left><a href=editfilter.php?id=" . $row['filter_id'] . ">" . $row['name'] . "</a></td>\n";
  107. $cl = "data";
  108. if ($row['action']) {
  109. $cl = "up";
  110. } else {
  111. $cl = "warn";
  112. }
  113. print "<td class=" . $cl . ">";
  114. print_action_select('f_action[' . $row['id'] . ']', $row['action']);
  115. print "</td>";
  116. print "<td colspan=2 class=\"data\" align=left>" . $row['comment'] . "</a></td>\n";
  117. print "</tr>";
  118. }
  119. ?>
  120. </table>
  121. <div>
  122. <input type="submit" name="addfilter" value="<?php echo WEB_msg_add_filter; ?>"> <?php print_filter_select($db_link, 'newfilter', $id); ?>
  123. </div>
  124. </form>
  125. <?php
  126. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
  127. ?>