#!/usr/bin/php # This is the MySQL table it reads. #DROP TABLE IF EXISTS `dns`; #CREATE TABLE `dns` ( # `uniq` int(10) NOT NULL auto_increment, # `login` varchar(20) NOT NULL default 'login', # `host` varchar(60) default NULL, # `domain` varchar(60) default NULL, # `type` varchar(10) NOT NULL default 'A', # `address` varchar(250) default NULL, # `created` date NOT NULL default '0000-00-00', # `lastmod` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, # PRIMARY KEY (`uniq`), # UNIQUE KEY `id` (`uniq`) #) ENGINE=MyISAM DEFAULT CHARSET=latin1; 'PTR' order by domain,host,type" ; $result = mysql_query($query,$db) or die("Query failed : " . mysql_error()); $i = 0 ; while (list($uniq,$login,$host,$domain,$type,$address) = mysql_fetch_row($result)) { print "$host.$domain\n" ; if($dn == "$domain") { } else { fclose($out) ; $out = fopen("/home/orca/named/named.conf.include","a") ; $text = "zone \"$domain\" { type master ; file \"/home/orca/named/$domain\" ; allow-update { none ;} ;} ;\n" ; fputs($out,"$text") ; fclose($out) ; $out = fopen("/home/orca/named/$domain","w") ; $serial = date("Ymdh") ; $dnsd = "yourdomain.net" ; #Edit this for the main DNS servers domain. #--------------------------------------------------------------------------- $text = "\$TTL 3600 @ IN SOA ns1.$dnsd. support.$dnsd. ( $serial ; Serial see www.dnsreport.com for a good explaination 1200 ; Refresh 120 ; Retry 1209605 ; Expire 3600 ) ; Minimum IN NS ns1.$dnsd. IN NS ns2.$dnsd. @ IN TXT \"v=spf1 ip4:1.2.3.4/24 mx a:mail.$dnsd a:email.$dnsd a:nospam.$dnsd include:$dnsd ~all\"\n\n" ; #--------------------------------------------------------------------------- fputs($out,"$text") ; $dn = $domain ; } ; print "" ; if(strlen($host) > 7) { $tab = " " ; } else { $tab = " " ; } ; if($type == "A") { $text = "$host$tab IN A $address\n" ; } ; if($type == "CNAME") { $text = "$host$tab IN CNAME $address\n" ; } ; if($type == "TXT") { $text = "$host$tab IN TXT $address\n" ; } ; if($type == "MX-10") { $text = "$host$tab IN MX 10 $address\n" ; } ; if($type == "MX-20") { $text = "$host$tab IN MX 20 $address\n" ; } ; if($type == "MX-30") { $text = "$host$tab IN MX 30 $address\n" ; } ; if($type == "MX-40") { $text = "$host$tab IN MX 40 $address\n" ; } ; if($type == "MX-50") { $text = "$host$tab IN MX 50 $address\n" ; } ; fputs($out,"$text") ; $last = "$domain" ; } ; fclose($out) ; #=====================================REVERSE DNS=========================== $dn = "" ; $query = "select uniq,login,host,domain,type,address from dns where type = 'PTR' order by domain,host,type" ; $result = mysql_query($query,$db) or die("Query failed : " . mysql_error()); $i = 0 ; while (list($uniq,$login,$host,$domain,$type,$address) = mysql_fetch_row($result)) { print "$domain.$host\n" ; if($dn == "$domain") { } else { fclose($out) ; $out = fopen("/home/orca/named/named.conf.include","a") ; $rd = preg_split('/\./',$domain) ; $arpa = "$rd[2].$rd[1].$rd[0]" ; $text = "zone \"$arpa.in-addr.arpa\" { type master ; file \"$domain.in-addr.arpa\" ; notify YES ; allow-transfer { 66.242.236.238 ; } ; allow-update { none ; } ; } ;\n" ; fputs($out,"$text") ; fclose($out) ; $out = fopen("/home/orca/named/$domain.in-addr.arpa","w") ; #--------------------------------------------------------------------------- $text = "\$TTL 4800 @ IN SOA ns1.$dnsd. support.$dnsd. ( 2004112303 ; Serial see www.dnsreport.com for a good explaination 1200 ; Refresh 120 ; Retry 3600 ; Expire 3600 ) ; Minimum IN NS ns1.$dnsd. IN NS ns2.$dnsd.\n\n" ; #--------------------------------------------------------------------------- fputs($out,"$text") ; $dn = $domain ; } ; print "" ; if($type == "PTR") { $text = "$host IN PTR $address\n" ; } ; fputs($out,"$text") ; $last = "$domain" ; } ; fclose($out) ; #=========================================================================== } ; function glconnect() { global $systemname, $database, $dbhost, $dblogin, $dbpasswd, $sitelogin ; $db = mysql_connect($dbhost, $dblogin,$dbpasswd); mysql_select_db($database,$db); return $db ; } ; // end function glconnect ; function getstringfrommysql($query) { $db = glconnect() ; $result = mysql_query($query,$db) or die("Query failed : " . mysql_error()); while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $i = 0 ; while(list($key,$val) = each($row) ) { $answer = $val ; last ; $i++ ; } ; } ; return $answer ; } ; main() ; ?>