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

echo "<h2>Base URL Example</h2>";

echo "<h3>Constants:</h3>";
echo "<p><strong>BASE_URL:</strong> " . BASE_URL . "</p>";
echo "<p><strong>API_BASE:</strong> " . API_BASE . "</p>";

echo "<h3>Helper Functions:</h3>";
echo "<p><strong>url('dashboard.php'):</strong> " . url('dashboard.php') . "</p>";
echo "<p><strong>url('login.php'):</strong> " . url('login.php') . "</p>";
echo "<p><strong>url('detail-info.php?id=123'):</strong> " . url('detail-info.php?id=123') . "</p>";

echo "<p><strong>asset('css/style.css'):</strong> " . asset('css/style.css') . "</p>";
echo "<p><strong>asset('logo_bij3.png'):</strong> " . asset('logo_bij3.png') . "</p>";
echo "<p><strong>asset('favicon.ico'):</strong> " . asset('favicon.ico') . "</p>";

echo "<h3>Usage Examples:</h3>";
echo "<p>Link to dashboard: <a href='" . url('dashboard.php') . "'>Dashboard</a></p>";
echo "<p>CSS file: <link rel='stylesheet' href='" . asset('css/style.css') . "'>";
echo "<p>Image: <img src='" . asset('logo_bij3.png') . "' alt='Logo'>";

echo "<h3>Current URL Detection:</h3>";
echo "<p><strong>Current URL:</strong> " . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "</p>";

echo "<h3>Dynamic Base URL (Alternative):</h3>";
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$script_name = dirname($_SERVER['SCRIPT_NAME']);
$dynamic_base = $protocol . '://' . $host . $script_name . '/';
echo "<p><strong>Dynamic Base URL:</strong> " . $dynamic_base . "</p>";
