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

Last change on this file since 661 was 661, checked in by chronos, 11 years ago
  • Upraveno: Definice třídy Subject přesunuta do samostatného modulu Subject.
  • Přidáno: K Subjektům přidána definice Kontaktů a druhů kontaktů.
File size: 19.0 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/HostList.php');
4include_once(dirname(__FILE__).'/Availability.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 var $FullTitle = 'Výpis obsazení frekvenčních kanálů';
12 var $ShortTitle = 'Frekvenční plán';
13 var $ParentClass = 'PageNetwork';
14
15 function Show()
16 {
17 // http://en.wikipedia.org/wiki/List_of_WLAN_channels
18 //$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);
19 $Output = '<div align="center">'.
20 '<a href="?section=obsazeni_wifi_kanalu&range=a">Pásmo 2,4 GHz (a)</a> '.
21 '<a href="?section=obsazeni_wifi_kanalu&amp;range=bc">Pásmo 5 GHz dolní (b, c)</a> '.
22 '<a href="?section=obsazeni_wifi_kanalu&amp;range=d">Pásmo 5 GHz horní (d)</a> '.
23 '<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/>'.
24 '<strong>Seznam známých AP a obsazení kmitočtových pásem:</strong></div>'.
25 '<table class="WideTable">'.
26 '<tr><th/><br/>SSID<br/><br/></th>';
27 $ChannelList = array();
28 if(!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
29 if($_GET['range'] == 'a')
30 {
31 $Where = '(Frequency < 5000)';
32 for($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
33 }
34 if($_GET['range'] == 'bc')
35 {
36 $Where = '(Frequency >= 5000) AND (Frequency <= 5350)';
37 for($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
38 }
39 if($_GET['range'] == 'd')
40 {
41 $Where = '(Frequency >= 5470)';
42 for($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
43 }
44
45 foreach($ChannelList as $Frequency)
46 {
47 $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
48 }
49 $Output .= '</tr>';
50 $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`');
51 while($DbRow = $DbResult->fetch_assoc())
52 {
53 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where);
54 while($DbRow2 = $DbResult2->fetch_assoc())
55 {
56 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower'];
57 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper'];
58 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
59 foreach($ChannelList as $Frequency)
60 {
61 if(($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';
62 else if(($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';
63 else if(($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';
64
65 else $Color = '#ffffff';
66 $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
67 }
68
69 $Output .= '</tr>';
70 }
71 }
72 $Output .= '</table>';
73 return($Output);
74 }
75}
76
77class PageNetwork extends Page
78{
79 var $FullTitle = 'Technické informace o síti';
80 var $ShortTitle = 'Síť';
81 var $ParentClass = 'PagePortal';
82
83 function Show()
84 {
85 if(count($this->System->PathItems) > 1)
86 {
87 $Output = $this->PageNotFound();
88 } else $Output = $this->ShowInformation();
89 return($Output);
90 }
91
92 function ShowInformation()
93 {
94 $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />';
95 $Output .= '<a href="'.$this->System->Link('/network/availability/').'">Měření dostupnosti zařízení</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 function __construct($System)
105 {
106 parent::__construct($System);
107 $this->Name = 'Network';
108 $this->Version = '1.0';
109 $this->Creator = 'Chronos';
110 $this->License = 'GNU/GPLv3';
111 $this->Description = 'Networking related tools';
112 $this->Dependencies = array();
113 }
114
115 function DoInstall()
116 {
117 }
118
119 function DoUninstall()
120 {
121 }
122
123 function DoStart()
124 {
125 $this->System->RegisterPage('network', 'PageNetwork');
126 $this->System->RegisterPage(array('network', 'administration'), 'PageNetworkAdministration');
127 $this->System->RegisterPage(array('network', 'availability'), 'PageAvailability');
128 $this->System->RegisterPage(array('network', 'subnet'), 'PageSubnet');
129 $this->System->RegisterPage(array('network', 'user-hosts'), 'PageNetworkHostList');
130 $this->System->RegisterPage(array('network', 'hosting'),'PageHosting');
131 $this->System->RegisterPage(array('network', 'hosts'), 'PageHostList');
132 $this->System->RegisterPage(array('network', 'frequency-plan'), 'PageFrequencyPlan');
133
134 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
135 'Title' => 'Alias domény',
136 'Table' => 'NetworkDomainAlias',
137 'Items' => array(
138 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
139 'Target' => array('Type' => 'String', 'Caption' => 'Cíl', 'Default' => ''),
140 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
141 ),
142 ));
143 $this->System->FormManager->RegisterClass('NetworkDevice', array(
144 'Title' => 'Síťové zařízení',
145 'Table' => 'NetworkDevice',
146 'Items' => array(
147 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
148 'Type' => array('Type' => 'TNetworkDeviceType', 'Caption' => 'Typ', 'Default' => '0'),
149 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '0'),
150 'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '0'),
151 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true),
152 'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '1'),
153 'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
154 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
155 'PermanentOnline' => array('Type' => 'Boolean', 'Caption' => 'Běží stále', 'Default' => '0'),
156 'Interfaces' => array('Type' => 'TInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''),
157 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '0', 'Null' => true),
158 'LoginName' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => '', 'Null' => true),
159 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => '', 'Null' => true),
160 ),
161 'Actions' => array(
162 array('Caption' => 'Dostupnost zařízení', 'URL' => '/network/availability/'),
163 ),
164 ));
165 $this->System->FormManager->RegisterClass('NetworkDeviceType', array(
166 'Title' => 'Typ síťového zařízení',
167 'Table' => 'NetworkDeviceType',
168 'Items' => array(
169 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
170 'ShowOnline' => array('Type' => 'Boolean', 'Caption' => 'Ukázat online', 'Default' => '0'),
171 'IconName' => array('Type' => 'String', 'Caption' => 'Jméno ikony', 'Default' => '0'),
172 ),
173 ));
174 $this->System->FormManager->RegisterClass('NetworkInterface', array(
175 'Title' => 'Síťové rozhraní',
176 'Table' => 'NetworkInterface',
177 'Items' => array(
178 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
179 'Type' => array('Type' => 'TNetworkInterfaceType', 'Caption' => 'Typ', 'Default' => '0'),
180 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
181 'LocalIP' => array('Type' => 'IPv4Address', 'Caption' => 'IPv4', 'Default' => ''),
182 'IPv6' => array('Type' => 'IPv6Address', 'Caption' => 'IPv6', 'Default' => '', 'Null' => true),
183 'ExternalIP' => array('Type' => 'IPv4Address', 'Caption' => 'Veřejná IPv4', 'Default' => '', 'Null' => true),
184 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
185 'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
186 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
187 'Links1' => array('Type' => 'TNetworkLinkListInterface1', 'Caption' => 'Propojení 1', 'Default' => ''),
188 'Links2' => array('Type' => 'TNetworkLinkListInterface2', 'Caption' => 'Propojení 2', 'Default' => ''),
189 'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
190 ),
191 ));
192 $this->System->FormManager->RegisterClass('NetworkInterfaceType', array(
193 'Title' => 'Typ síťového rozhraní',
194 'Table' => 'NetworkInterfaceType',
195 'Items' => array(
196 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
197 'MaxSpeed' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost', 'Default' => '0', 'Suffix' => 'Mbit/s'),
198 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'),
199 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'),
200 ),
201 ));
202 $this->System->FormManager->RegisterClass('NetworkSubnet', array(
203 'Title' => 'Podsítě',
204 'DefaultSortColumn' => 'Name',
205 'Table' => 'NetworkSubnet',
206 'Items' => array(
207 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
208 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
209 'Mask' => array('Type' => 'Integer', 'Caption' => 'Prefix', 'Default' => ''),
210 'DHCP' => array('Type' => 'IPv4Address', 'Caption' => 'DHCP', 'Default' => ''),
211 'Gateway' => array('Type' => 'IPv4Address', 'Caption' => 'Brána', 'Default' => ''),
212 'WINS' => array('Type' => 'IPv4Address', 'Caption' => 'WINS', 'Default' => ''),
213 'DNS' => array('Type' => 'String', 'Caption' => 'DNS', 'Default' => ''),
214 'Domain' => array('Type' => 'String', 'Caption' => 'Doména', 'Default' => ''),
215 'NTP' => array('Type' => 'String', 'Caption' => 'NTP', 'Default' => ''),
216 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'Null' => true),
217 'ExtAddressRange' => array('Type' => 'String', 'Caption' => 'Vnější rozsah adres', 'Default' => ''),
218 'ExtMask' => array('Type' => 'String', 'Caption' => 'Vnější prefix', 'Default' => ''),
219 'AddressRangeIPv6' => array('Type' => 'String', 'Caption' => 'Rozsah adres IPv6', 'Default' => ''),
220 'Configure' => array('Type' => 'Boolean', 'Caption' => 'Nastavovat', 'Default' => ''),
221 ),
222 ));
223 $this->System->FormManager->RegisterClass('NetworkLink', array(
224 'Title' => 'Síťové propojení',
225 'Table' => 'NetworkLink',
226 'Items' => array(
227 'Type' => array('Type' => 'Integer', 'Caption' => 'Typ', 'Default' => '1'),
228 'Interface1' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => ''),
229 'Interface2' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => ''),
230 ),
231 ));
232 $this->System->FormManager->RegisterClass('NetworkDeviceConfig',array(
233 'Title' => 'Nastavení zařízení',
234 'Table' => 'NetworkDeviceConfig',
235 'DefaultSortColumn' => 'Time',
236 'DefaultSortOrder' => 1,
237 'Items' => array(
238 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
239 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
240 'ConfigFull' => array('Type' => 'Text', 'Caption' => 'Kompletní nastavení', 'Default' => ''),
241 'ConfigCompact' => array('Type' => 'Text', 'Caption' => 'Rozdílové nastavení', 'Default' => ''),
242 ),
243 ));
244 $this->System->FormManager->RegisterClass('NetworkSegment', array(
245 'Title' => 'Úsek sítě',
246 'Table' => 'NetworkSegment',
247 'Items' => array(
248 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
249 'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
250 'Parent' => array('Type' => 'TNetworkSegment', 'Caption' => 'Nadřazený', 'Default' => '', 'Null' => true),
251 'Users' => array('Type' => 'Integer', 'Caption' => 'Uživatelů', 'Default' => '0', 'ReadOnly' => true),
252 'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => '0', 'ReadOnly' => true, 'Suffix' => 'Wattů'),
253 'UsersOverheads' => array('Type' => 'Integer', 'Caption' => 'Podílníků', 'Default' => '0', 'ReadOnly' => true),
254 ),
255 ));
256 $this->System->FormManager->RegisterClass('NetworkInterfaceWireless', array(
257 'Title' => 'Bezdrátová rozhraní',
258 'Table' => 'NetworkInterfaceWireless',
259 'Items' => array(
260 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
261 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
262 'NetworkInterface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''),
263 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
264 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
265 'Antenna' => array('Type' => 'TProduct', 'Caption' => 'Anténa', 'Default' => '', 'Null' => true),
266 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
267 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
268 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
269 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
270 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
271 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
272 'Mode' => array('Type'
273 => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
274 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
275 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
276 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
277 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
278 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
279 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
280 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
281 ),
282 'Actions' => array(
283 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
284 ),
285 ));
286 $this->System->FormManager->RegisterClass('NetworkInterfaceWirelessCTU', array(
287 'Title' => 'Bezdrátová rozhraní pro ČTÚ',
288 'Table' => 'NetworkInterfaceWireless',
289 'Items' => array(
290 'SSID' => array('Type' => 'String', 'Caption' => 'SSID', 'Default' => ''),
291 'MAC' => array('Type' => 'MacAddress', 'Caption' => 'MAC', 'Default' => ''),
292 'TxPower' => array('Type' => 'Integer', 'Caption' => 'Výstupní výkon', 'Default' => '18', 'Suffix' => 'dBm'),
293 'CableAttenuation' => array('Type' => 'Integer', 'Caption' => 'Útlum vedení', 'Default' => '0', 'Suffix' => 'dB'),
294 'AntenaGain' => array('Type' => 'Integer', 'Caption' => 'Zisk antény', 'Default' => '', 'Suffix' => 'dBi'),
295 'AntennaPolarity' => array('Type' => 'TAntennaPolarity', 'Caption' => 'Polarizace antény', 'Default' => '0'),
296 'Frequency' => array('Type' => 'Float', 'Caption' => 'Frekvence', 'Default' => '5600', 'Suffix' => 'MHz'),
297 'ChannelWidthLower' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu dolního', 'Default' => '0', 'Suffix' => 'MHz'),
298 'ChannelWidth' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu', 'Default' => '20', 'Suffix' => 'MHz'),
299 'ChannelWidthUpper' => array('Type' => 'Integer', 'Caption' => 'Šírka kanálu horního', 'Default' => '0', 'Suffix' => 'MHz'),
300 'Mode' => array('Type' => 'TWirelessMode', 'Caption' => 'Režim', 'Default' => '0', 'Suffix' => ''),
301 'TotalPower' => array('Type' => 'Integer', 'Caption' => 'Celkový výkon', 'Default' => '20', 'Suffix' => 'dBm',
302 'SQL' => '(`TxPower` - `CableAttenuation` + `AntenaGain`)', 'ReadOnly' => true),
303 'LimitPower' => array('Type' => 'Integer', 'Caption' => 'Max. limit', 'Default' => '', 'Suffix' => 'dBm',
304 'ReadOnly' => true, 'SQL' => '(CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END)'),
305 'UnderLimit' => array('Type' => 'Boolean', 'Caption' => 'V limitu', 'Default' => '', 'Suffix' => '',
306 'ReadOnly' => true, 'SQL' => '((`TxPower` - `CableAttenuation` + `AntenaGain`) <= (CASE WHEN `Frequency` >= 5450 AND `Frequency` <= 5725 THEN 27 ELSE 20 END))'),
307 'Position' => array('Type' => 'String', 'Caption' => 'GPS poloha', 'Default' => '',
308 'SQL' => '(SELECT MapPosition.Pos FROM MapPosition WHERE MapPosition.Id=#Id)'),
309 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
310 ),
311 'Actions' => array(
312 array('Caption' => 'Frekvenční plán', 'URL' => '/network/frequency-plan/'),
313 ),
314 ));
315 }
316
317 function DoStop()
318 {
319 }
320}
Note: See TracBrowser for help on using the repository browser.