Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php

    r819 r873  
    77    $Timeout = 1;
    88    $State = 0;
    9     if($Protocol == 'tcp') $Prefix = '';
    10       else if($Protocol == 'udp') $Prefix = 'udp://';
     9    if ($Protocol == 'tcp') $Prefix = '';
     10      else if ($Protocol == 'udp') $Prefix = 'udp://';
    1111      else throw new Exception('Unsupported protocol "'.$Protocol.'"');
    12     if($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))
     12    if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))
    1313    {
    1414      fclose($Socket);
    1515      $State = 1;
    1616    }
    17     return($State);
     17    return ($State);
    1818  }
    1919 
     
    2929      'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id`=`NetworkPort`.`Interface` '.
    3030      'WHERE (`NetworkPort`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")');
    31     while($DbRow = $DbResult->fetch_assoc())
     31    while ($DbRow = $DbResult->fetch_assoc())
    3232      $Ports[$DbRow['Id']] = $DbRow;
    3333
    34     foreach($Ports as $Index => $Port)
     34    foreach ($Ports as $Index => $Port)
    3535    {
    36       if($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';
    37       if($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';
     36      if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';
     37      if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';
    3838      $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']);
    3939
    4040      // Update last online time if still online
    41       if($Port['NewOnline'])
     41      if ($Port['NewOnline'])
    4242      {
    4343        $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"',
     
    4646
    4747      // Update UpDown table
    48       if($Port['Online'] != $Port['NewOnline'])
     48      if ($Port['Online'] != $Port['NewOnline'])
    4949      {
    5050        // Online state changed
     
    6565    $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '.
    6666      '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")');
    67     while($DbRow = $DbResult->fetch_assoc())
     67    while ($DbRow = $DbResult->fetch_assoc())
    6868    {
    6969      echo('Port '.$DbRow['Number'].' online but time not updated.'."\n");
     
    7171    $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 0) AND '.
    7272      '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")');
    73     while($DbRow = $DbResult->fetch_assoc())
     73    while ($DbRow = $DbResult->fetch_assoc())
    7474    {
    7575      echo('Port '.$DbRow['Number'].' not online but time updated.'."\n");
Note: See TracChangeset for help on using the changeset viewer.