[Web] Fix autodiscover merge on user.php

master
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')) { if(file_exists('inc/vars.local.inc.php')) {
include_once '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); error_reporting(0);
@ -33,15 +33,15 @@ header('Content-Type: application/xml');
<displayShortName>mail server</displayShortName> <displayShortName>mail server</displayShortName>
<incomingServer type="imap"> <incomingServer type="imap">
<hostname><?=$configuration['imap']['server']; ?></hostname> <hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
<port><?=$configuration['imap']['port']; ?></port> <port><?=$autodiscover_config['imap']['port']; ?></port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
</incomingServer> </incomingServer>
<incomingServer type="imap"> <incomingServer type="imap">
<hostname><?=$configuration['imap']['server']; ?></hostname> <hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
<port><?=$configuration['imap']['tlsport']; ?></port> <port><?=$autodiscover_config['imap']['tlsport']; ?></port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <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 $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'] != '') { ?> if (count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$configuration['pop3']['server']; ?></hostname> <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$configuration['pop3']['port']; ?></port> <port><?=$autodiscover_config['pop3']['port']; ?></port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <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 $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'] != '') { ?> if (count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$configuration['pop3']['server']; ?></hostname> <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$configuration['pop3']['tlsport']; ?></port> <port><?=$autodiscover_config['pop3']['tlsport']; ?></port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
@ -71,15 +71,15 @@ if (count($records) == 0 || $records[0]['target'] != '') { ?>
<?php } ?> <?php } ?>
<outgoingServer type="smtp"> <outgoingServer type="smtp">
<hostname><?=$configuration['smtp']['server']; ?></hostname> <hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
<port><?=$configuration['smtp']['port']; ?></port> <port><?=$autodiscover_config['smtp']['port']; ?></port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
</outgoingServer> </outgoingServer>
<outgoingServer type="smtp"> <outgoingServer type="smtp">
<hostname><?=$configuration['smtp']['server']; ?></hostname> <hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
<port><?=$configuration['smtp']['tlsport']; ?></port> <port><?=$autodiscover_config['smtp']['tlsport']; ?></port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>

View File

@ -5,7 +5,7 @@ $default_autodiscover_config = $autodiscover_config;
if(file_exists('inc/vars.local.inc.php')) { if(file_exists('inc/vars.local.inc.php')) {
include_once '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
$redis = new 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 // Desktop client needs IMAP, unless it's Outlook 2013 or higher on Windows
if (strpos($data, 'autodiscover/outlook/responseschema') !== false) { // desktop client if (strpos($data, 'autodiscover/outlook/responseschema') !== false) { // desktop client
$configuration['autodiscoverType'] = 'imap'; $autodiscover_config['autodiscoverType'] = 'imap';
if ($configuration['useEASforOutlook'] == 'yes' && if ($autodiscover_config['useEASforOutlook'] == 'yes' &&
// Office for macOS does not support EAS // Office for macOS does not support EAS
strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false &&
// Outlook 2013 (version 15) or higher // Outlook 2013 (version 15) or higher
preg_match('/(Outlook|Office).+1[5-9]\./', $_SERVER['HTTP_USER_AGENT']) 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; $displayname = $email;
} }
if ($configuration['autodiscoverType'] == 'imap') { if ($autodiscover_config['autodiscoverType'] == 'imap') {
?> ?>
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"> <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<User> <User>
@ -99,8 +99,8 @@ else {
<Action>settings</Action> <Action>settings</Action>
<Protocol> <Protocol>
<Type>IMAP</Type> <Type>IMAP</Type>
<Server><?=$configuration['imap']['server'];?></Server> <Server><?=$autodiscover_config['imap']['server'];?></Server>
<Port><?=$configuration['imap']['port'];?></Port> <Port><?=$autodiscover_config['imap']['port'];?></Port>
<DomainRequired>off</DomainRequired> <DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName> <LoginName><?=$email;?></LoginName>
<SPA>off</SPA> <SPA>off</SPA>
@ -109,8 +109,8 @@ else {
</Protocol> </Protocol>
<Protocol> <Protocol>
<Type>SMTP</Type> <Type>SMTP</Type>
<Server><?=$configuration['smtp']['server'];?></Server> <Server><?=$autodiscover_config['smtp']['server'];?></Server>
<Port><?=$configuration['smtp']['port'];?></Port> <Port><?=$autodiscover_config['smtp']['port'];?></Port>
<DomainRequired>off</DomainRequired> <DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName> <LoginName><?=$email;?></LoginName>
<SPA>off</SPA> <SPA>off</SPA>
@ -121,13 +121,13 @@ else {
</Protocol> </Protocol>
<Protocol> <Protocol>
<Type>CalDAV</Type> <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> <DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName> <LoginName><?=$email;?></LoginName>
</Protocol> </Protocol>
<Protocol> <Protocol>
<Type>CardDAV</Type> <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> <DomainRequired>off</DomainRequired>
<LoginName><?=$email;?></LoginName> <LoginName><?=$email;?></LoginName>
</Protocol> </Protocol>
@ -135,7 +135,7 @@ else {
</Response> </Response>
<?php <?php
} }
else if ($configuration['autodiscoverType'] == 'activesync') { else if ($autodiscover_config['autodiscoverType'] == 'activesync') {
?> ?>
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006"> <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006">
<Culture>en:en</Culture> <Culture>en:en</Culture>
@ -147,8 +147,8 @@ else {
<Settings> <Settings>
<Server> <Server>
<Type>MobileSync</Type> <Type>MobileSync</Type>
<Url><?=$configuration['activesync']['url'];?></Url> <Url><?=$autodiscover_config['activesync']['url'];?></Url>
<Name><?=$configuration['activesync']['url'];?></Name> <Name><?=$autodiscover_config['activesync']['url'];?></Name>
</Server> </Server>
</Settings> </Settings>
</Action> </Action>

View File

@ -1,8 +1,10 @@
<?php <?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')) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
include_once $_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'; require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';

View File

@ -60,21 +60,18 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
/ USER / USER
*/ */
require_once("inc/header.inc.php"); require_once("inc/header.inc.php");
$_SESSION['return_to'] = $_SERVER['REQUEST_URI']; $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
$username = $_SESSION['mailcow_cc_username']; $username = $_SESSION['mailcow_cc_username'];
$mailboxdata = mailbox('get', 'mailbox_details', $username); $mailboxdata = mailbox('get', 'mailbox_details', $username);
$clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&port=" . urlencode($autodiscover_config['caldav']['port']); $clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&port=" . urlencode($autodiscover_config['caldav']['port']);
if ($autodiscover_config['useEASforOutlook'] == 'yes') if ($autodiscover_config['useEASforOutlook'] == 'yes')
$clientconfigstr .= "&outlookEAS=1"; $clientconfigstr .= "&outlookEAS=1";
if (file_exists('thunderbird-plugins/version.csv')) if (file_exists('thunderbird-plugins/version.csv')) {
{
$fh = fopen('thunderbird-plugins/version.csv', 'r'); $fh = fopen('thunderbird-plugins/version.csv', 'r');
if ($fh) if ($fh) {
{ while (($row = fgetcsv($fh, 1000, ';')) !== FALSE) {
while (($row = fgetcsv($fh, 1000, ';')) !== FALSE)
{
if ($row[0] == 'sogo-integrator@inverse.ca') { if ($row[0] == 'sogo-integrator@inverse.ca') {
$clientconfigstr .= "&integrator=" . urlencode($row[1]); $clientconfigstr .= "&integrator=" . urlencode($row[1]);
} }
@ -82,7 +79,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
fclose($fh); fclose($fh);
} }
} }
?> ?>
<div class="container"> <div class="container">
<h3><?=$lang['user']['user_settings'];?></h3> <h3><?=$lang['user']['user_settings'];?></h3>