More changes to the UI, more API...

This commit is contained in:
andryyy
2017-05-29 21:51:06 +02:00
parent f84a3a731a
commit 5a95d2062c
34 changed files with 519 additions and 385 deletions

View File

@@ -0,0 +1,68 @@
<?php
session_start();
$AuthUsers = array("admin");
if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role'], $AuthUsers)) {
echo "Not allowed." . PHP_EOL;
exit();
}
if ($_GET['ACTION'] == "start") {
$request = xmlrpc_encode_request("supervisor.startProcess", 'reconf-domains', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
'content' => $request
)));
$file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
$response = xmlrpc_decode($file);
if (isset($response['faultString'])) {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
sleep(4);
$request = xmlrpc_encode_request("supervisor.startProcess", 'sogo', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
'content' => $request
)));
$file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
$response = xmlrpc_decode($file);
if (isset($response['faultString'])) {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
echo '<b><span class="pull-right text-success">OK</span></b>';
}
}
}
elseif ($_GET['ACTION'] == "stop") {
$request = xmlrpc_encode_request("supervisor.stopProcess", 'sogo', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
'content' => $request
)));
$file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
$response = xmlrpc_decode($file);
if (isset($response['faultString'])) {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
sleep(1);
$request = xmlrpc_encode_request("supervisor.stopProcess", 'reconf-domains', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
'content' => $request
)));
$file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
$response = xmlrpc_decode($file);
if (isset($response['faultString'])) {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
echo '<b><span class="pull-right text-success">OK</span></b>';
}
}
}
?>

View File

@@ -1,48 +1,8 @@
<?php
include 'modals/footer.php';
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'admin'):
require_once $_SERVER['DOCUMENT_ROOT'] . '/modals/footer.php';
?>
<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>
<?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 id="DeleteText"><?= $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>
<div style="margin-bottom: 100px;"></div>
<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.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>
@@ -205,7 +165,7 @@ $(document).ready(function() {
$('#statusTriggerRestartSogo').text('Stopping SOGo workers, this may take a while... ');
$.ajax({
method: 'get',
url: 'call_sogo_ctrl.php',
url: '/inc/call_sogo_ctrl.php',
data: {
'ajax': true,
'ACTION': 'stop'
@@ -215,7 +175,7 @@ $(document).ready(function() {
$('#statusTriggerRestartSogo').append('<br>Starting SOGo...');
$.ajax({
method: 'get',
url: 'call_sogo_ctrl.php',
url: '/inc/call_sogo_ctrl.php',
data: {
'ajax': true,
'ACTION': 'start'

View File

@@ -1389,7 +1389,7 @@ function mailbox($_action, $_type, $_data = null) {
$relay_all_recipients = (isset($_data['relay_all_recipients'])) ? $_data['relay_all_recipients'] : $is_now['relay_all_recipients_int'];
$aliases = (!empty($_data['aliases'])) ? $_data['aliases'] : $is_now['max_num_aliases_for_domain'];
$mailboxes = (!empty($_data['mailboxes'])) ? $_data['mailboxes'] : $is_now['max_num_mboxes_for_domain'];
$maxquota = (!empty($_data['maxquota'])) ? $_data['maxquota'] : ($is_now['max_new_mailbox_quota'] / 1048576);
$maxquota = (!empty($_data['maxquota'])) ? $_data['maxquota'] : ($is_now['max_quota_for_mbox'] / 1048576);
$quota = (!empty($_data['quota'])) ? $_data['quota'] : ($is_now['max_quota_for_domain'] / 1048576);
$description = (!empty($_data['description'])) ? $_data['description'] : $is_now['description'];
($relay_all_recipients == '1') ? $backupmx = '1' : null;

View File

@@ -9,9 +9,12 @@
<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://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js" integrity="sha256-g6iAfvZp+nDQ2TdTR/VVKJf3bGro4ub5fvWSWVRi2NE=" crossorigin="anonymous"></script>
<![endif]-->
<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.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<script src="/js/jquery-1.12.4.min.js"></script>
<?php if (strtolower(trim($DEFAULT_THEME)) != "lumen"): ?>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/<?= strtolower(trim($DEFAULT_THEME)); ?>/bootstrap.min.css">
<?php else: ?>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<?php endif; ?>
<link rel="stylesheet" href="/css/bootstrap-select.min.css">
<link rel="stylesheet" href="/css/bootstrap-slider.min.css">
<link rel="stylesheet" href="/css/bootstrap-switch.min.css">

View File

@@ -1,11 +1,11 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php';
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';
// Yubi OTP API
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/Yubico.php';

View File

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

View File

@@ -32,6 +32,7 @@ $AVAILABLE_LANGUAGES = array('de', 'en', 'es', 'nl', 'pt', 'ru', 'it');
// Needs to be one of those: cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper, readable, sandstone,
// simplex, slate, spacelab, superhero, united, yeti
// See https://bootswatch.com/
// WARNING: Only lumen is loaded locally. Enabling any other theme, will download external sources.
$DEFAULT_THEME = 'lumen';
// Password complexity as regular expression
@@ -52,6 +53,9 @@ $MAILCOW_APPS = array(
// Rows until pagination begins
$PAGINATION_SIZE = 10;
// Rows until pagination begins (log table)
$LOG_PAGINATION_SIZE = 30;
// Session lifetime in seconds
$SESSION_LIFETIME = 3600;