footer.inc.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. 'last_version_tag' => $GLOBALS['MAILCOW_LAST_GIT_VERSION'],
  28. 'project_url' => $GLOBALS['MAILCOW_GIT_URL'],
  29. 'project_owner' => $GLOBALS['MAILCOW_GIT_OWNER'],
  30. 'project_repo' => $GLOBALS['MAILCOW_GIT_REPO'],
  31. 'updatedAt' => $GLOBALS['MAILCOW_UPDATEDAT']
  32. ),
  33. 'js_path' => '/cache/'.basename($JSPath),
  34. 'pending_tfa_method' => @$_SESSION['pending_tfa_method'],
  35. 'pending_mailcow_cc_username' => @$_SESSION['pending_mailcow_cc_username'],
  36. 'lang_footer' => json_encode($lang['footer']),
  37. 'lang_acl' => json_encode($lang['acl']),
  38. 'lang_tfa' => json_encode($lang['tfa']),
  39. 'lang_fido2' => json_encode($lang['fido2']),
  40. 'docker_timeout' => $DOCKER_TIMEOUT,
  41. 'session_lifetime' => (int)$SESSION_LIFETIME,
  42. 'csrf_token' => $_SESSION['CSRF']['TOKEN'],
  43. 'pagination_size' => $PAGINATION_SIZE,
  44. 'log_pagination_size' => $LOG_PAGINATION_SIZE,
  45. 'alerts' => $alerts,
  46. 'totp_secret' => $tfa->createSecret(),
  47. ];
  48. foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
  49. $twig->addGlobal($globalVariableName, $globalVariableValue);
  50. }
  51. if (is_array($template_data)) {
  52. echo $twig->render($template, $template_data);
  53. }
  54. if (isset($_SESSION['mailcow_cc_api'])) {
  55. session_regenerate_id(true);
  56. session_unset();
  57. session_destroy();
  58. session_write_close();
  59. header("Location: /");
  60. }
  61. $stmt = null;
  62. $pdo = null;