source: trunk/Modules/Network/Subnet.php

Last change on this file was 912, checked in by chronos, 3 years ago
  • Modified: Updated Common package.
File size: 2.3 KB
Line 
1<?php
2
3class PageSubnet extends Page
4{
5 function __construct(System $System)
6 {
7 parent::__construct($System);
8 $this->Title = 'Podsítě';
9 $this->Description = 'Informace o podsítích';
10 $this->ParentClass = 'PageNetwork';
11 }
12
13 function Show(): string
14 {
15 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`');
16 $DbRow = $DbResult->fetch_row();
17 $PageList = GetPageList('Subnets', $DbRow[0]);
18
19 $Output = $PageList['Output'];
20 $Output .= '<table class="WideTable" style="font-size: small;">';
21
22 $TableColumns = array(
23 array('Name' => 'Name', 'Title' => 'Název'),
24 array('Name' => 'AddressRange', 'Title' => 'IP rozsah'),
25 array('Name' => 'DHCP', 'Title' => 'Adresa DHCP'),
26 array('Name' => 'Gateway', 'Title' => 'Výchozí brána'),
27 array('Name' => '', 'Title' => 'Max. adres'),
28 array('Name' => '', 'Title' => 'Registrovaných adres'),
29 array('Name' => '', 'Title' => 'Využití'),
30 array('Name' => 'SubjectName', 'Title' => 'Účastník'),
31 );
32 $Order = GetOrderTableHeader('Subnets', $TableColumns, 'AddressRange', 0);
33 $Output .= $Order['Output'];
34
35 $Query = 'SELECT NetworkSubnet.*, Subject.Name AS SubjectName FROM NetworkSubnet LEFT JOIN Member ON Member.Id = NetworkSubnet.Member LEFT JOIN Subject ON Subject.Id = Member.Subject '.$Order['SQL'].$PageList['SQLLimit'];
36
37 $DbResult = $this->Database->query($Query);
38 while ($Subnet = $DbResult->fetch_assoc())
39 {
40 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')');
41 $DbRow = $DbResult2->fetch_row();
42 $AddressCount = $DbRow[0];
43 $MaxAddressCount = $SubnetMask = pow(2, 32 - $Subnet['Mask']) - 2;
44
45 $Output .= '<tr><td>'.$Subnet['Name'].'</td>'.
46 '<td>'.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'</td>'.
47 '<td>'.$Subnet['DHCP'].'</td>'.
48 '<td>'.$Subnet['Gateway'].'</td>'.
49 '<td>'.$MaxAddressCount.'</td>'.
50 '<td>'.$AddressCount.'</td>'.
51 '<td>'.round($AddressCount / $MaxAddressCount * 100).'</td>'.
52 '<td>'.$Subnet['SubjectName'].'</td></tr>';
53 }
54 $Output .= '</table>';
55 $Output .= $PageList['Output'];
56 return $Output;
57 }
58}
Note: See TracBrowser for help on using the repository browser.