<?php
require_once 'includes/config.php';

echo "<h2>🧪 Server Environment Test</h2>";
echo "<p><strong>Current Base URL:</strong> " . getBaseUrl() . "</p>";
echo "<p><strong>Server Host:</strong> " . $_SERVER['HTTP_HOST'] . "</p>";
echo "<p><strong>Script Path:</strong> " . $_SERVER['SCRIPT_NAME'] . "</p>";
echo "<p><strong>Server IP:</strong> " . $_SERVER['SERVER_ADDR'] . "</p>";

// Test image URL generation
$testImage = 'test.jpg';
echo "<p><strong>Generated Image URL:</strong> " . getBaseUrl() . "/uploads/images/{$testImage}</p>";

echo "<h3>Test Image Access:</h3>";
// Coba akses gambar yang ada
$images = glob('uploads/images/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
foreach (array_slice($images, 0, 3) as $image) {
    $filename = basename($image);
    $url = getBaseUrl() . '/uploads/images/' . $filename;
    echo "<div>";
    echo "<p>File: {$filename}</p>";
    echo "<p>URL: <a href='{$url}' target='_blank'>{$url}</a></p>";
    echo "<img src='{$url}' style='max-width: 200px; border: 2px solid #ccc;' onerror='this.style.border=\"2px solid red\"' onload='this.style.border=\"2px solid green\"'>";
    echo "</div><hr>";
}
?>