Ignore:
Timestamp:
Jan 17, 2015, 9:24:47 PM (10 years ago)
Author:
chronos
Message:
  • Added: NetworkDomain table for managing multiple network domains. It is not completed and linked to real functionality yet.
  • Added: ModuleLinks and Model tables as preparation for better modules and models in-database representation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Network/Network.php

    r715 r731  
    1515  function Show()
    1616  {
    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 
     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>';
    4559        foreach($ChannelList as $Frequency)
    4660        {
    47           $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
     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            else $Color = '#ffffff';
     65          $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
    4866        }
    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>';
     67                   
     68        $Output .= '</tr>';       
     69      }
     70    }
     71    $Output .= '</table>';
    7372    return($Output);
    7473  }
     
    250249      ),
    251250    ));
    252     $this->System->FormManager->RegisterClass('NetworkDeviceConfig',array(
     251    $this->System->FormManager->RegisterClass('NetworkDeviceConfig', array(
    253252      'Title' => 'Nastavení zařízení',
    254253      'Table' => 'NetworkDeviceConfig',
     
    261260        'ConfigCompact' => array('Type' => 'Text', 'Caption' => 'Rozdílové nastavení', 'Default' => ''),
    262261      ),
     262    ));
     263    $this->System->FormManager->RegisterClass('NetworkDomain', array(
     264      'Title' => 'Síťová doména',
     265      'Table' => 'NetworkDomain',
     266      'DefaultSortColumn' => 'Name',
     267      'DefaultSortOrder' => 1,
     268      'Items' => array(
     269        'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
     270        'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
     271        'Parent' => array('Type' => 'TNetworkDomain', 'Caption' => 'Nadřazená doména', 'Default' => '', 'Null' => true),
     272        'Serial' => array('Type' => 'Integer', 'Caption' => 'Sériové číslo', 'Default' => '1'),
     273        'Minimum' => array('Type' => 'Integer', 'Caption' => 'Minimum', 'Default' => '10800'),
     274        'Retry' => array('Type' => 'Integer', 'Caption' => 'Opakování', 'Default' => '7200'),
     275        'Expire' => array('Type' => 'Integer', 'Caption' => 'Čas vypršení', 'Default' => '2419200'),
     276        'Refresh' => array('Type' => 'Integer', 'Caption' => 'Obnovení', 'Default' => '28800'),
     277        'TTL' => array('Type' => 'Integer', 'Caption' => 'TTL', 'Default' => '86400', 'Suffix' => 'sekund'),
     278      ),
     279    ));
     280    $this->System->FormManager->RegisterFormType('TNetworkDomain', array(
     281      'Type' => 'Reference',
     282      'Table' => 'NetworkDomain',
     283      'Id' => 'Id',
     284      'Name' => 'Name',
     285      'Filter' => '1',
    263286    ));
    264287    $this->System->FormManager->RegisterClass('DeviceAPIType', array(
     
    358381        'Name' => 'Name',
    359382        'Filter' => '1',
    360     ));   
     383    ));
    361384    $this->System->FormManager->RegisterFormType('TDeviceList', array(
    362385      'Type' => 'ManyToOne',
Note: See TracChangeset for help on using the changeset viewer.