From 2b4d629419f4d9d82d736050e943793b5a778ea9 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 28 Jul 2022 11:37:34 +0200 Subject: use old ddns key if available --- html/maintenance.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'html/maintenance.php') diff --git a/html/maintenance.php b/html/maintenance.php index 39b0724..b45b731 100644 --- a/html/maintenance.php +++ b/html/maintenance.php @@ -96,9 +96,18 @@ if (array_key_exists('ddns', $_GET)) { ' WHERE keys.comment = ' . "'" . 'ddns' . "'" ); $row = $result -> fetchArray(); - if (! $row) - $key_id = $db -> add_key('ddns'); - else + if (! $row) { + unset($key); + if (file_exists('/srv/http/vhosts/eckner.net/ddns/colocation-token')) { + $key = trim(file_get_contents('/srv/http/vhosts/eckner.net/ddns/colocation-token')); + if (strlen($key) != 128) + unset($key); + } + if (isset($key)) + $key_id = $db -> add_key('ddns', $key); + else + $key_id = $db -> add_key('ddns'); + } else $key_id = $row['id']; $stm = $db -> prepare('INSERT INTO permissions (key_id, value_id) VALUES (:key_id, :value_id)'); -- cgit v1.2.3-54-g00ecf