Files
michaelschiemer/tests/debug/analyze-attached-svg.php
Michael Schiemer 95147ff23e refactor(deployment): Remove WireGuard VPN dependency and restore public service access
Remove WireGuard integration from production deployment to simplify infrastructure:
- Remove docker-compose-direct-access.yml (VPN-bound services)
- Remove VPN-only middlewares from Grafana, Prometheus, Portainer
- Remove WireGuard middleware definitions from Traefik
- Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers

All monitoring services now publicly accessible via subdomains:
- grafana.michaelschiemer.de (with Grafana native auth)
- prometheus.michaelschiemer.de (with Basic Auth)
- portainer.michaelschiemer.de (with Portainer native auth)

All services use Let's Encrypt SSL certificates via Traefik.
2025-11-05 12:48:25 +01:00

165 lines
4.4 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
echo "=== Analyzing Attached SVG ===\n\n";
// Read the problematic SVG
$svgPath = 'c:/Users/Mike/AppData/Local/Temp/Untitled.svg';
if (!file_exists($svgPath)) {
echo "❌ SVG file not found at: {$svgPath}\n";
echo "Trying to read from workspace...\n";
// Try to read from a local copy if it exists
$localPath = __DIR__ . '/Untitled.svg';
if (file_exists($localPath)) {
$svgPath = $localPath;
echo "✅ Found local copy\n";
} else {
echo "❌ No local copy found either\n";
exit(1);
}
}
$svg = file_get_contents($svgPath);
echo "SVG file size: " . strlen($svg) . " bytes\n\n";
// Parse SVG structure
if (preg_match('/width="(\d+)" height="(\d+)"/', $svg, $sizeMatches)) {
echo "Canvas size: {$sizeMatches[1]}x{$sizeMatches[2]}\n";
}
// Count rectangles
$rectCount = substr_count($svg, '<rect');
echo "Rectangles: {$rectCount}\n\n";
// Extract all rectangles
preg_match_all('/<rect x="(\d+\.?\d*)" y="(\d+\.?\d*)" width="(\d+\.?\d*)" height="(\d+\.?\d*)" fill="(black|white)"/', $svg, $matches, PREG_SET_ORDER);
echo "First 20 rectangles:\n";
for ($i = 0; $i < min(20, count($matches)); $i++) {
$m = $matches[$i];
echo " {$i}: x={$m[1]}, y={$m[2]}, w={$m[3]}, h={$m[4]}, color={$m[5]}\n";
}
// Check module size consistency
$moduleSizes = [];
foreach ($matches as $m) {
if ($m[5] === 'black') {
$w = (float)$m[3];
$h = (float)$m[4];
$key = "{$w}x{$h}";
$moduleSizes[$key] = ($moduleSizes[$key] ?? 0) + 1;
}
}
echo "\nModule size distribution (black rectangles):\n";
foreach ($moduleSizes as $size => $count) {
echo " {$size}: {$count} rectangles\n";
}
// Check for white background
$whiteRects = array_filter($matches, fn($m) => $m[5] === 'white');
if (count($whiteRects) > 0) {
$firstWhite = $whiteRects[array_key_first($whiteRects)];
echo "\nWhite background:\n";
echo " Size: {$firstWhite[3]}x{$firstWhite[4]}\n";
echo " Position: ({$firstWhite[1]}, {$firstWhite[2]})\n";
}
// Check if coordinates are consistent
echo "\n=== Coordinate Analysis ===\n";
$xs = [];
$ys = [];
foreach ($matches as $m) {
if ($m[5] === 'black') {
$xs[(float)$m[1]] = true;
$ys[(float)$m[2]] = true;
}
}
sort($xs);
sort($ys);
echo "Unique X coordinates: " . count($xs) . "\n";
echo "Unique Y coordinates: " . count($ys) . "\n";
// Check if coordinates form a grid
$xsArray = array_keys($xs);
$ysArray = array_keys($ys);
if (count($xsArray) > 1) {
$xStep = $xsArray[1] - $xsArray[0];
echo "X step: {$xStep}\n";
// Check if all X coordinates are multiples of the step
$xErrors = 0;
foreach ($xsArray as $x) {
$remainder = fmod($x, $xStep);
if (abs($remainder) > 0.01) {
$xErrors++;
}
}
if ($xErrors === 0) {
echo "✅ X coordinates form a regular grid\n";
} else {
echo "{$xErrors} X coordinates don't align with grid\n";
}
}
if (count($ysArray) > 1) {
$yStep = $ysArray[1] - $ysArray[0];
echo "Y step: {$yStep}\n";
$yErrors = 0;
foreach ($ysArray as $y) {
$remainder = fmod($y, $yStep);
if (abs($remainder) > 0.01) {
$yErrors++;
}
}
if ($yErrors === 0) {
echo "✅ Y coordinates form a regular grid\n";
} else {
echo "{$yErrors} Y coordinates don't align with grid\n";
}
}
// Check for potential issues
echo "\n=== Potential Issues ===\n";
// Check if all black rectangles have same size
$blackSizes = [];
foreach ($matches as $m) {
if ($m[5] === 'black') {
$key = "{$m[3]}x{$m[4]}";
$blackSizes[$key] = ($blackSizes[$key] ?? 0) + 1;
}
}
if (count($blackSizes) === 1) {
echo "✅ All black modules have same size\n";
} else {
echo "❌ Black modules have different sizes!\n";
foreach ($blackSizes as $size => $count) {
echo " {$size}: {$count} rectangles\n";
}
}
// Check quiet zone
$minX = min(array_map(fn($m) => (float)$m[1], array_filter($matches, fn($m) => $m[5] === 'black')));
$minY = min(array_map(fn($m) => (float)$m[2], array_filter($matches, fn($m) => $m[5] === 'black')));
echo "\nFirst black module position: ({$minX}, {$minY})\n";
if ($minX > 0 && $minY > 0) {
echo "✅ Quiet zone present (minimum {$minX}px)\n";
} else {
echo "❌ No quiet zone! QR code starts at edge\n";
}