public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Trace
data/web/inc/triggers.admin.inc.php
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
<?php
3
if (isset($_POST["verify_tfa_login"])) {
4
if (verify_tfa_login($_SESSION['pending_mailcow_cc_username'], $_POST)) {
5
if ($_SESSION['pending_mailcow_cc_role'] == "admin") {
6
$_SESSION['mailcow_cc_username'] = $_SESSION['pending_mailcow_cc_username'];
7
$_SESSION['mailcow_cc_role'] = "admin";
8
unset($_SESSION['pending_mailcow_cc_username']);
9
unset($_SESSION['pending_mailcow_cc_role']);
10
unset($_SESSION['pending_tfa_methods']);
12
// If pending actions exist, redirect to /admin to show modal
13
if (!empty($_SESSION['pending_tfa_setup']) || !empty($_SESSION['pending_pw_update'])) {
14
header("Location: /admin");
15
die();
16
}
17
header("Location: /admin/dashboard");
18
die();
19
}
20
}
22
unset($_SESSION['pending_mailcow_cc_username']);
23
unset($_SESSION['pending_mailcow_cc_role']);
24
unset($_SESSION['pending_tfa_methods']);
25
}
26
if (isset($_POST["verify_fido2_login"])) {
27
$res = fido2(array(
28
"action" => "verify",
29
"token" => $_POST["token"],
30
"user" => "admin"
31
));
32
if (is_array($res) && $res['role'] == "admin" && !empty($res['username'])){
33
$_SESSION["mailcow_cc_username"] = $res['username'];
34
$_SESSION["mailcow_cc_role"] = $res['role'];
35
$_SESSION["fido2_cid"] = $res['cid'];
36
}
37
exit;
38
}
40
if (isset($_GET["cancel_tfa_login"])) {
41
unset($_SESSION['pending_pw_reset_token']);
42
unset($_SESSION['pending_pw_new_password']);
43
unset($_SESSION['pending_mailcow_cc_username']);
44
unset($_SESSION['pending_mailcow_cc_role']);
45
unset($_SESSION['pending_tfa_methods']);
47
header("Location: /admin");
48
}
50
if (isset($_GET["cancel_tfa_setup"])) {
51
session_regenerate_id(true);
52
session_unset();
53
session_destroy();
54
session_write_close();
55
header("Location: /admin");
56
exit();
57
}
59
if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) {
60
$login_user = strtolower(trim($_POST["login_user"]));
61
$as = check_login($login_user, $_POST["pass_user"], array("role" => "admin", "service" => "MAILCOWUI"));
63
if ($as == "admin") {
64
session_regenerate_id(true);
65
$_SESSION['mailcow_cc_username'] = $login_user;
66
$_SESSION['mailcow_cc_role'] = "admin";
67
// If pending actions exist, redirect to /admin to show modal
68
if (!empty($_SESSION['pending_tfa_setup']) || !empty($_SESSION['pending_pw_update'])) {
69
header("Location: /admin");
70
die();
71
}
72
header("Location: /admin/dashboard");
73
die();
74
}
75
elseif ($as != "pending") {
76
unset($_SESSION['pending_mailcow_cc_username']);
77
unset($_SESSION['pending_mailcow_cc_role']);
78
unset($_SESSION['pending_tfa_methods']);
79
unset($_SESSION['mailcow_cc_username']);
80
unset($_SESSION['mailcow_cc_role']);
81
}
82
}
84
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin" && !isset($_SESSION['mailcow_cc_api'])) {
85
// TODO: Move file upload to API?
86
if (isset($_POST["submit_main_logo"])) {
87
if ($_FILES['main_logo']['error'] == 0) {
88
customize('add', 'main_logo', $_FILES);
89
}
90
if ($_FILES['main_logo_dark']['error'] == 0) {
91
customize('add', 'main_logo_dark', $_FILES);
92
}
93
}
94
if (isset($_POST["reset_main_logo"])) {
95
customize('delete', 'main_logo');
96
customize('delete', 'main_logo_dark');
97
}
98
// Some actions will not be available via API
99
if (isset($_POST["license_validate_now"])) {
100
license('verify');
101
}
102
if (isset($_POST["admin_api"])) {
103
if (isset($_POST["admin_api"]["ro"])) {
104
admin_api('ro', 'edit', $_POST);
105
}
106
elseif (isset($_POST["admin_api"]["rw"])) {
107
admin_api('rw', 'edit', $_POST);
108
}
109
}
110
if (isset($_POST["admin_api_regen_key"])) {
111
if (isset($_POST["admin_api_regen_key"]["ro"])) {
112
admin_api('ro', 'regen_key', $_POST);
113
}
114
elseif (isset($_POST["admin_api_regen_key"]["rw"])) {
115
admin_api('rw', 'regen_key', $_POST);
116
}
117
}
118
if (isset($_POST["rspamd_ui"])) {
119
rspamd_ui('edit', $_POST);
120
}
121
if (isset($_POST["mass_send"])) {
122
sys_mail($_POST);
123
}
124
}
125
?>