Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php'; |
| 3 | $AuthUsers = array("admin", "domainadmin", "user"); |
| 4 | if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role'], $AuthUsers)) { |
| 5 | header('Location: /'); |
| 6 | exit(); |
| 7 | } |
| 8 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; |
| 9 | |
| 10 | $template = 'edit.twig'; |
| 11 | $template_data = []; |
| 12 | $result = null; |
| 13 | if (isset($_SESSION['mailcow_cc_role'])) { |
| 14 | if ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin") { |
| 15 | if (isset($_GET["alias"]) && |
| 16 | !empty($_GET["alias"])) { |
| 17 | $alias = html_entity_decode(rawurldecode($_GET["alias"])); |
| 18 | $result = mailbox('get', 'alias_details', $alias); |
| 19 | |
| 20 | $template = 'edit/alias.twig'; |
| 21 | $template_data = [ |
| 22 | 'alias' => $alias, |
| 23 | 'goto' => (preg_match('/^(null|ham|spam)@localhost$/i', $result['goto'])) ? null : $result['goto'], |
| 24 | ]; |
| 25 | } |
| 26 | elseif (isset($_GET['domainadmin'])) { |
| 27 | $domain_admin = $_GET["domainadmin"]; |
| 28 | $result = domain_admin('details', $domain_admin); |
| 29 | $template = 'edit/domainadmin.twig'; |
| 30 | $template_data = [ |
| 31 | 'domain_admin' => $domain_admin, |
| 32 | 'da_acls' => acl('get', 'domainadmin', $domain_admin), |
| 33 | ]; |
| 34 | } |
| 35 | elseif (isset($_GET['admin'])) { |
| 36 | $admin = $_GET["admin"]; |
| 37 | $result = admin('details', $admin); |
| 38 | $template = 'edit/admin.twig'; |
| 39 | $template_data = ['admin' => $admin]; |
| 40 | } |
| 41 | elseif (isset($_GET['domain']) && |
| 42 | is_valid_domain_name($_GET["domain"]) && |
| 43 | !empty($_GET["domain"])) { |
| 44 | $domain = $_GET["domain"]; |
| 45 | $result = mailbox('get', 'domain_details', $domain); |
| 46 | $quota_notification_bcc = quota_notification_bcc('get', $domain); |
| 47 | $rl = ratelimit('get', 'domain', $domain); |
| 48 | $rlyhosts = relayhost('get'); |
| 49 | $template = 'edit/domain.twig'; |
| 50 | $template_data = [ |
| 51 | 'acl' => $_SESSION['acl'], |
| 52 | 'domain' => $domain, |
| 53 | 'quota_notification_bcc' => $quota_notification_bcc, |
| 54 | 'rl' => $rl, |
| 55 | 'rlyhosts' => $rlyhosts, |
| 56 | 'dkim' => dkim('details', $domain), |
| 57 | ]; |
| 58 | } |
| 59 | elseif (isset($_GET['oauth2client']) && |
| 60 | is_numeric($_GET["oauth2client"]) && |
| 61 | !empty($_GET["oauth2client"])) { |
| 62 | $oauth2client = $_GET["oauth2client"]; |
| 63 | $result = oauth2('details', 'client', $oauth2client); |
| 64 | $template = 'edit/oauth2client.twig'; |
| 65 | $template_data = ['oauth2client' => $oauth2client]; |
| 66 | } |
| 67 | elseif (isset($_GET['aliasdomain']) && |
| 68 | is_valid_domain_name(html_entity_decode(rawurldecode($_GET["aliasdomain"]))) && |
| 69 | !empty($_GET["aliasdomain"])) { |
| 70 | $alias_domain = html_entity_decode(rawurldecode($_GET["aliasdomain"])); |
| 71 | $result = mailbox('get', 'alias_domain_details', $alias_domain); |
| 72 | $rl = ratelimit('get', 'domain', $alias_domain); |
| 73 | $template = 'edit/aliasdomain.twig'; |
| 74 | $template_data = [ |
| 75 | 'alias_domain' => $alias_domain, |
| 76 | 'rl' => $rl, |
| 77 | 'domains' => mailbox('get', 'domains'), |
| 78 | 'dkim' => dkim('details', $alias_domain), |
| 79 | ]; |
| 80 | } |
| 81 | elseif (isset($_GET['mailbox']) && filter_var(html_entity_decode(rawurldecode($_GET["mailbox"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) { |
| 82 | $mailbox = html_entity_decode(rawurldecode($_GET["mailbox"])); |
| 83 | $result = mailbox('get', 'mailbox_details', $mailbox); |
| 84 | $rl = ratelimit('get', 'mailbox', $mailbox); |
| 85 | $pushover_data = pushover('get', $mailbox); |
| 86 | $quarantine_notification = mailbox('get', 'quarantine_notification', $mailbox); |
| 87 | $quarantine_category = mailbox('get', 'quarantine_category', $mailbox); |
| 88 | $get_tls_policy = mailbox('get', 'tls_policy', $mailbox); |
| 89 | $rlyhosts = relayhost('get'); |
| 90 | $template = 'edit/mailbox.twig'; |
| 91 | $template_data = [ |
| 92 | 'acl' => $_SESSION['acl'], |
| 93 | 'mailbox' => $mailbox, |
| 94 | 'rl' => $rl, |
| 95 | 'pushover_data' => $pushover_data, |
| 96 | 'quarantine_notification' => $quarantine_notification, |
| 97 | 'quarantine_category' => $quarantine_category, |
| 98 | 'get_tls_policy' => $get_tls_policy, |
| 99 | 'rlyhosts' => $rlyhosts, |
| 100 | 'sender_acl_handles' => mailbox('get', 'sender_acl_handles', $mailbox), |
| 101 | 'user_acls' => acl('get', 'user', $mailbox), |
| 102 | ]; |
| 103 | } |
| 104 | elseif (isset($_GET['relayhost']) && is_numeric($_GET["relayhost"]) && !empty($_GET["relayhost"])) { |
| 105 | $relayhost = intval($_GET["relayhost"]); |
| 106 | $result = relayhost('details', $relayhost); |
| 107 | $template = 'edit/relayhost.twig'; |
| 108 | $template_data = ['relayhost' => $relayhost]; |
| 109 | } |
| 110 | elseif (isset($_GET['transport']) && is_numeric($_GET["transport"]) && !empty($_GET["transport"])) { |
| 111 | $transport = intval($_GET["transport"]); |
| 112 | $result = transport('details', $transport); |
| 113 | $template = 'edit/transport.twig'; |
| 114 | $template_data = ['transport' => $transport]; |
| 115 | } |
| 116 | elseif (isset($_GET['resource']) && filter_var(html_entity_decode(rawurldecode($_GET["resource"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["resource"])) { |
| 117 | $resource = html_entity_decode(rawurldecode($_GET["resource"])); |
| 118 | $result = mailbox('get', 'resource_details', $resource); |
| 119 | $template = 'edit/resource.twig'; |
| 120 | } |
| 121 | elseif (isset($_GET['bcc']) && !empty($_GET["bcc"])) { |
| 122 | $bcc = intval($_GET["bcc"]); |
| 123 | $result = bcc('details', $bcc); |
| 124 | $template = 'edit/bcc.twig'; |
| 125 | $template_data = ['bcc' => $bcc]; |
| 126 | } |
| 127 | elseif (isset($_GET['recipient_map']) && |
| 128 | !empty($_GET["recipient_map"]) && |
| 129 | $_SESSION['mailcow_cc_role'] == "admin") { |
| 130 | $map = intval($_GET["recipient_map"]); |
| 131 | $result = recipient_map('details', $map); |
| 132 | if (substr($result['recipient_map_old'], 0, 1) == '@') { |
| 133 | $result['recipient_map_old'] = substr($result['recipient_map_old'], 1); |
| 134 | } |
| 135 | $template = 'edit/recipient_map.twig'; |
| 136 | $template_data = ['map' => $map]; |
| 137 | } |
| 138 | elseif (isset($_GET['tls_policy_map']) && |
| 139 | !empty($_GET["tls_policy_map"]) && |
| 140 | $_SESSION['mailcow_cc_role'] == "admin") { |
| 141 | $map = intval($_GET["tls_policy_map"]); |
| 142 | $result = tls_policy_maps('details', $map); |
| 143 | $template = 'edit/tls_policy_map.twig'; |
| 144 | $template_data = [ |
| 145 | 'map' => $map, |
| 146 | 'policy_options' => [ |
| 147 | 'none', |
| 148 | 'may', |
| 149 | 'encrypt', |
| 150 | 'dane', |
| 151 | 'dane-only', |
| 152 | 'fingerprint', |
| 153 | 'verify', |
| 154 | 'secure', |
| 155 | ], |
| 156 | ]; |
| 157 | } |
| 158 | } |
| 159 | if ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin" || $_SESSION['mailcow_cc_role'] == "user") { |
| 160 | if (isset($_GET['syncjob']) && |
| 161 | is_numeric($_GET['syncjob'])) { |
| 162 | $id = $_GET["syncjob"]; |
| 163 | $result = mailbox('get', 'syncjob_details', $id); |
| 164 | $template = 'edit/syncjob.twig'; |
| 165 | } |
| 166 | elseif (isset($_GET['filter']) && |
| 167 | is_numeric($_GET['filter'])) { |
| 168 | $id = $_GET["filter"]; |
| 169 | $result = mailbox('get', 'filter_details', $id); |
| 170 | $template = 'edit/filter.twig'; |
| 171 | } |
| 172 | elseif (isset($_GET['app-passwd']) && |
| 173 | is_numeric($_GET['app-passwd'])) { |
| 174 | $id = $_GET["app-passwd"]; |
| 175 | $result = app_passwd('details', $id); |
| 176 | $template = 'edit/app-passwd.twig'; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | else { |
| 181 | $template_data['access_denied'] = true; |
| 182 | } |
| 183 | |
| 184 | $js_minifier->add('/web/js/site/edit.js'); |
| 185 | $js_minifier->add('/web/js/site/pwgen.js'); |
| 186 | |
| 187 | $template_data['result'] = $result; |
| 188 | $template_data['return_to'] = $_SESSION['return_to']; |
| 189 | $template_data['lang_user'] = json_encode($lang['user']); |
| 190 | |
| 191 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; |