Changeset 873 for trunk/Modules/NetworkConfigLinux/Generators/DNS.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r854 r873 18 18 "\t\t\t".$DNS['Minimum']."\t; minimum\n". 19 19 "\t\t\t)\n"; 20 foreach ($DNS['NameServer'] as $NameServer)20 foreach ($DNS['NameServer'] as $NameServer) 21 21 { 22 22 $Output .= "\t\tIN\tNS\t".strtolower($NameServer).".\n"; … … 26 26 // Mail server records 27 27 $Priority = 10; 28 foreach ($DNS['MailServer'] as $MailServer)28 foreach ($DNS['MailServer'] as $MailServer) 29 29 { 30 30 $Output .="\t\t\tMX\t".$Priority." ".strtolower($MailServer).".\n"; … … 34 34 $DNS['Domain'].".\tIN\tTXT\t\"v=spf1 mx -all\"\n". 35 35 $DNS['Domain'].".\tIN\tSPF\t\"v=spf1 mx -all\"\n"; 36 foreach ($DNS['MailServer'] as $MailServer)36 foreach ($DNS['MailServer'] as $MailServer) 37 37 { 38 38 $Output .= $MailServer.".\tIN\tTXT\t\"v=spf1 a -all\"\n". … … 45 45 46 46 // 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"; 50 50 $Output .= strtolower($Host['Name'])."\tIN\tA\t".$Host['Address']."\n"; 51 51 } 52 52 53 53 // 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'] != '')) 58 58 $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n"; 59 59 } 60 60 61 61 // 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"; 65 65 $Output .= strtolower($Alias['Name'])."\tIN\tCNAME\t".strtolower($Alias['Target'])."\n"; 66 66 } … … 71 71 72 72 // Generate reverse DNS records 73 foreach ($DNS['Network'] as $Network)73 foreach ($DNS['Network'] as $Network) 74 74 { 75 75 $Parts = explode('.', $Network); … … 83 83 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 84 84 "\t\t\t\t)\n"; 85 foreach ($DNS['ReverseNameServer'] as $NameServer)85 foreach ($DNS['ReverseNameServer'] as $NameServer) 86 86 { 87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 88 88 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 89 89 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 90 90 } 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) 93 93 { 94 94 $AddressParts = explode('.', $Host['Address']); … … 103 103 104 104 // Generate reverse DNS IPv6 records 105 foreach ($DNS['IPv6Network'] as $Network)105 foreach ($DNS['IPv6Network'] as $Network) 106 106 { 107 107 $Parts = explode('/', $Network); … … 117 117 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 118 118 "\t\t\t\t)\n"; 119 foreach ($DNS['ReverseNameServer'] as $NameServer)119 foreach ($DNS['ReverseNameServer'] as $NameServer) 120 120 { 121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 122 122 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 123 123 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 124 124 } 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'] != '')) 127 127 { 128 128 $Addr = new NetworkAddressIPv6(); … … 161 161 $BaseDir = '/var/cache/bind'; 162 162 //$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.'); 164 164 $MailServer = 'centrala'; 165 165 … … 193 193 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 194 194 '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']; 199 199 $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'], 200 200 'IPv6' => $Interface['IPv6']); … … 205 205 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 206 206 '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']; 211 211 $LocalDNS['Host'][] = array('Name' => $Name.'-ext', 'Address' => $Interface['ExternalIP']); 212 212 } … … 216 216 $DbResult = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '. 217 217 'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.CZFreeIP <> ""'); 218 while ($Interface = $DbResult->fetch_assoc())218 while ($Interface = $DbResult->fetch_assoc()) 219 219 { 220 220 $Name = $Interface['DeviceName']; 221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 222 222 $LocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['CZFreeIP']); 223 223 } … … 226 226 // Domain aliases 227 227 $DbResult = $this->Database->select('NetworkDomainAlias', '*'); 228 while ($Alias = $DbResult->fetch_assoc())228 while ($Alias = $DbResult->fetch_assoc()) 229 229 { 230 230 $LocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 257 257 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE '. 258 258 '(`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']; 263 263 $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'], 264 264 'IPv6' => $Interface['IPv6']); … … 268 268 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 269 269 // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""'); 270 while ($Alias = $DbResult->fetch_assoc())270 while ($Alias = $DbResult->fetch_assoc()) 271 271 { 272 272 $ExternalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 302 302 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 303 303 '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']; 308 308 $CZFreeDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); 309 309 } … … 312 312 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 313 313 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 314 while ($Alias = $DbResult->fetch_assoc())314 while ($Alias = $DbResult->fetch_assoc()) 315 315 { 316 316 $CZFreeDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 344 344 $DbResult = $this->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '. 345 345 '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']; 350 350 // $CZFreeLocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['LocalIP']); 351 351 $CZFreeLocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); … … 355 355 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 356 356 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 357 while ($Alias = $DbResult->fetch_assoc())357 while ($Alias = $DbResult->fetch_assoc()) 358 358 { 359 359 $CZFreeLocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
Note:
See TracChangeset
for help on using the changeset viewer.