Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php'; |
| 3 | if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'domainadmin') { |
| 4 | |
| 5 | /* |
| 6 | / DOMAIN ADMIN |
| 7 | */ |
| 8 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 9 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; |
| 10 | $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 11 | $tfa_data = get_tfa(); |
| 12 | $fido2_data = fido2(array("action" => "get_friendly_names")); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 13 | $username = $_SESSION['mailcow_cc_username']; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 14 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 15 | $template = 'domainadmin.twig'; |
| 16 | $template_data = [ |
| 17 | 'acl' => $_SESSION['acl'], |
| 18 | 'acl_json' => json_encode($_SESSION['acl']), |
| 19 | 'user_spam_score' => mailbox('get', 'spam_score', $username), |
| 20 | 'tfa_data' => $tfa_data, |
| 21 | 'fido2_data' => $fido2_data, |
| 22 | 'lang_user' => json_encode($lang['user']), |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 23 | 'lang_datatables' => json_encode($lang['datatables']), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 24 | ]; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 25 | } |
| 26 | elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'user') { |
| 27 | |
| 28 | /* |
| 29 | / USER |
| 30 | */ |
| 31 | |
| 32 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; |
| 33 | $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; |
| 34 | $username = $_SESSION['mailcow_cc_username']; |
| 35 | $mailboxdata = mailbox('get', 'mailbox_details', $username); |
| 36 | $pushover_data = pushover('get', $username); |
| 37 | $tfa_data = get_tfa(); |
| 38 | $fido2_data = fido2(array("action" => "get_friendly_names")); |
| 39 | |
| 40 | $clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&ui=" . urlencode(strtok($_SERVER['HTTP_HOST'], ':')) . "&port=" . urlencode($autodiscover_config['caldav']['port']); |
| 41 | if ($autodiscover_config['useEASforOutlook'] == 'yes') |
| 42 | $clientconfigstr .= "&outlookEAS=1"; |
| 43 | if (file_exists('thunderbird-plugins/version.csv')) { |
| 44 | $fh = fopen('thunderbird-plugins/version.csv', 'r'); |
| 45 | if ($fh) { |
| 46 | while (($row = fgetcsv($fh, 1000, ';')) !== FALSE) { |
| 47 | if ($row[0] == 'sogo-connector@inverse.ca') { |
| 48 | $clientconfigstr .= "&connector=" . urlencode($row[1]); |
| 49 | } |
| 50 | } |
| 51 | fclose($fh); |
| 52 | } |
| 53 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 54 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 55 | // Get user information about aliases |
| 56 | $user_get_alias_details = user_get_alias_details($username); |
| 57 | $user_get_alias_details['direct_aliases'] = array_filter($user_get_alias_details['direct_aliases']); |
| 58 | $user_get_alias_details['shared_aliases'] = array_filter($user_get_alias_details['shared_aliases']); |
| 59 | $user_domains[] = mailbox('get', 'mailbox_details', $username)['domain']; |
| 60 | $user_alias_domains = $user_get_alias_details['alias_domains']; |
| 61 | if (!empty($user_alias_domains)) { |
| 62 | $user_domains = array_merge($user_domains, $user_alias_domains); |
| 63 | } |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 64 | |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 65 | // get number of app passwords |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 66 | $number_of_app_passwords = 0; |
| 67 | foreach (app_passwd("get") as $app_password) |
| 68 | { |
| 69 | $app_password = app_passwd("details", $app_password['id']); |
| 70 | if ($app_password['active']) |
| 71 | { |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 72 | $number_of_app_passwords++; |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 73 | } |
| 74 | } |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 75 | |
| 76 | $template = 'user.twig'; |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 77 | $template_data = [ |
| 78 | 'acl' => $_SESSION['acl'], |
| 79 | 'acl_json' => json_encode($_SESSION['acl']), |
| 80 | 'user_spam_score' => mailbox('get', 'spam_score', $username), |
| 81 | 'tfa_data' => $tfa_data, |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 82 | 'tfa_id' => @$_SESSION['tfa_id'], |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 83 | 'fido2_data' => $fido2_data, |
| 84 | 'mailboxdata' => $mailboxdata, |
| 85 | 'clientconfigstr' => $clientconfigstr, |
| 86 | 'user_get_alias_details' => $user_get_alias_details, |
| 87 | 'get_tagging_options' => mailbox('get', 'delimiter_action', $username), |
| 88 | 'get_tls_policy' => mailbox('get', 'tls_policy', $username), |
| 89 | 'quarantine_notification' => mailbox('get', 'quarantine_notification', $username), |
| 90 | 'quarantine_category' => mailbox('get', 'quarantine_category', $username), |
| 91 | 'user_domains' => $user_domains, |
| 92 | 'pushover_data' => $pushover_data, |
| 93 | 'lang_user' => json_encode($lang['user']), |
| 94 | 'number_of_app_passwords' => $number_of_app_passwords, |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 95 | 'lang_datatables' => json_encode($lang['datatables']), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 96 | ]; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 97 | } |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 98 | else { |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 99 | header('Location: /'); |
| 100 | exit(); |
| 101 | } |
| 102 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 103 | $js_minifier->add('/web/js/site/user.js'); |
| 104 | $js_minifier->add('/web/js/site/pwgen.js'); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 105 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 106 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; |