Update autodiscover-json.php

HTTP_HOST is okay.
Syntax for consistency. :-)
master
André Peters 2017-10-02 23:22:53 +02:00 committed by GitHub
parent c731a18f66
commit e1ee1e848f
1 changed files with 6 additions and 8 deletions

View File

@ -8,15 +8,13 @@ if(file_exists('inc/vars.local.inc.php')) {
$autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config); $autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
header('Content-type: application/json'); header('Content-type: application/json');
$domain_dot = strpos($_SERVER['HTTP_HOST'], '.');
$domain = substr($_SERVER['HTTP_HOST'], $domain_dot+1);
if ($_GET['Protocol'] == 'ActiveSync') { if ($_GET['Protocol'] == 'ActiveSync') {
echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config['activesync']['url'] . '"}'; echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config['activesync']['url'] . '"}';
} elseif ($_GET['Protocol'] == 'AutodiscoverV1') { }
echo '{"Protocol":"AutodiscoverV1","Url":"https://autodiscover.' . $domain . '/autodiscover/autodiscover.xml"}'; elseif ($_GET['Protocol'] == 'AutodiscoverV1') {
} else { echo '{"Protocol":"AutodiscoverV1","Url":"https://' . $_SERVER['HTTP_HOST'] . '/autodiscover/autodiscover.xml"}';
}
else {
http_response_code(400); http_response_code(400);
echo '{"ErrorCode":"InvalidProtocol","ErrorMessage":"The given protocol value \u0027' . $_GET['Protocol'] . '\u0027 is invalid. Supported values are \u0027ActiveSync,AutodiscoverV1\u0027"}'; echo '{"ErrorCode":"InvalidProtocol","ErrorMessage":"The given protocol value \u0027' . $_GET['Protocol'] . '\u0027 is invalid. Supported values are \u0027ActiveSync,AutodiscoverV1\u0027"}';
} }