index.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. // Сохранение ОТМЕЧЕННЫХ записей
  5. if (getPOST("save") !== null) {
  6. $selected_ids = getPOST("f_id", null, []); // отмеченные чекбоксы
  7. $all_ids = getPOST("r_id", null, []); // все ID
  8. $names = getPOST("f_queue_name", null, []);
  9. $downs = getPOST("f_down", null, []);
  10. $ups = getPOST("f_up", null, []);
  11. if (!empty($selected_ids) && is_array($selected_ids)) {
  12. $selected_ids = array_map('intval', $selected_ids);
  13. $selected_set = array_flip($selected_ids);
  14. foreach ($all_ids as $i => $id) {
  15. $id = (int)$id;
  16. if ($id <= 0 || !isset($selected_set[$id])) continue;
  17. $name = trim($names[$i] ?? '');
  18. if ($name === '') continue;
  19. update_record($db_link, "queue_list", "id = ?", [
  20. 'queue_name' => $name,
  21. 'download' => (int)($downs[$i] ?? 0),
  22. 'upload' => (int)($ups[$i] ?? 0)
  23. ], [$id]);
  24. }
  25. }
  26. header("Location: " . $_SERVER["REQUEST_URI"]);
  27. exit;
  28. }
  29. // Удаление отмеченных
  30. if (getPOST("remove") !== null) {
  31. $f_id = getPOST("f_id", null, []);
  32. if (!empty($f_id) && is_array($f_id)) {
  33. foreach ($f_id as $id) {
  34. $id = (int)$id;
  35. if ($id > 0) {
  36. delete_record($db_link, "queue_list", "id = ?", [$id]);
  37. }
  38. }
  39. }
  40. header("Location: " . $_SERVER["REQUEST_URI"]);
  41. exit;
  42. }
  43. // Создание новой очереди
  44. if (getPOST("create") !== null) {
  45. $queue_name = trim(getPOST("new_queue", null, ''));
  46. if ($queue_name !== '') {
  47. insert_record($db_link, "queue_list", ['queue_name' => $queue_name]);
  48. }
  49. header("Location: " . $_SERVER["REQUEST_URI"]);
  50. exit;
  51. }
  52. unset($_POST);
  53. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  54. ?>
  55. <div id="cont">
  56. <b><?php echo WEB_list_queues; ?></b> <br>
  57. <form name="def" action="index.php" method="post">
  58. <!-- ЕДИНАЯ КНОПКА СОХРАНЕНИЯ -->
  59. <div style="margin-top: 10px; text-align: right;">
  60. <input type="submit" name="save" value="<?php echo WEB_btn_save; ?>">
  61. <input type="submit"
  62. onclick="return confirm('<?php echo WEB_msg_delete; ?>?')"
  63. name="remove"
  64. value="<?php echo WEB_btn_delete; ?>">
  65. </div>
  66. <table class="data">
  67. <tr align="center">
  68. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  69. <td><b>Id</b></td>
  70. <td><b><?php echo WEB_cell_name; ?></b></td>
  71. <td><b>Download</b></td>
  72. <td><b>Upload</b></td>
  73. </tr>
  74. <?php
  75. $t_queue = get_records_sql($db_link, "SELECT * FROM queue_list ORDER BY id");
  76. foreach ($t_queue as $row) {
  77. print "<tr align=center>\n";
  78. print "<td class=\"data\" style='padding:0'><input type=\"checkbox\" name=\"f_id[]\" value=\"{$row['id']}\"></td>\n";
  79. print "<td class=\"data\"><input type=\"hidden\" name=\"r_id[]\" value=\"{$row['id']}\">{$row['id']}</td>\n";
  80. print "<td class=\"data\"><input type=\"text\" name=\"f_queue_name[]\" value=\"" . htmlspecialchars($row['queue_name']) . "\"></td>\n";
  81. print "<td class=\"data\"><input type=\"text\" name=\"f_down[]\" value=\"{$row['download']}\"></td>\n";
  82. print "<td class=\"data\"><input type=\"text\" name=\"f_up[]\" value=\"{$row['upload']}\"></td>\n";
  83. print "</tr>\n";
  84. }
  85. ?>
  86. </table>
  87. <div style="margin-top: 15px;">
  88. <input type="text" name="new_queue" value="New_queue">
  89. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  90. </div>
  91. </form>
  92. <?php
  93. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  94. ?>