$secretKey, 'solution' => $_POST['frc-captcha-solution'], 'sitekey' => $siteKey ]; $options = [ 'http' => [ 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($vars) ] ]; $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) { logNewMessage(LOG_ERR, 'Friendly Captcha validation failed, invalid server response.'); return false; } $responseJSON = json_decode($result); logNewMessage(LOG_DEBUG, "Friendly Captcha result: " . $result); return $responseJSON->{'success'} === true; } } /** * Creates a Friendly Captcha element. * * @package LAM\PLUGINS\CAPTCHA */ class htmlFriendlyCaptcha extends htmlElement { /** site key */ private string $key; /** * Constructor. * * @param string $key site key */ public function __construct(string $key) { $this->key = htmlspecialchars($key); } /** * {@inheritDoc} */ public function generateHTML($module, $input, $values, $restricted): array { $script = new htmlScript('../lib/extra/friendlyCaptcha/friendly-challenge-0.9.19.js'); $script->generateHTML($module, $input, $values, $restricted); echo '
'; return []; } }