diff --git a/scripts/plugins/template.php b/scripts/plugins/template.php new file mode 100644 index 0000000..46146d1 --- /dev/null +++ b/scripts/plugins/template.php @@ -0,0 +1,114 @@ + $service) + { + $services[$key] = scrape_between($service, "../../", ".txt"); + } + + $output = ""; + + foreach($files as $file) + { + if (in_array(scrape_between($file, "../../", ".txt"), $services)) + { + // ---------------------------------------------------------- + // Change below me + // ---------------------------------------------------------- + // Change the # to match comments in youre services (default # starts comment if not changed) + $output .= "# File: " . scrape_between($file, "../../", ".txt"); + // ---------------------------------------------------------- + // Change above me + // ---------------------------------------------------------- + $output .= PHP_EOL; + foreach (file($file) as $key => $line) + { + $line = trim($line, " \t\n\r\0\x0B"); + if (substr($line, 0,1) == "#") + { + // Comment handling + // ---------------------------------------------------------- + // Change below me + // ---------------------------------------------------------- + $output .= $line; // Change this to match comments in youre services (default # starts comment if not changed) + // ---------------------------------------------------------- + // Change above me + // ---------------------------------------------------------- + } + elseif (substr($line, 0,1) == "*") + { + // Wildcard handling change to match services + // Output for wildcard + + // ---------------------------------------------------------- + // Change below me + // ---------------------------------------------------------- + $line = ltrim($line, '*'); // Removing the * in the line + $line = ltrim($line, '.'); // Removing the . in the line + + // Append to the output file + // line is the corrent line in the file (domainname) + $output .= "# ------ Wildcard replaced with local-zone data ------ #" . PHP_EOL; + $output .= 'local-zone: "' . $line . '" redirect' . PHP_EOL; + $output .= 'local-data: "' . $line . ' A ' . $server . '"' . PHP_EOL; + $output .= "# ---------------------------------------------------- #"; + // ---------------------------------------------------------- + // Change above me + // ---------------------------------------------------------- + } + else + { + // Single domain handling + // ---------------------------------------------------------- + // Change below me + // ---------------------------------------------------------- + $output .= 'local-data: "' . $line . ' A ' . $server . '"'; + // ---------------------------------------------------------- + // Change above me + // ---------------------------------------------------------- + } + $output .= PHP_EOL; + } + $output .= PHP_EOL; + $output .= PHP_EOL; + } + } + if ($mode == "cli") + { + return $output; + } + else + { + echo $output; + } + } +} + +?> \ No newline at end of file