data ( array ('domains' => get_option ( 'home' ), 'app' => $this->application ()->name ) );
}
public function get_html() {
$keys = $this->data('_keys')->recaptcha_keys;
$pubkey = $keys ['public'];
if ($pubkey == null || $pubkey == '') {
return "";
}
$server = $this->API_SERVER;
$errorpart = "";
$theme = ' ';
return $theme . '
';
}
private static $is_valid_cache = array();
public function is_valid($challenge, $response)
{
if(!isset(av43v_recaptcha::$is_valid_cache[$challenge]))
{
$returned = $this->check_answer ( $_POST ['recaptcha_challenge_field'], $_POST ['recaptcha_response_field'] );
av43v_recaptcha::$is_valid_cache[$challenge] = $returned->is_valid;
}
return av43v_recaptcha::$is_valid_cache[$challenge];
}
public function check_answer($challenge, $response) {
$keys = $this->data('_keys')->recaptcha_keys;
$privkey = $keys ['private'];
$remoteip = $_SERVER ['REMOTE_ADDR'];
//discard spam submissions
if ($challenge == null || strlen ( $challenge ) == 0 || $response == null || strlen ( $response ) == 0) {
$this->is_valid = false;
$this->error = 'incorrect-captcha-sol';
return $this;
}
$http = new bv43v_http($this->VERIFY_SERVER. "/recaptcha/api/verify");
$http->addHeader('User-Agent', $this->application ()->name . '/' . $this->application ()->version);
$http->data(array ('privatekey' => $privkey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response ));
$http->method('POST');
$return = $http->get();
$answers = explode ( "\n", $return );
$this->is_valid = (trim ( $answers [0] ) == 'true');
return $this;
}
private $is_valid = null;
}