groups.php 2.9 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 (isset($_POST["create"])) {
  5. $fname = $_POST["newgroup"];
  6. if ($fname) {
  7. $new['group_name'] = $fname;
  8. $new_id = insert_record($db_link, "Group_list", $new);
  9. header("location: editgroup.php?id=$new_id");
  10. exit;
  11. }
  12. header("Location: " . $_SERVER["REQUEST_URI"]);
  13. exit;
  14. }
  15. if (isset($_POST["remove"])) {
  16. $fgid = $_POST["fid"];
  17. foreach ($fgid as $key => $val) {
  18. if (!empty($val)) {
  19. run_sql($db_link, "UPDATE User_auth SET filter_group_id=0, changed = 1 WHERE deleted=0 AND filter_group_id=" . $val * 1);
  20. run_sql($db_link, "DELETE FROM Group_filters WHERE group_id=" . $val * 1);
  21. delete_record($db_link, "Group_list", "id=" . $val * 1);
  22. }
  23. }
  24. header("Location: " . $_SERVER["REQUEST_URI"]);
  25. exit;
  26. }
  27. unset($_POST);
  28. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  29. print_filters_submenu($page_url);
  30. ?>
  31. <div id="cont">
  32. <form name="def" action="groups.php" method="post">
  33. <table class="data">
  34. <tr align="center">
  35. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  36. <td><b>Id</b></td>
  37. <td width=200><b><?php echo WEB_cell_name; ?></b></td>
  38. <td ><b><?php echo WEB_submenu_filter_instance; ?></b></td>
  39. <td width=200><b><?php echo WEB_cell_comment; ?></b></td>
  40. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
  41. </tr>
  42. <?php
  43. $groups = get_records_sql($db_link, 'SELECT * FROM Group_list ORDER BY id');
  44. foreach ($groups as $row) {
  45. $filter_instance = get_record_sql($db_link,'SELECT * FROM filter_instances WHERE id='.$row["instance_id"]);
  46. print "<tr align=center>\n";
  47. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row["id"] . "></td>\n";
  48. print "<td class=\"data\" ><input type=\"hidden\" name=\"" . $row["id"] . "\" value=" . $row["id"] . ">" . $row["id"] . "</td>\n";
  49. print "<td class=\"data\"><a href=editgroup.php?id=" . $row["id"] . ">" . $row["group_name"] . "</a></td>\n";
  50. print "<td class=\"data\">". $filter_instance["name"]."</td>\n";
  51. print "<td class=\"data\">" . $row["comment"] . "</td>\n";
  52. print "<td></td></tr>";
  53. }
  54. ?>
  55. </table>
  56. <div>
  57. <?php echo WEB_cell_name; ?><input type=text name=newgroup 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. ?>