index-subnets.php 4.1 KB

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