1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-26 02:57:04 +00:00

Merge branch 'fixes' of github.com:jkaberg/mailinabox into jkaberg-fixes

This commit is contained in:
Joshua Tauberer 2014-08-19 11:22:12 +00:00
commit 28eaf7cba9
5 changed files with 35 additions and 94 deletions

View File

@ -61,7 +61,8 @@ server {
# Microsoft Exchange autodiscover.xml for email # Microsoft Exchange autodiscover.xml for email
location /autodiscover/autodiscover.xml { location /autodiscover/autodiscover.xml {
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/bin/mailinabox-exchange-autodiscover.php; fastcgi_param SCRIPT_FILENAME /usr/local/lib/z-push/autodiscover/autodiscover.php;
fastcgi_param PHP_VALUE "short_open_tag=Off";
fastcgi_pass php-fpm; fastcgi_pass php-fpm;
} }

View File

@ -0,0 +1,24 @@
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : Autodiscover configuration file
************************************************/
// 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://' . $_SERVER['SERVER_NAME'] . '/Microsoft-Server-ActiveSync');
define('USE_FULLEMAIL_FOR_LOGIN', true);
define('LOGFILEDIR', '/var/log/z-push/');
define('LOGFILE', LOGFILEDIR . 'autodiscover.log');
define('LOGERRORFILE', LOGFILEDIR . 'autodiscover-error.log');
define('LOGLEVEL', LOGLEVEL_INFO);
define('LOGUSERLEVEL', LOGLEVEL);
// the backend data provider
define('BACKEND_PROVIDER', 'BackendCombined');
?>

View File

@ -60,6 +60,10 @@ cp conf/zpush/backend_carddav.php /usr/local/lib/z-push/backend/carddav/config.p
rm -f /usr/local/lib/z-push/backend/caldav/config.php rm -f /usr/local/lib/z-push/backend/caldav/config.php
cp conf/zpush/backend_caldav.php /usr/local/lib/z-push/backend/caldav/config.php cp conf/zpush/backend_caldav.php /usr/local/lib/z-push/backend/caldav/config.php
# Configure Autodiscover
rm -f /usr/local/lib/z-push/autodiscover/config.php
cp conf/zpush/autodiscover_config.php /usr/local/lib/z-push/autodiscover/config.php
# Some directories it will use. # Some directories it will use.
mkdir -p /var/log/z-push mkdir -p /var/log/z-push

View File

@ -1,92 +0,0 @@
<?php
// Parse our configuration file to get the PRIMARY_HOSTNAME.
$PRIMARY_HOSTNAME = NULL;
foreach (file("/etc/mailinabox.conf") as $line) {
$line = explode("=", rtrim($line), 2);
if ($line[0] == "PRIMARY_HOSTNAME") {
$PRIMARY_HOSTNAME = $line[1];
}
}
if ($PRIMARY_HOSTNAME == NULL) exit("no PRIMARY_HOSTNAME");
// We might get two kinds of requests.
$post_body = file_get_contents('php://input');
preg_match('/<AcceptableResponseSchema>(.*?)<\/AcceptableResponseSchema>/', $post_body, $match);
$AcceptableResponseSchema = $match[1];
if ($AcceptableResponseSchema == "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006") {
// There is no way to convey the user's login name with this?
?>
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover
xmlns:autodiscover="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006">
<autodiscover:Response>
<autodiscover:Action>
<autodiscover:Settings>
<autodiscover:Server>
<autodiscover:Type>MobileSync</autodiscover:Type>
<autodiscover:Url>https://<?php echo $PRIMARY_HOSTNAME ?></autodiscover:Url>
<autodiscover:Name>https://<?php echo $PRIMARY_HOSTNAME ?></autodiscover:Name>
</autodiscover:Server>
</autodiscover:Settings>
</autodiscover:Action>
</autodiscover:Response>
</Autodiscover>
<?php
} else {
// I don't know when this is actually used. I implemented this before seeing that
// it is not what my phone wanted.
// Parse the email address out of the POST request, which
// we pass back as the login name.
preg_match('/<EMailAddress>(.*?)<\/EMailAddress>/', $post_body, $match);
$LOGIN = $match[1];
header("Content-type: text/xml");
?>
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<ServiceHome>https://<?php echo $PRIMARY_HOSTNAME ?></ServiceHome>
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server><?php echo $PRIMARY_HOSTNAME ?></Server>
<Port>993</Port>
<SSL>on</SSL>
<LoginName><?php echo $LOGIN ?></LoginName>
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server><?php echo $PRIMARY_HOSTNAME ?></Server>
<Port>587</Port>
<SSL>on</SSL>
<LoginName><?php echo $LOGIN ?></LoginName>
</Protocol>
<Protocol>
<Type>DAV</Type>
<Server>https://<?php echo $PRIMARY_HOSTNAME ?></Server>
<SSL>on</SSL>
<DomainRequired>on</DomainRequired>
<LoginName><?php echo $LOGIN ?></LoginName>
</Protocol>
<Protocol>
<Type>WEB</Type>
<Server>https://<?php echo $PRIMARY_HOSTNAME ?>/mail</Server>
<SSL>on</SSL>
</Protocol>
</Account>
</Response>
</Autodiscover>
<?php
}
?>

View File

@ -1,5 +1,9 @@
<?php <?php
$resource = $_GET['resource']; $resource = '';
if(isset($_GET['resource'])){
$resource = $_GET['resource'];
}
// Parse our configuration file to get the STORAGE_ROOT. // Parse our configuration file to get the STORAGE_ROOT.
$STORAGE_ROOT = NULL; $STORAGE_ROOT = NULL;