Changeset 739 for trunk/Modules


Ignore:
Timestamp:
May 23, 2015, 12:07:08 AM (10 years ago)
Author:
chronos
Message:
Location:
trunk/Modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Network/Network.php

    r738 r739  
    294294        'Refresh' => array('Type' => 'Integer', 'Caption' => 'Obnovení', 'Default' => '28800'),
    295295        'TTL' => array('Type' => 'Integer', 'Caption' => 'TTL', 'Default' => '86400', 'Suffix' => 'sekund'),
     296        'Servers' => array('Type' => 'TNetworkDomainServerList', 'Caption' => 'Servery', 'Default' => ''),
    296297      ),
    297298    ));
     
    301302      'Id' => 'Id',
    302303      'Name' => 'Name',
     304      'Filter' => '1',
     305    ));
     306    $this->System->FormManager->RegisterClass('NetworkDomainServer', array(
     307      'Title' => 'Doménový server',
     308      'Table' => 'NetworkDomainServer',
     309      'DefaultSortColumn' => 'Address',
     310      'DefaultSortOrder' => 1,
     311      'Items' => array(
     312        'Address' => array('Type' => 'String', 'Caption' => 'Adresa', 'Default' => ''),
     313        'Domain' => array('Type' => 'TNetworkDomain', 'Caption' => 'Doména', 'Default' => ''),
     314        'Sequence' => array('Type' => 'Integer', 'Caption' => 'Pořadí', 'Default' => '1'),
     315      ),
     316    ));
     317    $this->System->FormManager->RegisterFormType('TNetworkDomainServerList', array(
     318      'Type' => 'ManyToOne',
     319      'Table' => 'NetworkDomainServer',
     320      'Id' => 'Id',
     321      'Ref' => 'Domain',
    303322      'Filter' => '1',
    304323    ));
  • trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php

    r738 r739  
    1313$Routerboard->Debug = true;
    1414
    15 // Devices, Interfaces
    16 $Items = array();
    17 $DbResult = $System->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '.
    18   'JOIN `NetworkDevice` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '.
    19   'WHERE `NetworkDevice`.`Used`=1');
    20 while($Interface = $DbResult->fetch_assoc())
     15$DbResult = $System->Database->query('SELECT * FROM `NetworkDomain`');
     16while($Domain = $DbResult->fetch_assoc())
    2117{
    22   $Name = $Interface['DeviceName'];
    23   if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    24   $Name .= '.zdechov.net';
    25   $Items[] = array('name' => $Name, 'address' => $Interface['LocalIP'], 'ttl' => '1d');
     18  $DomainName = $Domain['Name'];
     19
     20  // Get full domain name from parent items
     21  $CurrentDomain = $Domain;
     22  while($CurrentDomain['Parent'] > 0)
     23  {
     24    $DbResult2 = $System->Database->query('SELECT * FROM `NetworkDomain` WHERE `Id`='.$CurrentDomain['Parent']);
     25    $CurrentDomain = $DbResult2->fetch_assoc();
     26    $DomainName .= '.'.$CurrentDomain['Name'];
     27  }
     28
     29  // Devices, Interfaces
     30  $Items = array();
     31  $DbResult2 = $System->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '.
     32    'JOIN `NetworkDevice` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '.
     33    'WHERE `NetworkDevice`.`Used`=1');
     34  while($Interface = $DbResult2->fetch_assoc())
     35  {
     36    $Name = $Interface['DeviceName'];
     37    if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     38    $Name .= '.'.$DomainName;
     39    $Items[] = array('name' => $Name, 'address' => $Interface['LocalIP'], 'ttl' => '1d');
     40  }
     41
     42  // Domain aliases
     43  $DbResult2 = $System->Database->query('SELECT `NetworkDomainAlias`.*, `NetworkInterface`.`LocalIP` AS `LocalIP` FROM `NetworkDomainAlias` '.
     44    'JOIN `NetworkDevice` ON `NetworkDomainAlias`.`Target`=`NetworkDevice`.`Name` '.
     45    'JOIN `NetworkInterface` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '.
     46    'WHERE `NetworkDevice`.`Used`=1');
     47  while($Alias = $DbResult2->fetch_assoc())
     48  {
     49    $Name = $Alias['Name'];
     50    $Name .= '.'.$DomainName;
     51    $Items[] = array('name' => $Name, 'address' => $Alias['LocalIP'], 'ttl' => $Domain['TTL']);
     52  }
     53
     54  $DbResult2 = $System->Database->query('SELECT * FROM `NetworkDomainServer` WHERE `Domain`='.$Domain['Id']);
     55  if($DbResult2->num_rows > 0)
     56  {
     57    $Server = $DbResult2->fetch_assoc();
     58    $Routerboard->HostName = $Server['Address'];
     59    $Routerboard->ListUpdate($Path, array('name', 'address', 'ttl'), $Items);
     60  }
    2661}
    27 
    28 // Domain aliases
    29 $DbResult = $System->Database->query('SELECT `NetworkDomainAlias`.*, `NetworkInterface`.`LocalIP` AS `LocalIP` FROM `NetworkDomainAlias` '.
    30   'JOIN `NetworkDevice` ON `NetworkDomainAlias`.`Target`=`NetworkDevice`.`Name` '.
    31   'JOIN `NetworkInterface` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '.
    32   'WHERE `NetworkDevice`.`Used`=1');
    33 while($Alias = $DbResult->fetch_assoc())
    34 {
    35   $Name = $Alias['Name'];
    36   $Name .= '.zdechov.net';
    37   $Items[] = array('name' => $Name, 'address' => $Alias['LocalIP'], 'ttl' => '1d');
    38 }
    39 
    40 $Routerboard->HostName = '192.168.10.1';
    41 $Routerboard->ListUpdate($Path, array('name', 'address', 'ttl'), $Items);
Note: See TracChangeset for help on using the changeset viewer.