[Web] Fix autodiscover merge on user.php

This commit is contained in:
andryyy 2017-09-16 13:33:27 +02:00
parent e20d31e440
commit c6f81fe67b
4 changed files with 39 additions and 40 deletions

View File

@ -4,7 +4,7 @@ $default_autodiscover_config = $autodiscover_config;
if(file_exists('inc/vars.local.inc.php')) {
include_once 'inc/vars.local.inc.php';
}
$configuration = array_merge($default_autodiscover_config, $autodiscover_config);
$autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
error_reporting(0);
@ -33,15 +33,15 @@ header('Content-Type: application/xml');
<displayShortName>mail server</displayShortName>
<incomingServer type="imap">
<hostname><?=$configuration['imap']['server']; ?></hostname>
<port><?=$configuration['imap']['port']; ?></port>
<hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
<port><?=$autodiscover_config['imap']['port']; ?></port>
<socketType>SSL</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
</incomingServer>
<incomingServer type="imap">
<hostname><?=$configuration['imap']['server']; ?></hostname>
<port><?=$configuration['imap']['tlsport']; ?></port>
<hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
<port><?=$autodiscover_config['imap']['tlsport']; ?></port>
<socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
@ -51,8 +51,8 @@ header('Content-Type: application/xml');
$records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
if (count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3">
<hostname><?=$configuration['pop3']['server']; ?></hostname>
<port><?=$configuration['pop3']['port']; ?></port>
<hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$autodiscover_config['pop3']['port']; ?></port>
<socketType>SSL</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
@ -62,8 +62,8 @@ if (count($records) == 0 || $records[0]['target'] != '') { ?>
$records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
if (count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3">
<hostname><?=$configuration['pop3']['server']; ?></hostname>
<port><?=$configuration['pop3']['tlsport']; ?></port>
<hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$autodiscover_config['pop3']['tlsport']; ?></port>
<socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
@ -71,15 +71,15 @@ if (count($records) == 0 || $records[0]['target'] != '') { ?>
<?php } ?>
<outgoingServer type="smtp">
<hostname><?=$configuration['smtp']['server']; ?></hostname>
<port><?=$configuration['smtp']['port']; ?></port>
<hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
<port><?=$autodiscover_config['smtp']['port']; ?></port>
<socketType>SSL</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
</outgoingServer>
<outgoingServer type="smtp">
<hostname><?=$configuration['smtp']['server']; ?></hostname>
<port><?=$configuration['smtp']['tlsport']; ?></port>
<hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
<port><?=$autodiscover_config['smtp']['tlsport']; ?></port>
<socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>

View File

@ -5,7 +5,7 @@ $default_autodiscover_config = $autodiscover_config;
if(file_exists('inc/vars.local.inc.php')) {
include_once 'inc/vars.local.inc.php';
}
$configuration = array_merge($default_autodiscover_config, $autodiscover_config);
$autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
// Redis
$redis = new Redis();
@ -17,14 +17,14 @@ $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
$configuration['autodiscoverType'] = 'imap';
if ($configuration['useEASforOutlook'] == 'yes' &&
$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'])
) {
$configuration['autodiscoverType'] = 'activesync';
$autodiscover_config['autodiscoverType'] = 'activesync';
}
}
@ -88,7 +88,7 @@ else {
$displayname = $email;
}
if ($configuration['autodiscoverType'] == 'imap') {
if ($autodiscover_config['autodiscoverType'] == 'imap') {
?>
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<User>
@ -99,8 +99,8 @@ else {
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server><?=$configuration['imap']['server'];?></Server>
<Port><?=$configuration['imap']['port'];?></Port>
<Server><?=$autodiscover_config['imap']['server'];?></Server>
<Port><?=$autodiscover_config['imap']['port'];?></Port>
<DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName>
<SPA>off</SPA>
@ -109,8 +109,8 @@ else {
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server><?=$configuration['smtp']['server'];?></Server>
<Port><?=$configuration['smtp']['port'];?></Port>
<Server><?=$autodiscover_config['smtp']['server'];?></Server>
<Port><?=$autodiscover_config['smtp']['port'];?></Port>
<DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName>
<SPA>off</SPA>
@ -121,13 +121,13 @@ else {
</Protocol>
<Protocol>
<Type>CalDAV</Type>
<Server>https://<?=$configuration['caldav']['server'];?><?php if ($configuration['caldav']['port'] != 443) echo ':'.$configuration['caldav']['port']; ?>/SOGo/dav/<?=$email;?>/Calendar</Server>
<Server>https://<?=$autodiscover_config['caldav']['server'];?><?php if ($autodiscover_config['caldav']['port'] != 443) echo ':'.$autodiscover_config['caldav']['port']; ?>/SOGo/dav/<?=$email;?>/Calendar</Server>
<DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName>
</Protocol>
<Protocol>
<Type>CardDAV</Type>
<Server>https://<?=$configuration['carddav']['server'];?><?php if ($configuration['caldav']['port'] != 443) echo ':'.$configuration['carddav']['port']; ?>/SOGo/dav/<?=$email;?>/Contacts</Server>
<Server>https://<?=$autodiscover_config['carddav']['server'];?><?php if ($autodiscover_config['caldav']['port'] != 443) echo ':'.$autodiscover_config['carddav']['port']; ?>/SOGo/dav/<?=$email;?>/Contacts</Server>
<DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName>
</Protocol>
@ -135,7 +135,7 @@ else {
</Response>
<?php
}
else if ($configuration['autodiscoverType'] == 'activesync') {
else if ($autodiscover_config['autodiscoverType'] == 'activesync') {
?>
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006">
<Culture>en:en</Culture>
@ -147,8 +147,8 @@ else {
<Settings>
<Server>
<Type>MobileSync</Type>
<Url><?=$configuration['activesync']['url'];?></Url>
<Name><?=$configuration['activesync']['url'];?></Name>
<Url><?=$autodiscover_config['activesync']['url'];?></Url>
<Name><?=$autodiscover_config['activesync']['url'];?></Name>
</Server>
</Settings>
</Action>

View File

@ -1,8 +1,10 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
require_once 'inc/vars.inc.php';
$default_autodiscover_config = $autodiscover_config;
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php';
}
$autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';

View File

@ -68,13 +68,10 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
$clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&port=" . urlencode($autodiscover_config['caldav']['port']);
if ($autodiscover_config['useEASforOutlook'] == 'yes')
$clientconfigstr .= "&outlookEAS=1";
if (file_exists('thunderbird-plugins/version.csv'))
{
if (file_exists('thunderbird-plugins/version.csv')) {
$fh = fopen('thunderbird-plugins/version.csv', 'r');
if ($fh)
{
while (($row = fgetcsv($fh, 1000, ';')) !== FALSE)
{
if ($fh) {
while (($row = fgetcsv($fh, 1000, ';')) !== FALSE) {
if ($row[0] == 'sogo-integrator@inverse.ca') {
$clientconfigstr .= "&integrator=" . urlencode($row[1]);
}