Skip to content

Commit

Permalink
Added links to mxtoolbox for dmarc #28
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Jan 8, 2024
1 parent 21e9965 commit 853266b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion classes/dkim_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function get_domain_path() {
public function get_base_path($create = false) {
$certdir = $this->get_domain_path();
if ($create) {
mkdir($certdir, 0777, true);
@mkdir($certdir, 0777, true);
}
return $certdir . '/' . $this->selector;
}
Expand Down Expand Up @@ -182,6 +182,7 @@ public function get_dns_value() {
*/
public function get_dns_value_chunked() {

$dnsvalue = '';
$rawvalue = $this->get_dns_value();

// Split into chunks.
Expand Down
23 changes: 20 additions & 3 deletions dkim.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_unique(array_merge($domains, [$noreplydomain]));

print $OUTPUT->header();
print $OUTPUT->heading(get_string('dkimmanager', 'tool_emailutils'));

Expand All @@ -85,7 +92,7 @@
if (substr($domain, 0, 1) == '.') {
continue;
}
if (!is_dir($dkimdir . $domain)) {
if (!is_dir($dkimdir . $domain) && $domain != $noreplydomain) {
continue;
}

Expand All @@ -110,10 +117,20 @@
$url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "txt:$domain"]);
print "<li><a href='$url' target='_blank'>Raw TXT</a>";

$url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "dmarc:$domain", 'run' => 'toolpage']);
print "<li><a href='$url' target='_blank'>DMARC</a>";

$url = new moodle_url('https://mxtoolbox.com/SuperTool.aspx', ['action' => "txt:_dmarc.$domain"]);
print "<li><a href='$url' target='_blank'>DARMC TXT</a>";

print '</th></tr>';


$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);
Expand Down

0 comments on commit 853266b

Please sign in to comment.