blob: 2c1baec0fd381dbb5bfa20e19ee8537304b03b78 [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 Benkardb382b102021-01-02 15:32:21 +010014$js_minifier->add('/web/js/site/debug.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010015
16// vmail df
17$exec_fields = array('cmd' => 'system', 'task' => 'df', 'dir' => '/var/vmail');
18$vmail_df = explode(',', (string)json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
19
20// containers
21$containers = (array) docker('info');
22if ($clamd_status === false) unset($containers['clamd-mailcow']);
23if ($solr_status === false) unset($containers['solr-mailcow']);
24ksort($containers);
25foreach ($containers as $container => $container_info) {
26 date_default_timezone_set('UTC');
27 $StartedAt = date_parse($container_info['State']['StartedAt']);
28 if ($StartedAt['hour'] !== false) {
29 $date = new \DateTime();
30 $date->setTimestamp(mktime(
31 $StartedAt['hour'],
32 $StartedAt['minute'],
33 $StartedAt['second'],
34 $StartedAt['month'],
35 $StartedAt['day'],
36 $StartedAt['year']));
37 $user_tz = new DateTimeZone(getenv('TZ'));
38 $date->setTimezone($user_tz);
39 $started = $date->format('r');
40 }
41 else {
42 $started = '?';
43 }
44 $containers[$container]['State']['StartedAtHR'] = $started;
45}
46
47$template = 'debug.twig';
48$template_data = [
49 'log_lines' => getenv('LOG_LINES'),
50 'vmail_df' => $vmail_df,
51 'solr_status' => $solr_status,
52 'solr_uptime' => round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60),
53 'clamd_status' => $clamd_status,
54 'containers' => $containers,
55 'lang_admin' => json_encode($lang['admin']),
56];
57
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010058require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010059
60