From 5be1eed84136d6c12f278b730dc48f51acff3e2a Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Mon, 8 Jan 2024 17:26:21 +1100 Subject: [PATCH] Added links to mxtoolbox for dmarc #28 --- dkim.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dkim.php b/dkim.php index e66bed9..4b0dbc7 100644 --- a/dkim.php +++ b/dkim.php @@ -71,10 +71,17 @@ } $dkimdir = $CFG->dataroot . '/dkim/'; -$domains = scandir($dkimdir, SCANDIR_SORT_DESCENDING); +$domains = []; +if (is_dir($dkimdir)) { + $domains = scandir($dkimdir, SCANDIR_SORT_DESCENDING); +} + $domaincount = 0; $noreplydomain = substr($CFG->noreplyaddress, strpos($CFG->noreplyaddress, '@') + 1); +// Always make sure the noreply domain is included even if nothing has been setup yet. +$domains = array_merge($domains, [$noreplydomain]); + print $OUTPUT->header(); print $OUTPUT->heading(get_string('dkimmanager', 'tool_emailutils')); @@ -85,7 +92,7 @@ if (substr($domain, 0, 1) == '.') { continue; } - if (!is_dir($dkimdir . $domain)) { + if (!is_dir($dkimdir . $domain) && $domain != $noreplydomain) { continue; } @@ -110,10 +117,20 @@ $url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "txt:$domain"]); print "
  • Raw TXT"; + $url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "dmarc:$domain", 'run' => 'toolpage']); + print "
  • DMARC"; + + $url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "txt:_dmarc.$domain"]); + print "
  • DARMC TXT"; + print ''; - $selectors = scandir($dkimdir . $domain); + $selectors = []; + $selectordir = $dkimdir . $domain; + if (is_dir($selectordir)) { + $selectors = scandir($selectordir); + } // We want newer date based selectors to be at the top. natsort($selectors);