The datafile look like this:
zone "localdomain" IN {
type master;
file "/var/named/localdomain.zone";
allow-update { none; };
};
zone "abcd.org" {
type master;
file "/var/named/abcd.org.db";
};
zone "xyz.com" {
type master;
file "/var/named/xyz.com.db";
};
zone "localhost" IN {
type master;
file "/var/named/localhost.zone";
allow-update { none; };
};
currently, my code will take out all "zone" record from /etc/named.conf , a bind config file and compile into another file.
Here's my code. How do i skip/remove unwanted name that i specific. example, if it detect "localhost", "localdomain", ".apa"
Can someone tell me how much more do i need to modify? can tell me how do i do it in a array form?
Thanks.
<?php
$inputFile="/etc/named.conf";
$outputFile="newfile.named";
$handle = fopen($inputFile, "r");
while (!feof($handle)) {
$buffer= fgets($handle, 4096);
if($buffer{0}!="#") {
$text.=$buffer;
}
}
fclose($handle);
$text2=split("zone ",$text);$n=1;
while($text2[$n]) {
$text3=strstr($text2[$n],"};");
$textfinal=str_replace($text3,"",$text2[$n]);
$total.="zone ".$textfinal."\n};\n\n";$n++;
}
$write=fopen($outputFile,"w");
fputs ($write,$total);
fclose ($write);
?>