[Web] Apple mobileconfig enhancements by @feldsam
parent
4f278255a5
commit
ca9c610460
|
@ -1452,4 +1452,17 @@ function get_logs($application, $lines = false) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
function getGUID() {
|
||||||
|
if (function_exists('com_create_guid')) {
|
||||||
|
return com_create_guid();
|
||||||
|
}
|
||||||
|
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
|
||||||
|
$charid = strtoupper(md5(uniqid(rand(), true)));
|
||||||
|
$hyphen = chr(45);// "-"
|
||||||
|
return substr($charid, 0, 8).$hyphen
|
||||||
|
.substr($charid, 8, 4).$hyphen
|
||||||
|
.substr($charid,12, 4).$hyphen
|
||||||
|
.substr($charid,16, 4).$hyphen
|
||||||
|
.substr($charid,20,12);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
|
require_once 'inc/prerequisites.inc.php';
|
||||||
|
|
||||||
if (empty($mailcow_hostname)) {
|
if (empty($mailcow_hostname)) {
|
||||||
exit();
|
exit();
|
||||||
|
@ -12,158 +12,163 @@ if (!isset($_SESSION['mailcow_cc_role']) || $_SESSION['mailcow_cc_role'] != 'use
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
|
||||||
header('Content-Type: application/x-apple-aspen-config');
|
header('Content-Type: application/x-apple-aspen-config');
|
||||||
header('Content-Disposition: attachment; filename="Mailcow.mobileconfig"');
|
header('Content-Disposition: attachment; filename="'.$UI_TEXTS['main_name'].'.mobileconfig"');
|
||||||
|
|
||||||
$email = $_SESSION['mailcow_cc_username'];
|
$email = $_SESSION['mailcow_cc_username'];
|
||||||
$domain = explode('@', $_SESSION['mailcow_cc_username'])[1];
|
$domain = explode('@', $_SESSION['mailcow_cc_username'])[1];
|
||||||
$identifier = implode('.', array_reverse(explode('.', $domain))) . '.iphoneprofile.mailcow';
|
$identifier = implode('.', array_reverse(preg_split( '/(@|\.)/', $email))) . '.appleprofile.'.preg_replace('/[^a-zA-Z0-9]+/', '', $UI_TEXTS['main_name']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $pdo->prepare("SELECT `name` FROM `mailbox` WHERE `username`= :username");
|
$stmt = $pdo->prepare("SELECT `name` FROM `mailbox` WHERE `username`= :username");
|
||||||
$stmt->execute(array(':username' => $email));
|
$stmt->execute(array(':username' => $email));
|
||||||
$MailboxData = $stmt->fetch(PDO::FETCH_ASSOC);
|
$MailboxData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$displayname = empty($MailboxData['name']) ? $email : $MailboxData['name'];
|
||||||
}
|
}
|
||||||
catch(PDOException $e) {
|
catch(PDOException $e) {
|
||||||
die("Failed to determine name from SQL");
|
|
||||||
}
|
|
||||||
if (!empty($MailboxData['name'])) {
|
|
||||||
$displayname = $MailboxData['name'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$displayname = $email;
|
$displayname = $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['only_email'])) {
|
||||||
|
$onlyEmailAccount = true;
|
||||||
|
$description = 'IMAP';
|
||||||
|
} else {
|
||||||
|
$onlyEmailAccount = false;
|
||||||
|
$description = 'IMAP, CalDAV, CardDAV';
|
||||||
|
}
|
||||||
|
|
||||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>PayloadContent</key>
|
<key>PayloadContent</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CalDAVAccountDescription</key>
|
<key>EmailAccountDescription</key>
|
||||||
<string><?php echo $domain; ?></string>
|
<string><?=$email?></string>
|
||||||
<key>CalDAVHostName</key>
|
<key>EmailAccountType</key>
|
||||||
<string><?php echo $autodiscover_config['caldav']['server']; ?></string>
|
<string>EmailTypeIMAP</string>
|
||||||
<key>CalDAVPort</key>
|
<key>EmailAccountName</key>
|
||||||
<real><?php echo $autodiscover_config['caldav']['port']; ?></real>
|
<string><?=$displayname?></string>
|
||||||
<key>CalDAVPrincipalURL</key>
|
<key>EmailAddress</key>
|
||||||
<string>/SOGo/dav/<?php echo $email; ?></string>
|
<string><?=$email?></string>
|
||||||
<key>CalDAVUseSSL</key>
|
<key>IncomingMailServerAuthentication</key>
|
||||||
<true/>
|
<string>EmailAuthPassword</string>
|
||||||
<key>CalDAVUsername</key>
|
<key>IncomingMailServerHostName</key>
|
||||||
<string><?php echo $email; ?></string>
|
<string><?=$autodiscover_config['imap']['server']?></string>
|
||||||
<key>PayloadDescription</key>
|
<key>IncomingMailServerPortNumber</key>
|
||||||
<string>Configures CalDAV account.</string>
|
<integer><?=$autodiscover_config['imap']['port']?></integer>
|
||||||
<key>PayloadDisplayName</key>
|
<key>IncomingMailServerUseSSL</key>
|
||||||
<string>CalDAV (<?php echo $domain; ?>)</string>
|
<true/>
|
||||||
<key>PayloadIdentifier</key>
|
<key>IncomingMailServerUsername</key>
|
||||||
<string><?php echo $identifier; ?>.CalDAV</string>
|
<string><?=$email?></string>
|
||||||
<key>PayloadOrganization</key>
|
<key>OutgoingMailServerAuthentication</key>
|
||||||
<string></string>
|
<string>EmailAuthPassword</string>
|
||||||
<key>PayloadType</key>
|
<key>OutgoingMailServerHostName</key>
|
||||||
<string>com.apple.caldav.account</string>
|
<string><?=$autodiscover_config['smtp']['server']?></string>
|
||||||
<key>PayloadUUID</key>
|
<key>OutgoingMailServerPortNumber</key>
|
||||||
<string>FC898573-EBA8-48AF-93BD-BFA0C9778FA7</string>
|
<integer><?=$autodiscover_config['smtp']['port']?></integer>
|
||||||
<key>PayloadVersion</key>
|
<key>OutgoingMailServerUseSSL</key>
|
||||||
<integer>1</integer>
|
<true/>
|
||||||
</dict>
|
<key>OutgoingMailServerUsername</key>
|
||||||
<dict>
|
<string><?=$email?></string>
|
||||||
<key>EmailAccountDescription</key>
|
<key>OutgoingPasswordSameAsIncomingPassword</key>
|
||||||
<string><?php echo $domain; ?></string>
|
<true/>
|
||||||
<key>EmailAccountType</key>
|
<key>PayloadDescription</key>
|
||||||
<string>EmailTypeIMAP</string>
|
<string>Configures email account.</string>
|
||||||
<key>EmailAccountName</key>
|
<key>PayloadDisplayName</key>
|
||||||
<string><?php echo $displayname; ?></string>
|
<string>IMAP Account (<?=$email?>)</string>
|
||||||
<key>EmailAddress</key>
|
<key>PayloadIdentifier</key>
|
||||||
<string><?php echo $email; ?></string>
|
<string><?=$identifier?>.email</string>
|
||||||
<key>IncomingMailServerAuthentication</key>
|
<key>PayloadOrganization</key>
|
||||||
<string>EmailAuthPassword</string>
|
<string></string>
|
||||||
<key>IncomingMailServerHostName</key>
|
<key>PayloadType</key>
|
||||||
<string><?php echo $autodiscover_config['imap']['server']; ?></string>
|
<string>com.apple.mail.managed</string>
|
||||||
<key>IncomingMailServerPortNumber</key>
|
<key>PayloadUUID</key>
|
||||||
<integer><?php echo $autodiscover_config['imap']['port']; ?></integer>
|
<string><?=getGUID()?></string>
|
||||||
<key>IncomingMailServerUseSSL</key>
|
<key>PayloadVersion</key>
|
||||||
<true/>
|
<integer>1</integer>
|
||||||
<key>IncomingMailServerUsername</key>
|
<key>PreventAppSheet</key>
|
||||||
<string><?php echo $email; ?></string>
|
<false/>
|
||||||
<key>OutgoingMailServerAuthentication</key>
|
<key>PreventMove</key>
|
||||||
<string>EmailAuthPassword</string>
|
<false/>
|
||||||
<key>OutgoingMailServerHostName</key>
|
<key>SMIMEEnabled</key>
|
||||||
<string><?php echo $autodiscover_config['smtp']['server']; ?></string>
|
<false/>
|
||||||
<key>OutgoingMailServerPortNumber</key>
|
</dict>
|
||||||
<integer><?php echo $autodiscover_config['smtp']['port']; ?></integer>
|
<?php if($onlyEmailAccount === false): ?>
|
||||||
<key>OutgoingMailServerUseSSL</key>
|
<dict>
|
||||||
<true/>
|
<key>CalDAVAccountDescription</key>
|
||||||
<key>OutgoingMailServerUsername</key>
|
<string><?=$email?></string>
|
||||||
<string><?php echo $email; ?></string>
|
<key>CalDAVHostName</key>
|
||||||
<key>OutgoingPasswordSameAsIncomingPassword</key>
|
<string><?=$autodiscover_config['caldav']['server']?></string>
|
||||||
<true/>
|
<key>CalDAVPort</key>
|
||||||
<key>PayloadDescription</key>
|
<real><?=$autodiscover_config['caldav']['port']?></real>
|
||||||
<string>Configures email account.</string>
|
<key>CalDAVPrincipalURL</key>
|
||||||
<key>PayloadDisplayName</key>
|
<string>/SOGo/dav/<?=$email?></string>
|
||||||
<string>IMAP Account (<?php echo $domain; ?>)</string>
|
<key>CalDAVUseSSL</key>
|
||||||
<key>PayloadIdentifier</key>
|
<true/>
|
||||||
<string><?php echo $identifier; ?>.email</string>
|
<key>CalDAVUsername</key>
|
||||||
<key>PayloadOrganization</key>
|
<string><?=$email?></string>
|
||||||
<string></string>
|
<key>PayloadDescription</key>
|
||||||
<key>PayloadType</key>
|
<string>Configures CalDAV account.</string>
|
||||||
<string>com.apple.mail.managed</string>
|
<key>PayloadDisplayName</key>
|
||||||
<key>PayloadUUID</key>
|
<string>CalDAV (<?=$email?>)</string>
|
||||||
<string>00294FBB-1016-413E-87B9-652D856D6875</string>
|
<key>PayloadIdentifier</key>
|
||||||
<key>PayloadVersion</key>
|
<string><?=$identifier?>.CalDAV</string>
|
||||||
<integer>1</integer>
|
<key>PayloadOrganization</key>
|
||||||
<key>PreventAppSheet</key>
|
<string></string>
|
||||||
<false/>
|
<key>PayloadType</key>
|
||||||
<key>PreventMove</key>
|
<string>com.apple.caldav.account</string>
|
||||||
<false/>
|
<key>PayloadUUID</key>
|
||||||
<key>SMIMEEnabled</key>
|
<string><?=getGUID()?></string>
|
||||||
<false/>
|
<key>PayloadVersion</key>
|
||||||
</dict>
|
<integer>1</integer>
|
||||||
<dict>
|
</dict>
|
||||||
<key>CardDAVAccountDescription</key>
|
<dict>
|
||||||
<string><?php echo $domain; ?></string>
|
<key>CardDAVAccountDescription</key>
|
||||||
<key>CardDAVHostName</key>
|
<string><?=$email?></string>
|
||||||
<string><?php echo $autodiscover_config['carddav']['server']; ?></string>
|
<key>CardDAVHostName</key>
|
||||||
<key>CardDAVPort</key>
|
<string><?=$autodiscover_config['carddav']['server']?></string>
|
||||||
<integer><?php echo $autodiscover_config['carddav']['port']; ?></integer>
|
<key>CardDAVPort</key>
|
||||||
<key>CardDAVPrincipalURL</key>
|
<integer><?=$autodiscover_config['carddav']['port']?></integer>
|
||||||
<string>/SOGo/dav/<?php echo $email; ?></string>
|
<key>CardDAVPrincipalURL</key>
|
||||||
<key>CardDAVUseSSL</key>
|
<string>/SOGo/dav/<?=$email?></string>
|
||||||
<true/>
|
<key>CardDAVUseSSL</key>
|
||||||
<key>CardDAVUsername</key>
|
<true/>
|
||||||
<string><?php echo $email; ?></string>
|
<key>CardDAVUsername</key>
|
||||||
<key>PayloadDescription</key>
|
<string><?=$email?></string>
|
||||||
<string>Configures CardDAV accounts</string>
|
<key>PayloadDescription</key>
|
||||||
<key>PayloadDisplayName</key>
|
<string>Configures CardDAV accounts</string>
|
||||||
<string>CardDAV (<?php echo $domain; ?>)</string>
|
<key>PayloadDisplayName</key>
|
||||||
<key>PayloadIdentifier</key>
|
<string>CardDAV (<?=$email?>)</string>
|
||||||
<string><?php echo $identifier; ?>.carddav</string>
|
<key>PayloadIdentifier</key>
|
||||||
<key>PayloadOrganization</key>
|
<string><?=$identifier?>.carddav</string>
|
||||||
<string></string>
|
<key>PayloadOrganization</key>
|
||||||
<key>PayloadType</key>
|
<string></string>
|
||||||
<string>com.apple.carddav.account</string>
|
<key>PayloadType</key>
|
||||||
<key>PayloadUUID</key>
|
<string>com.apple.carddav.account</string>
|
||||||
<string>0797EF2B-B1F1-4BC7-ABCD-4580862252B4</string>
|
<key>PayloadUUID</key>
|
||||||
<key>PayloadVersion</key>
|
<string><?=getGUID()?></string>
|
||||||
<integer>1</integer>
|
<key>PayloadVersion</key>
|
||||||
</dict>
|
<integer>1</integer>
|
||||||
</array>
|
</dict>
|
||||||
<key>PayloadDescription</key>
|
<?php endif; ?>
|
||||||
<string>IMAP, CalDAV, CardDAV</string>
|
</array>
|
||||||
<key>PayloadDisplayName</key>
|
<key>PayloadDescription</key>
|
||||||
<string><?php echo $domain; ?> Mailcow</string>
|
<string><?=$description?></string>
|
||||||
<key>PayloadIdentifier</key>
|
<key>PayloadDisplayName</key>
|
||||||
<string><?php echo $identifier; ?></string>
|
<string><?=$email?></string>
|
||||||
<key>PayloadOrganization</key>
|
<key>PayloadIdentifier</key>
|
||||||
<string></string>
|
<string><?=$identifier?></string>
|
||||||
<key>PayloadRemovalDisallowed</key>
|
<key>PayloadOrganization</key>
|
||||||
<false/>
|
<string><?=$UI_TEXTS['main_name']?></string>
|
||||||
<key>PayloadType</key>
|
<key>PayloadRemovalDisallowed</key>
|
||||||
<string>Configuration</string>
|
<false/>
|
||||||
<key>PayloadUUID</key>
|
<key>PayloadType</key>
|
||||||
<string>5EE248C5-ACCB-42D8-9199-8F8ED08D5624</string>
|
<string>Configuration</string>
|
||||||
<key>PayloadVersion</key>
|
<key>PayloadUUID</key>
|
||||||
<integer>1</integer>
|
<string><?=getGUID()?></string>
|
||||||
</dict>
|
<key>PayloadVersion</key>
|
||||||
|
<integer>1</integer>
|
||||||
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
Loading…
Reference in New Issue