footer.inc.php 1.8 KB

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