Use dkim selector by default
parent
833e1843b3
commit
4c75967b2b
|
@ -206,30 +206,23 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?php
|
<?php
|
||||||
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
||||||
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..', '.dkim_pub_keys'));
|
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..'));
|
||||||
foreach($dnstxt_files as $file) {
|
foreach($dnstxt_files as $file) {
|
||||||
$str = file_get_contents($GLOBALS["MC_DKIM_TXTS"]."/".$file);
|
$pubKey = file_get_contents($GLOBALS["MC_DKIM_TXTS"]."/".$file);
|
||||||
$str = preg_replace('/\r|\t|\n/', '', $str);
|
$domain = substr($file, 0, -5);
|
||||||
preg_match('/\(.*\)/im', $str, $matches);
|
|
||||||
$domain = explode("_", $file)[1];
|
|
||||||
$selector = explode("_", $file)[0];
|
|
||||||
if(isset($matches[0])) {
|
|
||||||
$str = str_replace(array(' ', '"', '(', ')'), '', $matches[0]);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-2">
|
<div class="col-xs-2">
|
||||||
<p>Domain: <strong><?=htmlspecialchars($domain);?></strong> (<?=htmlspecialchars($selector);?>._domainkey)</p>
|
<p>Domain: <strong><?=htmlspecialchars($domain);?></strong> (dkim._domainkey)</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-9">
|
<div class="col-xs-9">
|
||||||
<pre>v=DKIM1;k=rsa;t=s;s=email;p=<?=$str;?></pre>
|
<pre>v=DKIM1;k=rsa;t=s;s=email;p=<?=$pubKey;?></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-1">
|
<div class="col-xs-1">
|
||||||
<form class="form-inline" role="form" method="post">
|
<form class="form-inline" role="form" method="post">
|
||||||
<a href="#" onclick="$(this).closest('form').submit()"><span class="glyphicon glyphicon-remove-circle"></span></a>
|
<a href="#" onclick="$(this).closest('form').submit()"><span class="glyphicon glyphicon-remove-circle"></span></a>
|
||||||
<input type="hidden" name="delete_dkim_record" value="<?=htmlspecialchars($file);?>">
|
<input type="hidden" name="delete_dkim_record" value="<?=htmlspecialchars($file);?>">
|
||||||
<input type="hidden" name="dkim[domain]" value="<?=$domain;?>">
|
<input type="hidden" name="dkim[domain]" value="<?=$domain;?>">
|
||||||
<input type="hidden" name="dkim[selector]" value="<?=$selector;?>">
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -242,10 +235,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<label for="dkim_domain">Domain</label>
|
<label for="dkim_domain">Domain</label>
|
||||||
<input class="form-control" id="dkim_domain" name="dkim[domain]" placeholder="example.org" required>
|
<input class="form-control" id="dkim_domain" name="dkim[domain]" placeholder="example.org" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="dkim_selector">Selector</label>
|
|
||||||
<input class="form-control" id="dkim_selector" name="dkim[selector]" value="default" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select class="form-control" id="dkim_key_size" name="dkim[key_size]" title="<?=$lang['admin']['dkim_key_length'];?>" required>
|
<select class="form-control" id="dkim_key_size" name="dkim[key_size]" title="<?=$lang['admin']['dkim_key_length'];?>" required>
|
||||||
<option>1024</option>
|
<option>1024</option>
|
||||||
|
|
|
@ -277,37 +277,27 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
if (file_exists($GLOBALS["MC_DKIM_TXTS"]. "/" . $domain . "." . "dkim")) {
|
||||||
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..', '.dkim_pub_keys'));
|
$pubKey = file_get_contents($GLOBALS["MC_DKIM_TXTS"]. "/" . $domain . "." . "dkim");
|
||||||
foreach($dnstxt_files as $file) {
|
|
||||||
if (explode("_", $file)[1] == $domain) {
|
|
||||||
$str = file_get_contents($GLOBALS["MC_DKIM_TXTS"]."/".$file);
|
|
||||||
$str = preg_replace('/\r|\t|\n/', '', $str);
|
|
||||||
preg_match('/\(.*\)/im', $str, $matches);
|
|
||||||
if(isset($matches[0])) {
|
|
||||||
$str = str_replace(array(' ', '"', '(', ')'), '', $matches[0]);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-2">
|
<div class="col-xs-2">
|
||||||
<p class="text-right"><?=$lang['edit']['dkim_signature'];?></p>
|
<p>Domain: <strong><?=htmlspecialchars($domain);?></strong> (dkim._domainkey)</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-10">
|
<div class="col-xs-9">
|
||||||
<div class="col-md-2"><b><?=$lang['edit']['dkim_txt_name'];?></b></div>
|
<pre>v=DKIM1;k=rsa;t=s;s=email;p=<?=$pubKey;?></pre>
|
||||||
<div class="col-md-10">
|
|
||||||
<pre><?=htmlspecialchars(explode("_", $file)[0]);?>._domainkey</pre>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2"><b><?=$lang['edit']['dkim_txt_value'];?></b></div>
|
|
||||||
<div class="col-md-10">
|
|
||||||
<pre>v=DKIM1;k=rsa;t=s;s=email;p=<?=htmlspecialchars($str);?></pre>
|
|
||||||
<?=$lang['edit']['dkim_record_info'];?>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-xs-1">
|
||||||
|
<form class="form-inline" role="form" method="post">
|
||||||
|
<a href="#" onclick="$(this).closest('form').submit()"><span class="glyphicon glyphicon-remove-circle"></span></a>
|
||||||
|
<input type="hidden" name="delete_dkim_record" value="<?=htmlspecialchars($file);?>">
|
||||||
|
<input type="hidden" name="dkim[domain]" value="<?=$domain;?>">
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
?>
|
?>
|
||||||
<div class="alert alert-info" role="alert"><?=$lang['info']['no_action'];?></div>
|
<div class="alert alert-info" role="alert"><?=$lang['info']['no_action'];?></div>
|
||||||
|
|
|
@ -162,15 +162,14 @@ function dkim_table($action, $item) {
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case "delete":
|
case "delete":
|
||||||
$domain = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['domain']);
|
$domain = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['domain']);
|
||||||
$selector = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['selector']);
|
if (!is_valid_domain_name($domain)) {
|
||||||
if (!ctype_alnum($selector) || !is_valid_domain_name($domain)) {
|
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exec('rm ' . escapeshellarg($GLOBALS['MC_DKIM_TXTS'] . '/' . $selector . '_' . $domain), $out, $return);
|
exec('rm ' . escapeshellarg($GLOBALS['MC_DKIM_TXTS'] . '/' . $domain . '.dkim'), $out, $return);
|
||||||
if ($return != "0") {
|
if ($return != "0") {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -178,7 +177,7 @@ function dkim_table($action, $item) {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exec('rm ' . escapeshellarg($GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.' . $selector), $out, $return);
|
exec('rm ' . escapeshellarg($GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.dkim'), $out, $return);
|
||||||
if ($return != "0") {
|
if ($return != "0") {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -193,9 +192,8 @@ function dkim_table($action, $item) {
|
||||||
break;
|
break;
|
||||||
case "add":
|
case "add":
|
||||||
$domain = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['domain']);
|
$domain = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['domain']);
|
||||||
$selector = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['selector']);
|
|
||||||
$key_length = intval($item['dkim']['key_size']);
|
$key_length = intval($item['dkim']['key_size']);
|
||||||
if (!ctype_alnum($selector) || !is_valid_domain_name($domain) || !is_numeric($key_length)) {
|
if (!is_valid_domain_name($domain) || !is_numeric($key_length)) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||||
|
@ -203,8 +201,7 @@ function dkim_table($action, $item) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($GLOBALS['MC_DKIM_TXTS'] . '/' . $selector . '_' . $domain) ||
|
if (!empty(glob($GLOBALS['MC_DKIM_TXTS'] . '/' . $domain . '.dkim'))) {
|
||||||
file_exists($GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.' . $selector)) {
|
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||||
|
@ -225,9 +222,9 @@ function dkim_table($action, $item) {
|
||||||
), 1, -1)
|
), 1, -1)
|
||||||
);
|
);
|
||||||
// Save public key to file
|
// Save public key to file
|
||||||
file_put_contents($GLOBALS['MC_DKIM_TXTS'] . '/' . $selector . '_' . $domain, $pubKey);
|
file_put_contents($GLOBALS['MC_DKIM_TXTS'] . '/' . $domain . '.dkim', $pubKey);
|
||||||
// Save private key to file
|
// Save private key to file
|
||||||
openssl_pkey_export_to_file($keypair_ressource, $GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.' . $selector);
|
openssl_pkey_export_to_file($keypair_ressource, $GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.dkim');
|
||||||
|
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
|
|
|
@ -19,8 +19,8 @@ $database_name = getenv('DBNAME');
|
||||||
$FORM_ACTION = "previous";
|
$FORM_ACTION = "previous";
|
||||||
|
|
||||||
// File locations should not be changed
|
// File locations should not be changed
|
||||||
$MC_DKIM_TXTS = "/shared/dkim/txt";
|
$MC_DKIM_TXTS = "/data/dkim/txt";
|
||||||
$MC_DKIM_KEYS = "/shared/dkim/keys";
|
$MC_DKIM_KEYS = "/data/dkim/keys";
|
||||||
|
|
||||||
// Change default language, "en", "pt", "de" or "nl"
|
// Change default language, "en", "pt", "de" or "nl"
|
||||||
$DEFAULT_LANG = "en";
|
$DEFAULT_LANG = "en";
|
||||||
|
|
Loading…
Reference in New Issue