This commit is contained in:
Mikki Sørensen 2018-03-06 23:40:47 +00:00 committed by GitHub
commit 5b287cf5c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 79 additions and 0 deletions

24
scripts/index.php Normal file
View File

@ -0,0 +1,24 @@
<?php
if (isset($_POST["conf"]) && $_POST["conf"] == "unbound")
{
require "unbound_conf.php";
$unbound_conf = new unbound_conf();
$unbound_conf->print();
}
else
{
?>
<form action="/steamcache/scripts/" method="post">
<input type="text" name="ip" placeholder="ip of cache server"><br>
<input type="radio" name="conf" value="unbound" checked> unbound<br>
<input type="radio" name="conf" value="other"> Other<br>
<input type="radio" name="conf" value="other2"> Other2<br>
<input type="submit" value="Submit">
</form>
<?php
}
?>

55
scripts/unbound_conf.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/**
* Class to make unbound config file
*/
class unbound_conf
{
function __construct()
{
header("Content-Type: text/plain");
}
function print()
{
//Steamcache server ip
$server = $_POST["ip"];
$files = glob("../*.txt");
foreach($files as $file)
{
echo "# File: " . substr($file, 3);
echo PHP_EOL;
foreach (file($file) as $key => $value)
{
$value = trim($value, " \t\n\r\0\x0B");
if (substr($value, 0,1) == "#")
{
$content = $value;
}
elseif (substr($value, 0,1) == "*")
{
$value = ltrim($value, '*');
$value = ltrim($value, '.');
$content = "# ------ Wildcard replaced with local-zone data ------ #" . PHP_EOL;
$content = $content . 'local-zone: "' . $value . '" redirect' . PHP_EOL;
$content = $content . 'local-data: "' . $value . ' A ' . $server . '"' . PHP_EOL;
$content = $content . "# ---------------------------------------------------- #";
}
else
{
$content = 'local-data: "' . $value . ' A ' . $server . '"';
}
echo $content;
echo PHP_EOL;
}
echo PHP_EOL;
echo PHP_EOL;
}
}
}
?>