- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r819 r873 7 7 $Timeout = 1; 8 8 $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://'; 11 11 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)) 13 13 { 14 14 fclose($Socket); 15 15 $State = 1; 16 16 } 17 return ($State);17 return ($State); 18 18 } 19 19 … … 29 29 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id`=`NetworkPort`.`Interface` '. 30 30 'WHERE (`NetworkPort`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")'); 31 while ($DbRow = $DbResult->fetch_assoc())31 while ($DbRow = $DbResult->fetch_assoc()) 32 32 $Ports[$DbRow['Id']] = $DbRow; 33 33 34 foreach ($Ports as $Index => $Port)34 foreach ($Ports as $Index => $Port) 35 35 { 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'; 38 38 $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']); 39 39 40 40 // Update last online time if still online 41 if ($Port['NewOnline'])41 if ($Port['NewOnline']) 42 42 { 43 43 $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"', … … 46 46 47 47 // Update UpDown table 48 if ($Port['Online'] != $Port['NewOnline'])48 if ($Port['Online'] != $Port['NewOnline']) 49 49 { 50 50 // Online state changed … … 65 65 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '. 66 66 '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")'); 67 while ($DbRow = $DbResult->fetch_assoc())67 while ($DbRow = $DbResult->fetch_assoc()) 68 68 { 69 69 echo('Port '.$DbRow['Number'].' online but time not updated.'."\n"); … … 71 71 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 0) AND '. 72 72 '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")'); 73 while ($DbRow = $DbResult->fetch_assoc())73 while ($DbRow = $DbResult->fetch_assoc()) 74 74 { 75 75 echo('Port '.$DbRow['Number'].' not online but time updated.'."\n");
Note:
See TracChangeset
for help on using the changeset viewer.