Remove DKIM keys with api
parent
93046dea45
commit
a8e550244e
|
@ -155,6 +155,7 @@ $tfa_data = get_tfa();
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><?=$lang['admin']['dkim_keys'];?></div>
|
<div class="panel-heading"><?=$lang['admin']['dkim_keys'];?></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<form class="form-inline" method="post" data-id="dkimkeys">
|
||||||
<?php
|
<?php
|
||||||
foreach(mailbox_get_domains() as $domain) {
|
foreach(mailbox_get_domains() as $domain) {
|
||||||
if (!empty($dkim = dkim_get_key_details($domain))) {
|
if (!empty($dkim = dkim_get_key_details($domain))) {
|
||||||
|
@ -171,11 +172,7 @@ $tfa_data = get_tfa();
|
||||||
<pre><?=$dkim['dkim_txt'];?></pre>
|
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-1">
|
<div class="col-xs-1">
|
||||||
<form class="form-inline" method="post">
|
<span style="cursor:pointer" data-dkim-domain="<?=$domain;?>" data-dkim-selector="<?=$dkim['dkim_selector'];?>" id="delete_dkim_key" class="text-danger glyphicon glyphicon-remove"></span></a>
|
||||||
<input type="hidden" name="domain" value="<?=$domain;?>">
|
|
||||||
<input type="hidden" name="dkim_delete_key" value="1">
|
|
||||||
<a href="#" onclick="$(this).closest('form').submit()" data-toggle="tooltip" data-placement="top" title="<?=$lang['user']['delete_now'];?>"><span class="glyphicon glyphicon-remove"></span></a>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
@ -206,11 +203,7 @@ $tfa_data = get_tfa();
|
||||||
<pre><?=$dkim['dkim_txt'];?></pre>
|
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-1">
|
<div class="col-xs-1">
|
||||||
<form class="form-inline" method="post">
|
<span style="cursor:pointer" data-dkim-domain="<?=$domain;?>" data-dkim-selector="<?=$dkim['dkim_selector'];?>" id="delete_dkim_key" class="text-danger glyphicon glyphicon-remove"></span></a>
|
||||||
<input type="hidden" name="domain" value="<?=$alias_domain;?>">
|
|
||||||
<input type="hidden" name="dkim_delete_key" value="1">
|
|
||||||
<a href="#" onclick="$(this).closest('form').submit()" data-toggle="tooltip" data-placement="top" title="<?=$lang['user']['delete_now'];?>"><span class="glyphicon glyphicon-remove"></span></a>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
@ -243,17 +236,15 @@ $tfa_data = get_tfa();
|
||||||
<pre><?=$dkim['dkim_txt'];?></pre>
|
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-1">
|
<div class="col-xs-1">
|
||||||
<form class="form-inline" method="post">
|
<span style="cursor:pointer" data-dkim-domain="<?=$blind;?>" data-dkim-selector="<?=$dkim['dkim_selector'];?>" id="delete_dkim_key" class="text-danger glyphicon glyphicon-remove"></span></a>
|
||||||
<input type="hidden" name="domain" value="<?=$blind;?>">
|
|
||||||
<input type="hidden" name="dkim_delete_key" value="1">
|
|
||||||
<a href="#" onclick="$(this).closest('form').submit()" data-toggle="tooltip" data-placement="top" title="<?=$lang['user']['delete_now'];?>"><span class="glyphicon glyphicon-remove"></span></a>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
</form>
|
||||||
|
|
||||||
<legend style="margin-top:40px"><?=$lang['admin']['dkim_add_key'];?></legend>
|
<legend style="margin-top:40px"><?=$lang['admin']['dkim_add_key'];?></legend>
|
||||||
<form class="form-inline" role="form" method="post">
|
<form class="form-inline" role="form" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -2497,8 +2497,13 @@ function dkim_get_blind_keys() {
|
||||||
function dkim_delete_key($postarray) {
|
function dkim_delete_key($postarray) {
|
||||||
global $redis;
|
global $redis;
|
||||||
global $lang;
|
global $lang;
|
||||||
$domain = $postarray['domain'];
|
if (!is_array($postarray['domains'])) {
|
||||||
|
$domains = array();
|
||||||
|
$domains[] = $postarray['domains'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$domains = $postarray['domains'];
|
||||||
|
}
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -2506,6 +2511,7 @@ function dkim_delete_key($postarray) {
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
foreach ($domains as $domain) {
|
||||||
if (!is_valid_domain_name($domain)) {
|
if (!is_valid_domain_name($domain)) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -2514,15 +2520,12 @@ function dkim_delete_key($postarray) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
foreach ($redis->hGetAll('DKIM_PRIV_KEYS') as $key => $value) {
|
foreach ($redis->hGetAll('DKIM_SELECTORS') as $domain_name => $selector) {
|
||||||
if (preg_match('/\.' . $domain . '$/i', $key)) {
|
$redis->hDel('DKIM_PUB_KEYS', $domain_name);
|
||||||
$redis->hDel('DKIM_PUB_KEYS', $key);
|
$redis->hDel('DKIM_PRIV_KEYS', $selector . '.' . $domain_name);
|
||||||
|
$redis->hDel('DKIM_SELECTORS', $domain_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$redis->hDel('DKIM_PUB_KEYS', $domain);
|
|
||||||
$redis->hDel('DKIM_SELECTORS', $domain);
|
|
||||||
$redis->hDel('DKIM_PRIV_KEYS', $domain);
|
|
||||||
}
|
|
||||||
catch (RedisException $e) {
|
catch (RedisException $e) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -2530,6 +2533,7 @@ function dkim_delete_key($postarray) {
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
'msg' => sprintf($lang['success']['dkim_removed'])
|
'msg' => sprintf($lang['success']['dkim_removed'])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// Collect values of input fields with name multi_select to js array multi_data[data-id-of-checkbox]
|
// Collect values of input fields with name multi_select with same data-form-id to js array multi_data[data-form-id-of-checkbox]
|
||||||
var multi_data = [];
|
var multi_data = [];
|
||||||
$(document).on('change', 'input[name=multi_select]:checkbox', function() {
|
$(document).on('change', 'input[name=multi_select]:checkbox', function() {
|
||||||
if ($(this).is(':checked') && $(this).attr('data-form-id')) {
|
if ($(this).is(':checked') && $(this).attr('data-form-id')) {
|
||||||
|
@ -15,7 +15,7 @@ $(document).ready(function() {
|
||||||
multi_data[id].splice($.inArray($(this).val(), multi_data[id]),1);
|
multi_data[id].splice($.inArray($(this).val(), multi_data[id]),1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Select by click on tr
|
// Select checkbox by click on parent tr
|
||||||
$(document).on('click', 'tr', function(e) {
|
$(document).on('click', 'tr', function(e) {
|
||||||
if (e.target.type == "checkbox") {
|
if (e.target.type == "checkbox") {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -27,8 +27,8 @@ $(document).ready(function() {
|
||||||
// Select or deselect all checkboxes with same data-form-id
|
// Select or deselect all checkboxes with same data-form-id
|
||||||
$(document).on('click', '#toggle_multi_select_all', function(e) {
|
$(document).on('click', '#toggle_multi_select_all', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var closests_checkboxes = $("input[data-form-id=" + $(this).attr("data-form-id") + "]");
|
var all_checkboxes = $("input[data-form-id=" + $(this).attr("data-form-id") + "]");
|
||||||
closests_checkboxes.prop("checked", !closests_checkboxes.prop("checked")).change();
|
all_checkboxes.prop("checked", !closests_checkboxes.prop("checked")).change();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Draw domain admin table
|
// Draw domain admin table
|
||||||
|
@ -140,7 +140,7 @@ $(document).ready(function() {
|
||||||
url: '/api/v1/delete/fwdhost',
|
url: '/api/v1/delete/fwdhost',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
window.location.href = window.location.href;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -150,6 +150,35 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '#delete_dkim_key', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var dkim_domain = $(this).data('dkim-domain');
|
||||||
|
var dkim_selector = $(this).data('dkim-selector');
|
||||||
|
$(document).on('show.bs.modal','#ConfirmDeleteModal', function () {
|
||||||
|
$("#ItemsToDelete").empty();
|
||||||
|
$("#ItemsToDelete").append("<li>" + dkim_domain + ", " + dkim_selector + "</li>");
|
||||||
|
})
|
||||||
|
$('#ConfirmDeleteModal').modal({
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: false
|
||||||
|
})
|
||||||
|
.one('click', '#IsConfirmed', function(e) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: { "domains": JSON.stringify(dkim_domain) },
|
||||||
|
url: '/api/v1/delete/dkim',
|
||||||
|
jsonp: false,
|
||||||
|
complete: function (data) {
|
||||||
|
window.location.href = window.location.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.one('click', '#isCanceled', function(e) {
|
||||||
|
$('#ConfirmDeleteModal').modal('hide');
|
||||||
|
});;
|
||||||
|
});
|
||||||
|
|
||||||
$("#refresh_dovecot_log").on('click', function(e) {
|
$("#refresh_dovecot_log").on('click', function(e) {
|
||||||
function unix_time_format(tm) {
|
function unix_time_format(tm) {
|
||||||
var date = new Date(tm ? tm * 1000 : 0);
|
var date = new Date(tm ? tm * 1000 : 0);
|
||||||
|
|
|
@ -309,7 +309,7 @@ $(document).ready(function() {
|
||||||
url: '/api/v1/edit/alias',
|
url: '/api/v1/edit/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
window.location.href = window.location.href;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ $(document).ready(function() {
|
||||||
url: '/api/v1/edit/alias',
|
url: '/api/v1/edit/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
window.location.href = window.location.href;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ $(document).ready(function() {
|
||||||
url: '/api/v1/delete/alias',
|
url: '/api/v1/delete/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
window.location.href = window.location.href;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -356,6 +356,18 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "csrf-cookie":
|
||||||
|
if (isset($_SESSION['mailcow_cc_username']) && isset($_SESSION['mailcow_cc_role'])) {
|
||||||
|
csrfprotector::refreshToken();
|
||||||
|
echo json_encode(array(
|
||||||
|
'type' => 'success',
|
||||||
|
'msg' => 'Cookie refreshed'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
echo '{}';
|
echo '{}';
|
||||||
break;
|
break;
|
||||||
|
@ -368,46 +380,94 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
$address = json_decode($_POST['address'], true);
|
$address = json_decode($_POST['address'], true);
|
||||||
if (is_array($address)) {
|
if (is_array($address)) {
|
||||||
if (mailbox_delete_alias(array('address' => $address)) === false) {
|
if (mailbox_delete_alias(array('address' => $address)) === false) {
|
||||||
echo json_encode(array(
|
if (isset($_SESSION['return'])) {
|
||||||
'type' => 'error',
|
echo json_encode($_SESSION['return']);
|
||||||
'message' => 'Deletion of item/s failed'
|
|
||||||
));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
echo json_encode(array(
|
|
||||||
'type' => 'success',
|
|
||||||
'message' => 'Task completed'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'error',
|
'type' => 'error',
|
||||||
'message' => 'Cannot find address array in post data'
|
'msg' => 'Deletion of items/s failed'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['return'])) {
|
||||||
|
echo json_encode($_SESSION['return']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo json_encode(array(
|
||||||
|
'type' => 'success',
|
||||||
|
'msg' => 'Item/s deleted: ' . $domains
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "fwdhost":
|
case "fwdhost":
|
||||||
if (isset($_POST['forwardinghost'])) {
|
if (isset($_POST['forwardinghost'])) {
|
||||||
$forwardinghost = json_decode($_POST['forwardinghost'], true);
|
$forwardinghost = (array)json_decode($_POST['forwardinghost'], true);
|
||||||
if (is_array($forwardinghost)) {
|
if (is_array($forwardinghost)) {
|
||||||
if (delete_forwarding_host(array('forwardinghost' => $forwardinghost)) === false) {
|
if (delete_forwarding_host(array('forwardinghost' => $forwardinghost)) === false) {
|
||||||
|
if (isset($_SESSION['return'])) {
|
||||||
|
echo json_encode($_SESSION['return']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'error',
|
'type' => 'error',
|
||||||
'message' => 'Deletion of item/s failed'
|
'msg' => 'Deletion of items/s failed'
|
||||||
));
|
));
|
||||||
|
}
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
if (isset($_SESSION['return'])) {
|
||||||
|
echo json_encode($_SESSION['return']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
'message' => 'Task completed'
|
'msg' => 'Item/s deleted: ' . $domains
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'error',
|
'type' => 'error',
|
||||||
'message' => 'Cannot find forwardinghost array in post data'
|
'msg' => 'Cannot find forwardinghost array in post data'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "dkim":
|
||||||
|
if (isset($_POST['domains'])) {
|
||||||
|
$domains = (array)json_decode($_POST['domains'], true);
|
||||||
|
if (is_array($domains)) {
|
||||||
|
if (dkim_delete_key(array('domains' => $domains)) === false) {
|
||||||
|
if (isset($_SESSION['return'])) {
|
||||||
|
echo json_encode($_SESSION['return']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo json_encode(array(
|
||||||
|
'type' => 'error',
|
||||||
|
'msg' => 'Deletion of items/s failed'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['return'])) {
|
||||||
|
echo json_encode($_SESSION['return']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo json_encode(array(
|
||||||
|
'type' => 'success',
|
||||||
|
'msg' => 'Item/s deleted: ' . $domains
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo json_encode(array(
|
||||||
|
'type' => 'error',
|
||||||
|
'msg' => 'Cannot find domains array in post data'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -417,25 +477,25 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
switch ($category) {
|
switch ($category) {
|
||||||
case "alias":
|
case "alias":
|
||||||
if (isset($_POST['address']) && isset($_POST['active'])) {
|
if (isset($_POST['address']) && isset($_POST['active'])) {
|
||||||
$address = json_decode($_POST['address'], true);
|
$address = (array)json_decode($_POST['address'], true);
|
||||||
if (is_array($address)) {
|
if (is_array($address)) {
|
||||||
if (mailbox_edit_alias(array('address' => $address, 'active' => ($_POST['active'] == "1") ? $active = 1 : null)) === false) {
|
if (mailbox_edit_alias(array('address' => $address, 'active' => ($_POST['active'] == "1") ? $active = 1 : null)) === false) {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'error',
|
'type' => 'error',
|
||||||
'message' => 'Edit item failed'
|
'msg' => 'Edit item failed'
|
||||||
));
|
));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
'message' => 'Task completed'
|
'msg' => 'Task completed'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'type' => 'error',
|
'type' => 'error',
|
||||||
'message' => 'Cannot find address array in post data'
|
'msg' => 'Cannot find address array in post data'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue