autodiscover-json.php 1.0 KB

12345678910111213141516171819202122
  1. <?php
  2. require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
  3. require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.inc.php';
  4. $default_autodiscover_config = $autodiscover_config;
  5. if(file_exists('inc/vars.local.inc.php')) {
  6. include_once 'inc/vars.local.inc.php';
  7. }
  8. $autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
  9. header('Content-type: application/json');
  10. if (strtolower($_GET['Protocol']) == 'activesync' && getenv('SKIP_SOGO') != "y") {
  11. echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config['activesync']['url'] . '"}';
  12. }
  13. elseif (strtolower($_GET['Protocol']) == 'autodiscoverv1') {
  14. echo '{"Protocol":"AutodiscoverV1","Url":"https://' . $_SERVER['HTTP_HOST'] . '/Autodiscover/Autodiscover.xml"}';
  15. }
  16. else {
  17. http_response_code(400);
  18. 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"}';
  19. }
  20. ?>