footer.inc.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // html breaks from mysql alerts, replace ` with '
  19. $alerts[$alert_type] = implode('<hr class="alert-hr">', str_replace("`", "'", $alert_msg));
  20. }
  21. unset($_SESSION['return']);
  22. }
  23. // globals
  24. $globalVariables = [
  25. 'mailcow_info' => array(
  26. 'version_tag' => $GLOBALS['MAILCOW_GIT_VERSION'],
  27. 'git_project_url' => $GLOBALS['MAILCOW_GIT_URL']
  28. ),
  29. 'js_path' => '/cache/'.basename($JSPath),
  30. 'pending_tfa_method' => @$_SESSION['pending_tfa_method'],
  31. 'pending_mailcow_cc_username' => @$_SESSION['pending_mailcow_cc_username'],
  32. 'lang_footer' => json_encode($lang['footer']),
  33. 'lang_acl' => json_encode($lang['acl']),
  34. 'lang_tfa' => json_encode($lang['tfa']),
  35. 'lang_fido2' => json_encode($lang['fido2']),
  36. 'docker_timeout' => $DOCKER_TIMEOUT,
  37. 'session_lifetime' => (int)$SESSION_LIFETIME,
  38. 'csrf_token' => $_SESSION['CSRF']['TOKEN'],
  39. 'pagination_size' => $PAGINATION_SIZE,
  40. 'log_pagination_size' => $LOG_PAGINATION_SIZE,
  41. 'alerts' => $alerts,
  42. 'totp_secret' => $tfa->createSecret(),
  43. ];
  44. foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
  45. $twig->addGlobal($globalVariableName, $globalVariableValue);
  46. }
  47. if (is_array($template_data)) {
  48. echo $twig->render($template, $template_data);
  49. }
  50. if (isset($_SESSION['mailcow_cc_api'])) {
  51. session_regenerate_id(true);
  52. session_unset();
  53. session_destroy();
  54. session_write_close();
  55. header("Location: /");
  56. }
  57. $stmt = null;
  58. $pdo = null;