index.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. while (list ($key, $val) = @each($fid)) {
  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) {
  25. continue;
  26. }
  27. $value = $_POST['f_group_name'][$j];
  28. if (isset($value)) {
  29. $new[ou_name] = $value;
  30. update_record($db_link, "OU", "id='{$save_id}'", $new);
  31. }
  32. }
  33. }
  34. header("Location: " . $_SERVER["REQUEST_URI"]);
  35. }
  36. if (isset($_POST["create"])) {
  37. $ou_name = $_POST["new_ou"];
  38. if (isset($ou_name)) {
  39. $new[ou_name] = $ou_name;
  40. insert_record($db_link, "OU", $new);
  41. }
  42. header("Location: " . $_SERVER["REQUEST_URI"]);
  43. }
  44. unset($_POST);
  45. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  46. ?>
  47. <div id="cont">
  48. <table>
  49. <tr>
  50. <td><b>Список групп</b><br>
  51. <form name="def" action="index.php" method="post">
  52. <table class="data">
  53. <tr align="center">
  54. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  55. <td><b>Id</b></td>
  56. <td><b>Название</b></td>
  57. <td><input type="submit" name="remove" value="Удалить"></td>
  58. </tr>
  59. <?
  60. $t_ou = get_records($db_link,'OU','TRUE ORDER BY ou_name');
  61. foreach ($t_ou as $row) {
  62. print "<tr align=center>\n";
  63. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";
  64. print "<td class=\"data\"><input type=\"hidden\" name='id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  65. print "<td class=\"data\"><input type=\"text\" name='f_group_name[]' value='{$row['ou_name']}'></td>\n";
  66. print "<td class=\"data\"><button name='save[]' value='{$row['id']}'>Сохранить</button></td>\n";
  67. print "</tr>\n";
  68. }
  69. ?>
  70. </table>
  71. <table>
  72. <tr>
  73. <td><input type=text name=new_ou value="Unknown"></td>
  74. <td><input type="submit" name="create" value="Добавить"></td>
  75. <td align="right"></td>
  76. </tr>
  77. </table>
  78. </form>
  79. <?php
  80. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  81. ?>