<?php
// Final test of 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 "Final Watermark 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') {
    if ($watermark_type === 'image' && !empty($watermark_image_paths)) {
        $paths = explode(',', $watermark_image_paths);
        echo "SUCCESS: Image watermark should be displayed!\n";
        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";
        }
    } elseif ($watermark_type === 'text') {
        echo "INFO: Text watermark is enabled instead of image.\n";
    } else {
        echo "WARNING: Watermark type is set but no content available.\n";
    }
} else {
    echo "INFO: Watermark is disabled.\n";
}
?>