<?php
require_once 'vendor/autoload.php';

use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;

// Set up QR code settings
$options = new QROptions([
    'version' => 5,
    'outputType' => QRCode::OUTPUT_IMAGE_PNG,
    'eccLevel' => QRCode::ECC_L,
]);

$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";

// Get the host (includes IP or Domain)
$host = $_SERVER['HTTP_HOST'];

// Get the project directory (useful if your project isn't in the root)
$projectDir = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

// Combine them
$projectURL = $protocol . $host . $projectDir;

// Create QR code data
$data = $projectURL . 'apk-api/'; // URL or text to encode into the QR code

// Instantiate QRCode object with options
$qrcode = new QRCode($options);
?>

<!DOCTYPE html>
<html lang="en" style="font-family: monospace;">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Visionsoft - APK API</title>
</head>

<body>
    <h1>Visionsoft - APK API</h1>
    <p>This API allow us to manage and update our Android applications.</p>

    <img src="<?= $qrcode->render($data); ?>" alt="" srcset="">

    <h2>API Details</h2>
    <ul>
        <li><strong>Base endpoint: </strong><code><?php echo $projectURL ?>apk-api/</code></li>
        <li><strong>Response Type: </strong><code>application/json</code></li>
    </ul>

    <h2>Change Log</h2>
    <h3>[1.2.1] - 2026/06/30</h3>
    <p>Correção da falta dos headers nas exceções</p>
    <p>Correção da configuração do Apache do pedido (sem precisar do `index.php` na URL)</p>

    <h3>[1.2.0] - 2026/03/19</h3>
    <p>QR Code Endpoint homepage</p>
    <p>API Version Header</p>

    <h3>[1.1.0] - 2026/02/27</h3>
    <p>Validação adicional de parâmetros de PHP INI para evitar erros de processamento (system_warning).</p>

    <h3>[1.0.0] - 2026/02/10</h3>
    <p>First production release of the APK API.</p>
</body>

</html>