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 | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 14 | |
| 15 | if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CACHE')) { |
| 16 | $_SESSION['gal'] = json_decode($license_cache, true); |
| 17 | } |
| 18 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 19 | $js_minifier->add('/web/js/site/debug.js'); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 20 | |
| 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'); |
| 27 | if ($clamd_status === false) unset($containers['clamd-mailcow']); |
| 28 | if ($solr_status === false) unset($containers['solr-mailcow']); |
| 29 | ksort($containers); |
| 30 | foreach ($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 Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 52 | // get mailcow data |
| 53 | $hostname = getenv('MAILCOW_HOSTNAME'); |
| 54 | $timezone = getenv('TZ'); |
| 55 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 56 | $template = 'debug.twig'; |
| 57 | $template_data = [ |
| 58 | 'log_lines' => getenv('LOG_LINES'), |
| 59 | 'vmail_df' => $vmail_df, |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 60 | 'hostname' => $hostname, |
| 61 | 'timezone' => $timezone, |
| 62 | 'gal' => @$_SESSION['gal'], |
| 63 | 'license_guid' => license('guid'), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 64 | '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, |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 68 | 'ip_check' => customize('get', 'ip_check'), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 69 | 'lang_admin' => json_encode($lang['admin']), |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 70 | 'lang_debug' => json_encode($lang['debug']), |
| 71 | 'lang_datatables' => json_encode($lang['datatables']), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 72 | ]; |
| 73 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 74 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 75 | |
| 76 | |