Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 1 | <?php |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 2 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 3 | // CSS |
| 4 | if (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) { |
| 5 | $css_minifier->add('/web/css/site/mailbox.css'); |
| 6 | } |
| 7 | if (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) { |
| 8 | $css_minifier->add('/web/css/site/admin.css'); |
| 9 | } |
| 10 | if (preg_match("/user/i", $_SERVER['REQUEST_URI'])) { |
| 11 | $css_minifier->add('/web/css/site/user.css'); |
| 12 | } |
| 13 | if (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) { |
| 14 | $css_minifier->add('/web/css/site/edit.css'); |
| 15 | } |
| 16 | if (preg_match("/(quarantine|qhandler)/i", $_SERVER['REQUEST_URI'])) { |
| 17 | $css_minifier->add('/web/css/site/quarantine.css'); |
| 18 | } |
| 19 | if (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) { |
| 20 | $css_minifier->add('/web/css/site/debug.css'); |
| 21 | } |
| 22 | if ($_SERVER['REQUEST_URI'] == '/') { |
| 23 | $css_minifier->add('/web/css/site/index.css'); |
| 24 | } |
| 25 | |
| 26 | $hash = $css_minifier->getDataHash(); |
| 27 | $CSSPath = '/tmp/' . $hash . '.css'; |
| 28 | if(!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 Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 42 | '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 Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 51 | 'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time'] |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 52 | ]; |
| 53 | |
| 54 | foreach ($globalVariables as $globalVariableName => $globalVariableValue) { |
| 55 | $twig->addGlobal($globalVariableName, $globalVariableValue); |
| 56 | } |