-
Notifications
You must be signed in to change notification settings - Fork 20
/
process.mvps.php
49 lines (37 loc) · 913 Bytes
/
process.mvps.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
if (!defined("IN_PROCESS")) die("You must call `php process.php`, not this file!");
$extraHeader = <<<TAG
#
# Hosts pointed to $destIp
/ip dns static
TAG;
$headerFinished = false;
while ($line = fgets($fpRead)) {
$line = trim($line);
$line = str_replace("\t", " ", $line);
if ($line == '') {
continue;
}
if (!$headerFinished) {
if ($line[0] == '#') {
// Pass the header straight through
fputs($fpWrite, "$line\r\n");
continue;
} // else we've finished reading the header
}
if (!$headerFinished) {
// First non-header line
if (!BIND9_OUTPUT) {
fputs($fpWrite, $extraHeader);
}
$headerFinished = true;
}
if ($line[0] == '#') {
// whole-line comment after the header; drop it
continue;
}
// Normal line, in theory
if (preg_match('/^0\.0\.0\.0\s+(\S+)(?:\s*#\s*(.+))?$/S', $line, $matches)) {
$addLn($matches[1], @$matches[2]);
} else { echo '.'; }
}