Commit c1a7096f authored by Manfred Kutas's avatar Manfred Kutas

ZP-1130 Improve default autodiscover config.

Added ZPUSH_HOST constant to autodiscover config. If it is not defined,
try to guess the server from $_SERVER['HTTP_HOST'] or
$_SERVER['SERVER_NAME'].

Released under the Affero GNU General Public License (AGPL) version 3.
parent 7a7ebdb5
......@@ -221,11 +221,13 @@ class ZPushAutodiscover {
*/
private function createResponse($email, $userFullname) {
$xml = file_get_contents('response.xml');
$zpushHost = defined('ZPUSH_HOST') ? ZPUSH_HOST : ( $_SERVER['HTTP_HOST'] ? : $_SERVER['SERVER_NAME']);
$serverUrl = "https://" . $zpushHost . "/Microsoft-Server-ActiveSync";
$response = new SimpleXMLElement($xml);
$response->Response->User->DisplayName = $userFullname;
$response->Response->User->EMailAddress = $email;
$response->Response->Action->Settings->Server->Url = SERVERURL;
$response->Response->Action->Settings->Server->Name = SERVERURL;
$response->Response->Action->Settings->Server->Url = $serverUrl;
$response->Response->Action->Settings->Server->Name = $serverUrl;
$response = $response->asXML();
ZLog::Write(LOGLEVEL_WBXML, sprintf("ZPushAutodiscover->createResponse() XML response:%s%s", PHP_EOL, $response));
return $response;
......
......@@ -26,15 +26,16 @@
/**********************************************************************************
* Default settings
*/
// Replace zpush.example.com with your z-push's host name and uncomment the line below.
// define('ZPUSH_HOST', 'zpush.example.com');
// Defines the default time zone, change e.g. to "Europe/London" if necessary
define('TIMEZONE', '');
// Defines the base path on the server
define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']). '/');
// The Z-Push server location for the autodiscover response
define('SERVERURL', 'https://localhost/Microsoft-Server-ActiveSync');
/*
* Whether to use the complete email address as a login name
* (e.g. user@company.com) or the username only (user).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment