control-subnets-usage.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. unset($_POST);
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  6. print_control_submenu($page_url);
  7. $zombi_days = get_option($db_link, 35);
  8. // Создаём временную метку: сейчас минус $zombi_days дней
  9. $zombi_threshold = date('Y-m-d H:i:s', strtotime("-$zombi_days days"));
  10. ?>
  11. <div id="cont">
  12. <br>
  13. <b><?php echo WEB_network_usage_title; ?></b> <br>
  14. <table class="data">
  15. <tr align="center">
  16. <td><b><?php echo WEB_network_subnet; ?></b></td>
  17. <td><b><?php echo WEB_network_all_ip; ?></b></td>
  18. <td><b><?php echo WEB_network_used_ip; ?></b></td>
  19. <td><b><?php echo WEB_network_free_ip; ?></b></td>
  20. <td><b><?php echo WEB_network_dhcp_size; ?></b></td>
  21. <td><b><?php echo WEB_network_dhcp_used; ?></b></td>
  22. <td><b><?php echo WEB_network_dhcp_free; ?></b></td>
  23. <td><b><?php echo WEB_network_static_free; ?></b></td>
  24. <td><b><?php echo WEB_network_zombi; ?><br><?php print "(> ".$zombi_days." ".WEB_days.")"; ?></b></td>
  25. <td><b><?php echo WEB_network_zombi_dhcp; ?><br><?php print "(> ".$zombi_days." ".WEB_days.")"; ?></b></td>
  26. </tr>
  27. <?php
  28. $t_subnets = get_records_SQL($db_link,'SELECT * FROM subnets WHERE office=1 ORDER BY ip_int_start');
  29. if (!empty($t_subnets)) {
  30. foreach ( $t_subnets as $row ) {
  31. print "<tr align=center>\n";
  32. $cl="data";
  33. print "<td class=\"$cl\"><a href=/admin/iplist/index.php?ou=0&cidr=".$row['subnet'].">".$row['subnet']."</a></td>\n";
  34. $all_ips = $row['ip_int_stop']-$row['ip_int_start']-3;
  35. print "<td class=\"$cl\">".$all_ips."</td>\n";
  36. #used
  37. $used_all = get_count_records($db_link,'user_auth','deleted = 0 AND ip_int >= ? AND ip_int <= ?', [ $row['ip_int_start'], $row['ip_int_stop']]);
  38. print "<td class=\"$cl\">".$used_all."</td>\n";
  39. $free_all = $all_ips - $used_all;
  40. print "<td class=\"$cl\">".$free_all."</td>\n";
  41. $dhcp_pool = $row['dhcp_stop']-$row['dhcp_start']+1;
  42. print "<td class=\"$cl\">".$dhcp_pool."</td>\n";
  43. #used pool
  44. $used_dhcp = get_count_records($db_link,'user_auth','deleted = 0 AND ip_int >= ? AND ip_int <= ?', [$row['dhcp_start'], $row['dhcp_stop']]);
  45. print "<td class=\"$cl\">".$used_dhcp."</td>\n";
  46. $free_dhcp = $dhcp_pool - $used_dhcp;
  47. print "<td class=\"$cl\">".$free_dhcp."</td>\n";
  48. $free_static = $free_all - $free_dhcp;
  49. print "<td class=\"$cl\">".$free_static."</td>\n";
  50. $zombi = get_count_records( $db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ? AND last_found <= ?', [ $row['ip_int_start'], $row['ip_int_stop'], $zombi_threshold]);
  51. print "<td class=\"$cl\">".$zombi."</td>\n";
  52. $zombi = get_count_records( $db_link, 'user_auth', 'deleted = 0 AND ip_int >= ? AND ip_int <= ? AND last_found <= ?', [ $row['dhcp_start'], $row['dhcp_stop'], $zombi_threshold]);
  53. print "<td class=\"$cl\">".$zombi."</td>\n";
  54. print "</tr>\n";
  55. }
  56. }
  57. ?>
  58. </table>
  59. <?php require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); ?>