blob: 30b7d3e44a17af94e6e66a2d216f44d3f91ca306 [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"));
13if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CACHE')) {
14 $_SESSION['gal'] = json_decode($license_cache, true);
15}
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010016
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010017$js_minifier->add('/web/js/site/admin.js');
18$js_minifier->add('/web/js/presets/rspamd.js');
19$js_minifier->add('/web/js/site/pwgen.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010020
21// all domains
22$domains = mailbox('get', 'domains');
23$all_domains = array_merge($domains, mailbox('get', 'alias_domains'));
24
25// mailboxes
26$mailboxes = [];
27foreach ($all_domains as $domain) {
28 foreach (mailbox('get', 'mailboxes', $domain) as $mailbox) {
29 $mailboxes[] = $mailbox;
30 }
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010031}
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010032$mailboxes = array_filter($mailboxes);
33
34// DKIM domains
35$dkim_domains = [];
36$dkim_domains_with_keys = [];
37foreach($domains as $domain) {
38 $dkim_domains[$domain] = ['dkim' => null, 'alias_domains' => []];
39 if (!empty($dkim = dkim('details', $domain))) {
40 $dkim_domains_with_keys[] = $domain;
41 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
42 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
43 }
44 $dkim_domains[$domain]['dkim'] = $dkim;
45 }
46
47 // get alias domains
48 foreach (mailbox('get', 'alias_domains', $domain) as $alias_domain) {
49 $dkim_domains[$domain]['alias_domains'][$alias_domain] = ['dkim' => null];
50 if (!empty($dkim = dkim('details', $alias_domain))) {
51 $dkim_domains_with_keys[] = $alias_domain;
52 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
53 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
54 }
55 $dkim_domains[$domain]['alias_domains'][$alias_domain]['dkim'] = $dkim;
56 }
57 }
58}
59$dkim_blind_domains = [];
60foreach(dkim('blind') as $blind) {
61 $dkim_blind_domains[$blind] = ['dkim' => null];
62 if (!empty($dkim = dkim('details', $blind))) {
63 $dkim_domains_with_keys[] = $blind;
64 if ($GLOBALS['SHOW_DKIM_PRIV_KEYS'] !== true) {
65 $dkim['privkey'] = base64_encode('Please set $SHOW_DKIM_PRIV_KEYS to true to show DKIM private keys.');
66 }
67 $dkim_blind_domains[$blind]['dkim'] = $dkim;
68 }
69}
70
71// rsettings
72$rsettings = array_map(function ($rsetting){
73 $rsetting['details'] = rsettings('details', $rsetting['id']);
74 return $rsetting;
75}, rsettings('get'));
76
77// rspamd regex maps
78$rspamd_regex_maps = [];
79foreach ($RSPAMD_MAPS['regex'] as $rspamd_regex_desc => $rspamd_regex_map) {
80 $rspamd_regex_maps[$rspamd_regex_desc] = [
81 'map' => $rspamd_regex_map,
82 'data' => file_get_contents('/rspamd_custom_maps/' . $rspamd_regex_map)
83 ];
84}
85
86
87$template = 'admin.twig';
88$template_data = [
89 'tfa_data' => $tfa_data,
90 'tfa_id' => @$_SESSION['tfa_id'],
91 'fido2_cid' => @$_SESSION['fido2_cid'],
92 'fido2_data' => $fido2_data,
93 'gal' => @$_SESSION['gal'],
94 'license_guid' => license('guid'),
95 'api' => [
96 'ro' => admin_api('ro', 'get'),
97 'rw' => admin_api('rw', 'get'),
98 ],
99 'dkim_domains' => $dkim_domains,
100 'dkim_domains_with_keys' => $dkim_domains_with_keys,
101 'dkim_blind_domains' => $dkim_blind_domains,
102 'domains' => $domains,
103 'all_domains' => $all_domains,
104 'mailboxes' => $mailboxes,
105 'f2b_data' => fail2ban('get'),
106 'q_data' => quarantine('settings'),
107 'qn_data' => quota_notification('get'),
108 'rsettings_map' => file_get_contents('http://nginx:8081/settings.php'),
109 'rsettings' => $rsettings,
110 'rspamd_regex_maps' => $rspamd_regex_maps,
111 'logo_specs' => customize('get', 'main_logo_specs'),
112 'password_complexity' => password_complexity('get'),
113 'show_rspamd_global_filters' => @$_SESSION['show_rspamd_global_filters'],
114 'lang_admin' => json_encode($lang['admin']),
115];
116
117require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';