summaryrefslogtreecommitdiff
path: root/ddns-status.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-04-03 10:30:50 +0200
committerErich Eckner <git@eckner.net>2019-04-03 10:30:50 +0200
commitdcf87bab819740f263f6024ac75e9d0c09967376 (patch)
tree8149aa10fc52128c1759671c961deb557aab0f0b /ddns-status.php
parent77d4ea28c7aaa960f4e201cd88c9d5e5a074df9b (diff)
downloadddns-dcf87bab819740f263f6024ac75e9d0c09967376.tar.xz
ddns-status.php: give more helpful error messages
Diffstat (limited to 'ddns-status.php')
-rw-r--r--ddns-status.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/ddns-status.php b/ddns-status.php
index 5c42ca7..2e7c38a 100644
--- a/ddns-status.php
+++ b/ddns-status.php
@@ -1,9 +1,17 @@
<?php
+function die_http($error, $message, $extra_message) {
+ header('Status: ' . $error . ' ' . $message);
+ print 'Error ' . $error . ': ' . $message . "\n";
+ if ($extra_message != '')
+ print "<br>\n" . $extra_message . "\n";
+ die();
+}
+
$pin = popen('dig @127.0.0.1 ddns.eckner.net AXFR', 'r');
if (!$pin)
- die();
+ die_http(500, 'Internal Server Error', 'Failed to get Zone.');
$found = false;
$axfr = array();
@@ -30,7 +38,7 @@ while (($line = fgets($pin)) !== false) {
pclose($pin);
if (! $found)
- die();
+ die_http(403, 'Forbidden', 'You are not known to ddns.');
$hosts = explode(
"\n",