Changeset 873 for trunk/Modules/Network


Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
Location:
trunk/Modules/Network
Files:
5 edited

Legend:

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

    r833 r873  
    1111  function Show()
    1212  {
    13     if(!$this->System->User->CheckPermission('Network', 'ShowHostList'))
    14       return('Nemáte oprávnění');
     13    if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))
     14      return ('Nemáte oprávnění');
    1515
    16     if(array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
     16    if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
    1717      else $Where = '';
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
     
    2222      'LEFT JOIN User ON Member.ResponsibleUser = User.Id '.
    2323      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name');
    24     while($Device = $DbResult->fetch_assoc())
     24    while ($Device = $DbResult->fetch_assoc())
    2525    {
    26       if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     26      if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
    2727      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']);
    2828      $DbRow = $DbResult2->fetch_row();
    29       if($DbRow[0] == 1)
     29      if ($DbRow[0] == 1)
    3030      {
    3131        $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    3232        $Interface = $DbResult2->fetch_assoc();
    33         if($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = '&nbsp;';
    34         if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
    35         if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     33        if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = '&nbsp;';
     34        if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
     35        if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    3636        $InterfaceName = $Device['Name'];
    37         if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     37        if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    3838        $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Interface['ExternalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
    3939      } else
     
    4141        $Output .= '<tr><td colspan="3" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
    4242        $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    43         while($Interface = $DbResult2->fetch_assoc())
     43        while ($Interface = $DbResult2->fetch_assoc())
    4444        {
    45           if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
    46           if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     45          if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
     46          if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    4747          $InterfaceName = $Device['Name'];
    48           if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     48          if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    4949          $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
    5050        }
     
    5252    }
    5353    $Output .= '</table></div>';
    54     return($Output);
     54    return ($Output);
    5555  }
    5656}
  • trunk/Modules/Network/Hosting.php

    r790 r873  
    1111    $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>';
    1212    $DbResult = $this->Database->query('SELECT NetworkDevice.Name as ServerName, HostedProject.Name, HostedProject.Homepage, HostedProject.TimeCreate, User.Name AS UserName FROM HostedProject JOIN User ON User.Id = HostedProject.User JOIN NetworkDevice ON NetworkDevice.Id = HostedProject.Server ORDER BY HostedProject.Name');
    13     while($DbRow = $DbResult->fetch_assoc())
     13    while ($DbRow = $DbResult->fetch_assoc())
    1414    {
    1515      $Output .= '<tr><td><a href="'.$DbRow['Homepage'].'">'.$DbRow['Name'].'</a></td><td>'.HumanDate($DbRow['TimeCreate']).'</td><td>'.$DbRow['ServerName'].'</td><td>'.$DbRow['UserName'].'</td></tr>';
    1616    }
    1717    $Output .= '</table>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020}
  • trunk/Modules/Network/Network.php

    r871 r873  
    2525    '<tr><th/><br/>SSID<br/><br/></th>';
    2626    $ChannelList = array();
    27     if(!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
    28     if($_GET['range'] == 'a')
     27    if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
     28    if ($_GET['range'] == 'a')
    2929    {
    3030      $Where = '(Frequency < 5000)';
    31       for($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     31      for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    3232    }
    33     if($_GET['range'] == 'bc')
     33    if ($_GET['range'] == 'bc')
    3434    {
    3535      $Where = '(Frequency >= 5000) AND (Frequency <= 5350)';
    36       for($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     36      for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    3737    }
    38     if($_GET['range'] == 'd')
     38    if ($_GET['range'] == 'd')
    3939    {
    4040      $Where = '(Frequency >= 5470)';
    41       for($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     41      for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    4242    }
    4343
    44     foreach($ChannelList as $Frequency)
     44    foreach ($ChannelList as $Frequency)
    4545    {
    4646      $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
     
    4848    $Output .= '</tr>';
    4949    $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`');
    50     while($DbRow = $DbResult->fetch_assoc())
     50    while ($DbRow = $DbResult->fetch_assoc())
    5151    {
    5252      $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where);
    53       while($DbRow2 = $DbResult2->fetch_assoc())
     53      while ($DbRow2 = $DbResult2->fetch_assoc())
    5454      {
    5555        $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower'];
    5656        $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper'];
    5757        $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
    58         foreach($ChannelList as $Frequency)
     58        foreach ($ChannelList as $Frequency)
    5959        {
    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';
     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';
    6363            else $Color = '#ffffff';
    6464          $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
     
    6969    }
    7070    $Output .= '</table>';
    71     return($Output);
     71    return ($Output);
    7272  }
    7373}
     
    8181  function Show()
    8282  {
    83     if(count($this->System->PathItems) > 1)
     83    if (count($this->System->PathItems) > 1)
    8484    {
    8585      $Output = $this->PageNotFound();
    8686    } else $Output = $this->ShowInformation();
    87     return($Output);
     87    return ($Output);
    8888  }
    8989
    9090  function ShowInformation()
    9191  {
    92     if(!$this->System->User->CheckPermission('Network', 'ShowInfo'))
    93       return('Nemáte oprávnění');
     92    if (!$this->System->User->CheckPermission('Network', 'ShowInfo'))
     93      return ('Nemáte oprávnění');
    9494
    9595    $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />';
    9696    $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />';
    9797    $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />';
    98     return($Output);
     98    return ($Output);
    9999  }
    100100}
     
    862862      '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'.
    863863      'ORDER BY `Name` ASC');
    864     if($DbResult3->num_rows > 0)
     864    if ($DbResult3->num_rows > 0)
    865865    {
    866866      $Output .= $Title.'<br/>';
    867867      $Output .= '<table>'.
    868868        '<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";
    869       while($Item = $DbResult3->fetch_assoc())
     869      while ($Item = $DbResult3->fetch_assoc())
    870870      {
    871871        $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
     
    874874          sprintf('%02d', floor($Duration % 60));
    875875        $Days = floor($Duration / (60 * 60 * 24));
    876         if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
     876        if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
    877877
    878878        $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
     
    895895    $Output .= $StillOffline['Report'];
    896896    $Offline = $this->OnlineList('Offline', 0, -1, 0);
    897     return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));
     897    return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));
    898898  }
    899899
     
    918918      $Output .= '<table>'.
    919919        '<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";
    920       while($Item = $DbResult3->fetch_assoc())
     920      while ($Item = $DbResult3->fetch_assoc())
    921921      {
    922922        $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
     
    925925          sprintf('%02d', floor($Duration % 60));
    926926        $Days = floor($Duration / (60 * 60 * 24));
    927         if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
     927        if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
    928928
    929929        $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
     
    947947    $Output .= $StillOffline['Report'];
    948948    $Offline = $this->PortCheckList('Offline', 0, -1, 0);
    949     return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));
     949    return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));
    950950  }
    951951}
  • trunk/Modules/Network/Subnet.php

    r825 r873  
    3636
    3737    $DbResult = $this->Database->query($Query);
    38     while($Subnet = $DbResult->fetch_assoc())
     38    while ($Subnet = $DbResult->fetch_assoc())
    3939    {
    4040      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')');
     
    5454    $Output .= '</table>';
    5555    $Output .= $PageList['Output'];
    56     return($Output);
     56    return ($Output);
    5757  }
    5858}
  • trunk/Modules/Network/UserHosts.php

    r738 r873  
    1515    global $Config;
    1616
    17     if($this->System->User->User['Id'] == '') return($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));
     17    if ($this->System->User->User['Id'] == '') return ($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1919    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
     
    2121      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
    2222      'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');
    23     while($Device = $DbResult->fetch_assoc())
     23    while ($Device = $DbResult->fetch_assoc())
    2424    {
    25       if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     25      if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
    2626      $Output .= '<tr><td colspan="4" style="text-align: left; font-weight: bold; '.
    2727        $Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>';
    2828      $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    29       while($Interface = $DbResult2->fetch_assoc())
     29      while ($Interface = $DbResult2->fetch_assoc())
    3030      {
    31         if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     31        if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    3232        $InterfaceName = $Device['Name'];
    33         if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     33        if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    3434        $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.
    3535          $InterfaceName.'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'.
     
    3939    }
    4040    $Output .= '</table></div>';
    41     return($Output);
     41    return ($Output);
    4242  }
    4343}
Note: See TracChangeset for help on using the changeset viewer.