From 5e69decd7b65ebcc2dbf5c1c61f39a500b746ad4 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 2 Oct 2017 22:19:20 +0200 Subject: [PATCH] [Web] Temp. workaround for em Client which sends an empty user-agent --- data/web/autodiscover.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index 69324f8b..e191aa42 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -15,6 +15,8 @@ error_reporting(0); $data = trim(file_get_contents("php://input")); +file_put_contents('/tmp/dsa', json_encode($_SERVER), FILE_APPEND); + if ($autodiscover_config['autodiscoverType'] == 'activesync') { if (preg_match("/(Outlook|Office)/i", $_SERVER['HTTP_USER_AGENT'])) { if ($autodiscover_config['useEASforOutlook'] == 'yes') { @@ -27,7 +29,7 @@ if ($autodiscover_config['autodiscoverType'] == 'activesync') { $autodiscover_config['autodiscoverType'] = 'imap'; } } - if (preg_match("/eM Client/i", $_SERVER['HTTP_USER_AGENT'])) { + if (preg_match("/eM Client/i", $_SERVER['HTTP_USER_AGENT']) || !isset($_SERVER['HTTP_USER_AGENT'])) { $autodiscover_config['autodiscoverType'] = 'imap'; } } @@ -62,7 +64,7 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $login_role !== "user") { ); return false; } - header('WWW-Authenticate: Basic realm=""'); + header('WWW-Authenticate: Basic realm="' . $_SERVER['HTTP_HOST'] . '"'); header('HTTP/1.0 401 Unauthorized'); exit(0); }