- DB + uploads stored outside app bundle (survives updates) - Router uses DOCUMENT_ROOT instead of __DIR__ (fixes AppImage paths) - Footer count shifts right below 1250px, min-width 1150px - Gallery opens gracefully on fetch errors - Stabilized gallery, export, and find/replace tests with poll loops Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
// Router for PHP's built-in server (replaces .htaccess rewrite rules).
|
|
// Static files are served directly; everything else goes to index.php.
|
|
|
|
// docRoot is set via `php -S ... -t <docRoot>` in main.js
|
|
$docRoot = $_SERVER['DOCUMENT_ROOT'];
|
|
|
|
// Electron passes HYPRCRD_DATA_DIR so the app stores all user data
|
|
// outside the app bundle (survives updates).
|
|
$dataDir = getenv('HYPRCRD_DATA_DIR');
|
|
if ($dataDir) {
|
|
define('DB_PATH', $dataDir . '/hyprcrd.db');
|
|
define('UPLOAD_DIR', $dataDir . '/uploads');
|
|
if (!is_dir($dataDir . '/uploads')) {
|
|
mkdir($dataDir . '/uploads', 0755, true);
|
|
}
|
|
}
|
|
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
$file = $docRoot . $path;
|
|
if ($path !== '/' && is_file($file)) {
|
|
return false;
|
|
}
|
|
|
|
// Serve uploaded files from the external data dir
|
|
if ($dataDir && str_starts_with($path, '/uploads/')) {
|
|
$extFile = $dataDir . $path;
|
|
if (is_file($extFile)) {
|
|
$mime = mime_content_type($extFile) ?: 'application/octet-stream';
|
|
header('Content-Type: ' . $mime);
|
|
readfile($extFile);
|
|
return;
|
|
}
|
|
}
|
|
|
|
require $docRoot . '/index.php';
|