/** * 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); }
/** * Load BotDetect CAPTCHA Library and override Captcha Library settings. * * @param array $p_Config * @return void */ public static function Load($p_Config = array()) { // load bd php library self::IncludeFile(Path::GetBotDetectFilePathInLibrary()); // user's captcha config file $userConfig = new UserCaptchaConfiguration(); if (array_key_exists('CaptchaId', $p_Config) && array_key_exists('CaptchaConfigFilePath', $p_Config)) { $captchaConfigPath = $p_Config['CaptchaConfigFilePath']; $captchaId = $p_Config['CaptchaId']; $userConfig->StorePath($captchaId, $captchaConfigPath); } // load the captcha configuration defaults self::IncludeFile(Path::GetCaptchaConfigDefaultsFilePath()); // load user's captcha configuration $userCaptchaConfigFilePath = $userConfig->GetPhysicalPath(); self::IncludeFile($userCaptchaConfigFilePath); }