- Timestamp:
- Jun 3, 2014, 10:36:43 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r658 r663 30 30 else $Online = 0; 31 31 32 $DbResult = $System->Database->select('NetworkInterface', '`Id`,`Online`', '`LocalIP` = "'.$Properties['host'].'";');33 while($DbRow = $DbResult->fetch_assoc())34 {35 $LastOnline = $DbRow['Online'];36 $Interface = $DbRow['Id'];37 38 // Record state changes39 if($Online != $LastOnline)40 {41 $System->Database->insert('NetworkInterfaceUpDown', array(42 'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime)));43 }44 }45 46 32 if($Online) 47 33 { 34 // Set only online state 35 $DbResult = $System->Database->select('NetworkInterface', '`Id`, `Online`', '`LocalIP` = "'.$Properties['host'].'";'); 36 while($DbRow = $DbResult->fetch_assoc()) 37 { 38 $LastOnline = $DbRow['Online']; 39 $Interface = $DbRow['Id']; 40 41 // Record state changes 42 if($Online != $LastOnline) 43 { 44 $System->Database->insert('NetworkInterfaceUpDown', array( 45 'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime))); 46 } 47 } 48 48 49 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 49 50 array('Online' => 1, 'LastOnline' => TimeToMysqlDateTime($StartTime))); 50 51 } 51 52 } 53 } 54 55 // Set offline state for not updated interfaces 56 $DbResult = $System->Database->select('NetworkInterface', 'Id', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"'); 57 while($DbRow = $DbResult->fetch_assoc()) 58 { 59 $System->Database->insert('NetworkInterfaceUpDown', array( 60 'Interface' => $DbRow['Id'], 'State' => 0, 'Time' => TimeToMysqlDateTime($StartTime))); 52 61 } 53 62 $DbResult = $System->Database->update('NetworkInterface', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0));
Note:
See TracChangeset
for help on using the changeset viewer.