blob: 9c08c663c3037f1311a4d65e934b8621a55f0325 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01002logger();
3
4$hash = $js_minifier->getDataHash();
5$JSPath = '/tmp/' . $hash . '.js';
6if(!file_exists($JSPath)) {
7 $js_minifier->minify($JSPath);
8 cleanupJS($hash);
9}
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010010
11$alertbox_log_parser = alertbox_log_parser($_SESSION);
12$alerts = [];
13if (is_array($alertbox_log_parser)) {
14 foreach ($alertbox_log_parser as $log) {
15 $message = strtr($log['msg'], ["\n" => '', "\r" => '', "\t" => '<br>']);
16 $alerts[trim($log['type'], '"')][] = trim($message, '"');
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010017 }
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010018 $alert = array_filter(array_unique($alerts));
19 foreach($alert as $alert_type => $alert_msg) {
20 $alerts[$alert_type] = implode('<hr class="alert-hr">', $alert_msg);
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010021 }
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010022 unset($_SESSION['return']);
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010023}
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010024
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010025$globalVariables = [
26 'js_path' => '/cache/'.basename($JSPath),
27 'pending_tfa_method' => @$_SESSION['pending_tfa_method'],
28 'pending_mailcow_cc_username' => @$_SESSION['pending_mailcow_cc_username'],
29 'lang_footer' => json_encode($lang['footer']),
30 'lang_acl' => json_encode($lang['acl']),
31 'lang_tfa' => json_encode($lang['tfa']),
32 'lang_fido2' => json_encode($lang['fido2']),
33 'docker_timeout' => $DOCKER_TIMEOUT,
34 'session_lifetime' => (int)$SESSION_LIFETIME,
35 'csrf_token' => $_SESSION['CSRF']['TOKEN'],
36 'pagination_size' => $PAGINATION_SIZE,
37 'log_pagination_size' => $LOG_PAGINATION_SIZE,
38 'alerts' => $alerts,
39 'totp_secret' => $tfa->createSecret(),
40];
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010041
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010042foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
43 $twig->addGlobal($globalVariableName, $globalVariableValue);
44}
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010045
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010046if (is_array($template_data)) {
47 echo $twig->render($template, $template_data);
48}
49
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020050if (isset($_SESSION['mailcow_cc_api'])) {
51 session_regenerate_id(true);
52 session_unset();
53 session_destroy();
54 session_write_close();
55 header("Location: /");
56}
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010057$stmt = null;
58$pdo = null;