/** * Get contents of Captcha resources (js, css, gif files). * * @param string $p_FileName * @return string */ public function GetResource($p_FileName) { $resourcePath = realpath(Path::GetPublicDirPathInLibrary() . $p_FileName); if (!is_readable($resourcePath)) { HttpHelper::BadRequest('command'); } // allow caching HttpHelper::AllowCache(); // captcha resource file information $fileInfo = pathinfo($resourcePath); $fileLength = filesize($resourcePath); $fileContents = file_get_contents($resourcePath); $mimeType = self::GetMimeType($fileInfo['extension']); return (new Response($fileContents, 200))->header('Content-Type', $mimeType)->header('Content-Length', $fileLength); }