Binary Files :: They Keep Adding Blocks
| From: | vins | Date: | Wed, 17 Jul 2002 22:57:05 +0000 |
| Subject: | Binary Files :: They Keep Adding Blocks | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108178@lists.php.net to get a copy of this message | ||
Hi....
I've just made this script to update a binary file for my BIND 9 DNS server.
=======================
$WorkFile = "domains/db.nom.za";
$buffer = file($WorkFile);
$DBfile = implode($buffer, "");
$DBfile = ereg_replace("$domain.nom.za. IN NS $fqdnold[0].",
"$domain.nom.za. IN NS $fqdnnew[0].", $DBfile);
$DBfile = ereg_replace("$domain.nom.za. IN NS $fqdnold[1].",
"$domain.nom.za. IN NS $fqdnnew[1].", $DBfile);
$DBfile = trim($DBfile)."\n";
$fp = fopen($WorkFile, 'w');
fwrite($fp, $DBfile);
fclose($fp);
=======================
Basicall I want to find "dub.domain.com IN NS dns.example.com" and replace
it with "dub.domain.com IN NS dns1.expample.com". Note the '1' and still
maintain the format of the file...
My script keeps adding and extra line to every line even when I told it to
trim.
Any please help
Kindest Regards
Vins
:D