Merge pull request #280 from Dennis14e/patch-2

Fix session bug, formatting, update bootstrap/bootswatch
master
André Peters 2017-05-16 20:11:25 +02:00 committed by GitHub
commit 73920fbbc0
7 changed files with 468 additions and 458 deletions

View File

@ -1,24 +1,28 @@
<?php <?php
require_once "inc/vars.inc.php"; require_once 'inc/vars.inc.php';
if (empty($mailcow_hostname)) { exit(); }
header("Content-Type: application/xml"); if (empty($mailcow_hostname)) {
exit();
}
header('Content-Type: application/xml');
?> ?>
<?='<?xml version="1.0"?>';?> <?= '<?xml version="1.0"?>'; ?>
<clientConfig version="1.1"> <clientConfig version="1.1">
<emailProvider id="<?=$mailcow_hostname;?>"> <emailProvider id="<?= $mailcow_hostname; ?>">
<domain>%EMAILDOMAIN%</domain> <domain>%EMAILDOMAIN%</domain>
<displayName>A mailcow mail server</displayName> <displayName>A mailcow mail server</displayName>
<displayShortName>mail server</displayShortName> <displayShortName>mail server</displayShortName>
<incomingServer type="imap"> <incomingServer type="imap">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>993</port> <port>993</port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
</incomingServer> </incomingServer>
<incomingServer type="imap"> <incomingServer type="imap">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>143</port> <port>143</port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
@ -26,14 +30,14 @@ header("Content-Type: application/xml");
</incomingServer> </incomingServer>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>995</port> <port>995</port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
</incomingServer> </incomingServer>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>110</port> <port>110</port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
@ -41,7 +45,7 @@ header("Content-Type: application/xml");
</incomingServer> </incomingServer>
<outgoingServer type="smtp"> <outgoingServer type="smtp">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>465</port> <port>465</port>
<socketType>SSL</socketType> <socketType>SSL</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
@ -49,14 +53,14 @@ header("Content-Type: application/xml");
</outgoingServer> </outgoingServer>
<outgoingServer type="smtp"> <outgoingServer type="smtp">
<hostname><?=$mailcow_hostname;?></hostname> <hostname><?= $mailcow_hostname; ?></hostname>
<port>587</port> <port>587</port>
<socketType>STARTTLS</socketType> <socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username> <username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication> <authentication>password-cleartext</authentication>
</outgoingServer> </outgoingServer>
<enable visiturl="https://<?=$mailcow_hostname;?>/admin.php"> <enable visiturl="https://<?= $mailcow_hostname; ?>/admin.php">
<instruction>If you didn't change the password given to you by the administrator or if you didn't change it in a long time, please consider doing that now.</instruction> <instruction>If you didn't change the password given to you by the administrator or if you didn't change it in a long time, please consider doing that now.</instruction>
<instruction lang="de">Sollten Sie das Ihnen durch den Administrator vergebene Passwort noch nicht geändert haben, empfehlen wir dies nun zu tun. Auch ein altes Passwort sollte aus Sicherheitsgründen geändert werden.</instruction> <instruction lang="de">Sollten Sie das Ihnen durch den Administrator vergebene Passwort noch nicht geändert haben, empfehlen wir dies nun zu tun. Auch ein altes Passwort sollte aus Sicherheitsgründen geändert werden.</instruction>
</enable> </enable>
@ -64,6 +68,6 @@ header("Content-Type: application/xml");
</emailProvider> </emailProvider>
<webMail> <webMail>
<loginPage url="https://<?=$mailcow_hostname;?>/SOGo/" /> <loginPage url="https://<?= $mailcow_hostname; ?>/SOGo/" />
</webMail> </webMail>
</clientConfig> </clientConfig>

View File

@ -1,234 +1,240 @@
<?php <?php
include("inc/tfa_modals.php"); include 'inc/tfa_modals.php';
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin"):
?> if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'admin'):
<div id="RestartSOGo" class="modal fade" role="dialog"> ?>
<div class="modal-dialog"> <div id="RestartSOGo" class="modal fade" role="dialog">
<div class="modal-content"> <div class="modal-dialog">
<div class="modal-header"> <div class="modal-content">
<button type="button" class="close" data-dismiss="modal">&times;</button> <div class="modal-header">
<h4 class="modal-title"><?=$lang['footer']['restart_sogo'];?></h4> <button type="button" class="close" data-dismiss="modal">&times;</button>
</div> <h4 class="modal-title"><?= $lang['footer']['restart_sogo']; ?></h4>
<div class="modal-body"> </div>
<p><?=$lang['footer']['restart_sogo_info'];?></p> <div class="modal-body">
<hr /> <p><?= $lang['footer']['restart_sogo_info']; ?></p>
<button class="btn btn-md btn-primary" id="triggerRestartSogo"><?=$lang['footer']['restart_now'];?></button> <hr>
<br /><br /> <button class="btn btn-md btn-primary" id="triggerRestartSogo"><?= $lang['footer']['restart_now']; ?></button>
<div id="statusTriggerRestartSogo"></div> <br><br>
</div> <div id="statusTriggerRestartSogo"></div>
</div> </div>
</div> </div>
</div> </div>
<?php </div>
endif; <?php
?> endif;
<div id="ConfirmDeleteModal" class="modal fade" role="dialog"> ?>
<div class="modal-dialog"> <div id="ConfirmDeleteModal" class="modal fade" role="dialog">
<div class="modal-content"> <div class="modal-dialog">
<div class="modal-header"> <div class="modal-content">
<button type="button" class="close" data-dismiss="modal">&times;</button> <div class="modal-header">
<h4 class="modal-title"><?=$lang['footer']['confirm_delete'];?></h4> <button type="button" class="close" data-dismiss="modal">&times;</button>
</div> <h4 class="modal-title"><?= $lang['footer']['confirm_delete']; ?></h4>
<div class="modal-body"> </div>
<p><?=$lang['footer']['delete_these_items'];?></p> <div class="modal-body">
<ul id="ItemsToDelete"></ul> <p><?= $lang['footer']['delete_these_items']; ?></p>
<hr /> <ul id="ItemsToDelete"></ul>
<button class="btn btn-sm btn-danger" id="IsConfirmed"><?=$lang['footer']['delete_now'];?></button> <hr>
<button class="btn btn-sm btn-default" id="isCanceled"><?=$lang['footer']['cancel'];?></button> <button class="btn btn-sm btn-danger" id="IsConfirmed"><?= $lang['footer']['delete_now']; ?></button>
</div> <button class="btn btn-sm btn-default" id="isCanceled"><?= $lang['footer']['cancel']; ?></button>
</div> </div>
</div> </div>
</div> </div>
<div style="margin-bottom:100px"></div> </div>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script> <div style="margin-bottom: 100px;"></div>
<script src="/js/bootstrap-switch.min.js"></script>
<script src="/js/bootstrap-slider.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<script src="/js/bootstrap-select.min.js"></script> <script src="/js/bootstrap-switch.min.js"></script>
<script src="/js/notifications.min.js"></script> <script src="/js/bootstrap-slider.min.js"></script>
<script src="/js/u2f-api.js"></script> <script src="/js/bootstrap-select.min.js"></script>
<script> <script src="/js/notifications.min.js"></script>
// Select language and reopen active URL without POST <script src="/js/u2f-api.js"></script>
function setLang(sel) { <script>
$.post( "<?=$_SERVER['REQUEST_URI'];?>", {lang: sel} ); // Select language and reopen active URL without POST
window.location.href = window.location.pathname + window.location.search; function setLang(sel) {
} $.post( "<?= $_SERVER['REQUEST_URI']; ?>", {lang: sel} );
window.location.href = window.location.pathname + window.location.search;
$(document).ready(function() { }
function mailcow_alert_box(message, type) {
$.notify({message: message},{type: type,placement: {from: "bottom",align: "right"},animate: {enter: 'animated fadeInUp',exit: 'animated fadeOutDown'}}); $(document).ready(function() {
} function mailcow_alert_box(message, type) {
<?php if (isset($_SESSION['return'])): ?> $.notify({message: message},{type: type,placement: {from: "bottom",align: "right"},animate: {enter: 'animated fadeInUp',exit: 'animated fadeOutDown'}});
mailcow_alert_box("<?=$_SESSION['return']['msg'];?>", "<?=$_SESSION['return']['type'];?>"); }
<?php endif; unset($_SESSION['return']); ?> <?php if (isset($_SESSION['return'])): ?>
// Confirm TFA modal mailcow_alert_box("<?= $_SESSION['return']['msg']; ?>", "<?= $_SESSION['return']['type']; ?>");
<?php if (isset($_SESSION['pending_tfa_method'])):?> <?php endif; unset($_SESSION['return']); ?>
$('#ConfirmTFAModal').modal({ // Confirm TFA modal
backdrop: 'static', <?php if (isset($_SESSION['pending_tfa_method'])):?>
keyboard: false $('#ConfirmTFAModal').modal({
}); backdrop: 'static',
$('#ConfirmTFAModal').on('shown.bs.modal', function(){ keyboard: false
$(this).find('#token').focus(); });
// If U2F $('#ConfirmTFAModal').on('shown.bs.modal', function(){
if(document.getElementById("u2f_auth_data") !== null) { $(this).find('#token').focus();
$.ajax({ // If U2F
type: "GET", if(document.getElementById("u2f_auth_data") !== null) {
cache: false, $.ajax({
dataType: 'script', type: "GET",
url: "/api/v1/get/u2f-authentication/<?=(isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null;?>", cache: false,
success: function(data){ dataType: 'script',
data; url: "/api/v1/get/u2f-authentication/<?= (isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null; ?>",
} success: function(data){
}); data;
setTimeout(function() { }
console.log("sign: ", req); });
u2f.sign(req, function(data) { setTimeout(function() {
var form = document.getElementById('u2f_auth_form'); console.log("sign: ", req);
var auth = document.getElementById('u2f_auth_data'); u2f.sign(req, function(data) {
console.log("Authenticate callback", data); var form = document.getElementById('u2f_auth_form');
auth.value = JSON.stringify(data); var auth = document.getElementById('u2f_auth_data');
form.submit(); console.log("Authenticate callback", data);
}); auth.value = JSON.stringify(data);
}, 1000); form.submit();
} });
}); }, 1000);
<?php endif; ?> }
});
// Set TFA modals <?php endif; ?>
$('#selectTFA').change(function () { // Set TFA modals
if ($(this).val() == "yubi_otp") {
$('#YubiOTPModal').modal('show'); $('#selectTFA').change(function () {
$("option:selected").prop("selected", false); if ($(this).val() == "yubi_otp") {
} $('#YubiOTPModal').modal('show');
if ($(this).val() == "totp") { $("option:selected").prop("selected", false);
$('#TOTPModal').modal('show'); }
$("option:selected").prop("selected", false); if ($(this).val() == "totp") {
} $('#TOTPModal').modal('show');
if ($(this).val() == "u2f") { $("option:selected").prop("selected", false);
$('#U2FModal').modal('show'); }
$("option:selected").prop("selected", false); if ($(this).val() == "u2f") {
$.ajax({ $('#U2FModal').modal('show');
type: "GET", $("option:selected").prop("selected", false);
cache: false, $.ajax({
dataType: 'script', type: "GET",
url: "/api/v1/get/u2f-registration/<?=(isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null;?>", cache: false,
success: function(data){ dataType: 'script',
data; url: "/api/v1/get/u2f-registration/<?= (isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null; ?>",
} success: function(data){
}); data;
setTimeout(function() { }
console.log("Register: ", req); });
u2f.register([req], sigs, function(data) { setTimeout(function() {
var form = document.getElementById('u2f_reg_form'); console.log("Register: ", req);
var reg = document.getElementById('u2f_register_data'); u2f.register([req], sigs, function(data) {
console.log("Register callback", data); var form = document.getElementById('u2f_reg_form');
if (data.errorCode && data.errorCode != 0) { var reg = document.getElementById('u2f_register_data');
var u2f_return_code = document.getElementById('u2f_return_code'); console.log("Register callback", data);
u2f_return_code.style.display = u2f_return_code.style.display === 'none' ? '' : null; if (data.errorCode && data.errorCode != 0) {
if (data.errorCode == "4") { data.errorCode = "4 - The presented device is not eligible for this request. For a registration request this may mean that the token is already registered, and for a sign request it may mean that the token does not know the presented key handle"; } var u2f_return_code = document.getElementById('u2f_return_code');
u2f_return_code.innerHTML = 'Error code: ' + data.errorCode; u2f_return_code.style.display = u2f_return_code.style.display === 'none' ? '' : null;
return; if (data.errorCode == "4") { data.errorCode = "4 - The presented device is not eligible for this request. For a registration request this may mean that the token is already registered, and for a sign request it may mean that the token does not know the presented key handle"; }
} u2f_return_code.innerHTML = 'Error code: ' + data.errorCode;
reg.value = JSON.stringify(data); return;
form.submit(); }
}); reg.value = JSON.stringify(data);
}, 1000); form.submit();
} });
if ($(this).val() == "none") { }, 1000);
$('#DisableTFAModal').modal('show'); }
$("option:selected").prop("selected", false); if ($(this).val() == "none") {
} $('#DisableTFAModal').modal('show');
}); $("option:selected").prop("selected", false);
}
// Activate tooltips });
$(function () {
$('[data-toggle="tooltip"]').tooltip() // Activate tooltips
}) $(function () {
// Hide alerts after n seconds $('[data-toggle="tooltip"]').tooltip()
$("#alert-fade").fadeTo(7000, 500).slideUp(500, function(){ })
$("#alert-fade").alert('close'); // Hide alerts after n seconds
}); $("#alert-fade").fadeTo(7000, 500).slideUp(500, function(){
$("#alert-fade").alert('close');
// Remember last navigation pill });
(function () {
'use strict'; // Remember last navigation pill
if ($('a[data-toggle="tab"]').length) { (function () {
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 'use strict';
var id = $(this).parents('[role="tablist"]').attr('id'); if ($('a[data-toggle="tab"]').length) {
var key = 'lastTag'; $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (id) { var id = $(this).parents('[role="tablist"]').attr('id');
key += ':' + id; var key = 'lastTag';
} if (id) {
localStorage.setItem(key, $(e.target).attr('href')); key += ':' + id;
}); }
$('[role="tablist"]').each(function (idx, elem) { localStorage.setItem(key, $(e.target).attr('href'));
var id = $(elem).attr('id'); });
var key = 'lastTag'; $('[role="tablist"]').each(function (idx, elem) {
if (id) { var id = $(elem).attr('id');
key += ':' + id; var key = 'lastTag';
} if (id) {
var lastTab = localStorage.getItem(key); key += ':' + id;
if (lastTab) { }
$('[href="' + lastTab + '"]').tab('show'); var lastTab = localStorage.getItem(key);
} if (lastTab) {
}); $('[href="' + lastTab + '"]').tab('show');
} }
})(); });
}
// Disable submit after submitting form })();
$('form').submit(function() {
if ($('form button[type="submit"]').data('submitted') == '1') { // Disable submit after submitting form
return false; $('form').submit(function() {
} else { if ($('form button[type="submit"]').data('submitted') == '1') {
$(this).find('button[type="submit"]').first().text('<?=$lang['footer']['loading'];?>'); return false;
$('form button[type="submit"]').attr('data-submitted', '1'); } else {
function disableF5(e) { if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e.preventDefault(); }; $(this).find('button[type="submit"]').first().text('<?= $lang['footer']['loading']; ?>');
$(document).on("keydown", disableF5); $('form button[type="submit"]').attr('data-submitted', '1');
} function disableF5(e) { if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e.preventDefault(); };
}); $(document).on("keydown", disableF5);
}
// IE fix to hide scrollbars when table body is empty });
$('tbody').filter(function (index) {
return $(this).children().length < 1; // IE fix to hide scrollbars when table body is empty
}).remove(); $('tbody').filter(function (index) {
return $(this).children().length < 1;
// Init Bootstrap Selectpicker }).remove();
$('select').selectpicker();
// Init Bootstrap Selectpicker
// Trigger SOGo restart $('select').selectpicker();
$('#triggerRestartSogo').click(function(){
$(this).prop("disabled",true); // Trigger SOGo restart
$(this).html('<span class="glyphicon glyphicon-refresh glyphicon-spin"></span> '); $('#triggerRestartSogo').click(function(){
$('#statusTriggerRestartSogo').text('Stopping SOGo workers, this may take a while... '); $(this).prop("disabled",true);
$.ajax({ $(this).html('<span class="glyphicon glyphicon-refresh glyphicon-spin"></span> ');
method: 'get', $('#statusTriggerRestartSogo').text('Stopping SOGo workers, this may take a while... ');
url: 'call_sogo_ctrl.php', $.ajax({
data: { method: 'get',
'ajax': true, url: 'call_sogo_ctrl.php',
'ACTION': 'stop' data: {
}, 'ajax': true,
success: function(data) { 'ACTION': 'stop'
$('#statusTriggerRestartSogo').append(data); },
$('#statusTriggerRestartSogo').append('<br />Starting SOGo... '); success: function(data) {
$.ajax({ $('#statusTriggerRestartSogo').append(data);
method: 'get', $('#statusTriggerRestartSogo').append('<br>Starting SOGo...');
url: 'call_sogo_ctrl.php', $.ajax({
data: { method: 'get',
'ajax': true, url: 'call_sogo_ctrl.php',
'ACTION': 'start' data: {
}, 'ajax': true,
success: function(data) { 'ACTION': 'start'
$('#statusTriggerRestartSogo').append(data); },
$('#triggerRestartSogo').html('<span class="glyphicon glyphicon-ok"></span> '); success: function(data) {
} $('#statusTriggerRestartSogo').append(data);
}); $('#triggerRestartSogo').html('<span class="glyphicon glyphicon-ok"></span> ');
} }
}); });
}); }
$("<input type='hidden' value='<?=$_SESSION['CSRF']['TOKEN'];?>' />").attr("id", "csrf_token").attr("name", "csrf_token").appendTo("form"); });
}); });
</script>
// CSRF
</body> $('<input type="hidden" value="<?= $_SESSION['CSRF']['TOKEN']; ?>">').attr('id', 'csrf_token').attr('name', 'csrf_token').appendTo('form');
</html> });
<?php $stmt = null; $pdo = null; ?> </script>
</body>
</html>
<?php
$stmt = null;
$pdo = null;

View File

@ -1,118 +1,119 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?= $_SESSION['mailcow_locale'] ?>"> <html lang="<?= $_SESSION['mailcow_locale'] ?>">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>mailcow UI</title> <title>mailcow UI</title>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" integrity="sha256-3Jy/GbSLrg0o9y5Z5n1uw0qxZECH7C6OQpVBgNFYa0g=" crossorigin="anonymous"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js" integrity="sha256-g6iAfvZp+nDQ2TdTR/VVKJf3bGro4ub5fvWSWVRi2NE=" crossorigin="anonymous"></script>
<![endif]--> <![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.min.js" integrity="sha384-XxcvoeNF5V0ZfksTnV+bejnCsJjOOIzN6UVwF85WBsAnU3zeYh5bloN+L4WLgeNE" crossorigin="anonymous"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/<?=strtolower(trim($DEFAULT_THEME));?>/bootstrap.min.css"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/<?= strtolower(trim($DEFAULT_THEME)); ?>/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap-select.min.css"> <link rel="stylesheet" href="/css/bootstrap-select.min.css">
<link rel="stylesheet" href="/css/bootstrap-slider.min.css"> <link rel="stylesheet" href="/css/bootstrap-slider.min.css">
<link rel="stylesheet" href="/css/bootstrap-switch.min.css"> <link rel="stylesheet" href="/css/bootstrap-switch.min.css">
<link rel="stylesheet" href="/css/footable.bootstrap.min.css"> <link rel="stylesheet" href="/css/footable.bootstrap.min.css">
<link rel="stylesheet" href="/inc/languages.min.css"> <link rel="stylesheet" href="/inc/languages.min.css">
<link rel="stylesheet" href="/css/mailcow.css"> <link rel="stylesheet" href="/css/mailcow.css">
<link rel="stylesheet" href="/css/animate.min.css"> <link rel="stylesheet" href="/css/animate.min.css">
<?=(preg_match("/mailbox.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/mailbox.css">' : null;?> <?= (preg_match("/mailbox.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/mailbox.css">' : null; ?>
<?=(preg_match("/admin.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/admin.css">' : null;?> <?= (preg_match("/admin.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/admin.css">' : null; ?>
<link rel="shortcut icon" href="/favicon.png" type="image/png"> <link rel="shortcut icon" href="/favicon.png" type="image/png">
<link rel="icon" href="/favicon.png" type="image/png"> <link rel="icon" href="/favicon.png" type="image/png">
</head> </head>
<body style="padding-top:70px"> <body style="padding-top: 70px;">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="/"><img height="32" alt="mailcow-logo" style="margin-top:-5px;" src="/img/cow_mailcow.svg" /></a> <a class="navbar-brand" href="/"><img height="32" alt="mailcow-logo" style="margin-top: -5px;" src="/img/cow_mailcow.svg"></a>
</div> </div>
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<?php <?php
if (isset($_SESSION['mailcow_locale'])) { if (isset($_SESSION['mailcow_locale'])) {
?> ?>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="lang-sm lang-lbl" lang="<?=$_SESSION['mailcow_locale'];?>"></span><span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="lang-sm lang-lbl" lang="<?= $_SESSION['mailcow_locale']; ?>"></span><span class="caret"></span></a>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li <?=($_SESSION['mailcow_locale'] == 'de') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "de"))) ?>"><span class="lang-xs lang-lbl-full" lang="de"></span></a></li> <?php
<li <?=($_SESSION['mailcow_locale'] == 'en') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "en"))) ?>"><span class="lang-xs lang-lbl-full" lang="en"></span></a></li> foreach ($AVAILABLE_LANGUAGES as $language) {
<li <?=($_SESSION['mailcow_locale'] == 'es') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "es"))) ?>"><span class="lang-xs lang-lbl-full" lang="es"></span></a></li> ?>
<li <?=($_SESSION['mailcow_locale'] == 'nl') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "nl"))) ?>"><span class="lang-xs lang-lbl-full" lang="nl"></span></a></li> <li<?= ($_SESSION['mailcow_locale'] == $language) ? ' class="active"' : ''; ?>><a href="?<?= http_build_query(array_merge($_GET, array('lang' => $language))); ?>"><span class="lang-xs lang-lbl-full" lang="<?= $language; ?>"></span></a></li>
<li <?=($_SESSION['mailcow_locale'] == 'pt') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "pt"))) ?>"><span class="lang-xs lang-lbl-full" lang="pt"></span></a></li> <?php
<li <?=($_SESSION['mailcow_locale'] == 'ru') ? 'class="active"' : ''?>> <a href="?<?= http_build_query(array_merge($_GET, array("lang" => "ru"))) ?>"><span class="lang-xs lang-lbl-full" lang="ru"></span></a></li> }
</ul> ?>
</li> </ul>
<?php </li>
} <?php
if (isset($_SESSION['mailcow_cc_role'])) { }
?> if (isset($_SESSION['mailcow_cc_role'])) {
<li class="dropdown"> ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> <?=$lang['header']['mailcow_settings'];?> <span class="caret"></span></a> <li class="dropdown">
<ul class="dropdown-menu" role="menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?= $lang['header']['mailcow_settings']; ?> <span class="caret"></span></a>
<?php <ul class="dropdown-menu" role="menu">
if (isset($_SESSION['mailcow_cc_role'])) { <?php
if ($_SESSION['mailcow_cc_role'] == "admin") { if (isset($_SESSION['mailcow_cc_role'])) {
?> if ($_SESSION['mailcow_cc_role'] == 'admin') {
<li <?=(preg_match("/admin/i", $_SERVER['REQUEST_URI'])) ? 'class="active"' : ''?>><a href="/admin.php"><?=$lang['header']['administration'];?></a></li> ?>
<?php <li<?= (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) ? ' class="active"' : ''; ?>><a href="/admin.php"><?= $lang['header']['administration']; ?></a></li>
} <?php
if ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin") { }
?> if ($_SESSION['mailcow_cc_role'] == 'admin' || $_SESSION['mailcow_cc_role'] == 'domainadmin') {
<li <?=(preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) ? 'class="active"' : ''?>><a href="/mailbox.php"><?=$lang['header']['mailboxes'];?></a></li> ?>
<?php <li<?= (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) ? ' class="active"' : ''; ?>><a href="/mailbox.php"><?= $lang['header']['mailboxes']; ?></a></li>
} <?php
if ($_SESSION['mailcow_cc_role'] != "admin") { }
?> if ($_SESSION['mailcow_cc_role'] != 'admin') {
<li <?=(preg_match("/user/i", $_SERVER['REQUEST_URI'])) ? 'class="active"' : ''?>><a href="/user.php"><?=$lang['header']['user_settings'];?></a></li> ?>
<?php <li<?= (preg_match("/user/i", $_SERVER['REQUEST_URI'])) ? ' class="active"' : ''; ?>><a href="/user.php"><?= $lang['header']['user_settings']; ?></a></li>
} <?php
} }
?> }
</ul> ?>
</li> </ul>
<?php </li>
if ($_SESSION['mailcow_cc_role'] == "admin"): <?php
?> if ($_SESSION['mailcow_cc_role'] == 'admin') {
<li><a href data-toggle="modal" data-target="#RestartSOGo"><span style="font-size:12px" class="glyphicon glyphicon-refresh" aria-hidden="true"></span> <?=$lang['header']['restart_sogo'];?></a></li> ?>
<?php <li><a href data-toggle="modal" data-target="#RestartSOGo"><span style="font-size: 12px;" class="glyphicon glyphicon-refresh" aria-hidden="true"></span> <?= $lang['header']['restart_sogo']; ?></a></li>
endif; <?php
?> }
<li class="dropdown"> ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-link" aria-hidden="true"></span> Apps <span class="caret"></span></a> <li class="dropdown">
<ul class="dropdown-menu" role="menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-link" aria-hidden="true"></span> Apps <span class="caret"></span></a>
<?php <ul class="dropdown-menu" role="menu">
foreach ($MAILCOW_APPS as $app): <?php
?> foreach ($MAILCOW_APPS as $app):
<li><a href="<?=$app['link'];?>"><?=$app['name'];?></a></li> ?>
<?php <li><a href="<?= $app['link']; ?>"><?= $app['name']; ?></a></li>
endforeach; <?php
?> endforeach;
</ul> ?>
</li> </ul>
<?php </li>
} <?php
if (!isset($_SESSION["dual-login"]) && isset($_SESSION['mailcow_cc_username'])): }
?> if (!isset($_SESSION['dual-login']) && isset($_SESSION['mailcow_cc_username'])):
<li><a style="border-left:1px solid #E7E7E7" href="#" onclick="logout.submit()"><?=sprintf($lang['header']['logged_in_as_logout'], $_SESSION['mailcow_cc_username']);?></a></li> ?>
<?php <li><a href="#" style="border-left: 1px solid #E7E7E7;" onclick="logout.submit()"><?= sprintf($lang['header']['logged_in_as_logout'], $_SESSION['mailcow_cc_username']); ?></a></li>
elseif (isset($_SESSION["dual-login"])): <?php
?> elseif (isset($_SESSION['dual-login'])):
<li><a style="border-left:1px solid #E7E7E7" href="#" onclick="logout.submit()"><?=sprintf($lang['header']['logged_in_as_logout_dual'], $_SESSION['mailcow_cc_username'], $_SESSION["dual-login"]["username"]);?></a></li> ?>
<?php <li><a href="#" style="border-left: 1px solid #E7E7E7;" onclick="logout.submit()"><?= sprintf($lang['header']['logged_in_as_logout_dual'], $_SESSION['mailcow_cc_username'], $_SESSION['dual-login']['username']); ?></a></li>
endif; <?php
?> endif;
</ul> ?>
</div><!--/.nav-collapse --> </ul>
</div><!--/.container-fluid --> </div><!--/.nav-collapse -->
</nav> </div><!--/.container-fluid -->
<form action="/" method="post" id="logout"><input type="hidden" name="logout"></form> </nav>
<form action="/" method="post" id="logout"><input type="hidden" name="logout"></form>

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@ elseif (isset($_SERVER['HTTPS'])) {
else { else {
$IS_HTTPS = false; $IS_HTTPS = false;
} }
session_set_cookie_params($GLOBALS['SESSION_LIFETIME'], '/', $_SERVER['SERVER_NAME'], $IS_HTTPS, true); session_set_cookie_params($GLOBALS['SESSION_LIFETIME'], '/', '', $IS_HTTPS, true);
session_start(); session_start();
if (!isset($_SESSION['CSRF']['TOKEN'])) { if (!isset($_SESSION['CSRF']['TOKEN'])) {
$_SESSION['CSRF']['TOKEN'] = bin2hex(random_bytes(32)); $_SESSION['CSRF']['TOKEN'] = bin2hex(random_bytes(32));

View File

@ -9,8 +9,8 @@ This file will be reset on upgrades.
*/ */
// SQL database connection variables // SQL database connection variables
$database_type = "mysql"; $database_type = 'mysql';
$database_host = "mysql"; $database_host = 'mysql';
$database_user = getenv('DBUSER'); $database_user = getenv('DBUSER');
$database_pass = getenv('DBPASS'); $database_pass = getenv('DBPASS');
$database_name = getenv('DBNAME'); $database_name = getenv('DBNAME');
@ -21,23 +21,23 @@ $mailcow_hostname = getenv('MAILCOW_HOSTNAME');
// Where to go after adding and editing objects // Where to go after adding and editing objects
// Can be "form" or "previous" // Can be "form" or "previous"
// "form" will stay in the current form, "previous" will redirect to previous page // "form" will stay in the current form, "previous" will redirect to previous page
$FORM_ACTION = "previous"; $FORM_ACTION = 'previous';
// File locations should not be changed // File locations should not be changed
$MC_DKIM_TXTS = "/data/dkim/txt"; $MC_DKIM_TXTS = '/data/dkim/txt';
$MC_DKIM_KEYS = "/data/dkim/keys"; $MC_DKIM_KEYS = '/data/dkim/keys';
// Change default language, "de", "en", "es", "nl", "pt", "ru" // Change default language, "de", "en", "es", "nl", "pt", "ru"
$DEFAULT_LANG = "en"; $DEFAULT_LANG = 'en';
// Available languages // Available languages
$AVAILABLE_LANGUAGES = array("de", "en", "es", "nl", "pt", "ru"); $AVAILABLE_LANGUAGES = array('de', 'en', 'es', 'nl', 'pt', 'ru');
// Change theme (default: lumen) // Change theme (default: lumen)
// Needs to be one of those: cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper, readable, sandstone, // Needs to be one of those: cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper, readable, sandstone,
// simplex, slate, spacelab, superhero, united, yeti // simplex, slate, spacelab, superhero, united, yeti
// See https://bootswatch.com/ // See https://bootswatch.com/
$DEFAULT_THEME = "lumen"; $DEFAULT_THEME = 'lumen';
// Password complexity as regular expression // Password complexity as regular expression
$PASSWD_REGEP = '.{4,}'; $PASSWD_REGEP = '.{4,}';
@ -59,5 +59,3 @@ $PAGINATION_SIZE = 10;
// Session lifetime in seconds // Session lifetime in seconds
$SESSION_LIFETIME = 3600; $SESSION_LIFETIME = 3600;
?>

View File

@ -1,97 +1,98 @@
<?php <?php
require_once("inc/prerequisites.inc.php"); require_once 'inc/prerequisites.inc.php';
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin") { if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'admin') {
header('Location: /admin.php'); header('Location: /admin.php');
exit(); exit();
} }
elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "domainadmin") { elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'domainadmin') {
header('Location: /mailbox.php'); header('Location: /mailbox.php');
exit(); exit();
} }
elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "user") { elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'user') {
header('Location: /user.php'); header('Location: /user.php');
exit(); exit();
} }
require_once("inc/header.inc.php");
require_once 'inc/header.inc.php';
$_SESSION['return_to'] = $_SERVER['REQUEST_URI']; $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
?> ?>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-offset-3 col-md-6"> <div class="col-md-offset-3 col-md-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> <?=$lang['login']['login'];?></div> <div class="panel-heading"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> <?= $lang['login']['login']; ?></div>
<div class="panel-body"> <div class="panel-body">
<center><img style="max-width:250px" src="/img/cow_mailcow.svg" alt="mailcow"></center> <div class="text-center"><img style="max-width: 250px;" src="/img/cow_mailcow.svg" alt="mailcow"></div>
<legend>mailcow UI</legend> <legend>mailcow UI</legend>
<form method="post" autofill="off"> <form method="post" autofill="off">
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="login_user"><?=$lang['login']['username'];?></label> <label class="sr-only" for="login_user"><?= $lang['login']['username']; ?></label>
<div class="input-group"> <div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div> <div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div>
<input name="login_user" autocorrect="off" autocapitalize="none" type="text" id="login_user" class="form-control" placeholder="<?=$lang['login']['username'];?>" required="" autofocus=""> <input name="login_user" autocorrect="off" autocapitalize="none" type="text" id="login_user" class="form-control" placeholder="<?= $lang['login']['username']; ?>" required="" autofocus="">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="pass_user"><?=$lang['login']['password'];?></label> <label class="sr-only" for="pass_user"><?= $lang['login']['password']; ?></label>
<div class="input-group"> <div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></div> <div class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></div>
<input name="pass_user" type="password" id="pass_user" class="form-control" placeholder="<?=$lang['login']['password'];?>" required=""> <input name="pass_user" type="password" id="pass_user" class="form-control" placeholder="<?= $lang['login']['password']; ?>" required="">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-success" value="Login"><?=$lang['login']['login'];?></button> <button type="submit" class="btn btn-success" value="Login"><?= $lang['login']['login']; ?></button>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="lang-sm lang-lbl" lang="<?=$_SESSION['mailcow_locale'];?>"></span> <span class="caret"></span> <span class="lang-sm lang-lbl" lang="<?= $_SESSION['mailcow_locale']; ?>"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li <?=($_SESSION['mailcow_locale'] == 'de') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "de"))) ?>"><span class="lang-xs lang-lbl-full" lang="de"></span></a></li> <?php
<li <?=($_SESSION['mailcow_locale'] == 'en') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "en"))) ?>"><span class="lang-xs lang-lbl-full" lang="en"></span></a></li> foreach ($AVAILABLE_LANGUAGES as $language):
<li <?=($_SESSION['mailcow_locale'] == 'es') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "es"))) ?>"><span class="lang-xs lang-lbl-full" lang="es"></span></a></li> ?>
<li <?=($_SESSION['mailcow_locale'] == 'nl') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "nl"))) ?>"><span class="lang-xs lang-lbl-full" lang="nl"></span></a></li> <li<?= ($_SESSION['mailcow_locale'] == $language) ? ' class="active"' : ''; ?>><a href="?<?= http_build_query(array_merge($_GET, array('lang' => $language))) ?>"><span class="lang-xs lang-lbl-full" lang="<?= $language; ?>"></span></a></li>
<li <?=($_SESSION['mailcow_locale'] == 'pt') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "pt"))) ?>"><span class="lang-xs lang-lbl-full" lang="pt"></span></a></li> <?php
<li <?=($_SESSION['mailcow_locale'] == 'ru') ? 'class="active"' : ''?>><a href="?<?= http_build_query(array_merge($_GET, array("lang" => "ru"))) ?>"><span class="lang-xs lang-lbl-full" lang="ru"></span></a></li> endforeach;
</ul> ?>
</div> </ul>
</div> </div>
</form> </div>
<?php </form>
if (isset($_SESSION['ldelay']) && $_SESSION['ldelay'] != "0"): <?php
?> if (isset($_SESSION['ldelay']) && $_SESSION['ldelay'] != '0'):
<p><div class="alert alert-info"><?=sprintf($lang['login']['delayed'], $_SESSION['ldelay']);?></b></div></p> ?>
<?php <p><div class="alert alert-info"><?= sprintf($lang['login']['delayed'], $_SESSION['ldelay']); ?></b></div></p>
endif; <?php
?> endif;
<legend>mailcow Apps</legend> ?>
<legend>mailcow Apps</legend>
<?php <?php
foreach ($MAILCOW_APPS as $app): foreach ($MAILCOW_APPS as $app):
?> ?>
<a href="<?=$app['link'];?>" role="button" class="btn btn-lg btn-default"><?=$app['name'];?></a>&nbsp; <a href="<?= $app['link']; ?>" role="button" class="btn btn-lg btn-default"><?= $app['name']; ?></a>&nbsp;
<?php <?php
endforeach; endforeach;
?> ?>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-offset-3 col-md-6"> <div class="col-md-offset-3 col-md-6">
<div class="panel panel-default" style=""> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<a data-toggle="collapse" href="#collapse1"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> <?=$lang['start']['help'];?></a> <a data-toggle="collapse" href="#collapse1"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> <?= $lang['start']['help']; ?></a>
</div> </div>
<div id="collapse1" class="panel-collapse collapse"> <div id="collapse1" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
<p><span style="border-bottom: 1px dotted #999">mailcow UI</span></p> <p><span style="border-bottom: 1px dotted #999;">mailcow UI</span></p>
<p><?=$lang['start']['mailcow_panel_detail'];?></p> <p><?= $lang['start']['mailcow_panel_detail']; ?></p>
<p><span style="border-bottom: 1px dotted #999">mailcow Apps</span></p> <p><span style="border-bottom: 1px dotted #999;">mailcow Apps</span></p>
<p><?=$lang['start']['mailcow_apps_detail'];?></p> <p><?= $lang['start']['mailcow_apps_detail']; ?></p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <!-- /container --> </div><!-- /.container -->
<script src="js/index.js"></script> <script src="js/index.js"></script>
<?php <?php
require_once("inc/footer.inc.php"); require_once 'inc/footer.inc.php';
?>