2017-09-27 04:11:01 +08:00
< ? php
2018-10-11 17:59:23 +08:00
require_once $_SERVER [ 'DOCUMENT_ROOT' ] . '/inc/vars.inc.php' ;
require_once $_SERVER [ 'DOCUMENT_ROOT' ] . '/inc/functions.inc.php' ;
2017-09-27 04:11:01 +08:00
$default_autodiscover_config = $autodiscover_config ;
if ( file_exists ( 'inc/vars.local.inc.php' )) {
include_once 'inc/vars.local.inc.php' ;
}
$autodiscover_config = array_merge ( $default_autodiscover_config , $autodiscover_config );
header ( 'Content-type: application/json' );
2020-07-14 18:15:49 +08:00
if ( strtolower ( $_GET [ 'Protocol' ]) == 'activesync' && getenv ( 'SKIP_SOGO' ) != " y " ) {
2017-09-27 04:11:01 +08:00
echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config [ 'activesync' ][ 'url' ] . '"}' ;
2017-10-03 05:22:53 +08:00
}
2019-02-11 20:52:24 +08:00
elseif ( strtolower ( $_GET [ 'Protocol' ]) == 'autodiscoverv1' ) {
2018-01-12 06:20:27 +08:00
echo '{"Protocol":"AutodiscoverV1","Url":"https://' . $_SERVER [ 'HTTP_HOST' ] . '/Autodiscover/Autodiscover.xml"}' ;
2017-10-03 05:22:53 +08:00
}
else {
2017-09-27 04:11:01 +08:00
http_response_code ( 400 );
2021-09-08 00:58:05 +08:00
echo '{"ErrorCode":"InvalidProtocol","ErrorMessage":"The given protocol value \u0027' . preg_replace ( " /[^ \ da-z]/i " , '' , $_GET [ 'Protocol' ]) . '\u0027 is invalid. Supported values are \u0027ActiveSync,AutodiscoverV1\u0027"}' ;
2017-09-27 04:11:01 +08:00
}
2017-10-03 05:22:53 +08:00
?>