Use dkim selector by default
parent
833e1843b3
commit
4c75967b2b
|
@ -205,31 +205,24 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
|||
<div id="collapseDKIM" class="panel-collapse">
|
||||
<div class="panel-body">
|
||||
<?php
|
||||
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
||||
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..', '.dkim_pub_keys'));
|
||||
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
||||
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..'));
|
||||
foreach($dnstxt_files as $file) {
|
||||
$str = file_get_contents($GLOBALS["MC_DKIM_TXTS"]."/".$file);
|
||||
$str = preg_replace('/\r|\t|\n/', '', $str);
|
||||
preg_match('/\(.*\)/im', $str, $matches);
|
||||
$domain = explode("_", $file)[1];
|
||||
$selector = explode("_", $file)[0];
|
||||
if(isset($matches[0])) {
|
||||
$str = str_replace(array(' ', '"', '(', ')'), '', $matches[0]);
|
||||
}
|
||||
$pubKey = file_get_contents($GLOBALS["MC_DKIM_TXTS"]."/".$file);
|
||||
$domain = substr($file, 0, -5);
|
||||
?>
|
||||
<div class="row">
|
||||
<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 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 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;?>">
|
||||
<input type="hidden" name="dkim[selector]" value="<?=$selector;?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -242,10 +235,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
|||
<label for="dkim_domain">Domain</label>
|
||||
<input class="form-control" id="dkim_domain" name="dkim[domain]" placeholder="example.org" required>
|
||||
</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">
|
||||
<select class="form-control" id="dkim_key_size" name="dkim[key_size]" title="<?=$lang['admin']['dkim_key_length'];?>" required>
|
||||
<option>1024</option>
|
||||
|
|
|
@ -277,35 +277,25 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
|
|||
</div>
|
||||
</form>
|
||||
<?php
|
||||
$dnstxt_folder = scandir($GLOBALS["MC_DKIM_TXTS"]);
|
||||
$dnstxt_files = array_diff($dnstxt_folder, array('.', '..', '.dkim_pub_keys'));
|
||||
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]);
|
||||
}
|
||||
if (file_exists($GLOBALS["MC_DKIM_TXTS"]. "/" . $domain . "." . "dkim")) {
|
||||
$pubKey = file_get_contents($GLOBALS["MC_DKIM_TXTS"]. "/" . $domain . "." . "dkim");
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-2">
|
||||
<p class="text-right"><?=$lang['edit']['dkim_signature'];?></p>
|
||||
</div>
|
||||
<div class="col-xs-10">
|
||||
<div class="col-md-2"><b><?=$lang['edit']['dkim_txt_name'];?></b></div>
|
||||
<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="row">
|
||||
<div class="col-xs-2">
|
||||
<p>Domain: <strong><?=htmlspecialchars($domain);?></strong> (dkim._domainkey)</p>
|
||||
</div>
|
||||
<div class="col-xs-9">
|
||||
<pre>v=DKIM1;k=rsa;t=s;s=email;p=<?=$pubKey;?></pre>
|
||||
</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>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -162,15 +162,14 @@ function dkim_table($action, $item) {
|
|||
switch ($action) {
|
||||
case "delete":
|
||||
$domain = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['domain']);
|
||||
$selector = preg_replace('/[^A-Za-z0-9._\-]/', '_', $item['dkim']['selector']);
|
||||
if (!ctype_alnum($selector) || !is_valid_domain_name($domain)) {
|
||||
if (!is_valid_domain_name($domain)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||
);
|
||||
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") {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -178,7 +177,7 @@ function dkim_table($action, $item) {
|
|||
);
|
||||
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") {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
|
@ -193,9 +192,8 @@ function dkim_table($action, $item) {
|
|||
break;
|
||||
case "add":
|
||||
$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']);
|
||||
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(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||
|
@ -203,8 +201,7 @@ function dkim_table($action, $item) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (file_exists($GLOBALS['MC_DKIM_TXTS'] . '/' . $selector . '_' . $domain) ||
|
||||
file_exists($GLOBALS['MC_DKIM_KEYS'] . '/' . $domain . '.' . $selector)) {
|
||||
if (!empty(glob($GLOBALS['MC_DKIM_TXTS'] . '/' . $domain . '.dkim'))) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['dkim_domain_or_sel_invalid'])
|
||||
|
@ -225,9 +222,9 @@ function dkim_table($action, $item) {
|
|||
), 1, -1)
|
||||
);
|
||||
// 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
|
||||
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(
|
||||
'type' => 'success',
|
||||
|
|
|
@ -19,8 +19,8 @@ $database_name = getenv('DBNAME');
|
|||
$FORM_ACTION = "previous";
|
||||
|
||||
// File locations should not be changed
|
||||
$MC_DKIM_TXTS = "/shared/dkim/txt";
|
||||
$MC_DKIM_KEYS = "/shared/dkim/keys";
|
||||
$MC_DKIM_TXTS = "/data/dkim/txt";
|
||||
$MC_DKIM_KEYS = "/data/dkim/keys";
|
||||
|
||||
// Change default language, "en", "pt", "de" or "nl"
|
||||
$DEFAULT_LANG = "en";
|
||||
|
|
Loading…
Reference in New Issue