getCountryStats($period); $daily = $sq->getDailyStats($period); $totalLogs = array_sum(array_column($countryStats, 'count')); $mapCountries = []; foreach ($countryStats as $c) { $mapCountries[$c['code']] = $c['count']; } $drillCountry = $_GET['country'] ?? null; $drillHosts = []; if ($drillCountry) { foreach ($countryStats as $c) { if (strtoupper($c['code']) === strtoupper($drillCountry)) { $drillHosts = $c['hosts']; break; } } } $svgPath = __DIR__ . '/assets/img/world-map.svg'; $svgContent = ''; if (file_exists($svgPath)) { $svgContent = file_get_contents($svgPath); $styles = ''; $maxCountry = count($countryStats) > 0 ? $countryStats[0]['count'] : 1; foreach ($countryStats as $c) { if ($c['code'] === 'UNKNOWN') continue; $ratio = $c['count'] / $maxCountry; if ($ratio > 0.66) $fill = '#052c65'; elseif ($ratio > 0.33) $fill = '#0d6efd'; elseif ($ratio > 0.1) $fill = '#6ea8fe'; else $fill = '#cfe2ff'; $styles .= "#{$c['code']} { fill: {$fill}; }"; } $svgContent = str_replace('', $styles . '', $svgContent); } ?>
php cli/generate-map.php
| # | Land | Berichten | % | |
|---|---|---|---|---|
| = $i + 1 ?> | = GeoIP::getCountryFlagEmoji($c['code']) ?> = GeoIP::getCountryName($c['code']) ?> | = number_format($c['count'], 0, ',', '.') ?> | = $totalLogs > 0 ? round($c['count'] / $totalLogs * 100, 1) : 0 ?>% |
|