Ignore:
Timestamp:
Aug 2, 2009, 10:28:58 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Vylepšena třída Routerboard pro načítání z/do nastavení do routerů Mikrotik.
  • Upraveno: Skripty pro generování DHCP a Netwatch routerů byly upraveny pro použití třídy Routerboar.
  • Upraveno: Zobrazování editačních políček formuláře lépe viditelné v IE8.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/system/generators/dhcp_routerboard.php

    r213 r239  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include_once('../../global.php');
     4include('../../global.php');
     5include('../routerboard.php');
     6$Path = array('ip', 'dhcp-server', 'lease');
     7
     8$Routerboard = new Routerboard();
     9$Routerboard->UserName = $Config['MainRouter']['UserName'];
     10$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    511
    612$DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0');
     
    814{
    915  echo($Subnet['DHCP']);
     16  $Routerboard->HostName = $Subnet['DHCP'];
    1017  $I = explode('.', $Subnet['AddressRange']);
    1118  $I = $I[2];
    12   $Commands = array();
    13   $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}';
     19  $Items = array();
    1420  $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (`LocalIP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`');
    1521  while($Interface = $DbResult2->fetch_assoc())
    1622  {
    17     $Commands[] = '/ip dhcp-server lease add mac-address='.$Interface['MAC'].' address='.$Interface['LocalIP'].' server=dhcp'.$I.' comment='.$Interface['DeviceName'].'-'.$Interface['Name'];
     23    $Name = $Interface['DeviceName'];
     24    if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     25    $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => 'dhcp'.$I, 'comment' => $Name);
    1826  }
    19   $Commands = implode(';', $Commands);
    20   $Command = '/usr/bin/ssh -o ConnectTimeout=5 -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"';
    21   //echo($Command."\n");
    22   $Output = '';
    23   exec($Command, $Output);
    24   print_r($Output);
     27 
     28  print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => 'dhcp'.$I)));   
    2529  echo("\n");
    2630}
Note: See TracChangeset for help on using the changeset viewer.