Changeset 739


Ignore:
Timestamp:
May 23, 2015, 12:07:08 AM (9 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r738 r739  
    11<?php
    22
    3 $Revision = 738; // Subversion revision
    4 $DatabaseRevision = 736; // SQL structure revision
    5 $ReleaseTime = strtotime('2015-04-14');
     3$Revision = 739; // Subversion revision
     4$DatabaseRevision = 739; // SQL structure revision
     5$ReleaseTime = strtotime('2015-05-22');
  • trunk/Common/Setup/Updates.php

    r738 r739  
    13431343  $Manager->Execute('ALTER TABLE `NetworkLinkType`
    13441344MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
     1345}
     1346
     1347function UpdateTo739($Manager)
     1348{
     1349  $Manager->Execute('ALTER TABLE `NetworkDomain` ADD KEY (`Parent`);');
     1350  $Manager->Execute('ALTER TABLE `NetworkDomain` ADD FOREIGN KEY (`Parent`) REFERENCES `NetworkDomain`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1351
     1352  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDomainServer` (
     1353  `Id` int(11) NOT NULL AUTO_INCREMENT,
     1354  `Address` varchar(255) NOT NULL,
     1355  `Domain` int(11) NOT NULL,
     1356  `Sequence` int(11) NOT NULL
     1357) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
     1358
     1359  $Manager->Execute('ALTER TABLE `NetworkDomainServer`
     1360 ADD PRIMARY KEY (`Id`), ADD KEY `Domain` (`Domain`);');
     1361
     1362  $Manager->Execute('ALTER TABLE `NetworkDomainServer`
     1363ADD CONSTRAINT `NetworkDomainServer_ibfk_1` FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`);');
     1364
    13451365}
    13461366
     
    14111431      731 => array('Revision' => 735, 'Function' => 'UpdateTo735'),
    14121432      735 => array('Revision' => 736, 'Function' => 'UpdateTo736'),
     1433      736 => array('Revision' => 739, 'Function' => 'UpdateTo739'),
    14131434    ));
    14141435  }
  • 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.