<?php
// Test watermark display
require_once 'config/database.php';
require_once 'includes/site_settings.php';

// Get all settings
$siteConfig = get_all_settings($pdo);

// Extract watermark settings
$watermark_enabled = $siteConfig['watermark_enabled'] ?? '1';
$watermark_type = $siteConfig['watermark_type'] ?? 'text';
$watermark_image_paths = $siteConfig['watermark_image_paths'] ?? '';

echo "Watermark Display Test\n";
echo "=====================\n";
echo "Enabled: " . $watermark_enabled . "\n";
echo "Type: " . $watermark_type . "\n";
echo "Image Paths: " . $watermark_image_paths . "\n";

if ($watermark_enabled === '1' && $watermark_type === 'image' && !empty($watermark_image_paths)) {
    $paths = explode(',', $watermark_image_paths);
    echo "Number of images: " . count($paths) . "\n";
    
    foreach ($paths as $index => $path) {
        $fullPath = __DIR__ . '/' . $path;
        echo "Image " . ($index + 1) . ": " . $path . " - " . (file_exists($fullPath) ? "FOUND" : "NOT FOUND") . "\n";
        if (file_exists($fullPath)) {
            echo "  Size: " . filesize($fullPath) . " bytes\n";
            echo "  URL: http://localhost/bidda/" . $path . "\n";
        }
    }
    
    echo "\nHTML for watermark display:\n";
    echo "<div class=\"educational-watermark\">\n";
    echo "  <div class=\"watermark-image-container\" style=\"opacity: 0.15;\">\n";
    foreach ($paths as $index => $path) {
        echo "    <img src=\"./" . htmlspecialchars($path) . "\" alt=\"Watermark " . ($index + 1) . "\" class=\"watermark-image\" style=\"display: " . ($index === 0 ? 'block' : 'none') . ";\">\n";
    }
    echo "  </div>\n";
    echo "</div>\n";
} else {
    echo "Watermark is not properly configured for image display.\n";
}
?>