5 use dns\util\DNSSECUtil
;
8 * @author Jan Altensen (Stricted)
9 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
10 * @copyright 2014-2016 Jan Altensen (Stricted)
12 class SecListPage
extends AbstractPage
{
13 public $activeMenuItem = 'index';
15 public function prepare() {
16 if (!isset($_GET['id']) ||
empty($_GET['id']) ||
!ENABLE_DNSSEC
) {
17 throw new \
Exception('The link you are trying to reach is no longer available or invalid.', 404);
20 $soaIDs = User
::getAccessibleDomains();
21 if (!in_array($_GET['id'], $soaIDs)) {
22 throw new \
Exception('Access denied. You\'re not authorized to view this page.', 403);
25 $sql = "SELECT * FROM dns_soa WHERE id = ?";
26 $res = DNS
::getDB()->query($sql, array($_GET['id']));
27 $soa = DNS
::getDB()->fetch_array($res);
32 $sql = "SELECT * FROM dns_sec WHERE zone = ?";
33 $res = DNS
::getDB()->query($sql, array($_GET['id']));
34 while ($row = DNS
::getDB()->fetch_array($res)) {
35 if ($row['type'] == 'KSK') {
36 preg_match("/".$soa['origin']." IN DNSKEY 257 3 ([0-9]+) ([\s\S]+)/i", $row['public'], $match);
37 preg_match("/; This is a key-signing key, keyid ([0-9]+), for ".$soa['origin']."/i", $row['public'], $match2);
38 if (!empty($match) && !empty($match2)) {
39 if ($match[1] == $row['algo']) {
40 $ds = DNSSECUtil
::calculateDS($soa['origin'], $match[1], $match[2]);
41 $ds['algo'] = $match[1];
42 $ds['keyid'] = $match2[1];
49 DNS
::getTPL()->assign(array("records" => $records, "soa" => $soa, 'ds' => $ds));