<commit_before><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Simple wrapper for Googles reCAPTCHA library
 *
 * @package openzula/kohana-recaptcha
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (C) 2011 <NAME>
 */

class Oz_Recaptcha {

	/**
	 * Public key
	 * @var string
	 */
	protected $_public_key;

	/**
	 * Private key
	 * @var string
	 */
	protected $_private_key;

	/**
	 * Error code returned when checking the answer
	 * @var string
	 */
	protected $_error;

	/**
	 * Load the reCAPTCHA PHP library and configure the keys from the config
	 * file or the provided array argument.
	 *
	 * @param array $config
	 * @return object
	 */
	public function __construct(array $config=NULL)
	{
		require_once Kohana::find_file('vendor', 'recaptcha/recaptchalib');

		if (empty($config))
		{
			$config = Kohana::config('recaptcha');
		}
		$this->_public_key = $config['public_key'];
		$this->_private_key = $config['private_key'];
	}

	/**
	 * Generate the HTML to display to the client
	 *
	 * @return string
	 */
	public function get_html()
	{
		return recaptcha_get_html($this->_public_key, $this->_error);
	}

	/**
	 * Returns bool true if successful, bool false if not.
	 *
	 * @param string $challenge
	 * @param string $response
	 * @return bool
	 */
	public function check($challenge=NULL, $response=NULL)
	{
		if (NULL === $challenge)
		{
			$challenge = Arr::get($_POST, 'recaptcha_challenge_field', FALSE);
		}
		if (NULL === $response)
		{
			$response = Arr::get($_POST, 'recaptcha_response_field', FALSE);
		}
		$result = recaptcha_check_answer($this->_private_key, Request::$client_ip, $challenge, $response);
		$this->_error = $result->error;
		return (bool) $result->is_valid;
	}

}<commit_msg>Added support for HTTPS<commit_after><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Simple wrapper for Googles reCAPTCHA library
 *
 * @package openzula/kohana-recaptcha
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (C) 2011 <NAME>
 */

class Oz_Recaptcha {

	/**
	 * Public key
	 * @var string
	 */
	protected $_public_key;

	/**
	 * Private key
	 * @var string
	 */
	protected $_private_key;

	/**
	 * Error code returned when checking the answer
	 * @var string
	 */
	protected $_error;

	/**
	 * Load the reCAPTCHA PHP library and configure the keys from the config
	 * file or the provided array argument.
	 *
	 * @param array $config
	 * @return object
	 */
	public function __construct(array $config=NULL)
	{
		require_once Kohana::find_file('vendor', 'recaptcha/recaptchalib');

		if (empty($config))
		{
			$config = Kohana::config('recaptcha');
		}
		$this->_public_key = $config['public_key'];
		$this->_private_key = $config['private_key'];
	}

	/**
	 * Generate the HTML to display to the client
	 *
	 * @return string
	 */
	public function get_html()
	{
		return recaptcha_get_html(
			$this->_public_key,
			$this->_error,
			(Request::$initial->protocol() === 'https')
		);
	}

	/**
	 * Returns bool true if successful, bool false if not.
	 *
	 * @param string $challenge
	 * @param string $response
	 * @return bool
	 */
	public function check($challenge=NULL, $response=NULL)
	{
		if (NULL === $challenge)
		{
			$challenge = Arr::get($_POST, 'recaptcha_challenge_field', FALSE);
		}
		if (NULL === $response)
		{
			$response = Arr::get($_POST, 'recaptcha_response_field', FALSE);
		}
		$result = recaptcha_check_answer($this->_private_key, Request::$client_ip, $challenge, $response);
		$this->_error = $result->error;
		return (bool) $result->is_valid;
	}

}
{'fraction_non_alphanumeric': 0.14974619289340102, 'fraction_numerical': 0.0022560631697687537, 'mean_word_length': 3.7997293640054126, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3066277', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1145, 'n_words': 300}