61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* vpanel-stack
|
|
* https://git.stack-source.com/msb/vpanel-stack
|
|
* Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
|
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
*/
|
|
|
|
namespace Panel\Vmail;
|
|
|
|
class DkimAdd extends \Panel\Vmail {
|
|
|
|
function beforeRoute($f3) {
|
|
|
|
parent::beforeRoute($f3);
|
|
|
|
}
|
|
|
|
static function get($f3) {
|
|
|
|
if ($f3->exists('PARAMS.domain')) {
|
|
$domain = $f3->get('PARAMS.domain');
|
|
if ($f3->call('\Panel::validateDomain', $domain)) {
|
|
if ($f3->call('\Panel::verifyVmailDomainExists', $domain)) {
|
|
if ($f3->call('\Panel::verifyDkimExists', $domain)) {
|
|
$messages = $f3->get('SESSION.messages');
|
|
$messages[] = "DKIM for $domain already exists.";
|
|
$f3->set('SESSION.messages', $messages);
|
|
} else {
|
|
exec("/usr/local/bin/vmail-dkim-add.sh -d $domain", $output, $result_code);
|
|
$messages = $f3->get('SESSION.messages');
|
|
if ($result_code == 0) {
|
|
$messages[] = "DKIM for $domain has been added.";
|
|
} else {
|
|
$messages[] = "ERROR: adding DKIM for $domain failed.";
|
|
}
|
|
$f3->set('SESSION.messages', $messages);
|
|
}
|
|
} else {
|
|
$messages = $f3->get('SESSION.messages');
|
|
$messages[] = "ERROR: $domain is not configured for email on this server.";
|
|
$f3->set('SESSION.messages', $messages);
|
|
}
|
|
} else {
|
|
$messages = $f3->get('SESSION.messages');
|
|
$messages[] = "ERROR: Invalid domain: $domain.";
|
|
$f3->set('SESSION.messages', $messages);
|
|
}
|
|
}
|
|
parse_str($f3->get('QUERY'), $output);
|
|
if (isset($output['r'])) {
|
|
$f3->reroute($output['r']);
|
|
} else {
|
|
$f3->reroute('/');
|
|
}
|
|
|
|
}
|
|
|
|
}
|