Changeset 781 for trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
- Timestamp:
- Jan 8, 2016, 11:00:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r738 r781 1 1 <?php 2 2 3 if(isset($_SERVER['REMOTE_ADDR'])) die();4 include_once(dirname(__FILE__).'/../../../Application/System.php');5 $System = new System();6 $System->ShowPage = false;7 $System->Run();8 $Path = array('ip', 'dhcp-server', 'lease');9 3 10 $Routerboard = new Routerboard(); 11 $Routerboard->UserName = $Config['MainRouter']['UserName']; 12 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 13 $Routerboard->Debug = true; 4 class ConfigRouterOSDHCP extends NetworkConfigItem 5 { 6 function Run() 7 { 8 $Path = array('ip', 'dhcp-server', 'lease'); 14 9 15 $DbResult = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1'); 16 while($Subnet = $DbResult->fetch_assoc()) 17 { 18 echo($Subnet['DHCP']); 19 $Routerboard->HostName = $Subnet['DHCP']; 20 $Items = array(); 21 $Server = 'dhcp'.$Subnet['Id']; 22 $DbResult2 = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` '. 23 ' LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE '. 24 ' CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 25 while($Interface = $DbResult2->fetch_assoc()) 26 { 27 $Name = $Interface['DeviceName']; 28 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 29 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name); 10 $Routerboard = new Routerboard(); 11 $Routerboard->UserName = $this->System->Config['MainRouter']['UserName']; 12 $Routerboard->Timeout = $this->System->Config['MainRouter']['ConnectTimeout']; 13 $Routerboard->Debug = true; 14 15 $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1'); 16 while($Subnet = $DbResult->fetch_assoc()) 17 { 18 echo($Subnet['DHCP']); 19 $Routerboard->HostName = $Subnet['DHCP']; 20 $Items = array(); 21 $Server = 'dhcp'.$Subnet['Id']; 22 $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` '. 23 ' LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE '. 24 ' CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 25 while($Interface = $DbResult2->fetch_assoc()) 26 { 27 $Name = $Interface['DeviceName']; 28 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 29 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name); 30 } 31 32 print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => $Server, 'dynamic' => 'no'))); 33 echo("\n"); 34 } 30 35 } 36 } 31 37 32 print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => $Server, 'dynamic' => 'no')));33 echo("\n");34 }
Note:
See TracChangeset
for help on using the changeset viewer.