isDir()) { continue; } $meta = $fileinfo->getPathname() . "/_data_.eadat"; if (!file_exists($meta)) { continue; } $data = json_decode(file_get_contents($meta), true); if (($data["id"] ?? "") === $project) { $project_dir = $fileinfo->getPathname(); break; } } } if (!$project_dir) { header("HTTP/1.1 404 Not Found"); die("Project not found"); } $path = $project_dir . "/" . $file; $uripath = str_replace("/DATA", "", $path); break; } if (!isset($path)) { $path = "/DATA/$relpath"; } if (!isset($uripath)) { $uripath = "/$relpath"; } if (!file_exists($path) || !is_file($path)) { header("HTTP/1.1 404 Not Found"); die("File not found"); } $mime = mime_content_type($path); // Check if thumbnail is requested if (file_exists($path . ".thumbnail") && $_GET["thumbnail"] == "1") { $path .= ".thumbnail"; $uripath .= ".thumbnail"; $mime = "image/jpeg"; } header("Content-Type: " . $mime); header('Content-Length: ' . filesize($path)); //header('Cache-Control: max-age=7200'); header("X-Accel-Redirect: $uripath"); // // stream the file // $fp = fopen($path, 'rb'); // fpassthru($fp); exit;