"ssh-rsa")); ssh2_auth_pubkey_file($connection, $user, $keypub, $keypriv); $stream = ssh2_exec($connection, $command); stream_set_blocking($stream, true); $stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO); return stream_get_contents($stream_out); } function getzone($domain, $password) { if (!preg_match('/^[0-9A-Za-z\.\-]*$/', $_POST['domain'])) { die("invalid domain"); } $string = sshrun("cat " . ZONEROOT . $domain . ZONESUFFIX); $zonelines = explode("\n", $string); $zonehash = explode(" ", $zonelines[0]); if (strtolower($zonehash[sizeof($zonehash) - 1]) == strtolower($password)) { return $string; } else { return; } } function writezone($domain, $password, $zonetext) { if (!preg_match('/^[0-9A-Za-z\.\-]*$/', $_POST['domain'])) { die("invalid domain"); } if (!getzone($domain, $password)) { die("somehow the password went bad"); } if (isset($_POST['increment'])) { $zonetext = incrementserial($zonetext)[0]; } $zonetext = str_replace('$', '\$', $zonetext); sshrun("echo -e \"$zonetext\" > " . ZONEROOT . "$domain" . ZONESUFFIX); sshrun("rndc reload $domain"); } // Main entry point if (isset($_POST['domain']) && isset($_POST['password']) && !isset($_POST['zonetext'])) { if (!preg_match('/^[0-9A-Za-z\.\-]*$/', $_POST['domain'])) { die("invalid domain"); } $password = hash("sha256", $_POST['password']); if ($zonefile = getzone($_POST['domain'], $password)) { ?>

Automatically increment serial number from ?

sorry, the domain or password is wrong :(

"; } } else if (isset($_POST['domain']) && isset($_POST['password']) && isset($_POST['zonetext'])) { $zonetext = str_replace("\r", '', $_POST['zonetext']); writezone($_POST['domain'], $_POST['password'], $zonetext); echo "

all done :)

"; } else { ?>
Domain name:
Password: