vpanel-stack/panel/classes/Panel/Vmail/DkimDelete.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2023-06-19 11:53:16 -07:00
<?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 DkimDelete extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
}
static function get($f3) {
$f3->set('confirm', 'true');
echo \Template::instance()->render('vmail/dkim-delete.html');
}
static function post($f3) {
if ($f3->exists('PARAMS.domain')) {
$domain = $f3->get('PARAMS.domain');
if ($f3->call('\Panel::validateDomain', $domain)) {
if ($f3->call('\Panel::verifyDkimExists', $domain)) {
/* delete the dkim keys */
exec("/usr/local/bin/vmail-dkim-del.sh -d $domain", $output, $result_code);
$messages = $f3->get('SESSION.messages');
if ($result_code == 0) {
$messages[] = "DKIM keys for $domain have been deleted.";
$messages[] = "Note that you probably want to delete the associated DNS record now too.";
} else {
$messages[] = "Error deleting DKIM keys for $domain.";
}
} else {
$messages = $f3->get('SESSION.messages');
$messages[] = "DKIM keys for $domain not found.";
}
} else {
$messages = $f3->get('SESSION.messages');
$messages[] = "Invalid domain name ($domain).";
}
}
$f3->set('SESSION.messages', $messages);
$mapping = $f3->get('NAV.mapping');
if ($mapping == 'vmail') {
$f3->reroute("/");
} else {
$f3->reroute("/Email/$domain");
}
}
}