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.
This commit is contained in:
231
tests/debug/analyze-svg-qrcode.php
Normal file
231
tests/debug/analyze-svg-qrcode.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\QrCode\QrCodeGenerator;
|
||||
use App\Framework\QrCode\QrCodeRenderer;
|
||||
use App\Framework\QrCode\ValueObjects\ErrorCorrectionLevel;
|
||||
use App\Framework\QrCode\ValueObjects\QrCodeConfig;
|
||||
use App\Framework\QrCode\ValueObjects\QrCodeVersion;
|
||||
use App\Framework\QrCode\ValueObjects\EncodingMode;
|
||||
|
||||
echo "=== Analyze SVG QR Code ===\n\n";
|
||||
|
||||
// Read the SVG file
|
||||
$svgPath = 'C:\Users\Mike\AppData\Local\Temp\Untitled.svg';
|
||||
if (!file_exists($svgPath)) {
|
||||
echo "❌ SVG file not found at: {$svgPath}\n";
|
||||
echo "Trying to analyze based on the structure...\n\n";
|
||||
|
||||
// Generate our own QR code for comparison
|
||||
$config = new QrCodeConfig(
|
||||
version: QrCodeVersion::fromNumber(1),
|
||||
errorCorrectionLevel: ErrorCorrectionLevel::M,
|
||||
encodingMode: EncodingMode::BYTE
|
||||
);
|
||||
|
||||
// Try with different data to see what might be in the SVG
|
||||
$testData = 'HELLO WORLD';
|
||||
$matrix = QrCodeGenerator::generate($testData, $config);
|
||||
|
||||
echo "Generated QR Code for: '{$testData}'\n";
|
||||
echo "Matrix size: {$matrix->getSize()}x{$matrix->getSize()}\n\n";
|
||||
|
||||
// Analyze the matrix structure
|
||||
echo "=== Matrix Analysis ===\n";
|
||||
|
||||
// Check format information
|
||||
$formatCols = [0, 1, 2, 3, 4, 5, 7, 8, 20, 19, 18, 17, 16, 15, 14];
|
||||
$formatH = '';
|
||||
foreach ($formatCols as $col) {
|
||||
$formatH .= $matrix->getModuleAt(8, $col)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
$formatRows = [20, 19, 18, 17, 16, 15, 14, 8, 7, 5, 4, 3, 2, 1, 0];
|
||||
$formatV = '';
|
||||
foreach ($formatRows as $row) {
|
||||
$formatV .= $matrix->getModuleAt($row, 8)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
echo "Format Information Horizontal: {$formatH}\n";
|
||||
echo "Format Information Vertical: {$formatV}\n";
|
||||
echo "Match: " . ($formatH === $formatV ? "✅" : "❌") . "\n\n";
|
||||
|
||||
// Decode format info
|
||||
$xorMask = "101010000010010";
|
||||
$unmasked = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$unmasked .= (int)$formatH[$i] ^ (int)$xorMask[$i];
|
||||
}
|
||||
|
||||
$ecBits = substr($unmasked, 0, 2);
|
||||
$maskBits = substr($unmasked, 2, 5);
|
||||
$ecLevel = match($ecBits) {
|
||||
'01' => 'L',
|
||||
'00' => 'M',
|
||||
'11' => 'Q',
|
||||
'10' => 'H',
|
||||
default => 'UNKNOWN'
|
||||
};
|
||||
$maskPattern = bindec($maskBits);
|
||||
|
||||
echo "Decoded Format Information:\n";
|
||||
echo " EC Level: {$ecLevel}\n";
|
||||
echo " Mask Pattern: {$maskPattern}\n\n";
|
||||
|
||||
// Check finder patterns
|
||||
echo "=== Finder Pattern Check ===\n";
|
||||
$finderPatterns = [
|
||||
['name' => 'Top-Left', 'row' => 0, 'col' => 0],
|
||||
['name' => 'Top-Right', 'row' => 0, 'col' => 14],
|
||||
['name' => 'Bottom-Left', 'row' => 14, 'col' => 0],
|
||||
];
|
||||
|
||||
$expectedFinder = [
|
||||
[1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 0, 0, 0, 0, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 0, 0, 0, 0, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1],
|
||||
];
|
||||
|
||||
foreach ($finderPatterns as $finder) {
|
||||
$errors = 0;
|
||||
for ($r = 0; $r < 7; $r++) {
|
||||
for ($c = 0; $c < 7; $c++) {
|
||||
$row = $finder['row'] + $r;
|
||||
$col = $finder['col'] + $c;
|
||||
$isDark = $matrix->getModuleAt($row, $col)->isDark();
|
||||
$expectedDark = $expectedFinder[$r][$c] === 1;
|
||||
|
||||
if ($isDark !== $expectedDark) {
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors === 0) {
|
||||
echo "✅ {$finder['name']} finder pattern correct\n";
|
||||
} else {
|
||||
echo "❌ {$finder['name']} finder pattern has {$errors} errors\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// Check timing patterns
|
||||
echo "=== Timing Pattern Check ===\n";
|
||||
$timingOk = true;
|
||||
|
||||
// Horizontal timing (row 6, cols 8-12)
|
||||
for ($col = 8; $col <= 12; $col++) {
|
||||
$expectedDark = (($col - 8) % 2) === 0;
|
||||
$isDark = $matrix->getModuleAt(6, $col)->isDark();
|
||||
if ($isDark !== $expectedDark) {
|
||||
$timingOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical timing (col 6, rows 8-12)
|
||||
for ($row = 8; $row <= 12; $row++) {
|
||||
$expectedDark = (($row - 8) % 2) === 0;
|
||||
$isDark = $matrix->getModuleAt($row, 6)->isDark();
|
||||
if ($isDark !== $expectedDark) {
|
||||
$timingOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($timingOk) {
|
||||
echo "✅ Timing patterns correct\n";
|
||||
} else {
|
||||
echo "❌ Timing patterns incorrect\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// Generate a new SVG for comparison
|
||||
$renderer = new QrCodeRenderer();
|
||||
$svg = $renderer->renderSvg($matrix);
|
||||
|
||||
// Save for comparison
|
||||
$outputPath = __DIR__ . '/test-output.svg';
|
||||
file_put_contents($outputPath, $svg);
|
||||
echo "✅ Generated comparison SVG: {$outputPath}\n";
|
||||
echo " Size: " . strlen($svg) . " bytes\n";
|
||||
|
||||
// Check if there are any obvious issues
|
||||
echo "\n=== Potential Issues ===\n";
|
||||
|
||||
// Check quiet zone
|
||||
$quietZoneOk = true;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
// Check top quiet zone
|
||||
if ($matrix->getModuleAt($i, 10)->isDark()) {
|
||||
$quietZoneOk = false;
|
||||
break;
|
||||
}
|
||||
// Check left quiet zone
|
||||
if ($matrix->getModuleAt(10, $i)->isDark()) {
|
||||
$quietZoneOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($quietZoneOk) {
|
||||
echo "✅ Quiet zone appears correct (checked sample)\n";
|
||||
} else {
|
||||
echo "❌ Quiet zone might have issues\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
echo "=== Next Steps ===\n";
|
||||
echo "1. Compare the SVG structure with a working reference\n";
|
||||
echo "2. Check if format information is correctly placed\n";
|
||||
echo "3. Verify mask pattern application\n";
|
||||
echo "4. Test with a simpler QR code first\n";
|
||||
|
||||
} else {
|
||||
echo "✅ SVG file found\n";
|
||||
$svgContent = file_get_contents($svgPath);
|
||||
echo "Size: " . strlen($svgContent) . " bytes\n";
|
||||
|
||||
// Parse SVG to extract QR code structure
|
||||
// Count rectangles
|
||||
$rectCount = substr_count($svgContent, '<rect');
|
||||
echo "Rectangles: {$rectCount}\n";
|
||||
|
||||
// Extract positions
|
||||
preg_match_all('/x="([0-9.]+)"\s+y="([0-9.]+)"/', $svgContent, $matches);
|
||||
if (!empty($matches[1])) {
|
||||
$uniqueX = array_unique(array_map('floatval', $matches[1]));
|
||||
$uniqueY = array_unique(array_map('floatval', $matches[2]));
|
||||
|
||||
sort($uniqueX);
|
||||
sort($uniqueY);
|
||||
|
||||
echo "\nUnique X positions: " . count($uniqueX) . "\n";
|
||||
echo "Unique Y positions: " . count($uniqueY) . "\n";
|
||||
|
||||
// Calculate module size
|
||||
if (count($uniqueX) > 1) {
|
||||
$moduleSize = $uniqueX[1] - $uniqueX[0];
|
||||
echo "Module size: {$moduleSize}px\n";
|
||||
|
||||
// Calculate quiet zone
|
||||
$firstX = min($uniqueX);
|
||||
$quietZone = $firstX / $moduleSize;
|
||||
echo "Quiet zone: {$quietZone} modules\n";
|
||||
|
||||
// Calculate matrix size
|
||||
$matrixSize = (max($uniqueX) - min($uniqueX)) / $moduleSize + 1;
|
||||
echo "Matrix size: {$matrixSize}x{$matrixSize}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user