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

Last change on this file since 819 was 819, checked in by chronos, 9 years ago
  • Fixed: Checking network port states.
  • Modified: Check only state of enabled interfaces.
File size: 40.1 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/HostList.php');
4include_once(dirname(__FILE__).'/Subnet.php');
5include_once(dirname(__FILE__).'/Hosting.php');
6include_once(dirname(__FILE__).'/UserHosts.php');
7
8class PageFrequencyPlan extends Page
9{
10 var $FullTitle = 'Výpis obsazení frekvenčních kanálů';
11 var $ShortTitle = 'Frekvenční plán';
12 var $ParentClass = 'PageNetwork';
13
14 function Show()
15 {
16 // http://en.wikipedia.org/wiki/List_of_WLAN_channels
17 //$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);
18 $Output = '<div align="center">'.
19 '<a href="?section=obsazeni_wifi_kanalu&range=a">Pásmo 2,4 GHz (a)</a> '.
20 '<a href="?section=obsazeni_wifi_kanalu&amp;range=bc">Pásmo 5 GHz dolní (b, c)</a> '.
21 '<a href="?section=obsazeni_wifi_kanalu&amp;range=d">Pásmo 5 GHz horní (d)</a> '.
22 '<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/>'.
23 '<strong>Seznam známých AP a obsazení kmitočtových pásem:</strong></div>'.
24 '<table class="WideTable">'.
25 '<tr><th/><br/>SSID<br/><br/></th>';
26 $ChannelList = array();
27 if(!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
28 if($_GET['range'] == 'a')
29 {
30 $Where = '(Frequency < 5000)';
31 for($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
32 }
33 if($_GET['range'] == 'bc')
34 {
35 $Where = '(Frequency >= 5000) AND (Frequency <= 5350)';
36 for($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
37 }
38 if($_GET['range'] == 'd')
39 {
40 $Where = '(Frequency >= 5470)';
41 for($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
42 }
43
44 foreach($ChannelList as $Frequency)
45 {
46 $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
47 }
48 $Output .= '</tr>';
49 $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`');
50 while($DbRow = $DbResult->fetch_assoc())
51 {
52 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where);
53 while($DbRow2 = $DbResult2->fetch_assoc())
54 {
55 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower'];
56 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper'];
57 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
58 foreach($ChannelList as $Frequency)
59 {
60 if(($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';
61 else if(($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';
62 else if(($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';
63 else $Color = '#ffffff';
64 $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
65 }
66
67 $Output .= '</tr>';
68 }
69 }
70 $Output .= '</table>';
71 return($Output);
72 }
73}
74
75class PageNetwork extends Page
76{
77 var $FullTitle = 'Technické informace o síti';
78 var $ShortTitle = 'Síť';
79 var $ParentClass = 'PagePortal';
80
81 function Show()
82 {
83 if(count($this->System->PathItems) > 1)
84 {
85 $Output = $this->PageNotFound();
86 } else $Output = $this->ShowInformation();
87 return($Output);
88 }
89
90 function ShowInformation()
91 {
92 $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />';
93 $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />';
94 $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />';
95 return($Output);
96 }
97}
98
99class ModuleNetwork extends AppModule
100{
101 function __construct($System)
102 {
103 parent::__construct($System);
104 $this->Name = 'Network';
105 $this->Version = '1.0';
106 $this->Creator = 'Chronos';
107 $this->License = 'GNU/GPLv3';
108 $this->Description = 'Networking related tools';
109 $this->Dependencies = array('Notify');
110 }
111
112 function DoInstall()
113 {
114 }
115
116 function DoUninstall()
117 {
118 }
119
120 function DoStart()
121 {
122 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability',
123 array($this, 'ReachabilityCheck'));
124 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',
125 array($this, 'PortCheck'));
126
127
128 $this->System->RegisterPage('network', 'PageNetwork');
129 $this->System->RegisterPage(array('network', 'administration'), 'PageNetworkAdministration');
130 $this->System->RegisterPage(array('network', 'subnet'), 'PageSubnet');
131 $this->System->RegisterPage(array('network', 'user-hosts'), 'PageNetworkHostList');
132 $this->System->RegisterPage(array('network', 'hosting'),'PageHosting');
133 $this->System->RegisterPage(array('network', 'hosts'), 'PageHostList');
134 $this->System->RegisterPage(array('network', 'frequency-plan'), 'PageFrequencyPlan');
135
136 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
137 'Title' => 'Alias domény',
138 'Table' => 'NetworkDomainAlias',
139 'Items' => array(
140 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
141 'Target' => array('Type' => 'String', 'Caption' => 'Cíl', 'Default' => ''),
142 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
143 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Síťová doména', 'Default' => ''),
144 ),
145 ));
146 $this->System->FormManager->RegisterFormType('TNetworkDomainAliasListDomain', array(
147 'Type' => 'ManyToOne',
148 'Table' => 'NetworkDomainAlias',
149 'Id' => 'Id',
150 'Ref' => 'Domain',
151 'Filter' => '1',
152 ));
153 $this->System->FormManager->RegisterClass('NetworkDevice', array(
154 'Title' => 'Síťové zařízení',
155 'Table' => 'NetworkDevice',
156 'Items' => array(
157 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
158 'Type' => array('Type' => 'TNetworkDeviceType', 'Caption' => 'Typ', 'Default' => '0'),
159 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '0'),
160 'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '0'),
161 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true),
162 'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '1'),
163 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
164 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
165 'PermanentOnline' => array('Type' => 'Boolean', 'Caption' => 'Běží stále', 'Default' => '0'),
166 'Interfaces' => array('Type' => 'TInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''),
167 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '0', 'Null' => true),
168 'Product' => array('Type' => 'TProduct', 'Caption' => 'Produkt', 'Default' => '', 'Null' => true),
169 'LoginName' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => '', 'Null' => true, 'NotInList' => true),
170 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => '', 'Null' => true, 'NotInList' => true),
171 'API' => array('Type' => 'TDeviceAPIType', 'Caption' => 'API', 'Default' => '', 'Null' => true),
172 ),
173 'AfterInsert' => array($this, 'AfterInsertNetworkDevice'),
174 'AfterModify' => array($this, 'AfterModifyNetworkDevice'),
175 'AfterDelete' => array($this, 'AfterModifyNetworkDevice'),
176 ));
177 $this->System->FormManager->RegisterClass('NetworkDeviceType', array(
178 'Title' => 'Typ síťového zařízení',
179 'Table' => 'NetworkDeviceType',
180 'Items' => array(
181 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
182 'ShowOnline' => array('Type' => 'Boolean', 'Caption' => 'Ukázat online', 'Default' => '0'),
183 'IconName' => array('Type' => 'String', 'Caption' => 'Jméno ikony', 'Default' => '0'),
184 ),
185 ));
186 $this->System->FormManager->RegisterClass('NetworkInterface', array(
187 'Title' => 'Síťové rozhraní',
188 'Table' => 'NetworkInterface',
189 'Items' => array(
190 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
191 'Type' => array('Type' => 'TNetworkInterfaceType', 'Caption' => 'Typ', 'Default' => '0'),
192 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
193 'LocalIP' => array('Type' => 'IPv4Address', 'Caption' => 'IPv4', 'Default' => '', 'Null' => true),
194 'IPv6' => array('Type' => 'IPv6Address', 'Caption' => 'IPv6', 'Default' => '', 'Null' => true),
195 'ExternalIP' => array('Type' => 'IPv4Address', 'Caption' => 'Veřejná IPv4', 'Default' => '', 'Null' => true),
196 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
197 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '1'),
198 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
199 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
200 'Links' => array('Type' => 'TNetworkLinkListInterface', 'Caption' => 'Propojení', 'Default' => ''),
201 'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
202 'Signal' => array('Type' => 'TNetworkSignalListInterface', 'Caption' => 'Signál', 'Default' => ''),
203 'Wireless' => array('Type' => 'TNetworkInterfaceWirelessListInterface', 'Caption' => 'Bezdrátové spoje', 'Default' => ''),
204 'Ports' => array('Type' => 'TDevicePortListInterface', 'Caption' => 'Síťové porty', 'Default' => ''),
205 ),
206 'AfterInsert' => array($this, 'AfterInsertNetworkInterface'),
207 'AfterModify' => array($this, 'AfterModifyNetworkInterface'),
208 'AfterDelete' => array($this, 'AfterModifyNetworkInterface'),
209 ));
210 $this->System->FormManager->RegisterClass('NetworkInterfaceType', array(
211 'Title' => 'Typ síťového rozhraní',
212 'Table' => 'NetworkInterfaceType',
213 'Items' => array(
214 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
215 'MaxSpeed' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost', 'Default' => '0', 'Suffix' => 'Mbit/s'),
216 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'),
217 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'),
218 ),
219 ));
220 $this->System->FormManager->RegisterClass('NetworkSubnet', array(
221 'Title' => 'Podsítě',
222 'DefaultSortColumn' => 'Name',
223 'Table' => 'NetworkSubnet',
224 'Items' => array(
225 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
226 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
227 'Mask' => array('Type' => 'Integer', 'Caption' => 'Prefix', 'Default' => ''),
228 'DHCP' => array('Type' => 'IPv4Address', 'Caption' => 'DHCP', 'Default' => ''),
229 'Gateway' => array('Type' => 'IPv4Address', 'Caption' => 'Brána', 'Default' => ''),
230 'WINS' => array('Type' => 'IPv4Address', 'Caption' => 'WINS', 'Default' => ''),
231 'DNS' => array('Type' => 'String', 'Caption' => 'DNS', 'Default' => ''),
232 'Domain' => array('Type' => 'String', 'Caption' => 'Doména', 'Default' => ''),
233 'NTP' => array('Type' => 'String', 'Caption' => 'NTP', 'Default' => ''),
234 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'Null' => true),
235 'ExtAddressRange' => array('Type' => 'String', 'Caption' => 'Vnější rozsah adres', 'Default' => ''),
236 'ExtMask' => array('Type' => 'String', 'Caption' => 'Vnější prefix', 'Default' => ''),
237 'AddressRangeIPv6' => array('Type' => 'String', 'Caption' => 'Rozsah adres IPv6', 'Default' => ''),
238 'Configure' => array('Type' => 'Boolean', 'Caption' => 'Nastavovat', 'Default' => ''),
239 ),
240 ));
241 $this->System->FormManager->RegisterClass('NetworkPort', array(
242 'Title' => 'Síťový port',
243 'Table' => 'NetworkPort',
244 'Items' => array(
245 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
246 'Protocol' => array('Type' => 'TNetworkProtocol', 'Caption' => 'Protokol', 'Default' => '0'),
247 'Number' => array('Type' => 'Integer', 'Caption' => 'Číslo', 'Default' => ''),
248 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
249 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '1'),
250 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
251 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
252 'UpDown' => array('Type' => 'TNetworkPortUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
253 ),
254 ));
255 $this->System->FormManager->RegisterClass('NetworkLink', array(
256 'Title' => 'Síťové propojení',
257 'Table' => 'NetworkLink',
258 'Items' => array(
259 'Type' => array('Type' => 'TNetworkLinkType', 'Caption' => 'Typ', 'Default' => '1'),
260 'Interface1' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => ''),
261 'Interface2' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => ''),
262 ),
263 ));
264 $this->System->FormManager->RegisterClass('NetworkLinkUnion', array(
265 'Title' => 'Síťové propojení',
266 'BaseTable' => 'NetworkLink',
267 'SQL' => '(SELECT `Id`, `Type`, `Interface1` AS `Interface`, `Interface2` AS `InterfaceOther` FROM `NetworkLink`) '.
268 'UNION (SELECT `Id`, `Type`, `Interface2` AS `Interface`, `Interface1` AS `InterfaceOther` FROM `NetworkLink`)',
269 'Items' => array(
270 'Type' => array('Type' => 'TNetworkLinkType', 'Caption' => 'Typ', 'Default' => '1', 'ReadOnly' => true),
271 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => '', 'ReadOnly' => true),
272 'InterfaceOther' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => '', 'ReadOnly' => true),
273 ),
274 ));
275
276 $this->System->FormManager->RegisterClass('NetworkLinkType', array(
277 'Title' => 'Typ síťového propojení',
278 'Table' => 'NetworkLinkType',
279 'Items' => array(
280 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
281 ),
282 ));
283 $this->System->FormManager->RegisterClass('NetworkSignal', array(
284 'Title' => 'Signál rozhraní',
285 'Table' => 'NetworkSignal',
286 'DefaultSortColumn' => 'Time',
287 'DefaultSortOrder' => 1,
288 'Items' => array(
289 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
290 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
291 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true),
292 'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0', 'Suffix' => 'dBm'),
293 'RateRx' => array('Type' => 'Integer', 'Caption' => 'Rychlost Rx', 'Default' => '0', 'Suffix' => 'MHz'),
294 'RateTx' => array('Type' => 'Integer', 'Caption' => 'Rychlost Tx', 'Default' => '0', 'Suffix' => 'MHz'),
295 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Měřeno z', 'Default' => '0'),
296 ),
297 ));
298 $this->System->FormManager->RegisterClass('NetworkAddressCategory', array(
299 'Title' => 'Kategorie síťové adresy',
300 'Table' => 'NetworkAddressCategory',
301 'DefaultSortColumn' => 'Name',
302 'DefaultSortOrder' => 1,
303 'Items' => array(
304 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
305 ),
306 ));
307 $this->System->FormManager->RegisterFormType('TNetworkAddressCategory', array(
308 'Type' => 'Reference',
309 'Table' => 'NetworkAddressCategory',
310 'Id' => 'Id',
311 'Name' => 'Name',
312 'Filter' => '1',
313 ));
314 $this->System->FormManager->RegisterClass('NetworkDeviceConfig', array(
315 'Title' => 'Nastavení zařízení',
316 'Table' => 'NetworkDeviceConfig',
317 'DefaultSortColumn' => 'Time',
318 'DefaultSortOrder' => 1,
319 'Items' => array(
320 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
321 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
322 'ConfigFull' => array('Type' => 'Text', 'Caption' => 'Kompletní nastavení', 'Default' => ''),
323 'ConfigCompact' => array('Type' => 'Text', 'Caption' => 'Rozdílové nastavení', 'Default' => ''),
324 ),
325 ));
326 $this->System->FormManager->RegisterClass('NetworkDomain', array(
327 'Title' => 'Síťová doména',
328 'Table' => 'NetworkDomain',
329 'DefaultSortColumn' => 'Name',
330 'DefaultSortOrder' => 1,
331 'Items' => array(
332 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
333 'Parent' => array('Type' => 'TNetworkDomain', 'Caption' => 'Nadřazená doména', 'Default' => '', 'Null' => true),
334 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
335 'Serial' => array('Type' => 'Integer', 'Caption' => 'Sériové číslo', 'Default' => '1'),
336 'Minimum' => array('Type' => 'Integer', 'Caption' => 'Minimum', 'Default' => '10800'),
337 'Retry' => array('Type' => 'Integer', 'Caption' => 'Opakování', 'Default' => '7200'),
338 'Expire' => array('Type' => 'Integer', 'Caption' => 'Čas vypršení', 'Default' => '2419200'),
339 'Refresh' => array('Type' => 'Integer', 'Caption' => 'Obnovení', 'Default' => '28800'),
340 'TTL' => array('Type' => 'Integer', 'Caption' => 'TTL', 'Default' => '86400', 'Suffix' => 'sekund'),
341 'Servers' => array('Type' => 'TNetworkDomainServerList', 'Caption' => 'Servery', 'Default' => ''),
342 'Views' => array('Type' => 'TNetworkDomainViewListDomain', 'Caption' => 'Pohledy', 'Default' => ''),
343 'ItemFilters' => array('Type' => 'TNetworkDomainItemFilterListDomain', 'Caption' => 'Filtry položek', 'Default' => ''),
344 'Aliases' => array('Type' => 'TNetworkDomainAliasListDomain', 'Caption' => 'Aliasy', 'Default' => ''),
345 ),
346 ));
347 $this->System->FormManager->RegisterFormType('TNetworkDomain', array(
348 'Type' => 'Reference',
349 'Table' => 'NetworkDomain',
350 'Id' => 'Id',
351 'Name' => 'Name',
352 'Filter' => '1',
353 ));
354 $this->System->FormManager->RegisterClass('NetworkDomainServer', array(
355 'Title' => 'Doménový server',
356 'Table' => 'NetworkDomainServer',
357 'DefaultSortColumn' => 'Address',
358 'DefaultSortOrder' => 1,
359 'Items' => array(
360 'Address' => array('Type' => 'String', 'Caption' => 'Adresa', 'Default' => ''),
361 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Doména', 'Default' => ''),
362 'Sequence' => array('Type' => 'Integer', 'Caption' => 'Pořadí', 'Default' => '1'),
363 ),
364 ));
365 $this->System->FormManager->RegisterFormType('TNetworkDomainServerList', array(
366 'Type' => 'ManyToOne',
367 'Table' => 'NetworkDomainServer',
368 'Id' => 'Id',
369 'Ref' => 'Domain',
370 'Filter' => '1',
371 ));
372 $this->System->FormManager->RegisterClass('NetworkDomainView', array(
373 'Title' => 'Pohled síťové domény',
374 'Table' => 'NetworkDomainView',
375 'DefaultSortColumn' => 'Name',
376 'DefaultSortOrder' => 1,
377 'Items' => array(
378 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
379 'SysName' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
380 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Doména', 'Default' => ''),
381 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
382 'ItemFilters' => array('Type' => 'TNetworkDomainItemFilterListView', 'Caption' => 'Filtry položek', 'Default' => ''),
383 ),
384 ));
385 $this->System->FormManager->RegisterFormType('TNetworkDomainView', array(
386 'Type' => 'Reference',
387 'Table' => 'NetworkDomainView',
388 'Id' => 'Id',
389 'Name' => 'Name',
390 'Filter' => '1',
391 ));
392 $this->System->FormManager->RegisterFormType('TNetworkDomainViewListDomain', array(
393 'Type' => 'ManyToOne',
394 'Table' => 'NetworkDomainView',
395 'Id' => 'Id',
396 'Ref' => 'Domain',
397 'Filter' => '1',
398 ));
399 $this->System->FormManager->RegisterClass('NetworkDomainItemFilter', array(
400 'Title' => 'Filtr doménových položek',
401 'Table' => 'NetworkDomainItemFilter',
402 'DefaultSortColumn' => 'Name',
403 'DefaultSortOrder' => 1,
404 'Items' => array(
405 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
406 'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Domén', 'Default' => ''),
407 'AddressCategory' => array('Type' => 'TNetworkAddressCategory', 'Caption' => 'Kategorie adresy', 'Default' => ''),
408 'Suffix' => array('Type' => 'String', 'Caption' => 'Přípona jména položek', 'Default' => ''),
409 'View' => array('Type' => 'TNetworkDomainView', 'Caption' => 'Pohled', 'Default' => ''),
410 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
411 ),
412 ));
413 $this->System->FormManager->RegisterFormType('TNetworkDomainItemFilterListDomain', array(
414 'Type' => 'ManyToOne',
415 'Table' => 'NetworkDomainItemFilter',
416 'Id' => 'Id',
417 'Ref' => 'Domain',
418 'Filter' => '1',
419 ));
420 $this->System->FormManager->RegisterFormType('TNetworkDomainItemFilterListView', array(
421 'Type' => 'ManyToOne',
422 'Table' => 'NetworkDomainItemFilter',
423 'Id' => 'Id',
424 'Ref' => 'View',
425 'Filter' => '1',
426 ));
427 $this->System->FormManager->RegisterClass('DeviceAPIType', array(
428 'Title' => 'Typ API zařízení',
429 'Table' => 'DeviceAPIType',
430 'Items' => array(
431 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
432 'Devices' => array('Type' => 'TDeviceListAPI', 'Caption' => 'Zařízení', 'Default' => ''),
433 ),
434 ));
435 $this->System->FormManager->RegisterClass('NetworkInterfaceWireless', array(
436 'Title' => 'Bezdrátová rozhraní',
437 'Table' => 'NetworkInterfaceWireless',
438 'Items' => array(
439 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
440 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
441 'NetworkInterface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
442 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
443 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
444 'Antenna' => array('Type' => 'TProduct', 'Caption' => 'Anténa', 'Default' => '', 'Null' => true),
445 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
446 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
447 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
448 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
449 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
450 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
451 'Mode' => array('Type'
452 => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
453 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
454 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
455 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
456 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
457 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
458 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
459 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
460 ),
461 'Actions' => array(
462 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
463 ),
464 ));
465 $this->System->FormManager->RegisterClass('NetworkInterfaceWirelessCTU', array(
466 'Title' => 'Bezdrátová rozhraní pro ČTÚ',
467 'Table' => 'NetworkInterfaceWireless',
468 'Items' => array(
469 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
470 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
471 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
472 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
473 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
474 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
475 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
476 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
477 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
478 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
479 'Mode' => array('Type' => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
480 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
481 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
482 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
483 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
484 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
485 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
486 'Position' => array('Type' => 'String', 'Caption' => 'GPS poloha', 'Default' => '',
487 'SQL' => '(SELECT MapPosition.Pos FROM MapPosition WHERE MapPosition.Id=#Id)'),
488 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
489 ),
490 'Actions' => array(
491 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
492 ),
493 ));
494 $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array(
495 'Title' => 'Změny stavu rozhraní',
496 'Table' => 'NetworkInterfaceUpDown',
497 'DefaultSortColumn' => 'Time',
498 'DefaultSortOrder' => 1,
499 'Items' => array(
500 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
501 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),
502 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
503 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
504 ),
505 ));
506 $this->System->FormManager->RegisterClass('NetworkPortUpDown', array(
507 'Title' => 'Změny stavu portů',
508 'Table' => 'NetworkPortUpDown',
509 'DefaultSortColumn' => 'Time',
510 'DefaultSortOrder' => 1,
511 'Items' => array(
512 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
513 'Port' => array('Type' => 'TNetworkPort', 'Caption' => 'Port', 'Default' => '', 'ReadOnly' => true),
514 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
515 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
516 ),
517 ));
518 $this->System->FormManager->RegisterFormType('TNetworkProtocol', array(
519 'Type' => 'Enumeration',
520 'States' => array('TCP', 'UDP'),
521 ));
522 $this->System->FormManager->RegisterFormType('TNetworkDevice', array(
523 'Type' => 'Reference',
524 'Table' => 'NetworkDevice',
525 'Id' => 'Id',
526 'Name' => 'Name',
527 'Filter' => '1',
528 ));
529 $this->System->FormManager->RegisterFormType('TNetworkDeviceType', array(
530 'Type' => 'Reference',
531 'Table' => 'NetworkDeviceType',
532 'Id' => 'Id',
533 'Name' => 'Name',
534 'Filter' => '1',
535 ));
536 $this->System->FormManager->RegisterFormType('TNetworkInterface', array(
537 'Type' => 'Reference',
538 'Table' => 'NetworkInterface',
539 'View' => '(SELECT NetworkInterface.*, CONCAT_WS("-", NetworkDevice.Name, NULLIF(NetworkInterface.Name, "")) AS DeviceName FROM NetworkInterface '.
540 'LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device) AS T',
541 'Id' => 'Id',
542 'Name' => 'DeviceName',
543 'Filter' => '1',
544 ));
545 $this->System->FormManager->RegisterFormType('TNetworkPort', array(
546 'Type' => 'Reference',
547 'Table' => 'NetworkPort',
548 'View' => '(SELECT `NetworkPort`.*, CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`) AS `PortName` FROM `NetworkPort` '.
549 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkPort`.`Interface` '.
550 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device`) AS `T`',
551 'Id' => 'Id',
552 'Name' => 'PortName',
553 'Filter' => '1',
554 ));
555 $this->System->FormManager->RegisterFormType('TNetworkInterfaceType', array(
556 'Type' => 'Reference',
557 'Table' => 'NetworkInterfaceType',
558 'Id' => 'Id',
559 'Name' => 'Name',
560 'Filter' => '1',
561 ));
562 $this->System->FormManager->RegisterFormType('TDeviceList', array(
563 'Type' => 'ManyToOne',
564 'Table' => 'NetworkDevice',
565 'Id' => 'Id',
566 'Ref' => 'Member',
567 'Filter' => '1',
568 ));
569 $this->System->FormManager->RegisterFormType('TDeviceListAPI', array(
570 'Type' => 'ManyToOne',
571 'Table' => 'NetworkDevice',
572 'Id' => 'Id',
573 'Ref' => 'API',
574 'Filter' => '1',
575 ));
576 $this->System->FormManager->RegisterFormType('TDevicePortListInterface', array(
577 'Type' => 'ManyToOne',
578 'Table' => 'NetworkPort',
579 'Id' => 'Id',
580 'Ref' => 'Interface',
581 'Filter' => '1',
582 ));
583 $this->System->FormManager->RegisterFormType('TNetworkLinkType', array(
584 'Type' => 'Reference',
585 'Table' => 'NetworkLinkType',
586 'Id' => 'Id',
587 'Name' => 'Name',
588 'Filter' => '1',
589 ));
590 $this->System->FormManager->RegisterFormType('TDeviceAPIType', array(
591 'Type' => 'Reference',
592 'Table' => 'DeviceAPIType',
593 'Id' => 'Id',
594 'Name' => 'Name',
595 'Filter' => '1',
596 ));
597 $this->System->FormManager->RegisterFormType('TNetworkInterfaceWirelessListInterface', array(
598 'Type' => 'ManyToOne',
599 'Table' => 'NetworkInterfaceWireless',
600 'Id' => 'Id',
601 'Ref' => 'NetworkInterface',
602 'Filter' => '1',
603 ));
604 $this->System->FormManager->RegisterFormType('TInterfaceList', array(
605 'Type' => 'ManyToOne',
606 'Table' => 'NetworkInterface',
607 'Id' => 'Id',
608 'Ref' => 'Device',
609 'Filter' => '1',
610 ));
611 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface', array(
612 'Type' => 'ManyToOne',
613 'Table' => 'NetworkLinkUnion',
614 'Id' => 'Id',
615 'Ref' => 'Interface',
616 'Filter' => '1',
617 ));
618 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface1', array(
619 'Type' => 'ManyToOne',
620 'Table' => 'NetworkLink',
621 'Id' => 'Id',
622 'Ref' => 'Interface1',
623 'Filter' => '1',
624 ));
625 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface2', array(
626 'Type' => 'ManyToOne',
627 'Table' => 'NetworkLink',
628 'Id' => 'Id',
629 'Ref' => 'Interface2',
630 'Filter' => '1',
631 ));
632 $this->System->FormManager->RegisterFormType('TNetworkInterfaceUpDown', array(
633 'Type' => 'ManyToOne',
634 'Table' => 'NetworkInterfaceUpDown',
635 'Id' => 'Id',
636 'Ref' => 'Interface',
637 'Filter' => '1',
638 ));
639 $this->System->FormManager->RegisterFormType('TNetworkPortUpDown', array(
640 'Type' => 'ManyToOne',
641 'Table' => 'NetworkPortUpDown',
642 'Id' => 'Id',
643 'Ref' => 'Port',
644 'Filter' => '1',
645 ));
646
647 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network',
648 array('ModuleNetwork', 'ShowDashboardItem'));
649
650 $this->System->RegisterModel('NetworkDevice', array(
651 'Title' => 'Síťové zařízení',
652 ));
653 $this->System->RegisterModel('NetworkInterface', array(
654 'Title' => 'Síťové rozhraní',
655 ));
656 }
657
658 function AfterInsertNetworkDevice($Form)
659 {
660 $this->System->Models['NetworkDevice']->DoOnChange();
661 }
662
663 function AfterModifyNetworkDevice($Form, $Id)
664 {
665 $this->System->Models['NetworkDevice']->DoOnChange();
666 }
667
668 function AfterInsertNetworkInterface($Form)
669 {
670 $this->System->Models['NetworkInterface']->DoOnChange();
671 }
672
673 function AfterModifyNetworkInterface($Form, $Id)
674 {
675 $this->System->Models['NetworkInterface']->DoOnChange();
676 }
677
678 function ShowDashboardItem()
679 {
680 $Output = '';
681 $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
682 $DbRow = $DbResult->fetch_row();
683 $Output .= 'Síťových zařízení: registrovaných:'.$DbRow['0'];
684
685 $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '`Used`=1');
686 $DbRow = $DbResult->fetch_row();
687 $Output .= ' použitých:'.$DbRow['0'].'<br>';
688
689 $DbResult = $this->Database->select('NetworkInterface', 'COUNT(*)', '1');
690 $DbRow = $DbResult->fetch_row();
691 $Output .= 'Síťových rozhraní: '.$DbRow['0'].'<br>';
692
693 $DbResult = $this->Database->select('NetworkSubnet', 'COUNT(*)', '1');
694 $DbRow = $DbResult->fetch_row();
695 $Output .= 'Síťových podsítí: '.$DbRow['0'].'<br/>';
696 return $Output;
697 }
698
699 function DoStop()
700 {
701 }
702
703 function OnlineList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
704 {
705 $Time = time();
706 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
707 $Output = '';
708 $Condition = 'WHERE (`NetworkInterface`.`Online` = '.$OnlineNow.') AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.') '.
709 'AND (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
710 $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
711 '`NetworkInterface`.`Online`, `NetworkInterface`.`LastOnline` FROM `NetworkInterface` '.
712 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
713 $Condition.' AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) AND '.
714 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled` == 1)'.
715 'ORDER BY `Name` ASC');
716 if($DbResult3->num_rows > 0)
717 {
718 $Output .= $Title.'<br/>';
719 $Output .= '<table>'.
720 '<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";
721 while($Item = $DbResult3->fetch_assoc())
722 {
723 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
724 $DurationText = sprintf('%02d', floor($Duration / 3600 % 24)).':'.
725 sprintf('%02d', floor($Duration / 60 % 60)).':'.
726 sprintf('%02d', floor($Duration % 60));
727 $Days = floor($Duration / (60 * 60 * 24));
728 if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
729
730 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
731 '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n";
732 }
733 $Output .= '</table><br/>'."\n";
734 }
735 $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '.
736 $Condition);
737 return $Output;
738 }
739
740 function ReachabilityCheck()
741 {
742 $Output = '';
743 $Output = $this->OnlineList('Nově online', 1, 0, 0);
744 $Output .= $this->OnlineList('Nově offline', 0, 1, 5 * 60);
745 if($Output != '') $Output .= $this->OnlineList('Stále offline', 0, 0, 0);
746 return($Output);
747 }
748
749 function PortCheckList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
750 {
751 $Time = time();
752 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
753 $Output = '';
754 $Condition = 'WHERE (`NetworkPort`.`Online` = '.$OnlineNow.') AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.') '.
755 'AND (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
756 $DbResult3 = $this->Database->query('SELECT CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`, "(", `NetworkPort`.`Name`, ")") AS `Name`, '.
757 '`NetworkPort`.`Online`, `NetworkPort`.`LastOnline` FROM `NetworkPort` '.
758 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkPort`.`Interface` '.
759 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
760 $Condition.' AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) AND '.
761 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkPort`.`Enabled` = 1)'.
762 'ORDER BY `Name` ASC');
763 if($DbResult3->num_rows > 0)
764 {
765 $Output .= $Title.'<br/>';
766 $Output .= '<table>'.
767 '<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";
768 while($Item = $DbResult3->fetch_assoc())
769 {
770 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
771 $DurationText = sprintf('%02d', floor($Duration / 3600 % 24)).':'.
772 sprintf('%02d', floor($Duration / 60 % 60)).':'.
773 sprintf('%02d', floor($Duration % 60));
774 $Days = floor($Duration / (60 * 60 * 24));
775 if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
776
777 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
778 '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n";
779 }
780 $Output .= '</table><br/>'."\n";
781 }
782 $this->Database->query('UPDATE `NetworkPort` SET `OnlineNotify` = `Online` '.
783 $Condition);
784 return $Output;
785 }
786
787 function PortCheck()
788 {
789 $Output = '';
790 $Output = $this->PortCheckList('Nově online', 1, 0, 0);
791 $Output .= $this->PortCheckList('Nově offline', 0, 1, 5 * 60);
792 if($Output != '') $Output .= $this->PortCheckList('Stále offline', 0, 0, 0);
793 return($Output);
794 }
795}
Note: See TracBrowser for help on using the repository browser.