source: trunk/Modules/Network/Network.php@ 894

Last change on this file since 894 was 894, checked in by chronos, 4 years ago
  • Modified: Further improved models initialization system.
File size: 49.5 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/NetworkModels.php');
4include_once(dirname(__FILE__).'/HostList.php');
5include_once(dirname(__FILE__).'/Subnet.php');
6include_once(dirname(__FILE__).'/Hosting.php');
7include_once(dirname(__FILE__).'/UserHosts.php');
8
9class PageFrequencyPlan extends Page
10{
11 function __construct(System $System)
12 {
13 parent::__construct($System);
14 $this->FullTitle = 'Výpis obsazení frekvenčních kanálů';
15 $this->ShortTitle = 'Frekvenční plán';
16 $this->ParentClass = 'PageNetwork';
17 }
18
19 function Show(): string
20 {
21 // http://en.wikipedia.org/wiki/List_of_WLAN_channels
22 //$ChannelList = array(2412 => 1, 2417 => 2, 2422 => 3, 2427 => 4, 2432 => 5, 2437 => 6, 2442 => 7, 2447 => 8, 2452 => 9, 2457 => 10, 2462 => 11, 2467 => 12, 2472 => 13, 5200 => 40, 5205 => 41, 5210 => 42, 5215 => 43, 5220 => 44, 5225 => 45, 5230 => 46, 5235 => 47, 5240 => 48, 5245 => 49, 5250 => 50, 5255 => 51, 5260 => 52, 5265 => 53, 5270 => 54, 5275 => 55, 5280 => 56, 5285 => 57, 5290 => 58, 5295 => 59, 5300 => 60, 5500 => 100, 5520 => 104, 5540 => 108, 5560 => 112, 5580 => 116, 5600 => 120, 5620 => 124, 5640 => 128, 5660 => 132, 5700 => 140, 5720 => 144);
23 $Output = '<div align="center">'.
24 '<a href="?section=obsazeni_wifi_kanalu&range=a">Pásmo 2,4 GHz (a)</a> '.
25 '<a href="?section=obsazeni_wifi_kanalu&amp;range=bc">Pásmo 5 GHz dolní (b, c)</a> '.
26 '<a href="?section=obsazeni_wifi_kanalu&amp;range=d">Pásmo 5 GHz horní (d)</a> '.
27 '<a href="http://www.ctu.cz/1/download/Opatreni%20obecne%20povahy/VO_R_12_08_2005_34.pdf">VO_R_12_08_2005_34</a><br/>'.
28 '<strong>Seznam známých AP a obsazení kmitočtových pásem:</strong></div>'.
29 '<table class="WideTable">'.
30 '<tr><th/><br/>SSID<br/><br/></th>';
31 $ChannelList = array();
32 if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
33 if ($_GET['range'] == 'a')
34 {
35 $Where = '(Frequency < 5000)';
36 for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
37 }
38 if ($_GET['range'] == 'bc')
39 {
40 $Where = '(Frequency >= 5000) AND (Frequency <= 5350)';
41 for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
42 }
43 if ($_GET['range'] == 'd')
44 {
45 $Where = '(Frequency >= 5470)';
46 for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
47 }
48
49 foreach ($ChannelList as $Frequency)
50 {
51 $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
52 }
53 $Output .= '</tr>';
54 $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`');
55 while ($DbRow = $DbResult->fetch_assoc())
56 {
57 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where);
58 while ($DbRow2 = $DbResult2->fetch_assoc())
59 {
60 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower'];
61 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper'];
62 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
63 foreach ($ChannelList as $Frequency)
64 {
65 if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';
66 else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';
67 else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';
68 else $Color = '#ffffff';
69 $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
70 }
71
72 $Output .= '</tr>';
73 }
74 }
75 $Output .= '</table>';
76 return $Output;
77 }
78}
79
80class PageNetwork extends Page
81{
82 function __construct(System $System)
83 {
84 parent::__construct($System);
85 $this->FullTitle = 'Technické informace o síti';
86 $this->ShortTitle = 'Síť';
87 $this->ParentClass = 'PagePortal';
88 }
89
90 function Show(): string
91 {
92 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowInfo'))
93 return 'Nemáte oprávnění';
94
95 $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />';
96 $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />';
97 $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />';
98 return $Output;
99 }
100}
101
102class ModuleNetwork extends AppModule
103{
104 public int $MinNotifyTime;
105
106 function __construct(System $System)
107 {
108 parent::__construct($System);
109 $this->Name = 'Network';
110 $this->Version = '1.0';
111 $this->Creator = 'Chronos';
112 $this->License = 'GNU/GPLv3';
113 $this->Description = 'Networking related tools';
114 $this->Dependencies = array('Notify', 'IS');
115
116 // TODO: Make notify time configurable
117 $this->MinNotifyTime = 30; // seconds
118 }
119
120 function GetModels(): array
121 {
122 return array(NetworkDomainAlias::GetClassName(), NetworkDevice::GetClassName(), NetworkDeviceType::GetClassName(),
123 NetworkDeviceLog::GetClassName(), NetworkInterface::GetClassName(), NetworkInterfaceType::GetClassName(),
124 NetworkSubnet::GetClassName(), NetworkPort::GetClassName(), NetworkSpeedLimit::GetClassName(),
125 NetworkInterfaceLatency::GetClassName(), NetworkLink::GetClassName(), NetworkLinkType::GetClassName(),
126 NetworkSignal::GetClassName(), NetworkAddressCategory::GetClassName(), NetworkDeviceConfig::GetClassName(),
127 NetworkDomain::GetClassName(), NetworkDomainServer::GetClassName(), NetworkDomainView::GetClassName(),
128 NetworkDomainItemFilter::GetClassName(), DeviceAPIType::GetClassName(), NetworkInterfaceWireless::GetClassName(),
129 NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName());
130 }
131
132 function DoStart(): void
133 {
134 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkReachability',
135 array($this, 'ReachabilityCheck'));
136 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkPort',
137 array($this, 'PortCheck'));
138
139 $this->System->RegisterPage(['network'], 'PageNetwork');
140 $this->System->RegisterPage(['network', 'administration'], 'PageNetworkAdministration');
141 $this->System->RegisterPage(['network', 'subnet'], 'PageSubnet');
142 $this->System->RegisterPage(['network', 'user-hosts'], 'PageNetworkHostList');
143 $this->System->RegisterPage(['network', 'hosting'],'PageHosting');
144 $this->System->RegisterPage(['network', 'hosts'], 'PageHostList');
145 $this->System->RegisterPage(['network', 'frequency-plan'], 'PageFrequencyPlan');
146
147 $this->System->RegisterCommandLine('networklog_import', 'Imports network logs from remote server', array($this, 'ImportNetworkLog'));
148
149 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
150 'Title' => 'Alias domény',
151 'Table' => 'NetworkDomainAlias',
152 'Items' => array(
153 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
154 'Target' => array('Type' => 'String', 'Caption' => 'Cíl', 'Default' => ''),
155 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
156 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Síťová doména', 'Default' => ''),
157 ),
158 ));
159 $this->System->FormManager->RegisterFormType('TNetworkDomainAliasListDomain', array(
160 'Type' => 'ManyToOne',
161 'Table' => 'NetworkDomainAlias',
162 'Id' => 'Id',
163 'Ref' => 'Domain',
164 'Filter' => '1',
165 ));
166 $this->System->FormManager->RegisterClass('NetworkDevice', array(
167 'Title' => 'Síťové zařízení',
168 'Table' => 'NetworkDevice',
169 'Items' => array(
170 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
171 'Type' => array('Type' => 'TNetworkDeviceType', 'Caption' => 'Typ', 'Default' => '0'),
172 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '0'),
173 'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '0'),
174 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true),
175 'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '1'),
176 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
177 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
178 'PermanentOnline' => array('Type' => 'Boolean', 'Caption' => 'Běží stále', 'Default' => '0'),
179 'Interfaces' => array('Type' => 'TInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''),
180 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '0', 'Null' => true),
181 'Product' => array('Type' => 'TProduct', 'Caption' => 'Produkt', 'Default' => '', 'Null' => true),
182 'LoginName' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => '', 'Null' => true, 'NotInList' => true),
183 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => '', 'Null' => true, 'NotInList' => true),
184 'API' => array('Type' => 'TDeviceAPIType', 'Caption' => 'API', 'Default' => '', 'Null' => true),
185 'Logs' => array('Type' => 'TDeviceLogList', 'Caption' => 'Záznamy', 'Default' => ''),
186 ),
187 'AfterInsert' => array($this, 'AfterInsertNetworkDevice'),
188 'AfterModify' => array($this, 'AfterModifyNetworkDevice'),
189 'AfterDelete' => array($this, 'AfterModifyNetworkDevice'),
190 ));
191 $this->System->FormManager->RegisterClass('NetworkDeviceType', array(
192 'Title' => 'Typ síťového zařízení',
193 'Table' => 'NetworkDeviceType',
194 'Items' => array(
195 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
196 'ShowOnline' => array('Type' => 'Boolean', 'Caption' => 'Ukázat online', 'Default' => '0'),
197 'IconName' => array('Type' => 'String', 'Caption' => 'Jméno ikony', 'Default' => '0'),
198 'Devices' => array('Type' => 'TNetworkDeviceListType', 'Caption' => 'Síťová zařízení', 'Default' => ''),
199 ),
200 ));
201 $this->System->FormManager->RegisterFormType('TNetworkDeviceListType', array(
202 'Type' => 'ManyToOne',
203 'Table' => 'NetworkDevice',
204 'Id' => 'Id',
205 'Ref' => 'Type',
206 'Filter' => '1',
207 ));
208 $this->System->FormManager->RegisterClass('NetworkDeviceLog', array(
209 'Title' => 'Zprávy zařízení',
210 'Table' => 'NetworkDeviceLog',
211 'DefaultSortColumn' => 'Time',
212 'DefaultSortOrder' => 1,
213 'Items' => array(
214 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
215 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
216 'Message' => array('Type' => 'String', 'Caption' => 'Zpáva', 'Default' => ''),
217 'Tags' => array('Type' => 'String', 'Caption' => 'Značky', 'Default' => ''),
218 ),
219 ));
220 $this->System->FormManager->RegisterClass('NetworkInterface', array(
221 'Title' => 'Síťové rozhraní',
222 'Table' => 'NetworkInterface',
223 'Items' => array(
224 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
225 'Type' => array('Type' => 'TNetworkInterfaceType', 'Caption' => 'Typ', 'Default' => '0'),
226 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
227 'LocalIP' => array('Type' => 'IPv4Address', 'Caption' => 'IPv4', 'Default' => '', 'Null' => true),
228 'IPv6' => array('Type' => 'IPv6Address', 'Caption' => 'IPv6', 'Default' => '', 'Null' => true),
229 'ExternalIP' => array('Type' => 'IPv4Address', 'Caption' => 'Veřejná IPv4', 'Default' => '', 'Null' => true),
230 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
231 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '1'),
232 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
233 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
234 'Links' => array('Type' => 'TNetworkLinkListInterface', 'Caption' => 'Propojení', 'Default' => ''),
235 'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
236 'Signal' => array('Type' => 'TNetworkSignalListInterface', 'Caption' => 'Signál', 'Default' => ''),
237 'Wireless' => array('Type' => 'TNetworkInterfaceWirelessListInterface', 'Caption' => 'Bezdrátové spoje', 'Default' => ''),
238 'Ports' => array('Type' => 'TDevicePortListInterface', 'Caption' => 'Síťové porty', 'Default' => ''),
239 'Latency' => array('Type' => 'TDeviceInterfaceLatencyListInterface', 'Caption' => 'Síťová odezva', 'Default' => ''),
240 ),
241 'AfterInsert' => array($this, 'AfterInsertNetworkInterface'),
242 'AfterModify' => array($this, 'AfterModifyNetworkInterface'),
243 'BeforeDelete' => array($this, 'BeforeDeleteNetworkInterface'),
244 'AfterDelete' => array($this, 'AfterModifyNetworkInterface'),
245 ));
246 $this->System->FormManager->RegisterClass('NetworkInterfaceType', array(
247 'Title' => 'Typ síťového rozhraní',
248 'Table' => 'NetworkInterfaceType',
249 'Items' => array(
250 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
251 'MaxSpeed' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost', 'Default' => '0', 'Suffix' => 'Mbit/s'),
252 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'),
253 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'),
254 ),
255 ));
256 $this->System->FormManager->RegisterClass('NetworkSubnet', array(
257 'Title' => 'Podsítě',
258 'DefaultSortColumn' => 'Name',
259 'Table' => 'NetworkSubnet',
260 'Items' => array(
261 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
262 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
263 'Mask' => array('Type' => 'Integer', 'Caption' => 'Prefix', 'Default' => ''),
264 'DHCP' => array('Type' => 'IPv4Address', 'Caption' => 'DHCP', 'Default' => ''),
265 'Gateway' => array('Type' => 'IPv4Address', 'Caption' => 'Brána', 'Default' => ''),
266 'WINS' => array('Type' => 'IPv4Address', 'Caption' => 'WINS', 'Default' => ''),
267 'DNS' => array('Type' => 'String', 'Caption' => 'DNS', 'Default' => ''),
268 'Domain' => array('Type' => 'String', 'Caption' => 'Doména', 'Default' => ''),
269 'NTP' => array('Type' => 'String', 'Caption' => 'NTP', 'Default' => ''),
270 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'Null' => true),
271 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true),
272 'ExtAddressRange' => array('Type' => 'String', 'Caption' => 'Vnější rozsah adres', 'Default' => ''),
273 'ExtMask' => array('Type' => 'String', 'Caption' => 'Vnější prefix', 'Default' => ''),
274 'AddressRangeIPv6' => array('Type' => 'String', 'Caption' => 'Rozsah adres IPv6', 'Default' => ''),
275 'MaskIPv6' => array('Type' => 'Integer', 'Caption' => 'Prefix IPv6', 'Default' => ''),
276 'Configure' => array('Type' => 'Boolean', 'Caption' => 'Nastavovat', 'Default' => ''),
277 'Interfaces' => array('Type' => 'TNetworkSubnetInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''),
278 ),
279 ));
280 $this->System->FormManager->RegisterFormType('TNetworkSubnetInterfaceList', array(
281 'Type' => 'ManyToOne',
282 'Table' => 'NetworkInterface',
283 'Id' => 'Id',
284 'Ref' => null,
285 'Filter' => '(`TX`.`LocalIP` != "") AND CompareNetworkPrefix(INET_ATON(`TX`.`LocalIP`), INET_ATON((SELECT `NetworkSubnet`.`AddressRange` FROM `NetworkSubnet` WHERE `NetworkSubnet`.`Id`=#Id)), '.
286 '(SELECT `NetworkSubnet`.`Mask` FROM `NetworkSubnet` WHERE `NetworkSubnet`.`Id`=#Id))',
287 ));
288 $this->System->FormManager->RegisterClass('NetworkPort', array(
289 'Title' => 'Síťový port',
290 'Table' => 'NetworkPort',
291 'Items' => array(
292 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
293 'Protocol' => array('Type' => 'TNetworkProtocol', 'Caption' => 'Protokol', 'Default' => '0'),
294 'Number' => array('Type' => 'Integer', 'Caption' => 'Číslo', 'Default' => ''),
295 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
296 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '1'),
297 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
298 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
299 'UpDown' => array('Type' => 'TNetworkPortUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
300 ),
301 ));
302 $this->System->FormManager->RegisterClass('NetworkSpeedLimit', array(
303 'Title' => 'Omezení přenosové rychlosti',
304 'Table' => 'NetworkSpeedLimit',
305 'Items' => array(
306 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
307 'SpeedMaxOut' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost odesílání', 'Default' => '0', 'Suffix' => 'bits/s'),
308 'SpeedMaxIn' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost přijímání', 'Default' => 0, 'Suffix' => 'bits/s'),
309 'Parent' => array('Type' => 'TNetworkSpeedLimit', 'Caption' => 'Rodič', 'Default' => '', 'Null' => true),
310 'Items' => array('Type' => 'TNetworkSpeedLimitListParent', 'Caption' => 'Položky'),
311 'CustomerServices' => array('Type' => 'TServiceCustomerRelListSpeedLimit', 'Caption' => 'Služby zákazníka'),
312 ),
313 ));
314 $this->System->FormManager->RegisterFormType('TNetworkSpeedLimit', array(
315 'Type' => 'Reference',
316 'Table' => 'NetworkSpeedLimit',
317 'Id' => 'Id',
318 'Name' => 'Name',
319 'Filter' => '1',
320 ));
321 $this->System->FormManager->RegisterFormType('TNetworkSpeedLimitListParent', array(
322 'Type' => 'ManyToOne',
323 'Table' => 'NetworkSpeedLimit',
324 'Id' => 'Id',
325 'Ref' => 'Parent',
326 'Filter' => '1',
327 ));
328 $this->System->FormManager->RegisterFormType('TServiceCustomerRelListSpeedLimit', array(
329 'Type' => 'ManyToOne',
330 'Table' => 'ServiceCustomerRel',
331 'Id' => 'Id',
332 'Ref' => 'SpeedLimit',
333 'Filter' => '1',
334 ));
335 $this->System->FormManager->RegisterClass('NetworkInterfaceLatency', array(
336 'Title' => 'Síťová odezva',
337 'Table' => 'NetworkInterfaceLatency',
338 'DefaultSortColumn' => 'Time',
339 'DefaultSortOrder' => 1,
340 'Items' => array(
341 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
342 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
343 'Value' => array('Type' => 'Float', 'Caption' => 'Hodnota', 'Default' => '0', 'Suffix' => 'ms'),
344 ),
345 ));
346 $this->System->FormManager->RegisterClass('NetworkLink', array(
347 'Title' => 'Síťové propojení',
348 'Table' => 'NetworkLink',
349 'Items' => array(
350 'Type' => array('Type' => 'TNetworkLinkType', 'Caption' => 'Typ', 'Default' => '1'),
351 'Interface1' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => ''),
352 'Interface2' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => ''),
353 ),
354 ));
355 $this->System->FormManager->RegisterClass('NetworkLinkUnion', array(
356 'Title' => 'Síťové propojení',
357 'BaseTable' => 'NetworkLink',
358 'SQL' => '(SELECT `Id`, `Type`, `Interface1` AS `Interface`, `Interface2` AS `InterfaceOther` FROM `NetworkLink`) '.
359 'UNION (SELECT `Id`, `Type`, `Interface2` AS `Interface`, `Interface1` AS `InterfaceOther` FROM `NetworkLink`)',
360 'Items' => array(
361 'Type' => array('Type' => 'TNetworkLinkType', 'Caption' => 'Typ', 'Default' => '1', 'ReadOnly' => true),
362 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => '', 'ReadOnly' => true),
363 'InterfaceOther' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => '', 'ReadOnly' => true),
364 ),
365 ));
366
367 $this->System->FormManager->RegisterClass('NetworkLinkType', array(
368 'Title' => 'Typ síťového propojení',
369 'Table' => 'NetworkLinkType',
370 'Items' => array(
371 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
372 'MaxLinkSpeed' => array('Type' => 'Integer', 'Caption' => 'Maximální spojová rychlost', 'Default' => '0', 'Suffix' => 'bits/s'),
373 'MaxRealSpeed' => array('Type' => 'Integer', 'Caption' => 'Maximální reálná rychlost', 'Default' => '0', 'Suffix' => 'bits/s'),
374 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'),
375 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'),
376 ),
377 ));
378 $this->System->FormManager->RegisterClass('NetworkSignal', array(
379 'Title' => 'Signál rozhraní',
380 'Table' => 'NetworkSignal',
381 'DefaultSortColumn' => 'Time',
382 'DefaultSortOrder' => 1,
383 'Items' => array(
384 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
385 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
386 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true),
387 'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0', 'Suffix' => 'dBm'),
388 'RateRx' => array('Type' => 'Integer', 'Caption' => 'Rychlost Rx', 'Default' => '0', 'Suffix' => 'MHz'),
389 'RateTx' => array('Type' => 'Integer', 'Caption' => 'Rychlost Tx', 'Default' => '0', 'Suffix' => 'MHz'),
390 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Měřeno z', 'Default' => '0'),
391 ),
392 ));
393 $this->System->FormManager->RegisterClass('NetworkAddressCategory', array(
394 'Title' => 'Kategorie síťové adresy',
395 'Table' => 'NetworkAddressCategory',
396 'DefaultSortColumn' => 'Name',
397 'DefaultSortOrder' => 1,
398 'Items' => array(
399 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
400 ),
401 ));
402 $this->System->FormManager->RegisterFormType('TNetworkAddressCategory', array(
403 'Type' => 'Reference',
404 'Table' => 'NetworkAddressCategory',
405 'Id' => 'Id',
406 'Name' => 'Name',
407 'Filter' => '1',
408 ));
409 $this->System->FormManager->RegisterClass('NetworkDeviceConfig', array(
410 'Title' => 'Nastavení zařízení',
411 'Table' => 'NetworkDeviceConfig',
412 'DefaultSortColumn' => 'Time',
413 'DefaultSortOrder' => 1,
414 'Items' => array(
415 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
416 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
417 'ConfigFull' => array('Type' => 'Text', 'Caption' => 'Kompletní nastavení', 'Default' => ''),
418 'ConfigCompact' => array('Type' => 'Text', 'Caption' => 'Rozdílové nastavení', 'Default' => ''),
419 ),
420 ));
421 $this->System->FormManager->RegisterClass('NetworkDomain', array(
422 'Title' => 'Síťová doména',
423 'Table' => 'NetworkDomain',
424 'DefaultSortColumn' => 'Name',
425 'DefaultSortOrder' => 1,
426 'Items' => array(
427 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
428 'Parent' => array('Type' => 'TNetworkDomain', 'Caption' => 'Nadřazená doména', 'Default' => '', 'Null' => true),
429 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
430 'Serial' => array('Type' => 'Integer', 'Caption' => 'Sériové číslo', 'Default' => '1'),
431 'Minimum' => array('Type' => 'Integer', 'Caption' => 'Minimum', 'Default' => '10800'),
432 'Retry' => array('Type' => 'Integer', 'Caption' => 'Opakování', 'Default' => '7200'),
433 'Expire' => array('Type' => 'Integer', 'Caption' => 'Čas vypršení', 'Default' => '2419200'),
434 'Refresh' => array('Type' => 'Integer', 'Caption' => 'Obnovení', 'Default' => '28800'),
435 'TTL' => array('Type' => 'Integer', 'Caption' => 'TTL', 'Default' => '86400', 'Suffix' => 'sekund'),
436 'Servers' => array('Type' => 'TNetworkDomainServerList', 'Caption' => 'Servery', 'Default' => ''),
437 'Views' => array('Type' => 'TNetworkDomainViewListDomain', 'Caption' => 'Pohledy', 'Default' => ''),
438 'ItemFilters' => array('Type' => 'TNetworkDomainItemFilterListDomain', 'Caption' => 'Filtry položek', 'Default' => ''),
439 'Aliases' => array('Type' => 'TNetworkDomainAliasListDomain', 'Caption' => 'Aliasy', 'Default' => ''),
440 ),
441 ));
442 $this->System->FormManager->RegisterFormType('TNetworkDomain', array(
443 'Type' => 'Reference',
444 'Table' => 'NetworkDomain',
445 'Id' => 'Id',
446 'Name' => 'Name',
447 'Filter' => '1',
448 ));
449 $this->System->FormManager->RegisterClass('NetworkDomainServer', array(
450 'Title' => 'Doménový server',
451 'Table' => 'NetworkDomainServer',
452 'DefaultSortColumn' => 'Address',
453 'DefaultSortOrder' => 1,
454 'Items' => array(
455 'Address' => array('Type' => 'String', 'Caption' => 'Adresa', 'Default' => ''),
456 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Doména', 'Default' => ''),
457 'Sequence' => array('Type' => 'Integer', 'Caption' => 'Pořadí', 'Default' => '1'),
458 ),
459 ));
460 $this->System->FormManager->RegisterFormType('TNetworkDomainServerList', array(
461 'Type' => 'ManyToOne',
462 'Table' => 'NetworkDomainServer',
463 'Id' => 'Id',
464 'Ref' => 'Domain',
465 'Filter' => '1',
466 ));
467 $this->System->FormManager->RegisterClass('NetworkDomainView', array(
468 'Title' => 'Pohled síťové domény',
469 'Table' => 'NetworkDomainView',
470 'DefaultSortColumn' => 'Name',
471 'DefaultSortOrder' => 1,
472 'Items' => array(
473 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
474 'SysName' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
475 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Doména', 'Default' => ''),
476 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
477 'ItemFilters' => array('Type' => 'TNetworkDomainItemFilterListView', 'Caption' => 'Filtry položek', 'Default' => ''),
478 ),
479 ));
480 $this->System->FormManager->RegisterFormType('TNetworkDomainView', array(
481 'Type' => 'Reference',
482 'Table' => 'NetworkDomainView',
483 'Id' => 'Id',
484 'Name' => 'Name',
485 'Filter' => '1',
486 ));
487 $this->System->FormManager->RegisterFormType('TNetworkDomainViewListDomain', array(
488 'Type' => 'ManyToOne',
489 'Table' => 'NetworkDomainView',
490 'Id' => 'Id',
491 'Ref' => 'Domain',
492 'Filter' => '1',
493 ));
494 $this->System->FormManager->RegisterClass('NetworkDomainItemFilter', array(
495 'Title' => 'Filtr doménových položek',
496 'Table' => 'NetworkDomainItemFilter',
497 'DefaultSortColumn' => 'Name',
498 'DefaultSortOrder' => 1,
499 'Items' => array(
500 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
501 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Domén', 'Default' => ''),
502 'AddressCategory' => array('Type' => 'TNetworkAddressCategory', 'Caption' => 'Kategorie adresy', 'Default' => ''),
503 'Suffix' => array('Type' => 'String', 'Caption' => 'Přípona jména položek', 'Default' => ''),
504 'View' => array('Type' => 'TNetworkDomainView', 'Caption' => 'Pohled', 'Default' => ''),
505 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
506 ),
507 ));
508 $this->System->FormManager->RegisterFormType('TNetworkDomainItemFilterListDomain', array(
509 'Type' => 'ManyToOne',
510 'Table' => 'NetworkDomainItemFilter',
511 'Id' => 'Id',
512 'Ref' => 'Domain',
513 'Filter' => '1',
514 ));
515 $this->System->FormManager->RegisterFormType('TNetworkDomainItemFilterListView', array(
516 'Type' => 'ManyToOne',
517 'Table' => 'NetworkDomainItemFilter',
518 'Id' => 'Id',
519 'Ref' => 'View',
520 'Filter' => '1',
521 ));
522 $this->System->FormManager->RegisterClass('DeviceAPIType', array(
523 'Title' => 'Typ API zařízení',
524 'Table' => 'DeviceAPIType',
525 'Items' => array(
526 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
527 'Devices' => array('Type' => 'TDeviceListAPI', 'Caption' => 'Zařízení', 'Default' => ''),
528 ),
529 ));
530 $this->System->FormManager->RegisterClass('NetworkInterfaceWireless', array(
531 'Title' => 'Bezdrátová rozhraní',
532 'Table' => 'NetworkInterfaceWireless',
533 'Items' => array(
534 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
535 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
536 'NetworkInterface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
537 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
538 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
539 'Antenna' => array('Type' => 'TProduct', 'Caption' => 'Anténa', 'Default' => '', 'Null' => true),
540 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
541 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
542 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
543 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
544 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
545 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
546 'Mode' => array('Type'
547 => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
548 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
549 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
550 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
551 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
552 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
553 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
554 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
555 ),
556 'Actions' => array(
557 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
558 ),
559 ));
560 $this->System->FormManager->RegisterClass('NetworkInterfaceWirelessCTU', array(
561 'Title' => 'Bezdrátová rozhraní pro ČTÚ',
562 'Table' => 'NetworkInterfaceWireless',
563 'Items' => array(
564 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
565 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
566 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
567 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
568 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
569 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
570 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
571 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
572 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
573 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šířka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
574 'Mode' => array('Type' => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
575 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
576 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
577 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
578 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
579 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
580 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
581 'Position' => array('Type' => 'String', 'Caption' => 'GPS poloha', 'Default' => '',
582 'SQL' => '(SELECT MapPosition.Pos FROM MapPosition WHERE MapPosition.Id=(SELECT MapPosition FROM NetworkDevice WHERE NetworkDevice.Id=(SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id=NetworkInterface)))'),
583 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
584 ),
585 'Actions' => array(
586 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
587 ),
588 ));
589 $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array(
590 'Title' => 'Změny stavu rozhraní',
591 'Table' => 'NetworkInterfaceUpDown',
592 'DefaultSortColumn' => 'Time',
593 'DefaultSortOrder' => 1,
594 'Items' => array(
595 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
596 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),
597 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
598 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
599 ),
600 ));
601 $this->System->FormManager->RegisterClass('NetworkPortUpDown', array(
602 'Title' => 'Změny stavu portů',
603 'Table' => 'NetworkPortUpDown',
604 'DefaultSortColumn' => 'Time',
605 'DefaultSortOrder' => 1,
606 'Items' => array(
607 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
608 'Port' => array('Type' => 'TNetworkPort', 'Caption' => 'Port', 'Default' => '', 'ReadOnly' => true),
609 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
610 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
611 ),
612 ));
613 $this->System->FormManager->RegisterFormType('TNetworkProtocol', array(
614 'Type' => 'Enumeration',
615 'States' => array('TCP', 'UDP'),
616 ));
617 $this->System->FormManager->RegisterFormType('TNetworkDevice', array(
618 'Type' => 'Reference',
619 'Table' => 'NetworkDevice',
620 'Id' => 'Id',
621 'Name' => 'Name',
622 'Filter' => '1',
623 ));
624 $this->System->FormManager->RegisterFormType('TNetworkDeviceType', array(
625 'Type' => 'Reference',
626 'Table' => 'NetworkDeviceType',
627 'Id' => 'Id',
628 'Name' => 'Name',
629 'Filter' => '1',
630 ));
631 $this->System->FormManager->RegisterFormType('TNetworkInterface', array(
632 'Type' => 'Reference',
633 'Table' => 'NetworkInterface',
634 'View' => '(SELECT NetworkInterface.*, CONCAT_WS("-", NetworkDevice.Name, NULLIF(NetworkInterface.Name, "")) AS DeviceName FROM NetworkInterface '.
635 'LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device) AS T',
636 'Id' => 'Id',
637 'Name' => 'DeviceName',
638 'Filter' => '1',
639 ));
640 $this->System->FormManager->RegisterFormType('TNetworkPort', array(
641 'Type' => 'Reference',
642 'Table' => 'NetworkPort',
643 'View' => '(SELECT `NetworkPort`.*, CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`) AS `PortName` FROM `NetworkPort` '.
644 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkPort`.`Interface` '.
645 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device`) AS `T`',
646 'Id' => 'Id',
647 'Name' => 'PortName',
648 'Filter' => '1',
649 ));
650 $this->System->FormManager->RegisterFormType('TNetworkInterfaceType', array(
651 'Type' => 'Reference',
652 'Table' => 'NetworkInterfaceType',
653 'Id' => 'Id',
654 'Name' => 'Name',
655 'Filter' => '1',
656 ));
657 $this->System->FormManager->RegisterFormType('TDeviceList', array(
658 'Type' => 'ManyToOne',
659 'Table' => 'NetworkDevice',
660 'Id' => 'Id',
661 'Ref' => 'Member',
662 'Filter' => '1',
663 ));
664 $this->System->FormManager->RegisterFormType('TDeviceListAPI', array(
665 'Type' => 'ManyToOne',
666 'Table' => 'NetworkDevice',
667 'Id' => 'Id',
668 'Ref' => 'API',
669 'Filter' => '1',
670 ));
671 $this->System->FormManager->RegisterFormType('TDevicePortListInterface', array(
672 'Type' => 'ManyToOne',
673 'Table' => 'NetworkPort',
674 'Id' => 'Id',
675 'Ref' => 'Interface',
676 'Filter' => '1',
677 ));
678 $this->System->FormManager->RegisterFormType('TDeviceInterfaceLatencyListInterface', array(
679 'Type' => 'ManyToOne',
680 'Table' => 'NetworkInterfaceLatency',
681 'Id' => 'Id',
682 'Ref' => 'Interface',
683 'Filter' => '1',
684 ));
685 $this->System->FormManager->RegisterFormType('TNetworkLinkType', array(
686 'Type' => 'Reference',
687 'Table' => 'NetworkLinkType',
688 'Id' => 'Id',
689 'Name' => 'Name',
690 'Filter' => '1',
691 ));
692 $this->System->FormManager->RegisterFormType('TDeviceAPIType', array(
693 'Type' => 'Reference',
694 'Table' => 'DeviceAPIType',
695 'Id' => 'Id',
696 'Name' => 'Name',
697 'Filter' => '1',
698 ));
699 $this->System->FormManager->RegisterFormType('TNetworkInterfaceWirelessListInterface', array(
700 'Type' => 'ManyToOne',
701 'Table' => 'NetworkInterfaceWireless',
702 'Id' => 'Id',
703 'Ref' => 'NetworkInterface',
704 'Filter' => '1',
705 ));
706 $this->System->FormManager->RegisterFormType('TInterfaceList', array(
707 'Type' => 'ManyToOne',
708 'Table' => 'NetworkInterface',
709 'Id' => 'Id',
710 'Ref' => 'Device',
711 'Filter' => '1',
712 ));
713 $this->System->FormManager->RegisterFormType('TDeviceLogList', array(
714 'Type' => 'ManyToOne',
715 'Table' => 'NetworkDeviceLog',
716 'Id' => 'Id',
717 'Ref' => 'Device',
718 'Filter' => '1',
719 ));
720 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface', array(
721 'Type' => 'ManyToOne',
722 'Table' => 'NetworkLinkUnion',
723 'Id' => 'Id',
724 'Ref' => 'Interface',
725 'Filter' => '1',
726 ));
727 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface1', array(
728 'Type' => 'ManyToOne',
729 'Table' => 'NetworkLink',
730 'Id' => 'Id',
731 'Ref' => 'Interface1',
732 'Filter' => '1',
733 ));
734 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface2', array(
735 'Type' => 'ManyToOne',
736 'Table' => 'NetworkLink',
737 'Id' => 'Id',
738 'Ref' => 'Interface2',
739 'Filter' => '1',
740 ));
741 $this->System->FormManager->RegisterFormType('TNetworkInterfaceUpDown', array(
742 'Type' => 'ManyToOne',
743 'Table' => 'NetworkInterfaceUpDown',
744 'Id' => 'Id',
745 'Ref' => 'Interface',
746 'Filter' => '1',
747 ));
748 $this->System->FormManager->RegisterFormType('TNetworkPortUpDown', array(
749 'Type' => 'ManyToOne',
750 'Table' => 'NetworkPortUpDown',
751 'Id' => 'Id',
752 'Ref' => 'Port',
753 'Filter' => '1',
754 ));
755
756 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Network',
757 array($this, 'ShowDashboardItem'));
758
759 $this->System->RegisterModel('NetworkDevice', array(
760 'Title' => 'Síťové zařízení',
761 ));
762 $this->System->RegisterModel('NetworkInterface', array(
763 'Title' => 'Síťové rozhraní',
764 ));
765 }
766
767 function AfterInsertNetworkDevice(Form $Form): void
768 {
769 $this->System->Models['NetworkDevice']->DoOnChange();
770 }
771
772 function AfterModifyNetworkDevice(Form $Form, string $Id): void
773 {
774 $this->System->Models['NetworkDevice']->DoOnChange();
775 }
776
777 function AfterInsertNetworkInterface(Form $Form): void
778 {
779 $this->System->Models['NetworkInterface']->DoOnChange();
780 }
781
782 function AfterModifyNetworkInterface(Form $Form, string $Id): void
783 {
784 $this->System->Models['NetworkInterface']->DoOnChange();
785 }
786
787 function BeforeDeleteNetworkInterface(Form $Form, string $Id): void
788 {
789 $this->Database->query('DELETE FROM `NetworkInterfaceUpDown` WHERE `Interface`='.$Id);
790 $this->Database->query('DELETE FROM `NetworkLink` WHERE `Interface1`='.$Id.' OR `Interface2`='.$Id);
791 $this->Database->query('DELETE FROM `NetworkPort` WHERE `Interface`='.$Id);
792 $this->Database->query('DELETE FROM `NetworkSignal` WHERE `Interface`='.$Id);
793 $this->Database->query('DELETE FROM `NetworkInterfaceWireless` WHERE `NetworkInterface`='.$Id);
794 $this->Database->query('DELETE FROM `NetworkInterfaceLatency` WHERE `Interface`='.$Id);
795 }
796
797 function ImportNetworkLog(array $Parameters): void
798 {
799 global $Config;
800
801 $StartTime = time();
802
803 $DbResult = $this->System->Database->select('NetworkDeviceLog', 'Time',
804 '1 ORDER BY Time DESC LIMIT 1');
805 if ($DbResult->num_rows > 0)
806 {
807 $DbRow = $DbResult->fetch_assoc();
808 $WhereTime = ' AND (`Time` > "'.$DbRow['Time'].'")';
809 } else $WhereTime = '';
810
811 $RemoteDb = new Database();
812 $RemoteDb->Connect($Config['NetworkLog']['Host'], $Config['NetworkLog']['User'],
813 $Config['NetworkLog']['Password'], $Config['NetworkLog']['Database']);
814 $DbResult = $RemoteDb->select('SystemEvents', '*', '`ReceivedAt`>"'. TimeToMysqlDate($StartTime).'"'.$WhereTime.' ORDER BY `Time` DESC');
815 while ($DbRow = $DbResult->fetch_array())
816 {
817 $DbResult2 = $this->System->Database->select('NetworkInterface', 'Device, CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ".") AS `Name` ', '`Name` LIKE "'.$DbRow['FromHost'].'"');
818 if ($DbResult2->num_rows > 0)
819 {
820 $DbRow2 = $DbResult2->fetch_assoc();
821 $DeviceId = $DbRow2['Device'];
822 $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'],
823 'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag']));
824 } else echo('Host '.$DbRow['Host'].' not paired with network device.'."\n");
825 }
826 }
827
828 function ShowDashboardItem(): string
829 {
830 $Output = '';
831 $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
832 $DbRow = $DbResult->fetch_row();
833 $Output .= 'Síťových zařízení: registrovaných:'.$DbRow['0'];
834
835 $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '`Used`=1');
836 $DbRow = $DbResult->fetch_row();
837 $Output .= ' použitých:'.$DbRow['0'].'<br>';
838
839 $DbResult = $this->Database->select('NetworkInterface', 'COUNT(*)', '1');
840 $DbRow = $DbResult->fetch_row();
841 $Output .= 'Síťových rozhraní: '.$DbRow['0'].'<br>';
842
843 $DbResult = $this->Database->select('NetworkSubnet', 'COUNT(*)', '1');
844 $DbRow = $DbResult->fetch_row();
845 $Output .= 'Síťových podsítí: '.$DbRow['0'].'<br/>';
846 return $Output;
847 }
848
849 function OnlineList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array
850 {
851 $Time = time();
852 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
853 $Output = '';
854 $Condition = 'WHERE (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
855 echo($OnlineNow);
856 if ($OnlineNow >= 0) $Condition .= ' AND (`NetworkInterface`.`Online` = '.$OnlineNow.')';
857 echo($OnlinePrevious);
858 if ($OnlinePrevious >= 0) $Condition .= ' AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.')';
859 echo($Condition."\n");
860 $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
861 '`NetworkInterface`.`Online`, `NetworkInterface`.`LastOnline` FROM `NetworkInterface` '.
862 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
863 $Condition.' AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) AND '.
864 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'.
865 'ORDER BY `Name` ASC');
866 if ($DbResult3->num_rows > 0)
867 {
868 $Output .= $Title.'<br/>';
869 $Output .= '<table>'.
870 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n";
871 while ($Item = $DbResult3->fetch_assoc())
872 {
873 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
874 $DurationText = sprintf('%02d', floor($Duration / 3600 % 24)).':'.
875 sprintf('%02d', floor($Duration / 60 % 60)).':'.
876 sprintf('%02d', floor($Duration % 60));
877 $Days = floor($Duration / (60 * 60 * 24));
878 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
879
880 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
881 '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n";
882 }
883 $Output .= '</table><br/>'."\n";
884 }
885 $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '.
886 $Condition);
887 return array('Report' => $Output, 'Count' => $DbResult3->num_rows);
888 }
889
890 function ReachabilityCheck(): array
891 {
892 $NewOnline = $this->OnlineList('Nově online', 1, 0, 0);
893 $Output = $NewOnline['Report'];
894 $NewOffline = $this->OnlineList('Nově offline', 0, 1, $this->MinNotifyTime);
895 $Output .= $NewOffline['Report'];
896 $StillOffline = $this->OnlineList('Stále offline', 0, 0, 0);
897 $Output .= $StillOffline['Report'];
898 $Offline = $this->OnlineList('Offline', 0, -1, 0);
899 return array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva');
900 }
901
902 function PortCheckList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array
903 {
904 $Time = time();
905 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
906 $Output = '';
907 $Condition = 'WHERE (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
908 if ($OnlineNow >= null) $Condition .= ' AND (`NetworkPort`.`Online` = '.$OnlineNow.')';
909 if ($OnlinePrevious >= null) $Condition .= ' AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.')';
910 $DbResult3 = $this->Database->query('SELECT CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`, "(", `NetworkPort`.`Name`, ")") AS `Name`, '.
911 '`NetworkPort`.`Online`, `NetworkPort`.`LastOnline` FROM `NetworkPort` '.
912 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkPort`.`Interface` '.
913 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
914 $Condition.' AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) AND '.
915 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkPort`.`Enabled` = 1)'.
916 'ORDER BY `Name` ASC');
917 if ($DbResult3->num_rows > 0)
918 {
919 $Output .= $Title.'<br/>';
920 $Output .= '<table>'.
921 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n";
922 while ($Item = $DbResult3->fetch_assoc())
923 {
924 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
925 $DurationText = sprintf('%02d', floor($Duration / 3600 % 24)).':'.
926 sprintf('%02d', floor($Duration / 60 % 60)).':'.
927 sprintf('%02d', floor($Duration % 60));
928 $Days = floor($Duration / (60 * 60 * 24));
929 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
930
931 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
932 '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n";
933 }
934 $Output .= '</table><br/>'."\n";
935 }
936 $this->Database->query('UPDATE `NetworkPort` SET `OnlineNotify` = `Online` '.
937 $Condition);
938 return array('Report' => $Output, 'Count' => $DbResult3->num_rows);
939 }
940
941 function PortCheck(): array
942 {
943 $Output = '';
944 $NewOnline = $this->PortCheckList('Nově online', 1, 0, 0);
945 $Output .= $NewOnline['Report'];
946 $NewOffline = $this->PortCheckList('Nově offline', 0, 1, $this->MinNotifyTime);
947 $Output .= $NewOffline['Report'];
948 $StillOffline = $this->PortCheckList('Stále offline', 0, 0, 0);
949 $Output .= $StillOffline['Report'];
950 $Offline = $this->PortCheckList('Offline', 0, -1, 0);
951 return array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port');
952 }
953}
Note: See TracBrowser for help on using the repository browser.