PluginProbe
Contact Forms by Cimatti / 2.1.2
Contact Forms by Cimatti v2.1.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 / Captcha.php

Captcha.php in Contact Forms by Cimatti 2.1.2, at classes/Element/Captcha.php

52 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC framework extension, HTML output is controlled
3 class AccuaForm_Element_Captcha extends Element {
4 protected $privateKey = "6LcazwoAAAAAAD-auqUl-4txAK3Ky5jc5N3OXN0_";
5 protected $publicKey = "6LcazwoAAAAAADamFkwqj5KN1Gla7l4fpMMbdZfi";
6
7 public function __construct($label = "", $unused = '', array $properties = null) {
8 if ($properties === null && is_array($unused)) {
9 $properties = $unused;
10 }
11 parent::__construct($label, "recaptcha_response_field", $properties);
12 $validator = new AccuaForm_Validation_Captcha(__("The reCAPTCHA response provided was incorrect. Please retry.", 'contact-forms'));
13 $validator->configure(array('privateKey'=>$this->privateKey));
14 $this->setValidation($validator);
15 }
16
17 public function render() {
18 $js_lang = _accua_forms_json_encode($this->form->getLanguage());
19 $js_field_id = _accua_forms_json_encode($this->attributes["id"]);
20 $js_path = _accua_forms_json_encode(ACCUA_FORMS_DIR_URL . 'assets/js/frontend/recaptcha.js');
21 $js_publicKey = _accua_forms_json_encode($this->publicKey);
22
23 $field_id = htmlspecialchars($this->attributes["id"], ENT_QUOTES);
24 $publicKey = htmlspecialchars($this->publicKey, ENT_QUOTES);
25 $button_text = htmlspecialchars(__('Show Captcha', 'contact-forms'), ENT_QUOTES);
26
27 echo <<<EOT
28 <script type="text/javascript">
29 <!--
30 if (typeof(accuaform_recaptcha_ajax_loaded) == "undefined" || !accuaform_recaptcha_ajax_loaded) {
31 var accuaform_recaptcha_ajax_loaded = true;
32 jQuery.getScript( "https://www.recaptcha.net/recaptcha/api/js/recaptcha_ajax.js" , function(){
33 jQuery.getScript( $js_path , function(){
34 jQuery(function(){
35 accua_forms_show_recaptcha($js_publicKey, $js_field_id, {lang: $js_lang});
36 });
37 });
38 });
39 }
40 // -->
41 </script>
42 <input type='button' value='$button_text' class='accua_forms_show_recaptcha_button' onclick='accua_forms_show_recaptcha($js_publicKey, $js_field_id, {lang: $js_lang})' />
43 <div id="{$field_id}"></div>
44 <noscript>
45 <iframe src="https://www.recaptcha.net/recaptcha/api/noscript?k={$publicKey}" height="300" width="500" frameborder="0"></iframe><br/>
46 <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
47 <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
48 </noscript>
49 EOT;
50 }
51 }
52