2017-03-02 12:23:23 +02:00
|
|
|
<?php
|
|
|
|
if (isset($_POST["verify_tfa_login"])) {
|
|
|
|
if (verify_tfa_login($_SESSION['pending_mailcow_cc_username'], $_POST["token"])) {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $_SESSION['pending_mailcow_cc_username'];
|
|
|
|
$_SESSION['mailcow_cc_role'] = $_SESSION['pending_mailcow_cc_role'];
|
|
|
|
unset($_SESSION['pending_mailcow_cc_username']);
|
|
|
|
unset($_SESSION['pending_mailcow_cc_role']);
|
|
|
|
unset($_SESSION['pending_tfa_method']);
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /user");
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-06 10:29:00 +02:00
|
|
|
if (isset($_POST["quick_release"])) {
|
|
|
|
quarantine('quick_release', $_POST["quick_release"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_POST["quick_delete"])) {
|
|
|
|
quarantine('quick_delete', $_POST["quick_delete"]);
|
|
|
|
}
|
|
|
|
|
2017-03-02 12:23:23 +02:00
|
|
|
if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) {
|
|
|
|
$login_user = strtolower(trim($_POST["login_user"]));
|
|
|
|
$as = check_login($login_user, $_POST["pass_user"]);
|
|
|
|
if ($as == "admin") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "admin";
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /admin");
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
elseif ($as == "domainadmin") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "domainadmin";
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /mailbox");
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
elseif ($as == "user") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "user";
|
2019-12-15 14:02:38 +02:00
|
|
|
$http_parameters = explode('&', $_SESSION['index_query_string']);
|
|
|
|
unset($_SESSION['index_query_string']);
|
|
|
|
if (in_array('mobileconfig', $http_parameters)) {
|
|
|
|
if (in_array('only_email', $http_parameters)) {
|
|
|
|
header("Location: /mobileconfig.php?email_only");
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
header("Location: /mobileconfig.php");
|
|
|
|
die();
|
|
|
|
}
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /user");
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
elseif ($as != "pending") {
|
|
|
|
unset($_SESSION['pending_mailcow_cc_username']);
|
|
|
|
unset($_SESSION['pending_mailcow_cc_role']);
|
|
|
|
unset($_SESSION['pending_tfa_method']);
|
|
|
|
unset($_SESSION['mailcow_cc_username']);
|
|
|
|
unset($_SESSION['mailcow_cc_role']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-08 16:06:55 +02:00
|
|
|
if (isset($_SESSION['mailcow_cc_role']) && (isset($_SESSION['acl']['login_as']) && $_SESSION['acl']['login_as'] == "1")) {
|
2017-03-02 12:23:23 +02:00
|
|
|
if (isset($_GET["duallogin"])) {
|
2018-02-10 23:42:46 +02:00
|
|
|
$duallogin = html_entity_decode(rawurldecode($_GET["duallogin"]));
|
|
|
|
if (filter_var($duallogin, FILTER_VALIDATE_EMAIL)) {
|
|
|
|
if (!empty(mailbox('get', 'mailbox_details', $duallogin))) {
|
2017-03-02 12:23:23 +02:00
|
|
|
$_SESSION["dual-login"]["username"] = $_SESSION['mailcow_cc_username'];
|
|
|
|
$_SESSION["dual-login"]["role"] = $_SESSION['mailcow_cc_role'];
|
2018-02-10 23:42:46 +02:00
|
|
|
$_SESSION['mailcow_cc_username'] = $duallogin;
|
2017-03-02 12:23:23 +02:00
|
|
|
$_SESSION['mailcow_cc_role'] = "user";
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /user");
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-15 00:05:18 +02:00
|
|
|
else {
|
|
|
|
if (!empty(domain_admin('details', $duallogin))) {
|
|
|
|
$_SESSION["dual-login"]["username"] = $_SESSION['mailcow_cc_username'];
|
|
|
|
$_SESSION["dual-login"]["role"] = $_SESSION['mailcow_cc_role'];
|
|
|
|
$_SESSION['mailcow_cc_username'] = $duallogin;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "domainadmin";
|
2018-10-11 11:59:23 +02:00
|
|
|
header("Location: /user");
|
2018-08-15 00:05:18 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 10:32:17 +02:00
|
|
|
|
2021-06-22 07:17:55 +02:00
|
|
|
if (isset($_SESSION['mailcow_cc_role'])) {
|
2017-03-02 12:23:23 +02:00
|
|
|
if (isset($_POST["set_tfa"])) {
|
|
|
|
set_tfa($_POST);
|
|
|
|
}
|
|
|
|
if (isset($_POST["unset_tfa_key"])) {
|
|
|
|
unset_tfa_key($_POST);
|
|
|
|
}
|
2020-11-15 20:32:37 +02:00
|
|
|
if (isset($_POST["unset_fido2_key"])) {
|
|
|
|
fido2(array("action" => "unset_fido2_key", "post_data" => $_POST));
|
|
|
|
}
|
2017-03-02 12:23:23 +02:00
|
|
|
}
|
2021-05-20 15:51:52 +02:00
|
|
|
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin" && !isset($_SESSION['mailcow_cc_api'])) {
|
2017-12-09 14:17:15 +02:00
|
|
|
// TODO: Move file upload to API?
|
2017-10-21 10:07:06 +02:00
|
|
|
if (isset($_POST["submit_main_logo"])) {
|
|
|
|
if ($_FILES['main_logo']['error'] == 0) {
|
|
|
|
customize('add', 'main_logo', $_FILES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($_POST["reset_main_logo"])) {
|
|
|
|
customize('delete', 'main_logo');
|
|
|
|
}
|
2020-04-10 20:57:01 +02:00
|
|
|
// Some actions will not be available via API
|
2019-08-09 14:16:52 +02:00
|
|
|
if (isset($_POST["license_validate_now"])) {
|
|
|
|
license('verify');
|
|
|
|
}
|
|
|
|
if (isset($_POST["admin_api"])) {
|
2020-04-10 20:57:01 +02:00
|
|
|
if (isset($_POST["admin_api"]["ro"])) {
|
|
|
|
admin_api('ro', 'edit', $_POST);
|
|
|
|
}
|
|
|
|
elseif (isset($_POST["admin_api"]["rw"])) {
|
|
|
|
admin_api('rw', 'edit', $_POST);
|
|
|
|
}
|
2017-12-09 14:17:15 +02:00
|
|
|
}
|
2020-04-10 20:57:01 +02:00
|
|
|
if (isset($_POST["admin_api_regen_key"])) {
|
|
|
|
if (isset($_POST["admin_api_regen_key"]["ro"])) {
|
|
|
|
admin_api('ro', 'regen_key', $_POST);
|
|
|
|
}
|
|
|
|
elseif (isset($_POST["admin_api_regen_key"]["rw"])) {
|
|
|
|
admin_api('rw', 'regen_key', $_POST);
|
|
|
|
}
|
2017-12-09 14:17:15 +02:00
|
|
|
}
|
|
|
|
if (isset($_POST["rspamd_ui"])) {
|
|
|
|
rspamd_ui('edit', $_POST);
|
|
|
|
}
|
2018-10-11 11:59:23 +02:00
|
|
|
if (isset($_POST["mass_send"])) {
|
|
|
|
sys_mail($_POST);
|
|
|
|
}
|
2017-10-21 10:07:06 +02:00
|
|
|
}
|
2017-03-02 12:23:23 +02:00
|
|
|
?>
|