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/edit.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
2
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
4
protect_route();
6
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
8
$template = 'edit.twig';
9
$template_data = [];
10
$result = null;
11
if (isset($_SESSION['mailcow_cc_role'])) {
12
if ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin") {
13
if (isset($_GET["alias"]) &&
14
!empty($_GET["alias"])) {
15
$alias = html_entity_decode(rawurldecode($_GET["alias"]));
16
$result = mailbox('get', 'alias_details', $alias);
18
$template = 'edit/alias.twig';
19
$template_data = [
20
'alias' => $alias,
21
'goto' => (preg_match('/^(null|ham|spam)@localhost$/i', $result['goto'])) ? null : $result['goto'],
22
];
23
}
24
elseif (isset($_GET['domainadmin'])) {
25
$domain_admin = $_GET["domainadmin"];
26
$result = domain_admin('details', $domain_admin);
27
$template = 'edit/domainadmin.twig';
28
$template_data = [
29
'domain_admin' => $domain_admin,
30
'da_acls' => acl('get', 'domainadmin', $domain_admin),
31
];
32
}
33
elseif (isset($_GET['admin'])) {
34
$admin = $_GET["admin"];
35
$result = admin('details', $admin);
36
$template = 'edit/admin.twig';
37
$template_data = ['admin' => $admin];
38
}
39
elseif (isset($_GET['domain'])) {
40
if (is_valid_domain_name($_GET["domain"]) &&
41
!empty($_GET["domain"])) {
42
// edit domain
43
$domain = $_GET["domain"];
44
$result = mailbox('get', 'domain_details', $domain);
45
$quota_notification_bcc = quota_notification_bcc('get', $domain);
46
$rl = ratelimit('get', 'domain', $domain);
47
$rlyhosts = relayhost('get');
48
$domain_footer = mailbox('get', 'domain_wide_footer', $domain);
49
$mta_sts = mailbox('get', 'mta_sts', $domain);
50
if (count($mta_sts) == 0) {
51
$mta_sts = false;
52
} elseif (isset($mta_sts['mx'])) {
53
$mta_sts['mx'] = implode(',', $mta_sts['mx']);
54
}
55
$template = 'edit/domain.twig';
56
$template_data = [
57
'acl' => $_SESSION['acl'],
58
'domain' => $domain,
59
'quota_notification_bcc' => $quota_notification_bcc,
60
'rl' => $rl,
61
'rlyhosts' => $rlyhosts,
62
'dkim' => dkim('details', $domain),
63
'domain_details' => $result,
64
'domain_footer' => $domain_footer,
65
'mta_sts' => $mta_sts,
66
'mailboxes' => mailbox('get', 'mailboxes', $_GET["domain"]),
67
'aliases' => mailbox('get', 'aliases', $_GET["domain"], 'address'),
68
'alias_domains' => mailbox('get', 'alias_domains', $_GET["domain"])
69
];
70
}
71
}
72
elseif (isset($_GET['template'])){
73
$domain_template = mailbox('get', 'domain_templates', $_GET['template']);
74
if ($domain_template){
75
$template_data = [
76
'template' => $domain_template,
77
'rl' => ['frame' => $domain_template['attributes']['rl_frame']],
78
];
79
$template = 'edit/domain-templates.twig';
80
$result = true;
81
}
82
else {
83
$mailbox_template = mailbox('get', 'mailbox_templates', $_GET['template']);
84
if ($mailbox_template){
85
$template_data = [
86
'template' => $mailbox_template,
87
'rl' => ['frame' => $mailbox_template['attributes']['rl_frame']],
88
];
89
$template = 'edit/mailbox-templates.twig';
90
$result = true;
91
}
92
}
93
}
94
elseif (isset($_GET['oauth2client']) &&
95
is_numeric($_GET["oauth2client"]) &&
96
!empty($_GET["oauth2client"])) {
97
$oauth2client = $_GET["oauth2client"];
98
$result = oauth2('details', 'client', $oauth2client);
99
$template = 'edit/oauth2client.twig';
100
$template_data = ['oauth2client' => $oauth2client];
101
}
102
elseif (isset($_GET['aliasdomain']) &&
103
is_valid_domain_name(html_entity_decode(rawurldecode($_GET["aliasdomain"]))) &&
104
!empty($_GET["aliasdomain"])) {
105
$alias_domain = html_entity_decode(rawurldecode($_GET["aliasdomain"]));
106
$result = mailbox('get', 'alias_domain_details', $alias_domain);
107
$rl = ratelimit('get', 'domain', $alias_domain);
108
$template = 'edit/aliasdomain.twig';
109
$template_data = [
110
'alias_domain' => $alias_domain,
111
'rl' => $rl,
112
'domains' => mailbox('get', 'domains'),
113
'dkim' => dkim('details', $alias_domain),
114
];
115
}
116
elseif (isset($_GET['mailbox'])){
117
if(filter_var(html_entity_decode(rawurldecode($_GET["mailbox"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) {
118
// edit mailbox
119
$mailbox = html_entity_decode(rawurldecode($_GET["mailbox"]));
120
$result = mailbox('get', 'mailbox_details', $mailbox);
121
$rl = ratelimit('get', 'mailbox', $mailbox);
122
$pushover_data = pushover('get', $mailbox);
123
$quarantine_notification = mailbox('get', 'quarantine_notification', $mailbox);
124
$quarantine_category = mailbox('get', 'quarantine_category', $mailbox);
125
$get_tls_policy = mailbox('get', 'tls_policy', $mailbox);
126
$rlyhosts = relayhost('get');
127
$template = 'edit/mailbox.twig';
128
$template_data = [
129
'acl' => $_SESSION['acl'],
130
'mailbox' => $mailbox,
131
'rl' => $rl,
132
'pushover_data' => $pushover_data,
133
'get_tagging_options' => mailbox('get', 'delimiter_action', $mailbox),
134
'quarantine_notification' => $quarantine_notification,
135
'quarantine_category' => $quarantine_category,
136
'get_tls_policy' => $get_tls_policy,
137
'rlyhosts' => $rlyhosts,
138
'sender_acl_handles' => mailbox('get', 'sender_acl_handles', $mailbox),
139
'user_acls' => acl('get', 'user', $mailbox),
140
'mailbox_details' => $result,
141
'iam_settings' => $iam_settings,
142
];
143
}
144
}
145
elseif (isset($_GET['relayhost']) && is_numeric($_GET["relayhost"]) && !empty($_GET["relayhost"])) {
146
$relayhost = intval($_GET["relayhost"]);
147
$result = relayhost('details', $relayhost);
148
$template = 'edit/relayhost.twig';
149
$template_data = ['relayhost' => $relayhost];
150
}
151
elseif (isset($_GET['transport']) && is_numeric($_GET["transport"]) && !empty($_GET["transport"])) {
152
$transport = intval($_GET["transport"]);
153
$result = transport('details', $transport);
154
$template = 'edit/transport.twig';
155
$template_data = ['transport' => $transport];
156
}
157
elseif (isset($_GET['resource']) && filter_var(html_entity_decode(rawurldecode($_GET["resource"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["resource"])) {
158
$resource = html_entity_decode(rawurldecode($_GET["resource"]));
159
$result = mailbox('get', 'resource_details', $resource);
160
$template = 'edit/resource.twig';
161
}
162
elseif (isset($_GET['bcc']) && !empty($_GET["bcc"])) {
163
$bcc = intval($_GET["bcc"]);
164
$result = bcc('details', $bcc);
165
$template = 'edit/bcc.twig';
166
$template_data = ['bcc' => $bcc];
167
}
168
elseif (isset($_GET['recipient_map']) &&
169
!empty($_GET["recipient_map"]) &&
170
$_SESSION['mailcow_cc_role'] == "admin") {
171
$map = intval($_GET["recipient_map"]);
172
$result = recipient_map('details', $map);
173
if (substr($result['recipient_map_old'], 0, 1) == '@') {
174
$result['recipient_map_old'] = substr($result['recipient_map_old'], 1);
175
}
176
if (substr($result['recipient_map_new'], 0, 1) == '@') {
177
$result['recipient_map_new'] = substr($result['recipient_map_new'], 1);
178
}
179
$template = 'edit/recipient_map.twig';
180
$template_data = ['map' => $map];
181
}
182
elseif (isset($_GET['tls_policy_map']) &&
183
!empty($_GET["tls_policy_map"]) &&
184
$_SESSION['mailcow_cc_role'] == "admin") {
185
$map = intval($_GET["tls_policy_map"]);
186
$result = tls_policy_maps('details', $map);
187
$template = 'edit/tls_policy_map.twig';
188
$template_data = [
189
'map' => $map,
190
'policy_options' => [
191
'none',
192
'may',
193
'encrypt',
194
'dane',
195
'dane-only',
196
'fingerprint',
197
'verify',
198
'secure',
199
],
200
];
201
}
202
}
203
if ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin" || $_SESSION['mailcow_cc_role'] == "user") {
204
if (isset($_GET['syncjob']) &&
205
is_numeric($_GET['syncjob'])) {
206
$id = $_GET["syncjob"];
207
$result = mailbox('get', 'syncjob_details', $id);
208
$template = 'edit/syncjob.twig';
209
}
210
elseif (isset($_GET['filter']) &&
211
is_numeric($_GET['filter'])) {
212
$id = $_GET["filter"];
213
$result = mailbox('get', 'filter_details', $id);
214
$template = 'edit/filter.twig';
215
}
216
elseif (isset($_GET['app-passwd']) &&
217
is_numeric($_GET['app-passwd'])) {
218
$id = $_GET["app-passwd"];
219
$result = app_passwd('details', $id);
220
$template = 'edit/app-passwd.twig';
221
}
222
}
223
}
224
else {
225
$template_data['access_denied'] = true;
226
}
228
$js_minifier->add('/web/js/site/edit.js');
229
$js_minifier->add('/web/js/site/pwgen.js');
231
$template_data['result'] = $result;
232
$template_data['return_to'] = $_SESSION['return_to'];
233
$template_data['lang_user'] = json_encode($lang['user']);
234
$template_data['lang_admin'] = json_encode($lang['admin']);
235
$template_data['lang_datatables'] = json_encode($lang['datatables']);
237
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';