- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r738 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 5 include_once(dirname(__FILE__).'/../Routerboard.php'); … … 11 11 { 12 12 $TimeParts = explode(':', $Time); 13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]); 14 14 } 15 15 … … 19 19 20 20 $DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`'); 21 while ($Subnet = $DbResult3->fetch_assoc())21 while ($Subnet = $DbResult3->fetch_assoc()) 22 22 { 23 23 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 24 24 $Routerboard->HostName = $Subnet['DHCP']; 25 25 $List = $Routerboard->ListGet($Path, array('address', 'active-mac-address', 'active-address', 'expires-after', 'server', 'dynamic')); 26 foreach ($List as $Properties)26 foreach ($List as $Properties) 27 27 { 28 if ($Properties['dynamic'] == 'true')28 if ($Properties['dynamic'] == 'true') 29 29 //and ($Properties['address'] != $Properties['active-address'])) 30 30 { … … 32 32 echo('MAC: '.$Properties['active-mac-address']."\n"); 33 33 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"'); 34 if ($DbRows2->num_rows > 0)34 if ($DbRows2->num_rows > 0) 35 35 { 36 36 $Interface = $DbRows2->fetch_assoc(); 37 37 $InterfaceId = $Interface['Id']; 38 38 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId); 39 if ($DbRows2->num_rows > 0)39 if ($DbRows2->num_rows > 0) 40 40 { 41 41 $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1)); … … 53 53 $NATRule = array(); 54 54 $DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1'); 55 while ($Portable = $DbRows->fetch_assoc())55 while ($Portable = $DbRows->fetch_assoc()) 56 56 { 57 57 $Name = $Portable['DeviceName']; 58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName']; 59 59 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-in"] to-addresses='.$Portable['DynamicIP']); 60 60 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-out"] src-address='.$Portable['DynamicIP']);
Note:
See TracChangeset
for help on using the changeset viewer.