PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / classes / Element / Captcha2.php

Captcha2.php in Contact Forms by Cimatti 1.9.2, at classes/Element/Captcha2.php

61 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class AccuaForm_Element_Captcha2 extends Element {
3 protected $privateKey = "";
4 protected $publicKey = "";
5
6 public function __construct($label = "", $unused = null, array $properties = null) {
7 if ($properties === null && is_array($unused)) {
8 $properties = $unused;
9 }
10 parent::__construct($label, "recaptcha_response_field", $properties);
11 $validator = new AccuaForm_Validation_Captcha2b(__("The reCATPCHA response provided was incorrect. Please re-try.", 'contact-forms'));
12 $validator->configure(array('privateKey'=>$this->privateKey));
13 $this->setValidation($validator);
14 }
15
16 public function render() {
17 $js_lang = _accua_forms_json_encode($this->form->getLanguage());
18 $js_field_id = _accua_forms_json_encode($this->attributes["id"]);//$this->form->attributes['id'] per id del form
19 $js_publicKey = _accua_forms_json_encode($this->publicKey);
20 $js_path = _accua_forms_json_encode(ACCUA_FORMS_DIR_URL . 'accua-recaptcha2.js');
21
22 $field_id = htmlspecialchars($this->attributes["id"], ENT_QUOTES);
23 echo <<<EOT
24 <script type="text/javascript">
25 <!--
26 if (typeof(accuaform_recaptcha2_ajax_loaded) == "undefined" || !accuaform_recaptcha2_ajax_loaded) {
27 var accuaform_recaptcha2_ajax_loaded = true;
28 var accuaform_recaptcha2_ajax_delaying = true;
29 var accuaform_recaptcha2_ajax_loading = true ;
30 var accuaform_recaptcha2_ajax_controller = jQuery({});
31 var accuaform_recaptcha2_ajax_initialized = {};
32 jQuery(".accuaforms-field-required, .pfbc-fieldwrap > *").one('change', function() {
33 if(accuaform_recaptcha2_ajax_delaying){
34 accuaform_recaptcha2_ajax_delaying = false;
35 jQuery.getScript( $js_path , function(){
36 jQuery.getScript( "https://www.recaptcha.net/recaptcha/api.js?onload=accua_forms_onload_recaptcha2&render=explicit&hl=" + $js_lang );
37 accuaform_recaptcha2_ajax_loading = false;
38 accuaform_recaptcha2_ajax_controller.trigger('loaded');
39 });
40 }
41 });
42 }
43 if (!accuaform_recaptcha2_ajax_initialized[ $js_field_id ]) {
44 accuaform_recaptcha2_ajax_initialized[ $js_field_id ] = true;
45 jQuery(function(){
46 if (accuaform_recaptcha2_ajax_loading) {
47 accuaform_recaptcha2_ajax_controller.one('loaded', function(){
48 accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
49 })
50 } else {
51 accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
52 }
53 });
54 }
55 // -->
56 </script>
57 <div id="{$field_id}" class="accua_forms_recaptcha2_container" style="min-height: 78px !important;"></div>
58 EOT;
59 }
60 }
61