footer.inc.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. logger();
  3. $hash = $js_minifier->getDataHash();
  4. $JSPath = '/tmp/' . $hash . '.js';
  5. if(!file_exists($JSPath)) {
  6. $js_minifier->minify($JSPath);
  7. cleanupJS($hash);
  8. }
  9. $alertbox_log_parser = alertbox_log_parser($_SESSION);
  10. $alerts = [];
  11. if (is_array($alertbox_log_parser)) {
  12. foreach ($alertbox_log_parser as $log) {
  13. $message = strtr($log['msg'], ["\n" => '', "\r" => '', "\t" => '<br>']);
  14. $alerts[trim($log['type'], '"')][] = trim($message, '"');
  15. }
  16. $alert = array_filter(array_unique($alerts));
  17. foreach($alert as $alert_type => $alert_msg) {
  18. $alerts[$alert_type] = implode('<hr class="alert-hr">', $alert_msg);
  19. }
  20. unset($_SESSION['return']);
  21. }
  22. $globalVariables = [
  23. 'js_path' => '/cache/'.basename($JSPath),
  24. 'pending_tfa_method' => @$_SESSION['pending_tfa_method'],
  25. 'pending_mailcow_cc_username' => @$_SESSION['pending_mailcow_cc_username'],
  26. 'lang_footer' => json_encode($lang['footer']),
  27. 'lang_acl' => json_encode($lang['acl']),
  28. 'lang_tfa' => json_encode($lang['tfa']),
  29. 'lang_fido2' => json_encode($lang['fido2']),
  30. 'docker_timeout' => $DOCKER_TIMEOUT,
  31. 'session_lifetime' => (int)$SESSION_LIFETIME,
  32. 'csrf_token' => $_SESSION['CSRF']['TOKEN'],
  33. 'pagination_size' => $PAGINATION_SIZE,
  34. 'log_pagination_size' => $LOG_PAGINATION_SIZE,
  35. 'alerts' => $alerts,
  36. 'totp_secret' => $tfa->createSecret(),
  37. ];
  38. foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
  39. $twig->addGlobal($globalVariableName, $globalVariableValue);
  40. }
  41. if (is_array($template_data)) {
  42. echo $twig->render($template, $template_data);
  43. }
  44. if (isset($_SESSION['mailcow_cc_api'])) {
  45. session_regenerate_id(true);
  46. session_unset();
  47. session_destroy();
  48. session_write_close();
  49. header("Location: /");
  50. }
  51. $stmt = null;
  52. $pdo = null;