blob: 9afc288ddae3a6f16d49903444b9cc6da1d84591 [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'),
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010043 'logo_dark' => customize('get', 'main_logo_dark'),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010044 'available_languages' => $AVAILABLE_LANGUAGES,
45 'lang' => $lang,
46 'skip_sogo' => (getenv('SKIP_SOGO') == 'y'),
47 'allow_admin_email_login' => (getenv('ALLOW_ADMIN_EMAIL_LOGIN') == 'n'),
48 'mailcow_apps' => $MAILCOW_APPS,
49 'app_links' => customize('get', 'app_links'),
50 'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
51 'uri' => $_SERVER['REQUEST_URI'],
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010052 'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010053];
54
55foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
56 $twig->addGlobal($globalVariableName, $globalVariableValue);
57}