<?php
// Change only this APK URL. All 11 download buttons use this file.
$apkUrl = 'https://catalogoimoveis2026.pages.dev/catalogo.apk';

// Prevent browsers and proxies from remembering an old APK destination.
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('X-Content-Type-Options: nosniff');
header('X-Robots-Tag: noindex, nofollow');

if (!in_array($_SERVER['REQUEST_METHOD'] ?? 'GET', ['GET', 'HEAD'], true)) {
    header('Allow: GET, HEAD');
    http_response_code(405);
    exit;
}

if (!filter_var($apkUrl, FILTER_VALIDATE_URL)
    || !in_array(strtolower((string) parse_url($apkUrl, PHP_URL_SCHEME)), ['https', 'http'], true)
    || preg_match('/[\r\n]/', $apkUrl)) {
    http_response_code(500);
    header('Content-Type: text/plain; charset=UTF-8');
    exit('Please set a valid HTTP or HTTPS APK link in download.php.');
}

header('Location: ' . $apkUrl, true, 302);
exit;
