Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r854 r873  
    1818        "\t\t\t".$DNS['Minimum']."\t; minimum\n".
    1919        "\t\t\t)\n";
    20     foreach($DNS['NameServer'] as $NameServer)
     20    foreach ($DNS['NameServer'] as $NameServer)
    2121    {
    2222      $Output .= "\t\tIN\tNS\t".strtolower($NameServer).".\n";
     
    2626    // Mail server records
    2727    $Priority = 10;
    28     foreach($DNS['MailServer'] as $MailServer)
     28    foreach ($DNS['MailServer'] as $MailServer)
    2929    {
    3030      $Output .="\t\t\tMX\t".$Priority." ".strtolower($MailServer).".\n";
     
    3434        $DNS['Domain'].".\tIN\tTXT\t\"v=spf1 mx -all\"\n".
    3535        $DNS['Domain'].".\tIN\tSPF\t\"v=spf1 mx -all\"\n";
    36     foreach($DNS['MailServer'] as $MailServer)
     36    foreach ($DNS['MailServer'] as $MailServer)
    3737    {
    3838      $Output .= $MailServer.".\tIN\tTXT\t\"v=spf1 a -all\"\n".
     
    4545
    4646    // IPv4 host list
    47     foreach($DNS['Host'] as $Host)
    48     {
    49       if(strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
     47    foreach ($DNS['Host'] as $Host)
     48    {
     49      if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
    5050      $Output .= strtolower($Host['Name'])."\tIN\tA\t".$Host['Address']."\n";
    5151    }
    5252
    5353    // IPv6 host list
    54     foreach($DNS['Host'] as $Host)
    55     {
    56       if(strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
    57       if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     54    foreach ($DNS['Host'] as $Host)
     55    {
     56      if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
     57      if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
    5858        $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n";
    5959    }
    6060
    6161    // Alias list
    62     foreach($DNS['Alias'] as $Alias)
    63     {
    64       if(strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";
     62    foreach ($DNS['Alias'] as $Alias)
     63    {
     64      if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";
    6565      $Output .= strtolower($Alias['Name'])."\tIN\tCNAME\t".strtolower($Alias['Target'])."\n";
    6666    }
     
    7171
    7272    // Generate reverse DNS records
    73     foreach($DNS['Network'] as $Network)
     73    foreach ($DNS['Network'] as $Network)
    7474    {
    7575      $Parts = explode('.', $Network);
     
    8383      "\t\t\t\t".$DNS['Minimum']."\t; minimum\n".
    8484      "\t\t\t\t)\n";
    85       foreach($DNS['ReverseNameServer'] as $NameServer)
     85      foreach ($DNS['ReverseNameServer'] as $NameServer)
    8686      {
    87         if(substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
     87        if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
    8888          $Output .= "@\tIN\tNS\t".$NameServer.".\n";
    8989        else $Output .= "\tIN\tNS\t".$NameServer.".\n";
    9090      }
    91       foreach($DNS['Host'] as $Host)
    92         if(substr($Host['Address'], 0, strlen($Network)) == $Network)
     91      foreach ($DNS['Host'] as $Host)
     92        if (substr($Host['Address'], 0, strlen($Network)) == $Network)
    9393        {
    9494          $AddressParts = explode('.', $Host['Address']);
     
    103103
    104104    // Generate reverse DNS IPv6 records
    105     foreach($DNS['IPv6Network'] as $Network)
     105    foreach ($DNS['IPv6Network'] as $Network)
    106106    {
    107107      $Parts = explode('/', $Network);
     
    117117      "\t\t\t\t".$DNS['Minimum']."\t; minimum\n".
    118118      "\t\t\t\t)\n";
    119       foreach($DNS['ReverseNameServer'] as $NameServer)
     119      foreach ($DNS['ReverseNameServer'] as $NameServer)
    120120      {
    121         if(substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
     121        if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
    122122          $Output .= "@\tIN\tNS\t".$NameServer.".\n";
    123123        else $Output .= "\tIN\tNS\t".$NameServer.".\n";
    124124      }
    125       foreach($DNS['Host'] as $Host)
    126         if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     125      foreach ($DNS['Host'] as $Host)
     126        if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
    127127        {
    128128          $Addr = new NetworkAddressIPv6();
     
    161161    $BaseDir = '/var/cache/bind';
    162162    //$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named';
    163     if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
     163    if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
    164164    $MailServer = 'centrala';
    165165
     
    193193      'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    194194      'WHERE (`NetworkInterface`.`LocalIP` <> "") AND (`NetworkDevice`.`Used` = 1)');
    195     while($Interface = $DbResult->fetch_assoc())
    196     {
    197       $Name = $Interface['DeviceName'];
    198       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     195    while ($Interface = $DbResult->fetch_assoc())
     196    {
     197      $Name = $Interface['DeviceName'];
     198      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    199199      $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'],
    200200          'IPv6' => $Interface['IPv6']);
     
    205205        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    206206        'WHERE (`NetworkInterface`.`ExternalIP` <> "") AND (`NetworkDevice`.`Used` = 1)');
    207     while($Interface = $DbResult->fetch_assoc())
    208     {
    209       $Name = $Interface['DeviceName'];
    210       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     207    while ($Interface = $DbResult->fetch_assoc())
     208    {
     209      $Name = $Interface['DeviceName'];
     210      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    211211      $LocalDNS['Host'][] = array('Name' => $Name.'-ext', 'Address' => $Interface['ExternalIP']);
    212212    }
     
    216216     $DbResult = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '.
    217217     'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.CZFreeIP <> ""');
    218      while($Interface = $DbResult->fetch_assoc())
     218     while ($Interface = $DbResult->fetch_assoc())
    219219     {
    220220     $Name = $Interface['DeviceName'];
    221      if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     221     if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    222222     $LocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['CZFreeIP']);
    223223     }
     
    226226    // Domain aliases
    227227    $DbResult = $this->Database->select('NetworkDomainAlias', '*');
    228     while($Alias = $DbResult->fetch_assoc())
     228    while ($Alias = $DbResult->fetch_assoc())
    229229    {
    230230      $LocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    257257        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE '.
    258258        '(`NetworkInterface`.`ExternalIP` != "") AND (`NetworkDevice`.`Used` = 1)');
    259     while($Interface = $DbResult->fetch_assoc())
    260     {
    261       $Name = $Interface['DeviceName'];
    262       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     259    while ($Interface = $DbResult->fetch_assoc())
     260    {
     261      $Name = $Interface['DeviceName'];
     262      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    263263      $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'],
    264264          'IPv6' => $Interface['IPv6']);
     
    268268    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    269269    // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""');
    270     while($Alias = $DbResult->fetch_assoc())
     270    while ($Alias = $DbResult->fetch_assoc())
    271271    {
    272272      $ExternalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    302302        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    303303        'WHERE (`NetworkInterface`.`LocalIP` != "") AND (`NetworkDevice`.`Used` = 1)');
    304     while($Interface = $DbResult->fetch_assoc())
    305     {
    306       $Name = $Interface['DeviceName'];
    307       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     304    while ($Interface = $DbResult->fetch_assoc())
     305    {
     306      $Name = $Interface['DeviceName'];
     307      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    308308      $CZFreeDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']);
    309309    }
     
    312312    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    313313    // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    314     while($Alias = $DbResult->fetch_assoc())
     314    while ($Alias = $DbResult->fetch_assoc())
    315315    {
    316316      $CZFreeDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    344344    $DbResult = $this->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '.
    345345        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE `NetworkInterface`.`LocalIP` != ""');
    346     while($Interface = $DbResult->fetch_assoc())
    347     {
    348       $Name = $Interface['DeviceName'];
    349       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     346    while ($Interface = $DbResult->fetch_assoc())
     347    {
     348      $Name = $Interface['DeviceName'];
     349      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    350350      //  $CZFreeLocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['LocalIP']);
    351351      $CZFreeLocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']);
     
    355355    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    356356    // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    357     while($Alias = $DbResult->fetch_assoc())
     357    while ($Alias = $DbResult->fetch_assoc())
    358358    {
    359359      $CZFreeLocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
Note: See TracChangeset for help on using the changeset viewer.