blob: 45c4456ceefa30e329e330d658e07760e988477a [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
3
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01004if (!isset($_SESSION['mailcow_cc_role']) || $_SESSION['mailcow_cc_role'] != "admin") {
5 header('Location: /');
6 exit();
7}
8
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01009require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
10$_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
11$solr_status = (preg_match("/^([yY][eE][sS]|[yY])+$/", $_ENV["SKIP_SOLR"])) ? false : solr_status();
12$clamd_status = (preg_match("/^([yY][eE][sS]|[yY])+$/", $_ENV["SKIP_CLAMD"])) ? false : true;
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010013
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010014
15if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CACHE')) {
16 $_SESSION['gal'] = json_decode($license_cache, true);
17}
18
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010019$js_minifier->add('/web/js/site/debug.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010020
21// vmail df
22$exec_fields = array('cmd' => 'system', 'task' => 'df', 'dir' => '/var/vmail');
23$vmail_df = explode(',', (string)json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
24
25// containers
26$containers = (array) docker('info');
27if ($clamd_status === false) unset($containers['clamd-mailcow']);
28if ($solr_status === false) unset($containers['solr-mailcow']);
29ksort($containers);
30foreach ($containers as $container => $container_info) {
31 date_default_timezone_set('UTC');
32 $StartedAt = date_parse($container_info['State']['StartedAt']);
33 if ($StartedAt['hour'] !== false) {
34 $date = new \DateTime();
35 $date->setTimestamp(mktime(
36 $StartedAt['hour'],
37 $StartedAt['minute'],
38 $StartedAt['second'],
39 $StartedAt['month'],
40 $StartedAt['day'],
41 $StartedAt['year']));
42 $user_tz = new DateTimeZone(getenv('TZ'));
43 $date->setTimezone($user_tz);
44 $started = $date->format('r');
45 }
46 else {
47 $started = '?';
48 }
49 $containers[$container]['State']['StartedAtHR'] = $started;
50}
51
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010052// get mailcow data
53$hostname = getenv('MAILCOW_HOSTNAME');
54$timezone = getenv('TZ');
55
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010056$template = 'debug.twig';
57$template_data = [
58 'log_lines' => getenv('LOG_LINES'),
59 'vmail_df' => $vmail_df,
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010060 'hostname' => $hostname,
61 'timezone' => $timezone,
62 'gal' => @$_SESSION['gal'],
63 'license_guid' => license('guid'),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010064 'solr_status' => $solr_status,
65 'solr_uptime' => round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60),
66 'clamd_status' => $clamd_status,
67 'containers' => $containers,
68 'lang_admin' => json_encode($lang['admin']),
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010069 'lang_debug' => json_encode($lang['debug']),
70 'lang_datatables' => json_encode($lang['datatables']),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010071];
72
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010073require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010074
75