2017-05-17 01:20:58 +08:00
|
|
|
<?php
|
2018-08-04 02:31:33 +08:00
|
|
|
logger();
|
2019-10-21 03:25:58 +08:00
|
|
|
|
|
|
|
$hash = $js_minifier->getDataHash();
|
|
|
|
$JSPath = '/tmp/' . $hash . '.js';
|
|
|
|
if(!file_exists($JSPath)) {
|
|
|
|
$js_minifier->minify($JSPath);
|
|
|
|
cleanupJS($hash);
|
|
|
|
}
|
2021-09-23 02:47:10 +08:00
|
|
|
|
|
|
|
$alertbox_log_parser = alertbox_log_parser($_SESSION);
|
|
|
|
$alerts = [];
|
|
|
|
if (is_array($alertbox_log_parser)) {
|
|
|
|
foreach ($alertbox_log_parser as $log) {
|
2021-11-29 05:48:08 +08:00
|
|
|
$message = strtr($log['msg'], ["\n" => '', "\r" => '', "\t" => '<br>']);
|
|
|
|
$alerts[trim($log['type'], '"')][] = trim($message, '"');
|
2020-11-16 02:32:37 +08:00
|
|
|
}
|
2021-09-23 02:47:10 +08:00
|
|
|
$alert = array_filter(array_unique($alerts));
|
|
|
|
foreach($alert as $alert_type => $alert_msg) {
|
2022-01-13 04:57:21 +08:00
|
|
|
// html breaks from mysql alerts, replace ` with '
|
|
|
|
$alerts[$alert_type] = implode('<hr class="alert-hr">', str_replace("`", "'", $alert_msg));
|
2020-11-16 02:32:37 +08:00
|
|
|
}
|
2018-08-04 02:31:33 +08:00
|
|
|
unset($_SESSION['return']);
|
2021-09-23 02:47:10 +08:00
|
|
|
}
|
2017-05-17 01:20:58 +08:00
|
|
|
|
2022-02-21 17:46:24 +08:00
|
|
|
// map tfa details for twig
|
|
|
|
$pending_tfa_authmechs = [];
|
|
|
|
foreach($_SESSION['pending_tfa_methods'] as $authdata){
|
|
|
|
$pending_tfa_authmechs[$authdata['authmech']] = false;
|
|
|
|
}
|
|
|
|
if (isset($pending_tfa_authmechs['webauthn'])) {
|
|
|
|
$pending_tfa_authmechs['webauthn'] = true;
|
|
|
|
}
|
|
|
|
if (!isset($pending_tfa_authmechs['webauthn'])
|
|
|
|
&& isset($pending_tfa_authmechs['yubi_otp'])) {
|
|
|
|
$pending_tfa_authmechs['yubi_otp'] = true;
|
|
|
|
}
|
|
|
|
if (!isset($pending_tfa_authmechs['webauthn'])
|
|
|
|
&& !isset($pending_tfa_authmechs['yubi_otp'])
|
|
|
|
&& isset($pending_tfa_authmechs['totp'])) {
|
|
|
|
$pending_tfa_authmechs['totp'] = true;
|
|
|
|
}
|
|
|
|
if (isset($pending_tfa_authmechs['u2f'])) {
|
|
|
|
$pending_tfa_authmechs['u2f'] = true;
|
|
|
|
}
|
|
|
|
|
2022-02-01 22:26:48 +08:00
|
|
|
// globals
|
2021-09-23 02:47:10 +08:00
|
|
|
$globalVariables = [
|
2022-02-01 22:26:48 +08:00
|
|
|
'mailcow_info' => array(
|
|
|
|
'version_tag' => $GLOBALS['MAILCOW_GIT_VERSION'],
|
2022-08-24 20:37:00 +08:00
|
|
|
'last_version_tag' => $GLOBALS['MAILCOW_LAST_GIT_VERSION'],
|
|
|
|
'git_owner' => $GLOBALS['MAILCOW_GIT_OWNER'],
|
|
|
|
'git_repo' => $GLOBALS['MAILCOW_GIT_REPO'],
|
|
|
|
'git_project_url' => $GLOBALS['MAILCOW_GIT_URL'],
|
|
|
|
'git_commit' => $GLOBALS['MAILCOW_GIT_COMMIT'],
|
|
|
|
'git_commit_date' => $GLOBALS['MAILCOW_GIT_COMMIT_DATE'],
|
|
|
|
'mailcow_branch' => $GLOBALS['MAILCOW_BRANCH'],
|
|
|
|
'updated_at' => $GLOBALS['MAILCOW_UPDATEDAT']
|
2022-02-01 22:26:48 +08:00
|
|
|
),
|
2021-09-23 02:47:10 +08:00
|
|
|
'js_path' => '/cache/'.basename($JSPath),
|
2022-02-21 17:46:24 +08:00
|
|
|
'pending_tfa_methods' => @$_SESSION['pending_tfa_methods'],
|
|
|
|
'pending_tfa_authmechs' => $pending_tfa_authmechs,
|
2021-09-23 02:47:10 +08:00
|
|
|
'pending_mailcow_cc_username' => @$_SESSION['pending_mailcow_cc_username'],
|
|
|
|
'lang_footer' => json_encode($lang['footer']),
|
|
|
|
'lang_acl' => json_encode($lang['acl']),
|
|
|
|
'lang_tfa' => json_encode($lang['tfa']),
|
|
|
|
'lang_fido2' => json_encode($lang['fido2']),
|
|
|
|
'docker_timeout' => $DOCKER_TIMEOUT,
|
|
|
|
'session_lifetime' => (int)$SESSION_LIFETIME,
|
|
|
|
'csrf_token' => $_SESSION['CSRF']['TOKEN'],
|
|
|
|
'pagination_size' => $PAGINATION_SIZE,
|
|
|
|
'log_pagination_size' => $LOG_PAGINATION_SIZE,
|
|
|
|
'alerts' => $alerts,
|
2021-10-21 06:10:05 +08:00
|
|
|
'totp_secret' => $tfa->createSecret(),
|
2021-09-23 02:47:10 +08:00
|
|
|
];
|
2019-09-22 21:10:56 +08:00
|
|
|
|
2021-09-23 02:47:10 +08:00
|
|
|
foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
|
|
|
|
$twig->addGlobal($globalVariableName, $globalVariableValue);
|
|
|
|
}
|
|
|
|
|
2021-10-30 14:03:41 +08:00
|
|
|
if (is_array($template_data)) {
|
|
|
|
echo $twig->render($template, $template_data);
|
|
|
|
}
|
2019-10-24 04:09:10 +08:00
|
|
|
|
2021-05-20 21:51:52 +08:00
|
|
|
if (isset($_SESSION['mailcow_cc_api'])) {
|
|
|
|
session_regenerate_id(true);
|
|
|
|
session_unset();
|
|
|
|
session_destroy();
|
|
|
|
session_write_close();
|
|
|
|
header("Location: /");
|
|
|
|
}
|
2017-05-17 01:20:58 +08:00
|
|
|
$stmt = null;
|
2017-12-09 20:17:15 +08:00
|
|
|
$pdo = null;
|