edit_gw_subnets.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. $device = get_record($db_link, 'devices', "id = ?", [$id]);
  6. $user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$device['user_id']]);
  7. // Удаление подсетей шлюза
  8. if (getPOST("s_remove") !== null) {
  9. $s_id = getPOST("gs_id", null, []);
  10. if (!empty($s_id) && is_array($s_id)) {
  11. foreach ($s_id as $val) {
  12. $val = trim($val);
  13. if ($val === '') continue;
  14. delete_record($db_link, "gateway_subnets", "id = ?", [(int)$val]);
  15. }
  16. }
  17. header("Location: " . $_SERVER["REQUEST_URI"]);
  18. exit;
  19. }
  20. // Добавление подсети к шлюзу
  21. if (getPOST("s_create") !== null) {
  22. $new_subnet = trim(getPOST("new_subnet", null, ''));
  23. if ($new_subnet !== '') {
  24. $new = [
  25. 'subnet_id' => $new_subnet,
  26. 'device_id' => $id
  27. ];
  28. insert_record($db_link, "gateway_subnets", $new);
  29. }
  30. header("Location: " . $_SERVER["REQUEST_URI"]);
  31. exit;
  32. }
  33. unset($_POST);
  34. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  35. print_device_submenu($page_url);
  36. print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login']);
  37. ?>
  38. <div id="contsubmenu">
  39. <br>
  40. <?php print "<form name=def action='edit_gw_subnets.php?id=".$id."' method=post>"; ?>
  41. <?php
  42. if ($device['device_type'] == 0) { print WEB_list_l3_networks; } else { print WEB_list_gateway_subnets."<b>"; }
  43. print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
  44. </b> <br>
  45. <table class="data">
  46. <tr align="center">
  47. <td></td>
  48. <td width=10><b>id</b></td>
  49. <td><b><?php echo WEB_network_subnet; ?></b></td>
  50. <td>
  51. <input type="submit" onclick="return confirm('<?php print WEB_msg_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
  52. </td>
  53. </tr>
  54. <?php
  55. $gateway_subnets = get_records_sql($db_link,'SELECT gateway_subnets.*,subnets.subnet,subnets.description FROM gateway_subnets LEFT JOIN subnets ON gateway_subnets.subnet_id = subnets.id WHERE gateway_subnets.device_id=?', [$id]);
  56. foreach ( $gateway_subnets as $row ) {
  57. print "<tr align=center>\n";
  58. print "<td class=\"data\" style='padding:0' width=30><input type=checkbox name=gs_id[] value='{$row['id']}'></td>\n";
  59. print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  60. print "<td class=\"data\">"; print get_subnet_description($db_link,$row['subnet_id']); print "</td>\n";
  61. print "<td></td></tr>\n";
  62. }
  63. ?>
  64. <tr>
  65. <td colspan=3><?php print WEB_btn_add; print_add_gw_subnets($db_link,$id,"new_subnet"); ?>
  66. </td>
  67. <td>
  68. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  69. </td>
  70. </tr>
  71. </table>
  72. </form>
  73. <?php
  74. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  75. ?>