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-heading"><?=$lang['admin']['dkim_keys'];?></div>
|
||||
<div class="panel-body">
|
||||
<form class="form-inline" method="post" data-id="dkimkeys">
|
||||
<?php
|
||||
foreach(mailbox_get_domains() as $domain) {
|
||||
if (!empty($dkim = dkim_get_key_details($domain))) {
|
||||
|
@ -171,11 +172,7 @@ $tfa_data = get_tfa();
|
|||
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<form class="form-inline" method="post">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -206,11 +203,7 @@ $tfa_data = get_tfa();
|
|||
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<form class="form-inline" method="post">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -243,17 +236,15 @@ $tfa_data = get_tfa();
|
|||
<pre><?=$dkim['dkim_txt'];?></pre>
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<form class="form-inline" method="post">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
|
||||
<legend style="margin-top:40px"><?=$lang['admin']['dkim_add_key'];?></legend>
|
||||
<form class="form-inline" role="form" method="post">
|
||||
<div class="form-group">
|
||||
|
|
|
@ -2497,8 +2497,13 @@ function dkim_get_blind_keys() {
|
|||
function dkim_delete_key($postarray) {
|
||||
global $redis;
|
||||
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") {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -2506,6 +2511,7 @@ function dkim_delete_key($postarray) {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
foreach ($domains as $domain) {
|
||||
if (!is_valid_domain_name($domain)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -2514,15 +2520,12 @@ function dkim_delete_key($postarray) {
|
|||
return false;
|
||||
}
|
||||
try {
|
||||
foreach ($redis->hGetAll('DKIM_PRIV_KEYS') as $key => $value) {
|
||||
if (preg_match('/\.' . $domain . '$/i', $key)) {
|
||||
$redis->hDel('DKIM_PUB_KEYS', $key);
|
||||
foreach ($redis->hGetAll('DKIM_SELECTORS') as $domain_name => $selector) {
|
||||
$redis->hDel('DKIM_PUB_KEYS', $domain_name);
|
||||
$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) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -2530,6 +2533,7 @@ function dkim_delete_key($postarray) {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'success',
|
||||
'msg' => sprintf($lang['success']['dkim_removed'])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$(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 = [];
|
||||
$(document).on('change', 'input[name=multi_select]:checkbox', function() {
|
||||
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);
|
||||
}
|
||||
});
|
||||
// Select by click on tr
|
||||
// Select checkbox by click on parent tr
|
||||
$(document).on('click', 'tr', function(e) {
|
||||
if (e.target.type == "checkbox") {
|
||||
e.stopPropagation();
|
||||
|
@ -27,8 +27,8 @@ $(document).ready(function() {
|
|||
// Select or deselect all checkboxes with same data-form-id
|
||||
$(document).on('click', '#toggle_multi_select_all', function(e) {
|
||||
e.preventDefault();
|
||||
var closests_checkboxes = $("input[data-form-id=" + $(this).attr("data-form-id") + "]");
|
||||
closests_checkboxes.prop("checked", !closests_checkboxes.prop("checked")).change();
|
||||
var all_checkboxes = $("input[data-form-id=" + $(this).attr("data-form-id") + "]");
|
||||
all_checkboxes.prop("checked", !closests_checkboxes.prop("checked")).change();
|
||||
});
|
||||
|
||||
// Draw domain admin table
|
||||
|
@ -140,7 +140,7 @@ $(document).ready(function() {
|
|||
url: '/api/v1/delete/fwdhost',
|
||||
jsonp: false,
|
||||
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) {
|
||||
function unix_time_format(tm) {
|
||||
var date = new Date(tm ? tm * 1000 : 0);
|
||||
|
|
|
@ -309,7 +309,7 @@ $(document).ready(function() {
|
|||
url: '/api/v1/edit/alias',
|
||||
jsonp: false,
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ $(document).ready(function() {
|
|||
url: '/api/v1/edit/alias',
|
||||
jsonp: false,
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ $(document).ready(function() {
|
|||
url: '/api/v1/delete/alias',
|
||||
jsonp: false,
|
||||
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;
|
||||
}
|
||||
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:
|
||||
echo '{}';
|
||||
break;
|
||||
|
@ -368,46 +380,94 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||
$address = json_decode($_POST['address'], true);
|
||||
if (is_array($address)) {
|
||||
if (mailbox_delete_alias(array('address' => $address)) === false) {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Deletion of item/s failed'
|
||||
));
|
||||
exit();
|
||||
}
|
||||
echo json_encode(array(
|
||||
'type' => 'success',
|
||||
'message' => 'Task completed'
|
||||
));
|
||||
}
|
||||
if (isset($_SESSION['return'])) {
|
||||
echo json_encode($_SESSION['return']);
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'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;
|
||||
case "fwdhost":
|
||||
if (isset($_POST['forwardinghost'])) {
|
||||
$forwardinghost = json_decode($_POST['forwardinghost'], true);
|
||||
$forwardinghost = (array)json_decode($_POST['forwardinghost'], true);
|
||||
if (is_array($forwardinghost)) {
|
||||
if (delete_forwarding_host(array('forwardinghost' => $forwardinghost)) === false) {
|
||||
if (isset($_SESSION['return'])) {
|
||||
echo json_encode($_SESSION['return']);
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Deletion of item/s failed'
|
||||
'msg' => 'Deletion of items/s failed'
|
||||
));
|
||||
}
|
||||
exit();
|
||||
}
|
||||
if (isset($_SESSION['return'])) {
|
||||
echo json_encode($_SESSION['return']);
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'type' => 'success',
|
||||
'message' => 'Task completed'
|
||||
'msg' => 'Item/s deleted: ' . $domains
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'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;
|
||||
|
@ -417,25 +477,25 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
|||
switch ($category) {
|
||||
case "alias":
|
||||
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 (mailbox_edit_alias(array('address' => $address, 'active' => ($_POST['active'] == "1") ? $active = 1 : null)) === false) {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Edit item failed'
|
||||
'msg' => 'Edit item failed'
|
||||
));
|
||||
exit();
|
||||
}
|
||||
echo json_encode(array(
|
||||
'type' => 'success',
|
||||
'message' => 'Task completed'
|
||||
'msg' => 'Task completed'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Cannot find address array in post data'
|
||||
'msg' => 'Cannot find address array in post data'
|
||||
));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue