editgroup.php 5.4 KB

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