index.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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["remove"])) {
  5. $fid = $_POST["f_id"];
  6. foreach ($fid as $key => $val) {
  7. if (isset($val) and $val > 0) {
  8. $new['ou_id'] = 0;
  9. update_record($db_link, "User_list", "ou_id=" . $val, $new);
  10. delete_record($db_link, "OU", "id=" . $val);
  11. }
  12. }
  13. header("Location: " . $_SERVER["REQUEST_URI"]);
  14. }
  15. if (isset($_POST['save'])) {
  16. $len = is_array($_POST['id']) ? count($_POST['id']) : 0;
  17. for ($i = 0; $i < $len; $i ++) {
  18. $save_id = intval($_POST['save'][$i]);
  19. if ($save_id == 0) {
  20. continue;
  21. }
  22. $len_all = is_array($_POST['id']) ? count($_POST['id']) : 0;
  23. for ($j = 0; $j < $len_all; $j ++) {
  24. if (intval($_POST['id'][$j]) != $save_id) { continue; }
  25. $new['ou_name'] = $_POST['f_group_name'][$j];
  26. $new['nagios_dir'] = $_POST['f_nagios'][$j];
  27. update_record($db_link, "OU", "id='{$save_id}'", $new);
  28. }
  29. }
  30. header("Location: " . $_SERVER["REQUEST_URI"]);
  31. }
  32. if (isset($_POST["create"])) {
  33. $ou_name = $_POST["new_ou"];
  34. if (isset($ou_name)) {
  35. $new['ou_name'] = $ou_name;
  36. insert_record($db_link, "OU", $new);
  37. }
  38. header("Location: " . $_SERVER["REQUEST_URI"]);
  39. }
  40. unset($_POST);
  41. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  42. ?>
  43. <div id="cont">
  44. <table>
  45. <tr>
  46. <td><b>Список групп</b><br>
  47. <form name="def" action="index.php" method="post">
  48. <table class="data">
  49. <tr align="center">
  50. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  51. <td><b>Id</b></td>
  52. <td><b>Название</b></td>
  53. <td><b>Nagios directory</b></td>
  54. <td><input type="submit" name="remove" value="Удалить"></td>
  55. </tr>
  56. <?
  57. $t_ou = get_records($db_link,'OU','TRUE ORDER BY ou_name');
  58. foreach ($t_ou as $row) {
  59. print "<tr align=center>\n";
  60. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] 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\"><input type=\"text\" name='f_group_name[]' value='{$row['ou_name']}'></td>\n";
  63. print "<td class=\"data\"><input type=\"text\" name='f_nagios[]' value='{$row['nagios_dir']}'></td>\n";
  64. print "<td class=\"data\"><button name='save[]' value='{$row['id']}'>Сохранить</button></td>\n";
  65. print "</tr>\n";
  66. }
  67. ?>
  68. </table>
  69. <table>
  70. <tr>
  71. <td><input type=text name=new_ou value="Unknown"></td>
  72. <td><input type="submit" name="create" value="Добавить"></td>
  73. <td align="right"></td>
  74. </tr>
  75. </table>
  76. </form>
  77. <?php
  78. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  79. ?>