- Timestamp:
- Apr 15, 2013, 11:08:49 PM (12 years ago)
- Location:
- trunk/Modules/NetworkConfigRouterOS
- Files:
-
- 2 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 7 … … 18 18 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 19 19 20 $DbResult3 = $ Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`');20 $DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`'); 21 21 while($Subnet = $DbResult3->fetch_assoc()) 22 22 { … … 31 31 $Properties['expires-after'] = time() - (24 * 3600 - ConvertExpireTime2($Properties['expires-after'])); 32 32 echo('MAC: '.$Properties['active-mac-address']."\n"); 33 $DbRows2 = $ Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"');33 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"'); 34 34 if($DbRows2->num_rows > 0) 35 35 { 36 36 $Interface = $DbRows2->fetch_assoc(); 37 37 $InterfaceId = $Interface['Id']; 38 $DbRows2 = $ Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId);38 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId); 39 39 if($DbRows2->num_rows > 0) 40 40 { 41 $ Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1));42 } else $ Database->insert('NetworkInterfacePortable', array('NetworkInterface' => $InterfaceId, 'DynamicIP' => $Properties['active-address'], 'Time' => TimeToMysqlDateTime($Properties['expires-after']), 'Update' => 1));41 $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1)); 42 } else $System->Database->insert('NetworkInterfacePortable', array('NetworkInterface' => $InterfaceId, 'DynamicIP' => $Properties['active-address'], 'Time' => TimeToMysqlDateTime($Properties['expires-after']), 'Update' => 1)); 43 43 } else echo('Not registred'."\n"); 44 44 //print_r($Properties); … … 52 52 $MangleRule = array(); 53 53 $NATRule = array(); 54 $DbRows = $ 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');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 55 while($Portable = $DbRows->fetch_assoc()) 56 56 { … … 68 68 $Routerboard->ExecuteBatch($NATRule); 69 69 $Routerboard->ExecuteBatch($MangleRule); 70 $ Database->query('UPDATE NetworkInterfacePortable SET Update=0');70 $System->Database->query('UPDATE NetworkInterfacePortable SET Update=0'); 71 71 72 72 ?>
Note:
See TracChangeset
for help on using the changeset viewer.