Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php'; |
| 3 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 4 | if (!isset($_SESSION['mailcow_cc_role']) || $_SESSION['mailcow_cc_role'] != "admin") { |
| 5 | header('Location: /'); |
| 6 | exit(); |
| 7 | } |
| 8 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 9 | require_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 Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 13 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 14 | $js_minifier->add('/web/js/site/debug.js'); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 15 | |
| 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'); |
| 22 | if ($clamd_status === false) unset($containers['clamd-mailcow']); |
| 23 | if ($solr_status === false) unset($containers['solr-mailcow']); |
| 24 | ksort($containers); |
| 25 | foreach ($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 Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 58 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 59 | |
| 60 | |