Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added links to mxtoolbox for dmarc #28 #29

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading