AAAAwww/administrator/components/com_chronoforms/form_actions/load_recaptcha/load_recaptcha.php000060400000007121151372340530031450 0ustar00home/academiac 'anti_spam', 'title' => 'Anti SPAM'); var $details = array('title' => 'Load Recaptcha', 'tooltip' => 'Renders the ReCaptcha display, you need the "{ReCaptcha}" string in your form code, possibly using a "Custom Element".'); function run($form, $actiondata) { $mainframe = JFactory::getApplication(); $params = new JParameter($actiondata->params); if(!defined('RECAPTCHA_API_SERVER')){ define('RECAPTCHA_API_SERVER', $params->get('api_server')); } if(!defined('RECAPTCHA_API_SECURE_SERVER')){ define('RECAPTCHA_API_SECURE_SERVER', $params->get('api_secure_server')); } $recaptcha_load = "
".$this->recaptcha_get_html($params->get('public_key'))."
"; $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); } } ?>