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

Last change on this file since 554 was 554, checked in by chronos, 12 years ago
  • Opraveno: Negenerovat síťové fronty u služeb bez přiřazené rychlosti.
File size: 15.2 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 NetworkAP WHERE '.$Where.' GROUP BY Frequency');
51 while($DbRow = $DbResult->fetch_assoc())
52 {
53 $DbResult2 = $this->Database->query('SELECT * FROM NetworkAP WHERE Frequency='.$DbRow['Frequency'].' AND '.$Where);
54 while($DbRow2 = $DbResult2->fetch_assoc())
55 {
56 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2;
57 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2;
58 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
59 foreach($ChannelList as $Frequency)
60 {
61 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/availability/').'">Měření dostupnosti zařízení</a><br />';
94 $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />';
95 $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />';
96 return($Output);
97 }
98}
99
100class ModuleNetwork extends AppModule
101{
102 function __construct($System)
103 {
104 parent::__construct($System);
105 $this->Name = 'Network';
106 $this->Version = '1.0';
107 $this->Creator = 'Chronos';
108 $this->License = 'GNU/GPLv3';
109 $this->Description = 'Networking related tools';
110 $this->Dependencies = array();
111 }
112
113 function Install()
114 {
115 }
116
117 function Uninstall()
118 {
119 }
120
121 function Start()
122 {
123 parent::Start();
124 $this->System->RegisterPage('network', 'PageNetwork');
125 $this->System->RegisterPage(array('network', 'administration'), 'PageNetworkAdministration');
126 $this->System->RegisterPage(array('network', 'availability'), 'PageAvailability');
127 $this->System->RegisterPage(array('network', 'subnet'), 'PageSubnet');
128 $this->System->RegisterPage(array('network', 'user-hosts'), 'PageNetworkHostList');
129 $this->System->RegisterPage(array('network', 'hosting'),'PageHosting');
130 $this->System->RegisterPage(array('network', 'hosts'), 'PageHostList');
131 $this->System->RegisterPage(array('network', 'frequency-plan'), 'PageFrequencyPlan');
132
133 $this->System->FormManager->RegisterClass('Subject', array(
134 'Title' => 'Subjekty',
135 'Table' => 'Subject',
136 'DefaultSortColumn' => 'Name',
137 'Items' => array(
138 'Id' => array('Type' => 'Integer', 'Caption' => 'Identifikace', 'Default' => '', 'ReadOnly' => true),
139 'Name' => array('Type' => 'String', 'Caption' => 'Celé jméno', 'Default' => ''),
140 'AddressStreet' => array('Type' => 'String', 'Caption' => 'Ulice', 'Default' => ''),
141 'AddressTown' => array('Type' => 'String', 'Caption' => 'Město', 'Default' => ''),
142 'AddressPSC' => array('Type' => 'String', 'Caption' => 'PSČ', 'Default' => ''),
143 'AddressCountry' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => ''),
144 'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''),
145 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''),
146 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '', 'Null' => true),
147 'WWW' => array('Type' => 'Hyperlink', 'Caption' => 'WWW', 'Default' => ''),
148 'Note' => array('Type' => 'String', 'Caption' => 'Poznámka', 'Default' => ''),
149 'Customer' => array('Type' => 'TMemberListSubject', 'Caption' => 'Členové', 'Default' => ''),
150 'Operations' => array('Type' => 'TFinanceOperationListSubject', 'Caption' => 'Platby', 'Default' => ''),
151 'Invoices' => array('Type' => 'TFinanceInvoiceListSubject', 'Caption' => 'Faktury', 'Default' => ''),
152 ),
153 ));
154 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
155 'Title' => 'Alias domény',
156 'Table' => 'NetworkDomainAlias',
157 'Items' => array(
158 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
159 'Target' => array('Type' => 'String', 'Caption' => 'Cíl', 'Default' => ''),
160 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
161 ),
162 ));
163 $this->System->FormManager->RegisterClass('NetworkDevice', array(
164 'Title' => 'Síťové zařízení',
165 'Table' => 'NetworkDevice',
166 'Items' => array(
167 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
168 'Type' => array('Type' => 'TNetworkDeviceType', 'Caption' => 'Typ', 'Default' => '0'),
169 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '0'),
170 'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '0'),
171 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true),
172 'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '1'),
173 'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
174 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
175 'PermanentOnline' => array('Type' => 'Boolean', 'Caption' => 'Běží stále', 'Default' => '0'),
176 'Interfaces' => array('Type' => 'TInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''),
177 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '0', 'Null' => true),
178 ),
179 'Actions' => array(
180 array('Caption' => 'Dostupnost zařízení', 'URL' => '/network/availability/'),
181 ),
182 ));
183 $this->System->FormManager->RegisterClass('NetworkDeviceType', array(
184 'Title' => 'Typ síťového zařízení',
185 'Table' => 'NetworkDeviceType',
186 'Items' => array(
187 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
188 'ShowOnline' => array('Type' => 'Boolean', 'Caption' => 'Ukázat online', 'Default' => '0'),
189 'IconName' => array('Type' => 'String', 'Caption' => 'Jméno ikony', 'Default' => '0'),
190 ),
191 ));
192 $this->System->FormManager->RegisterClass('NetworkInterface', array(
193 'Title' => 'Síťové rozhraní',
194 'Table' => 'NetworkInterface',
195 'Items' => array(
196 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
197 'Type' => array('Type' => 'TNetworkInterfaceType', 'Caption' => 'Typ', 'Default' => '0'),
198 'MAC' => array('Type' => 'String', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
199 'LocalIP' => array('Type' => 'String', 'Caption' => 'IPv4', 'Default' => ''),
200 'IPv6' => array('Type' => 'String', 'Caption' => 'IPv6', 'Default' => ''),
201 'ExternalIP' => array('Type' => 'String', 'Caption' => 'Veřejná IPv4', 'Default' => ''),
202 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
203 'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
204 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true),
205 'Links1' => array('Type' => 'TNetworkLinkListInterface1', 'Caption' => 'Propojení 1', 'Default' => ''),
206 'Links2' => array('Type' => 'TNetworkLinkListInterface2', 'Caption' => 'Propojení 2', 'Default' => ''),
207 ),
208 ));
209 $this->System->FormManager->RegisterClass('NetworkInterfaceType', array(
210 'Title' => 'Typ síťového rozhraní',
211 'Table' => 'NetworkInterfaceType',
212 'Items' => array(
213 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
214 'MaxSpeed' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost', 'Default' => '0', 'Suffix' => 'Mbit/s'),
215 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'),
216 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'),
217 ),
218 ));
219 $this->System->FormManager->RegisterClass('NetworkSubnet', array(
220 'Title' => 'Podsítě',
221 'DefaultSortColumn' => 'Name',
222 'Table' => 'NetworkSubnet',
223 'Items' => array(
224 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
225 'AddressRange' => array('Type' => 'String', 'Caption' => 'Rozsah adres', 'Default' => ''),
226 'Mask' => array('Type' => 'Integer', 'Caption' => 'Prefix', 'Default' => ''),
227 'DHCP' => array('Type' => 'String', 'Caption' => 'DHCP', 'Default' => ''),
228 'Gateway' => array('Type' => 'String', 'Caption' => 'Brána', 'Default' => ''),
229 'WINS' => array('Type' => 'String', 'Caption' => 'WINS', 'Default' => ''),
230 'DNS' => array('Type' => 'String', 'Caption' => 'DNS', 'Default' => ''),
231 'Domain' => array('Type' => 'String', 'Caption' => 'Doména', 'Default' => ''),
232 'NTP' => array('Type' => 'String', 'Caption' => 'NTP', 'Default' => ''),
233 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '', 'Null' => true),
234 'ExtAddressRange' => array('Type' => 'String', 'Caption' => 'Vnější rozsah adres', 'Default' => ''),
235 'ExtMask' => array('Type' => 'String', 'Caption' => 'Vnější prefix', 'Default' => ''),
236 'AddressRangeIPv6' => array('Type' => 'String', 'Caption' => 'Rozsah adres IPv6', 'Default' => ''),
237 'Configure' => array('Type' => 'Boolean', 'Caption' => 'Nastavovat', 'Default' => ''),
238 ),
239 ));
240 $this->System->FormManager->RegisterClass('NetworkLink', array(
241 'Title' => 'Síťové propojení',
242 'Table' => 'NetworkLink',
243 'Items' => array(
244 'Type' => array('Type' => 'Integer', 'Caption' => 'Typ', 'Default' => '1'),
245 'Interface1' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => ''),
246 'Interface2' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => ''),
247 ),
248 ));
249 $this->System->FormManager->RegisterClass('NetworkDeviceConfig',array(
250 'Title' => 'Nastavení zařízení',
251 'Table' => 'NetworkDeviceConfig',
252 'DefaultSortColumn' => 'Time',
253 'Items' => array(
254 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
255 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
256 'ConfigFull' => array('Type' => 'Text', 'Caption' => 'Kompletní nastavení', 'Default' => ''),
257 'ConfigCompact' => array('Type' => 'Text', 'Caption' => 'Rozdílové nastavení', 'Default' => ''),
258 ),
259 ));
260 $this->System->FormManager->RegisterClass('NetworkSegment', array(
261 'Title' => 'Úsek sítě',
262 'Table' => 'NetworkSegment',
263 'Items' => array(
264 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
265 'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
266 'Parent' => array('Type' => 'TNetworkSegment', 'Caption' => 'Nadřazený', 'Default' => '', 'Null' => true),
267 'Users' => array('Type' => 'Integer', 'Caption' => 'Uživatelů', 'Default' => '0', 'ReadOnly' => true),
268 'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => '0', 'ReadOnly' => true, 'Suffix' => 'Wattů'),
269 'UsersOverheads' => array('Type' => 'Integer', 'Caption' => 'Podílníků', 'Default' => '0', 'ReadOnly' => true),
270 ),
271 ));
272
273
274 }
275
276 function Stop()
277 {
278 }
279}
Note: See TracBrowser for help on using the repository browser.