blob: f62819a2e85d8e6eb7e53e1f0361b722818349f2 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?php
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01002
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01003// CSS
4if (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) {
5 $css_minifier->add('/web/css/site/mailbox.css');
6}
7if (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) {
8 $css_minifier->add('/web/css/site/admin.css');
9}
10if (preg_match("/user/i", $_SERVER['REQUEST_URI'])) {
11 $css_minifier->add('/web/css/site/user.css');
12}
13if (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) {
14 $css_minifier->add('/web/css/site/edit.css');
15}
16if (preg_match("/(quarantine|qhandler)/i", $_SERVER['REQUEST_URI'])) {
17 $css_minifier->add('/web/css/site/quarantine.css');
18}
19if (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) {
20 $css_minifier->add('/web/css/site/debug.css');
21}
22if ($_SERVER['REQUEST_URI'] == '/') {
23 $css_minifier->add('/web/css/site/index.css');
24}
25
26$hash = $css_minifier->getDataHash();
27$CSSPath = '/tmp/' . $hash . '.css';
28if(!file_exists($CSSPath)) {
29 $css_minifier->minify($CSSPath);
30 cleanupCSS($hash);
31}
32
33$globalVariables = [
34 'mailcow_hostname' => getenv('MAILCOW_HOSTNAME'),
35 'mailcow_locale' => @$_SESSION['mailcow_locale'],
36 'mailcow_cc_role' => @$_SESSION['mailcow_cc_role'],
37 'mailcow_cc_username' => @$_SESSION['mailcow_cc_username'],
38 'is_master' => preg_match('/y|yes/i', getenv('MASTER')),
39 'dual_login' => @$_SESSION['dual-login'],
40 'ui_texts' => $UI_TEXTS,
41 'css_path' => '/cache/'.basename($CSSPath),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010042 'logo' => customize('get', 'main_logo'),
43 'available_languages' => $AVAILABLE_LANGUAGES,
44 'lang' => $lang,
45 'skip_sogo' => (getenv('SKIP_SOGO') == 'y'),
46 'allow_admin_email_login' => (getenv('ALLOW_ADMIN_EMAIL_LOGIN') == 'n'),
47 'mailcow_apps' => $MAILCOW_APPS,
48 'app_links' => customize('get', 'app_links'),
49 'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
50 'uri' => $_SERVER['REQUEST_URI'],
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010051 'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010052];
53
54foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
55 $twig->addGlobal($globalVariableName, $globalVariableValue);
56}