mailcow/data/web/inc/footer.inc.php

253 lines
8.5 KiB
PHP
Raw Normal View History

2017-03-02 18:23:23 +08:00
<?php
include("inc/tfa_modals.php");
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin"):
?>
<div id="RestartSOGo" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><?=$lang['footer']['restart_sogo'];?></h4>
</div>
<div class="modal-body">
<p><?=$lang['footer']['restart_sogo_info'];?></p>
<hr />
<button class="btn btn-md btn-primary" id="triggerRestartSogo"><?=$lang['footer']['restart_now'];?></button>
<br /><br />
<div id="statusTriggerRestartSogo"></div>
</div>
</div>
</div>
</div>
2017-05-09 19:43:54 +08:00
<?php
endif;
?>
<div id="ConfirmDeleteModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><?=$lang['footer']['confirm_delete'];?></h4>
</div>
<div class="modal-body">
<p><?=$lang['footer']['delete_these_items'];?></p>
<ul id="ItemsToDelete"></ul>
<hr />
<button class="btn btn-sm btn-danger" id="IsConfirmed"><?=$lang['footer']['delete_now'];?></button>
<button class="btn btn-sm btn-default" id="isCanceled"><?=$lang['footer']['cancel'];?></button>
</div>
</div>
</div>
</div>
2017-03-02 18:23:23 +08:00
<div style="margin-bottom:100px"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="/js/bootstrap-switch.min.js"></script>
<script src="/js/bootstrap-slider.min.js"></script>
<script src="/js/bootstrap-select.min.js"></script>
<script src="/js/u2f-api.js"></script>
<script>
// Select language and reopen active URL without POST
function setLang(sel) {
$.post( "<?=$_SERVER['REQUEST_URI'];?>", {lang: sel} );
window.location.href = window.location.pathname + window.location.search;
}
$(document).ready(function() {
2017-05-09 19:43:54 +08:00
function mailcow_alert_box(type, message) {
$('.mailcow-alert-box').show();
$('.mailcow-alert-box').addClass("alert-" + type);
$('#mailcow-alert-text').text(message);
}
// PHP error handler
2017-05-10 05:25:23 +08:00
2017-05-09 19:43:54 +08:00
2017-03-02 18:23:23 +08:00
// Confirm TFA modal
<?php if (isset($_SESSION['pending_tfa_method'])):?>
$('#ConfirmTFAModal').modal({
backdrop: 'static',
keyboard: false
});
$('#ConfirmTFAModal').on('shown.bs.modal', function(){
$(this).find('#token').focus();
// If U2F
if(document.getElementById("u2f_auth_data") !== null) {
$.ajax({
type: "GET",
cache: false,
dataType: 'script',
2017-05-01 22:34:09 +08:00
url: "/api/v1/get/u2f-authentication/<?=(isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null;?>",
2017-03-02 18:23:23 +08:00
success: function(data){
data;
}
});
setTimeout(function() {
console.log("sign: ", req);
u2f.sign(req, function(data) {
var form = document.getElementById('u2f_auth_form');
var auth = document.getElementById('u2f_auth_data');
console.log("Authenticate callback", data);
auth.value = JSON.stringify(data);
form.submit();
});
}, 1000);
}
});
<?php endif; ?>
// Set TFA modals
$('#selectTFA').change(function () {
if ($(this).val() == "yubi_otp") {
$('#YubiOTPModal').modal('show');
$("option:selected").prop("selected", false);
}
2017-05-04 00:05:35 +08:00
if ($(this).val() == "totp") {
$('#TOTPModal').modal('show');
$("option:selected").prop("selected", false);
}
2017-03-02 18:23:23 +08:00
if ($(this).val() == "u2f") {
$('#U2FModal').modal('show');
$("option:selected").prop("selected", false);
$.ajax({
type: "GET",
cache: false,
dataType: 'script',
2017-05-01 22:34:09 +08:00
url: "/api/v1/get/u2f-registration/<?=(isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null;?>",
2017-03-02 18:23:23 +08:00
success: function(data){
data;
}
});
setTimeout(function() {
console.log("Register: ", req);
u2f.register([req], sigs, function(data) {
var form = document.getElementById('u2f_reg_form');
var reg = document.getElementById('u2f_register_data');
console.log("Register callback", data);
if (data.errorCode && data.errorCode != 0) {
var u2f_return_code = document.getElementById('u2f_return_code');
u2f_return_code.style.display = u2f_return_code.style.display === 'none' ? '' : null;
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;
return;
}
reg.value = JSON.stringify(data);
form.submit();
});
}, 1000);
}
if ($(this).val() == "none") {
$('#DisableTFAModal').modal('show');
$("option:selected").prop("selected", false);
}
});
// Activate tooltips
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
// Hide alerts after n seconds
$("#alert-fade").fadeTo(7000, 500).slideUp(500, function(){
$("#alert-fade").alert('close');
});
// Remember last navigation pill
(function () {
'use strict';
2017-05-04 00:05:35 +08:00
if ($('a[data-toggle="tab"]').length) {
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var id = $(this).parents('[role="tablist"]').attr('id');
var key = 'lastTag';
if (id) {
key += ':' + id;
}
localStorage.setItem(key, $(e.target).attr('href'));
});
$('[role="tablist"]').each(function (idx, elem) {
var id = $(elem).attr('id');
var key = 'lastTag';
if (id) {
key += ':' + id;
}
var lastTab = localStorage.getItem(key);
if (lastTab) {
$('[href="' + lastTab + '"]').tab('show');
}
});
}
2017-03-02 18:23:23 +08:00
})();
// Disable submit after submitting form
$('form').submit(function() {
if ($('form button[type="submit"]').data('submitted') == '1') {
return false;
} else {
$(this).find('button[type="submit"]').first().text('<?=$lang['footer']['loading'];?>');
$('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;
}).remove();
// Init Bootstrap Selectpicker
$('select').selectpicker();
// Trigger SOGo restart
$('#triggerRestartSogo').click(function(){
$(this).prop("disabled",true);
$(this).html('<span class="glyphicon glyphicon-refresh glyphicon-spin"></span> ');
$('#statusTriggerRestartSogo').text('Stopping SOGo workers, this may take a while... ');
$.ajax({
method: 'get',
url: 'call_sogo_ctrl.php',
data: {
'ajax': true,
'ACTION': 'stop'
},
success: function(data) {
$('#statusTriggerRestartSogo').append(data);
$('#statusTriggerRestartSogo').append('<br />Starting SOGo... ');
$.ajax({
method: 'get',
url: 'call_sogo_ctrl.php',
data: {
'ajax': true,
'ACTION': 'start'
},
success: function(data) {
$('#statusTriggerRestartSogo').append(data);
$('#triggerRestartSogo').html('<span class="glyphicon glyphicon-ok"></span> ');
}
});
}
});
});
});
</script>
2017-05-10 05:25:23 +08:00
<div class="container">
<div id="mailcow-alert" class="alert" role="alert">
<a href="#" class="close" data-dismiss="alert"> &times;</a>
<span id="mailcow-alert-text"></span>
</div>
2017-03-02 18:23:23 +08:00
</div>
2017-05-10 05:25:23 +08:00
2017-03-02 18:23:23 +08:00
</body>
2017-05-10 05:25:23 +08:00
<?php // Notifications ?>
<script>
function mailcow_alert_box(msg, type) {
document.getElementById('mailcow-alert').style.display = 'visible';
document.getElementById('mailcow-alert-text').innerHTML = msg;
document.getElementById("mailcow-alert").className = "alert alert-" + type;
}
<?php if (isset($_SESSION['return'])): ?>
mailcow_alert_box("<?=$_SESSION['return']['msg'];?>", "<?=$_SESSION['return']['type'];?>");
<?php endif; unset($_SESSION['return']); ?>
</script>
2017-03-02 18:23:23 +08:00
</html>
<?php $stmt = null; $pdo = null; ?>