From 4c75967b2bd57bb4b274694184a21638dc78c447 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 15 Dec 2016 10:03:58 +0100 Subject: [PATCH] Use dkim selector by default --- data/web/admin.php | 23 +++++-------------- data/web/edit.php | 42 +++++++++++++--------------------- data/web/inc/functions.inc.php | 17 ++++++-------- data/web/inc/vars.inc.php | 4 ++-- 4 files changed, 31 insertions(+), 55 deletions(-) diff --git a/data/web/admin.php b/data/web/admin.php index 30b773c1..24327b02 100644 --- a/data/web/admin.php +++ b/data/web/admin.php @@ -205,31 +205,24 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

Domain: (._domainkey)

+

Domain: (dkim._domainkey)

-
v=DKIM1;k=rsa;t=s;s=email;p=
+
v=DKIM1;k=rsa;t=s;s=email;p=
-
@@ -242,10 +235,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
- - -
+ + +
+
'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', diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php index db96fb67..0f348ccc 100644 --- a/data/web/inc/vars.inc.php +++ b/data/web/inc/vars.inc.php @@ -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";