blob: a3b908b74036787fe561a455d77513c3870964d5 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
3
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01004if (!isset($_SESSION['mailcow_cc_role']) || $_SESSION['mailcow_cc_role'] != "admin") {
5 header('Location: /');
6 exit();
7}
8
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01009require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
10$_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
11$tfa_data = get_tfa();
12$fido2_data = fido2(array("action" => "get_friendly_names"));
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010013
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010014$js_minifier->add('/web/js/site/admin.js');
15$js_minifier->add('/web/js/presets/rspamd.js');
16$js_minifier->add('/web/js/site/pwgen.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010017
18// all domains
19$domains = mailbox('get', 'domains');
20$all_domains = array_merge($domains, mailbox('get', 'alias_domains'));
21
22// mailboxes
23$mailboxes = [];
24foreach ($all_domains as $domain) {
25 foreach (mailbox('get', 'mailboxes', $domain) as $mailbox) {
26 $mailboxes[] = $mailbox;
27 }
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010028}
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010029$mailboxes = array_filter($mailboxes);
30
31// DKIM domains
32$dkim_domains = [];
33$dkim_domains_with_keys = [];
34foreach($domains as $domain) {
35 $dkim_domains[$domain] = ['dkim' => null, 'alias_domains' => []];
36 if (!empty($dkim = dkim('details', $domain))) {
37 $dkim_domains_with_keys[] = $domain;
38 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
39 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
40 }
41 $dkim_domains[$domain]['dkim'] = $dkim;
42 }
43
44 // get alias domains
45 foreach (mailbox('get', 'alias_domains', $domain) as $alias_domain) {
46 $dkim_domains[$domain]['alias_domains'][$alias_domain] = ['dkim' => null];
47 if (!empty($dkim = dkim('details', $alias_domain))) {
48 $dkim_domains_with_keys[] = $alias_domain;
49 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
50 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
51 }
52 $dkim_domains[$domain]['alias_domains'][$alias_domain]['dkim'] = $dkim;
53 }
54 }
55}
56$dkim_blind_domains = [];
57foreach(dkim('blind') as $blind) {
58 $dkim_blind_domains[$blind] = ['dkim' => null];
59 if (!empty($dkim = dkim('details', $blind))) {
60 $dkim_domains_with_keys[] = $blind;
61 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
62 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
63 }
64 $dkim_blind_domains[$blind]['dkim'] = $dkim;
65 }
66}
67
68// rsettings
69$rsettings = array_map(function ($rsetting){
70 $rsetting['details'] = rsettings('details', $rsetting['id']);
71 return $rsetting;
72}, rsettings('get'));
73
74// rspamd regex maps
75$rspamd_regex_maps = [];
76foreach ($RSPAMD_MAPS['regex'] as $rspamd_regex_desc => $rspamd_regex_map) {
77 $rspamd_regex_maps[$rspamd_regex_desc] = [
78 'map' => $rspamd_regex_map,
79 'data' => file_get_contents('/rspamd_custom_maps/' . $rspamd_regex_map)
80 ];
81}
82
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010083$template = 'admin.twig';
84$template_data = [
85 'tfa_data' => $tfa_data,
86 'tfa_id' => @$_SESSION['tfa_id'],
87 'fido2_cid' => @$_SESSION['fido2_cid'],
88 'fido2_data' => $fido2_data,
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010089 'api' => [
90 'ro' => admin_api('ro', 'get'),
91 'rw' => admin_api('rw', 'get'),
92 ],
93 'dkim_domains' => $dkim_domains,
94 'dkim_domains_with_keys' => $dkim_domains_with_keys,
95 'dkim_blind_domains' => $dkim_blind_domains,
96 'domains' => $domains,
97 'all_domains' => $all_domains,
98 'mailboxes' => $mailboxes,
99 'f2b_data' => fail2ban('get'),
100 'q_data' => quarantine('settings'),
101 'qn_data' => quota_notification('get'),
102 'rsettings_map' => file_get_contents('http://nginx:8081/settings.php'),
103 'rsettings' => $rsettings,
104 'rspamd_regex_maps' => $rspamd_regex_maps,
105 'logo_specs' => customize('get', 'main_logo_specs'),
106 'password_complexity' => password_complexity('get'),
107 'show_rspamd_global_filters' => @$_SESSION['show_rspamd_global_filters'],
108 'lang_admin' => json_encode($lang['admin']),
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100109 'lang_datatables' => json_encode($lang['datatables'])
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +0100110];
111
112require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';