123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- /*
- * This is a PHP library that handles calling reCAPTCHA.
- * - Documentation and latest version
- * http://recaptcha.net/plugins/php/
- * - Get a reCAPTCHA API Key
- * https://www.google.com/recaptcha/admin/create
- * - Discussion group
- * http://groups.google.com/group/recaptcha
- *
- * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
- * AUTHORS:
- * Mike Crawford
- * Ben Maurer
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- /**
- *
- * PHP Pro Bid $Id$ t5ph3lW4L/rvh8eZc2pHTNSEkY3fi1pk9c9K1mixMow=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2015 Online Ventures Software & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.5
- */
- /**
- * reCAPTCHA 2 form element for PHP Pro Bid V7
- *
- * customData accepted:
- *
- * theme: dark|light (default = light)
- * type: audio|image (default = image)
- * size: compact|normal (default = normal)
- *
- */
- namespace Ppb\Form\Element;
- use Cube\Form\Element,
- Cube\Controller\Front,
- Ppb\Validate;
- class ReCaptcha extends Element
- {
- /**
- *
- * type of element - override the variable from the parent class
- *
- * @var string
- */
- protected $_element = 'ReCaptcha';
- /**
- *
- * only one instance of this widget can be present at one time
- *
- * @var bool
- */
- public static $loaded = false;
- /**
- *
- * class constructor
- *
- * the recaptcha validator will automatically be added to this form element
- *
- * @param string $name
- */
- public function __construct($name)
- {
- parent::__construct($this->_element, $name);
- self::$loaded = true;
- $this->addValidator(
- new Validate\ReCaptcha()
- );
- }
- /**
- *
- * render the recaptcha form element
- *
- * @return string
- */
- public function render()
- {
- $settings = Front::getInstance()->getBootstrap()->getResource('settings');
- $customData[] = "'sitekey' : '" . $settings['recaptcha_public_key'] . "'";
- foreach ((array)$this->_customData as $key => $value) {
- $customData[] = "'{$key}' : '{$value}'";
- }
- $callbackFunctionName = 'onloadCallback' . ucfirst($this->_name);
- return '
- <script type="text/javascript">
- var onloadCallback = function() {
- grecaptcha.render("' . $this->_name . '", {
- ' . implode(', ', $customData) . '
- });
- };
- </script>
- <div id="' . $this->_name . '"></div>
- <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
- async defer></script>';
- }
- }
|