/** * Load the captcha configuration defaults. * * @return void */ private static function loadCaptchaConfigDefaults($session) { self::includeFile(Path::getCaptchaConfigDefaultsFilePath(), true, $session); }
/** * Get contents of Captcha resources (js, css, gif files). * * @return string */ public function getResourceContents() { $filename = $this->request->query('get'); $resourcePath = realpath(Path::getPublicDirPathInLibrary() . $filename); if (!is_file($resourcePath)) { $this->badRequest(sprintf('File "%s" could not be found.', $filename)); } $mimeTypes = ['css' => 'text/css', 'gif' => 'image/gif', 'js' => 'application/x-javascript']; // captcha resource file information $fileInfo = pathinfo($resourcePath); $fileLength = filesize($resourcePath); $mimeType = $mimeTypes[$fileInfo['extension']]; header("Content-Type: {$mimeType}"); header("Content-Length: {$fileLength}"); echo file_get_contents($resourcePath); exit; }