public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] Better fkey handling in init_db; set body font size to 11pt instead of 14px; Changes to autodiscover functions
a837c9ab
data/web/autodiscover.php | 24 ++++++++++++++----------
data/web/css/mailcow.css | 3 +++
data/web/inc/init_db.inc.php | 18 ++++++++++--------
data/web/inc/vars.inc.php | 6 ++++--
4 files changed, 31 insertions(+), 20 deletions(-)
Diff
diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php
index 551cc6dc..e7c5f969 100644
--- a/data/web/autodiscover.php
+++ b/data/web/autodiscover.php
@@ -15,16 +15,20 @@ error_reporting(0);
$data = trim(file_get_contents("php://input"));
-// Desktop client needs IMAP, unless it's Outlook 2013 or higher on Windows
-if (strpos($data, 'autodiscover/outlook/responseschema') !== false) { // desktop client
- $autodiscover_config['autodiscoverType'] = 'imap';
- if ($autodiscover_config['useEASforOutlook'] == 'yes' &&
- // Office for macOS does not support EAS
- strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false &&
- // Outlook 2013 (version 15) or higher
- preg_match('/(Outlook|Office).+1[5-9]\./', $_SERVER['HTTP_USER_AGENT'])
- ) {
- $autodiscover_config['autodiscoverType'] = 'activesync';
+if ($autodiscover_config['autodiscoverType'] == 'activesync') {
+ if (preg_match("/Outlook/i", $_SERVER['HTTP_USER_AGENT'])) {
+ if ($autodiscover_config['useEASforOutlook'] == 'yes') {
+ preg_match("/^((?!.*Mac).)*(Outlook|Office).+1[5-9].*/i", $_SERVER['HTTP_USER_AGENT'], $supported_outlook);
+ if (empty($supported_outlook)) {
+ $autodiscover_config['autodiscoverType'] = 'imap';
+ }
+ }
+ else {
+ $autodiscover_config['autodiscoverType'] = 'imap';
+ }
+ }
+ if (preg_match("/emClient/i", $_SERVER['HTTP_USER_AGENT'])) {
+ $autodiscover_config['autodiscoverType'] = 'imap';
}
}
diff --git a/data/web/css/mailcow.css b/data/web/css/mailcow.css
index eeade3c7..e3356ee7 100644
--- a/data/web/css/mailcow.css
+++ b/data/web/css/mailcow.css
@@ -83,6 +83,9 @@ body.modal-open {
overflow: inherit;
padding-right: inherit !important;
}
+body {
+ font-size:11pt;
+}
#mailcow-alert {
position: fixed;
bottom: 8px;
diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php
index 32418534..e2d18517 100644
--- a/data/web/inc/init_db.inc.php
+++ b/data/web/inc/init_db.inc.php
@@ -3,7 +3,7 @@ function init_db_schema() {
try {
global $pdo;
- $db_version = "15092017_0754";
+ $db_version = "02102017_0748";
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
@@ -498,6 +498,13 @@ function init_db_schema() {
$stmt = $pdo->query("SHOW TABLES LIKE '" . $table . "'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results != 0) {
+ $stmt = $pdo->prepare("SELECT CONCAT('ALTER TABLE ', `table_schema`, '.', `table_name`, ' DROP FOREIGN KEY ', `constraint_name`, ';') AS `FKEY_DROP` FROM `information_schema`.`table_constraints`
+ WHERE `constraint_type` = 'FOREIGN KEY' AND `table_name` = :table;");
+ $stmt->execute(array(':table' => $table));
+ $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ while ($row = array_shift($rows)) {
+ $pdo->query($row['FKEY_DROP']);
+ }
foreach($properties['cols'] as $column => $type) {
$stmt = $pdo->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
@@ -542,7 +549,7 @@ function init_db_schema() {
$stmt = $pdo->query("SHOW KEYS FROM `" . $table . "` WHERE Key_name = '" . $key_name . "'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results != 0) {
- $pdo->query("ALTER TABLE `" . $table . "` DROP FOREIGN KEY `" . $key_name . "`");
+ $pdo->query("ALTER TABLE `" . $table . "` DROP INDEX `" . $key_name . "`");
}
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
$pdo->query("ALTER TABLE `" . $table . "` ADD FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
@@ -582,12 +589,7 @@ function init_db_schema() {
// Step 2: Drop all vanished indexes
while ($row = array_shift($keys_in_table)) {
if (!in_array($row['Key_name'], $keys_to_exist)) {
- try {
- $pdo->query("ALTER TABLE `" . $table . "` DROP FOREIGN KEY `" . $row['Key_name'] . "`");
- }
- finally {
- $pdo->query("ALTER TABLE `" . $table . "` DROP INDEX `" . $row['Key_name'] . "`");
- }
+ $pdo->query("ALTER TABLE `" . $table . "` DROP INDEX `" . $row['Key_name'] . "`");
}
}
// Step 3: Drop all vanished primary keys
diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php
index dfb40bea..76448a0d 100644
--- a/data/web/inc/vars.inc.php
+++ b/data/web/inc/vars.inc.php
@@ -30,10 +30,12 @@ if ($https_port === FALSE) {
//$https_port = 1234;
// Other settings =>
$autodiscover_config = array(
- // Enable the autodiscover service for Outlook desktop clients
- 'useEASforOutlook' => 'yes',
// General autodiscover service type: "activesync" or "imap"
+ // emClient uses autodiscover, but does not support ActiveSync. mailcow excludes emClient from ActiveSync.
'autodiscoverType' => 'activesync',
+ // If autodiscoverType => activesync, also use ActiveSync (EAS) for Outlook desktop clients (>= Outlook 2013 on Windows)
+ // Outlook for Mac does not support ActiveSync
+ 'useEASforOutlook' => 'yes',
// Please don't use STARTTLS-enabled service ports in the "port" variable.
// The autodiscover service will always point to SMTPS and IMAPS (TLS-wrapped services).
// The autoconfig service will additionally announce the STARTTLS-enabled ports, specified in the "tlsport" variable.