";
$script = "
var RecaptchaOptions = {
theme : '".$params->get('theme', 'red')."',
lang : '".$params->get('lang', 'en')."'
};
";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($script);
//add CSS fix to the recaptcha input field
$doc->addStyleDeclaration('label.recaptcha_input_area_text{line-height: 12px !important;}');
//replace the string
$form->form_details->content = str_replace('{ReCaptcha}', $recaptcha_load, $form->form_details->content);
}
/**
* Gets the challenge HTML (javascript and non-javascript version).
* This is called from the browser, and the resulting reCAPTCHA HTML widget
* is embedded within the HTML form it was called from.
* @param string $pubkey A public key for reCAPTCHA
* @param string $error The error given by reCAPTCHA (optional, default is null)
* @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
* @return string - The HTML to be embedded in the user's form.
*/
function recaptcha_get_html($pubkey, $error = null, $use_ssl = false)
{
if ( $pubkey == null || $pubkey == '' ) {
die ("To use reCAPTCHA you must get an API key from
https://www.google.com/recaptcha/admin/create");
}
if ( $use_ssl ) {
$server = RECAPTCHA_API_SECURE_SERVER;
} else {
$server = RECAPTCHA_API_SERVER;
}
$errorpart = "";
if ( $error ) {
$errorpart = "&error=" . $error;
}
return '
';
}
function load($clear)
{
if ( $clear ) {
$action_params = array(
'public_key' => '6LfNoAUAAAAAAKi8QZmjv-QHOvlGtyh509SG3FzG',
'ssl_server' => '0',
'theme' => 'red',
'lang' => 'en',
'api_server' => 'http://www.google.com/recaptcha/api',
'api_secure_server' => 'https://www.google.com/recaptcha/api'
);
}
return array('action_params' => $action_params);
}
}
?>