index-subnets.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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["s_remove"])) {
  5. if (!empty($_POST["s_id"])) {
  6. $s_id = $_POST["s_id"];
  7. foreach ($s_id as $key => $net_id) {
  8. if (isset($net_id)) {
  9. LOG_INFO($db_link, "Remove subnet id: $net_id ". dump_record($db_link,'subnets','id='.$val));
  10. delete_record($db_link, "subnets", "id=" . $net_id);
  11. delete_record($db_link, "gateway_subnets", "subnet_id=" . $net_id);
  12. }
  13. }
  14. }
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. exit;
  17. }
  18. if (isset($_POST["s_create"])) {
  19. $new_subnet = $_POST["s_create_subnet"];
  20. if (isset($new_subnet)) {
  21. $new['subnet'] = trim($new_subnet);
  22. $range = cidrToRange($new['subnet']);
  23. $first_user_ip = $range[0];
  24. $last_user_ip = $range[1];
  25. $cidr = $range[2][1];
  26. if (isset($cidr) and $cidr < 32) {
  27. $ip = $first_user_ip . '/' . $cidr;
  28. } else {
  29. $ip = $first_user_ip;
  30. }
  31. $new['ip_int_start'] = ip2long($first_user_ip);
  32. $new['ip_int_stop'] = ip2long($last_user_ip);
  33. $new['dhcp_start'] = ip2long($range[3]);
  34. $new['dhcp_stop'] = ip2long($range[4]);
  35. $new['gateway'] = ip2long($range[5]);
  36. LOG_INFO($db_link, "Create new subnet $new_subnet");
  37. insert_record($db_link, "subnets", $new);
  38. }
  39. header("Location: " . $_SERVER["REQUEST_URI"]);
  40. exit;
  41. }
  42. unset($_POST);
  43. fix_auth_rules($db_link);
  44. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  45. print_control_submenu($page_url);
  46. ?>
  47. <div id="cont">
  48. <br>
  49. <form name="def" action="index-subnets.php" method="post">
  50. <div>
  51. <?php print WEB_network_create . "&nbsp:<input type=\"text\" name='s_create_subnet' value=''>"; ?>
  52. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  53. <input class="button_right" type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
  54. </div>
  55. <b><?php echo WEB_network_org_title; ?></b> <br>
  56. <table class="data">
  57. <tr align="center">
  58. <td></td>
  59. <td><b><?php echo WEB_network_subnet; ?></b></td>
  60. <td><b><?php echo WEB_network_vlan; ?></b></td>
  61. <td><b><?php echo WEB_network_use_dhcp; ?></b></td>
  62. <td><b><?php echo WEB_network_static; ?></b></td>
  63. <td><b><?php echo WEB_network_office_subnet; ?></b></td>
  64. <td><b><?php echo WEB_network_hotspot; ?></b></td>
  65. <td><b><?php echo WEB_network_vpn; ?></b></td>
  66. <td><b><?php echo WEB_network_free; ?></b></td>
  67. <td><b><?php echo WEB_network_dyndns; ?></b></td>
  68. <td><b><?php echo WEB_network_discovery; ?></b></td>
  69. <td><b><?php echo WEB_network_notify; ?></b></td>
  70. <td><b><?php echo WEB_cell_description; ?></b></td>
  71. </tr>
  72. <?php
  73. $t_subnets = get_records($db_link, 'subnets', 'True ORDER BY ip_int_start');
  74. foreach ($t_subnets as $row) {
  75. print "<tr align=center>\n";
  76. print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='" . $row['id'] . "'></td>\n";
  77. print "<td class=\"data\" align=left><a href=editsubnet.php?id=".$row["id"].">" . $row["subnet"] . "</a></td>\n";
  78. print "<td class=\"data\">" . $row['vlan_tag'] . " </td>\n";
  79. print_td_yes_no($row['dhcp']);
  80. print_td_yes_no($row['static']);
  81. print_td_yes_no($row['office']);
  82. print_td_yes_no($row['hotspot']);
  83. print_td_yes_no($row['vpn']);
  84. print_td_yes_no($row['free']);
  85. print_td_yes_no($row['dhcp_update_hostname']);
  86. print_td_yes_no($row['discovery']);
  87. print "<td class=\"data\">" . printFlagsByFirstLetter($row['notify']) . " </td>\n";
  88. print "<td class=\"data\">" . $row['description'] . " </td>\n";
  89. print "</tr>\n";
  90. }
  91. ?>
  92. </table>
  93. </form>
  94. <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>