From b5793048dfd6a7bcc2e940fd3bc716f767c7a43a Mon Sep 17 00:00:00 2001 From: Kristian Date: Tue, 2 Jan 2018 12:30:45 +0100 Subject: [PATCH 1/2] Remember selected lang in cookie # Conflicts: # data/web/inc/prerequisites.inc.php --- data/web/inc/prerequisites.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/web/inc/prerequisites.inc.php b/data/web/inc/prerequisites.inc.php index c78b5aad..8aa20770 100644 --- a/data/web/inc/prerequisites.inc.php +++ b/data/web/inc/prerequisites.inc.php @@ -55,7 +55,7 @@ exit; require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php'; // Set language -if (!isset($_SESSION['mailcow_locale'])) { +if (!isset($_SESSION['mailcow_locale']) && !isset($_COOKIE['mailcow_locale'])) { if ($DETECT_LANGUAGE && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $header_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); foreach ($AVAILABLE_LANGUAGES as $available_lang) { @@ -68,8 +68,12 @@ if (!isset($_SESSION['mailcow_locale'])) { $_SESSION['mailcow_locale'] = strtolower(trim($DEFAULT_LANG)); } } +if (isset($_COOKIE['mailcow_locale'])) { + $_SESSION['mailcow_locale'] = $_COOKIE['mailcow_locale']; +} if (isset($_GET['lang']) && in_array($_GET['lang'], $AVAILABLE_LANGUAGES)) { $_SESSION['mailcow_locale'] = $_GET['lang']; + setcookie("mailcow_locale", $_GET['lang'], time()+30758400); // one year } require_once $_SERVER['DOCUMENT_ROOT'] . '/lang/lang.en.php'; From 7a54b5cb67cf83e32b4c7c4584117b4320ed8ec9 Mon Sep 17 00:00:00 2001 From: "andre.peters" Date: Wed, 3 Jan 2018 20:49:38 +0100 Subject: [PATCH 2/2] [Web] Some minor fixes/changes to DNS diagnostics --- data/web/inc/ajax/dns_diagnostics.php | 252 +++++++++++++++++++------- 1 file changed, 187 insertions(+), 65 deletions(-) diff --git a/data/web/inc/ajax/dns_diagnostics.php b/data/web/inc/ajax/dns_diagnostics.php index 0b29d253..43d3ea5f 100644 --- a/data/web/inc/ajax/dns_diagnostics.php +++ b/data/web/inc/ajax/dns_diagnostics.php @@ -2,8 +2,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/spf.inc.php'; -define('state_good', 'OK'); -define('state_missing', "✗"); +define('state_good', ''); +define('state_missing', ''); define('state_nomatch', "?"); define('state_optional', " 2"); @@ -63,72 +63,192 @@ if (!empty($ip6)) { $https_port = strpos($_SERVER['HTTP_HOST'], ':'); if ($https_port === FALSE) { $https_port = 443; -} else { - $https_port = substr($_SERVER['HTTP_HOST'], $https_port+1); } - -$records = array(); -$records[] = array($mailcow_hostname, 'A', $ip); -$records[] = array($ptr, 'PTR', $mailcow_hostname); -if (!empty($ip6)) { - $records[] = array($mailcow_hostname, 'AAAA', $ip6); - $records[] = array($ptr6, 'PTR', $mailcow_hostname); +else { + $https_port = substr($_SERVER['HTTP_HOST'], $https_port+1); } if (!isset($autodiscover_config['sieve'])) { $autodiscover_config['sieve'] = array('server' => $mailcow_hostname, 'port' => array_pop(explode(':', getenv('SIEVE_PORT')))); } -$records[] = array('_25._tcp.' . $autodiscover_config['smtp']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1)); -$records[] = array('_' . $https_port . '._tcp.' . $mailcow_hostname, 'TLSA', generate_tlsa_digest($mailcow_hostname, $https_port)); -$records[] = array('_' . $autodiscover_config['pop3']['tlsport'] . '._tcp.' . $autodiscover_config['pop3']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1)); -$records[] = array('_' . $autodiscover_config['imap']['tlsport'] . '._tcp.' . $autodiscover_config['imap']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1)); -$records[] = array('_' . $autodiscover_config['smtp']['port'] . '._tcp.' . $autodiscover_config['smtp']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port'])); -$records[] = array('_' . $autodiscover_config['smtp']['tlsport'] . '._tcp.' . $autodiscover_config['smtp']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1)); -$records[] = array('_' . $autodiscover_config['imap']['port'] . '._tcp.' . $autodiscover_config['imap']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port'])); -$records[] = array('_' . $autodiscover_config['pop3']['port'] . '._tcp.' . $autodiscover_config['pop3']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port'])); -$records[] = array('_' . $autodiscover_config['sieve']['port'] . '._tcp.' . $autodiscover_config['sieve']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1)); -$records[] = array($domain, 'MX', $mailcow_hostname); -$records[] = array('autodiscover.' . $domain, 'CNAME', $mailcow_hostname); -$records[] = array('_autodiscover._tcp.' . $domain, 'SRV', $mailcow_hostname . ' ' . $https_port); -$records[] = array('autoconfig.' . $domain, 'CNAME', $mailcow_hostname); -$records[] = array($domain, 'TXT', 'SPF Record Syntax', state_optional); -$records[] = array('_dmarc.' . $domain, 'TXT', 'DMARC Assistant', state_optional); +// Init records array +$records = array(); +$records[] = array( + $mailcow_hostname, + 'A', + $ip +); +$records[] = array( + $ptr, + 'PTR', + $mailcow_hostname +); +if (!empty($ip6)) { + $records[] = array( + $mailcow_hostname, + 'AAAA', + $ip6 + ); + $records[] = array( + $ptr6, + 'PTR', + $mailcow_hostname + ); +} +$records[] = array( + '_25._tcp.' . $autodiscover_config['smtp']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1) +); +$records[] = array( + '_' . $https_port . '._tcp.' . $mailcow_hostname, + 'TLSA', + generate_tlsa_digest($mailcow_hostname, $https_port) +); +$records[] = array( + '_' . $autodiscover_config['pop3']['tlsport'] . '._tcp.' . $autodiscover_config['pop3']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1) +); +$records[] = array( + '_' . $autodiscover_config['imap']['tlsport'] . '._tcp.' . $autodiscover_config['imap']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1) +); +$records[] = array( + '_' . $autodiscover_config['smtp']['port'] . '._tcp.' . $autodiscover_config['smtp']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port']) +); +$records[] = array( + '_' . $autodiscover_config['smtp']['tlsport'] . '._tcp.' . $autodiscover_config['smtp']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1) +); +$records[] = array( + '_' . $autodiscover_config['imap']['port'] . '._tcp.' . $autodiscover_config['imap']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port']) +); +$records[] = array( + '_' . $autodiscover_config['pop3']['port'] . '._tcp.' . $autodiscover_config['pop3']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port']) +); +$records[] = array( + '_' . $autodiscover_config['sieve']['port'] . '._tcp.' . $autodiscover_config['sieve']['server'], + 'TLSA', + generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1) +); +$records[] = array( + $domain, + 'MX', + $mailcow_hostname +); +$records[] = array( + 'autodiscover.' . $domain, + 'CNAME', + $mailcow_hostname +); +$records[] = array( + '_autodiscover._tcp.' . $domain, + 'SRV', + $mailcow_hostname . ' ' . $https_port +); +$records[] = array( + 'autoconfig.' . $domain, + 'CNAME', + $mailcow_hostname +); +$records[] = array( + $domain, + 'TXT', + 'SPF Record Syntax', + state_optional +); +$records[] = array( + '_dmarc.' . $domain, + 'TXT', + 'DMARC Assistant', + state_optional +); if (!empty($dkim = dkim('details', $domain))) { - $records[] = array($dkim['dkim_selector'] . '._domainkey.' . $domain, 'TXT', $dkim['dkim_txt']); + $records[] = array( + $dkim['dkim_selector'] . '._domainkey.' . $domain, + 'TXT', + $dkim['dkim_txt'] + ); } - $current_records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); if (count($current_records) == 0 || $current_records[0]['target'] != '') { - if ($autodiscover_config['pop3']['tlsport'] != '110') { - $records[] = array('_pop3._tcp.' . $domain, 'SRV', $autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['tlsport']); + if ($autodiscover_config['pop3']['tlsport'] != '110') { + $records[] = array( + '_pop3._tcp.' . $domain, + 'SRV', + $autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['tlsport'] + ); } -} else { - $records[] = array('_pop3._tcp.' . $domain, 'SRV', '. 0'); +} +else { + $records[] = array( + '_pop3._tcp.' . $domain, + 'SRV', + '. 0' + ); } $current_records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); if (count($current_records) == 0 || $current_records[0]['target'] != '') { - if ($autodiscover_config['pop3']['port'] != '995') { - $records[] = array('_pop3s._tcp.' . $domain, 'SRV', $autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['port']); + if ($autodiscover_config['pop3']['port'] != '995') { + $records[] = array( + '_pop3s._tcp.' . $domain, + 'SRV', + $autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['port'] + ); } -} else { - $records[] = array('_pop3s._tcp.' . $domain, 'SRV', '. 0'); } -if ($autodiscover_config['imap']['tlsport'] != '143') { - $records[] = array('_imap._tcp.' . $domain, 'SRV', $autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['tlsport']); +else { + $records[] = array( + '_pop3s._tcp.' . $domain, + 'SRV', + '. 0' + ); } -if ($autodiscover_config['imap']['port'] != '993') { - $records[] = array('_imaps._tcp.' . $domain, 'SRV', $autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['port']); +if ($autodiscover_config['imap']['tlsport'] != '143') { + $records[] = array( + '_imap._tcp.' . $domain, + 'SRV', + $autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['tlsport'] + ); } -if ($autodiscover_config['smtp']['tlsport'] != '587') { - $records[] = array('_submission._tcp.' . $domain, 'SRV', $autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['tlsport']); +if ($autodiscover_config['imap']['port'] != '993') { + $records[] = array( + '_imaps._tcp.' . $domain, + 'SRV', + $autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['port'] + ); } -if ($autodiscover_config['smtp']['port'] != '465') { - $records[] = array('_smtps._tcp.' . $domain, 'SRV', $autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['port']); +if ($autodiscover_config['smtp']['tlsport'] != '587') { + $records[] = array( + '_submission._tcp.' . $domain, + 'SRV', + $autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['tlsport'] + ); } -if ($autodiscover_config['sieve']['port'] != '4190') { - $records[] = array('_sieve._tcp.' . $domain, 'SRV', $autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port']); +if ($autodiscover_config['smtp']['port'] != '465') { + $records[] = array( + '_smtps._tcp.' . $domain, + 'SRV', + $autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['port'] + ); +} +if ($autodiscover_config['sieve']['port'] != '4190') { + $records[] = array( + '_sieve._tcp.' . $domain, + 'SRV', + $autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port'] + ); } $record_types = array( @@ -151,9 +271,14 @@ $data_field = array( 'TXT' => 'txt', ); ?> -
- - +
+
+ + + + + + ', $record[0], $record[1], $record[2], $state); } ?> -
-
-

- 1
- 2 -

+ + +

+1
+2 +