@extends('layouts.app') @section('content')
{{-- 統計檢測項目總數與完成數 --}} @php // 定義需要檢查的欄位(部分為陣列或複合資料,依據後端 API 結構) $fields = [ 'os_release', // 陣列:以 PRETTY_NAME 判斷 'kernel_version', 'timezone', 'ip', 'cpu_model', 'cpu_count', 'memory', // 陣列:檢查 memory.total_gb 'disk_info', // 陣列:判斷根目錄掛載是否存在 'apache_version', 'php_version', 'mysql_version', 'openssl_version', 'openssh_version', 'ntp_status', 'ntp_servers', 'privileged_accounts', 'account_expiry', 'antivirus_installed', 'antivirus_version', 'antivirus_result', 'certificate_expiry', 'log_rotate_180days', 'apache_logrotate_180days', 'screensaver_configured', 'screensaver_timeout', 'subsites' ]; $totalTests = count($fields); $completedTests = 0; // 取得根目錄硬碟資訊:從 disk_info 陣列中取出掛載點為 '/' $rootDisk = null; if(isset($reportData['disk_info']) && is_array($reportData['disk_info'])) { foreach($reportData['disk_info'] as $disk) { if(isset($disk['mounted_on']) && $disk['mounted_on'] == '/') { $rootDisk = $disk; break; } } } // 統計每一項是否有資料 foreach($fields as $f) { if($f === 'os_release'){ if(isset($reportData['os_release']['PRETTY_NAME']) && is_string($reportData['os_release']['PRETTY_NAME']) && trim($reportData['os_release']['PRETTY_NAME']) !== ''){ $completedTests++; } } elseif($f === 'memory'){ if(isset($reportData['memory']['total_gb']) && is_numeric($reportData['memory']['total_gb'])){ $completedTests++; } } elseif($f === 'disk_info'){ if($rootDisk){ $completedTests++; } } elseif($f === 'privileged_accounts' || $f === 'ntp_servers' || $f === 'subsites'){ if(isset($reportData[$f]) && is_array($reportData[$f]) && !empty($reportData[$f])){ $completedTests++; } } elseif(isset($reportData[$f])){ $value = $reportData[$f]; if(is_bool($value)){ if($value) { $completedTests++; } } elseif(is_numeric($value)){ $completedTests++; } elseif(is_string($value)){ if(trim($value) !== '' && trim($value) !== 'N/A'){ $completedTests++; } } } } @endphp
檢測項目共 {{ $totalTests }} 項,已完成 {{ $completedTests }}

{{ $host->name }} - 主機檢查報告

報告日期:{{ $reportDate }}

匯出 PDF 返回主機列表
基本系統資訊

作業系統:{{ $reportData['os_release']['PRETTY_NAME'] ?? $reportData['os'] ?? 'N/A' }}

核心版本: {{ $reportData['kernel_version'] ?? 'N/A' }}

時區: {{ $reportData['timezone'] ?? 'N/A' }}

IP 位址: {{ $reportData['ip'] ?? 'N/A' }}

硬體資訊

CPU 型號: {{ $reportData['cpu_model'] ?? 'N/A' }}

CPU 數量: {{ $reportData['cpu_count'] ?? 'N/A' }}

記憶體: @if(isset($reportData['memory']) && isset($reportData['memory']['total_gb'])) 總容量:{{ $reportData['memory']['total_gb'] }} GB, 使用中:{{ $reportData['memory']['used_gb'] }} GB, 可用:{{ $reportData['memory']['free_gb'] }} GB @else N/A @endif

硬碟資訊(根目錄): @if($rootDisk) 檔案系統:{{ $rootDisk['filesystem'] }}, 總容量:{{ $rootDisk['size'] }}, 已使用:{{ $rootDisk['used'] }}, 可用:{{ $rootDisk['avail'] }} @else N/A @endif

網路與服務資訊
@php $apacheRaw = $reportData['apache_version'] ?? 'N/A'; $apacheVersion = $apacheRaw; if($apacheRaw !== 'N/A' && preg_match('/Apache\/([\d\.]+)/', $apacheRaw, $matches)){ $apacheVersion = $matches[1]; } $phpVersion = $reportData['php_version'] ?? 'N/A'; $mysqlRaw = $reportData['mysql_version'] ?? 'N/A'; $mysqlVersion = $mysqlRaw; if($mysqlRaw !== 'N/A' && preg_match('/([\d\.]+)/', $mysqlRaw, $matches)){ $mysqlVersion = $matches[1]; } $opensslRaw = $reportData['openssl_version'] ?? 'N/A'; $opensslVersion = $opensslRaw; if($opensslRaw !== 'N/A' && preg_match('/OpenSSL\s+([\d\.]+)/', $opensslRaw, $matches)){ $opensslVersion = $matches[1]; } $opensshRaw = $reportData['openssh_version'] ?? 'N/A'; $opensshVersion = $opensshRaw; if($opensshRaw !== 'N/A' && preg_match('/OpenSSH_([^\s]+)/', $opensshRaw, $matches)){ $opensshVersion = $matches[1]; } $ntpStatus = $reportData['ntp_status'] ?? 'N/A'; $ntpServers = (isset($reportData['ntp_servers']) && is_array($reportData['ntp_servers'])) ? implode(', ', $reportData['ntp_servers']) : 'N/A'; @endphp

Apache 版本: {{ $apacheVersion }}

PHP 版本: {{ $phpVersion }}

MySQL 版本: {{ $mysqlVersion }}

OpenSSL 版本: {{ $opensslVersion }}

OpenSSH 版本: {{ $opensshVersion }}

NTP 狀態: {{ $ntpStatus }}

校時伺服器: {{ $ntpServers }}

帳號清單

特權帳號: @if(isset($reportData['privileged_accounts']) && is_array($reportData['privileged_accounts'])) {{ implode(', ', $reportData['privileged_accounts']) }} @else N/A @endif

帳號到期日: @php $rawAccountExpiry = $reportData['account_expiry'] ?? ''; $accountExpiryDetails = []; $mapping = [ "Last password change" => "最後更改密碼日期", "Password expires" => "密碼到期", "Password inactive" => "密碼失效", "Account expires" => "帳號到期", "Minimum number of days between password change" => "密碼更改最小間隔天數", "Maximum number of days between password change" => "密碼更改最大間隔天數", "Number of days of warning before password expires" => "密碼到期前警告天數" ]; if($rawAccountExpiry) { $lines = preg_split('/\r?\n/', $rawAccountExpiry); foreach ($lines as $line) { $line = trim($line); if($line === '') continue; $parts = explode(":", $line, 2); if(count($parts) == 2) { $key = trim($parts[0]); $value = trim($parts[1]); $label = $mapping[$key] ?? $key; $accountExpiryDetails[$label] = $value; } } } @endphp @if(!empty($accountExpiryDetails)) @foreach($accountExpiryDetails as $label => $value) @endforeach
項目 資訊
{{ $label }} {{ $value }}
@else N/A @endif
掃毒資訊

掃毒軟體: {{ (isset($reportData['antivirus_installed']) && $reportData['antivirus_installed']) ? '已安裝' : '未安裝' }}

掃毒版本: {{ $reportData['antivirus_version'] ?? 'N/A' }}

掃毒結果: @if(isset($reportData['antivirus_result'])) {!! nl2br(e($reportData['antivirus_result'])) !!} @else N/A @endif

Log 管理

Logrotate (180天): {{ (isset($reportData['log_rotate_180days']) && $reportData['log_rotate_180days']) ? '已設定' : '未設定' }}

Apache Logrotate (180天): {{ (isset($reportData['apache_logrotate_180days']) && $reportData['apache_logrotate_180days']) ? '已設定' : '未設定' }}

螢幕保護設定

螢幕保護程式: {{ (isset($reportData['screensaver_configured']) && $reportData['screensaver_configured']) ? '已設定' : '未設定' }}

@php $rawTimeout = $reportData['screensaver_timeout'] ?? ''; $humanTimeout = $rawTimeout; if(is_string($rawTimeout) && preg_match('/uint32\s+(\d+)/', $rawTimeout, $matches)) { $seconds = intval($matches[1]); $minutes = round($seconds / 60, 2); $humanTimeout = $seconds . " 秒 (約 " . $minutes . " 分鐘)"; } @endphp

螢幕保護等待時間: {{ $humanTimeout }}

安全設定
@if(isset($reportData['subsites']) && is_array($reportData['subsites']) && isset($reportData['subsites']['exists']) && $reportData['subsites']['exists'] && isset($reportData['subsites']['details']) && is_array($reportData['subsites']['details']))
子網站詳細資訊:
@foreach($reportData['subsites']['details'] as $site) @endforeach
網址 憑證狀態 資料夾
{{ $site['url'] ?? 'N/A' }} {{ $site['certificate_status'] ?? 'N/A' }} {{ $site['folder'] ?? 'N/A' }}
@else

子網站: {{ (isset($reportData['subsites']['count'])) ? '共 ' . $reportData['subsites']['count'] . ' 個' : '無' }}

@endif
@endsection