1
0

control-subnets-usage.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".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. ?>
  9. <div id="cont">
  10. <br>
  11. <form name="def" action="control-subnets.php" method="post">
  12. <b>Статистика использования сетей организации</b> <br>
  13. <table class="data">
  14. <tr align="center">
  15. <td><b>Сеть</b></td>
  16. <td><b>Всего<br>адресов</b></td>
  17. <td><b>Занято</b></td>
  18. <td><b>Свободно<br>(всего)</b></td>
  19. <td><b>Размер<br>dhcp пула</b></td>
  20. <td><b>Занято<br>в пуле</b></td>
  21. <td><b>Свободно<br>в пуле</b></td>
  22. <td><b>Свободно<br>(static)</b></td>
  23. <?php
  24. print "<td><b>Зомби, всего <br>(> $zombi_days дней)</b></td>";
  25. print "<td><b>Зомби dhcp<br>(> $zombi_days дней)</b></td>";
  26. ?>
  27. </tr>
  28. <?
  29. $t_subnets = get_records($db_link,'subnets','office=1 ORDER BY ip_int_start');
  30. if (!empty($t_subnets)) {
  31. foreach ( $t_subnets as $row ) {
  32. print "<tr align=center>\n";
  33. $cl="data";
  34. print "<td class=\"$cl\"><a href=/admin/iplist/index.php?ou=0&subnet=".$row['id'].">".$row['subnet']."</a></td>\n";
  35. $all_ips = $row['ip_int_stop']-$row['ip_int_start']-3;
  36. print "<td class=\"$cl\">".$all_ips."</td>\n";
  37. #used
  38. $used_all = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop']);
  39. print "<td class=\"$cl\">".$used_all."</td>\n";
  40. $free_all = $all_ips - $used_all;
  41. print "<td class=\"$cl\">".$free_all."</td>\n";
  42. $dhcp_pool = $row['dhcp_stop']-$row['dhcp_start']+1;
  43. print "<td class=\"$cl\">".$dhcp_pool."</td>\n";
  44. #used pool
  45. $used_dhcp = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop']);
  46. print "<td class=\"$cl\">".$used_dhcp."</td>\n";
  47. $free_dhcp = $dhcp_pool - $used_dhcp;
  48. print "<td class=\"$cl\">".$free_dhcp."</td>\n";
  49. $free_static = $free_all - $free_dhcp;
  50. print "<td class=\"$cl\">".$free_static."</td>\n";
  51. $zombi = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['ip_int_start'].' and ip_int<='.$row['ip_int_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
  52. print "<td class=\"$cl\">".$zombi."</td>\n";
  53. $zombi = get_count_records($db_link,'User_auth','deleted=0 and ip_int>='.$row['dhcp_start'].' and ip_int<='.$row['dhcp_stop'].' and last_found<=(NOW() - INTERVAL '.$zombi_days.' DAY)');
  54. print "<td class=\"$cl\">".$zombi."</td>\n";
  55. print "</tr>\n";
  56. }
  57. }
  58. ?>
  59. </table>
  60. </form>
  61. <?php
  62. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  63. ?>