<commit_before><?php

/**
 * Recaptcha Plugin.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME> <http://hauke-schade.de>
 * @license MIT
 * @since 2.0
 *
 */

namespace CandyCMS\Plugins;

use CandyCMS\Core\Helpers\Helper;
use CandyCMS\Core\Helpers\SmartySingleton;
use CandyCMS\Core\Helpers\I18n;

if (!defined('SHOW_CAPTCHA'))
  define('SHOW_CAPTCHA', MOBILE === false && WEBSITE_MODE !== 'test');

final class Recaptcha {

  /**
   * ReCaptcha public key.
   *
   * @access protected
   * @var string
   * @see app/config/Plugins.inc.php
   *
   */
  protected $_sPublicKey = PLUGIN_RECAPTCHA_PUBLIC_KEY;

  /**
   * ReCaptcha private key.
   *
   * @access protected
   * @var string
   * @see app/config/Plugins.inc.php
   *
   */
  protected $_sPrivateKey = PLUGIN_RECAPTCHA_PRIVATE_KEY;

  /**
   * ReCaptcha object.
   *
   * @var object
   * @access protected
   *
   */
  protected $_oResponse = '';

  /**
   * Provided ReCaptcha error message.
   *
   * @var string
   * @access protected
   *
   */
  protected $_sError = '';

  /**
   * Identifier for template replacements
   *
   * @var constant
   *
   */
  const IDENTIFIER = 'recaptcha';

  /**
   *
   * @var static
   * @access private
   *
   */
  private static $_oInstance = null;

  /**
   * Error Message of last captcha check
   *
   * @var string
   * @access private
   */
  private $_sErrorMessage = '';

  /**
   * Get the Recaptcha instance
   *
   * @static
   * @access public
   * @return object self::$_oInstance Recaptcha instance that was found or generated
   *
   */
  public static function getInstance() {
    if (self::$_oInstance === null)
      self::$_oInstance = new self();

    return self::$_oInstance;
  }

  /**
   * Include the needed lib.
   *
   * @access public
   *
   */
  public function __construct() {
    require PATH_STANDARD . '/vendor/recaptcha/recaptchalib.php';
  }

  /**
   * Get the HTML-Code for the Recaptcha form.
   *
   * @final
   * @access public
   * @param array $aRequest
   * @param array $aSession
   * @return string HTML
   *
   */
  public final function show(&$aRequest, &$aSession) {
    $sTemplateDir   = Helper::getPluginTemplateDir('Recaptcha', 'recaptcha');
    $sTemplateFile  = Helper::getTemplateType($sTemplateDir, 'recaptcha');

    $oSmarty = SmartySingleton::getInstance();
    $oSmarty->setTemplateDir($sTemplateDir);

    # No caching for this very dynamic form
    $oSmarty->setCaching(SmartySingleton::CACHING_OFF);

    $oSmarty->assign('WEBSITE_MODE', WEBSITE_MODE);
    $oSmarty->assign('MOBILE', MOBILE);
    $oSmarty->assign('_captcha_', recaptcha_get_html($this->_sPublicKey, $this->_sError));
<commit_msg>smushit and recaptcha as composer dependency<commit_after><?php

/**
 * Recaptcha Plugin.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME> <http://hauke-schade.de>
 * @license MIT
 * @since 2.0
 *
 */

namespace CandyCMS\Plugins;

use CandyCMS\Core\Helpers\Helper;
use CandyCMS\Core\Helpers\SmartySingleton;
use CandyCMS\Core\Helpers\I18n;

if (!defined('SHOW_CAPTCHA'))
  define('SHOW_CAPTCHA', MOBILE === false && WEBSITE_MODE !== 'test');

final class Recaptcha {

  /**
   * ReCaptcha public key.
   *
   * @access protected
   * @var string
   * @see app/config/Plugins.inc.php
   *
   */
  protected $_sPublicKey = PLUGIN_RECAPTCHA_PUBLIC_KEY;

  /**
   * ReCaptcha private key.
   *
   * @access protected
   * @var string
   * @see app/config/Plugins.inc.php
   *
   */
  protected $_sPrivateKey = PLUGIN_RECAPTCHA_PRIVATE_KEY;

  /**
   * ReCaptcha object.
   *
   * @var object
   * @access protected
   *
   */
  protected $_oResponse = '';

  /**
   * Provided ReCaptcha error message.
   *
   * @var string
   * @access protected
   *
   */
  protected $_sError = '';

  /**
   * Identifier for template replacements
   *
   * @var constant
   *
   */
  const IDENTIFIER = 'recaptcha';

  /**
   *
   * @var static
   * @access private
   *
   */
  private static $_oInstance = null;

  /**
   * Error Message of last captcha check
   *
   * @var string
   * @access private
   */
  private $_sErrorMessage = '';

  /**
   * Get the Recaptcha instance
   *
   * @static
   * @access public
   * @return object self::$_oInstance Recaptcha instance that was found or generated
   *
   */
  public static function getInstance() {
    if (self::$_oInstance === null)
      self::$_oInstance = new self();

    return self::$_oInstance;
  }

  /**
   * Include the needed lib.
   *
   * @access public
   *
   */
  public function __construct() {
    require PATH_STANDARD . '/vendor/recaptcha/recaptcha/recaptchalib.php';
  }

  /**
   * Get the HTML-Code for the Recaptcha form.
   *
   * @final
   * @access public
   * @param array $aRequest
   * @param array $aSession
   * @return string HTML
   *
   */
  public final function show(&$aRequest, &$aSession) {
    $sTemplateDir   = Helper::getPluginTemplateDir('Recaptcha', 'recaptcha');
    $sTemplateFile  = Helper::getTemplateType($sTemplateDir, 'recaptcha');

    $oSmarty = SmartySingleton::getInstance();
    $oSmarty->setTemplateDir($sTemplateDir);

    # No caching for this very dynamic form
    $oSmarty->setCaching(SmartySingleton::CACHING_OFF);

    $oSmarty->assign('WEBSITE_MODE', WEBSITE_MODE);
    $oSmarty->assign('MOBILE', MOBILE);
    $oSmarty->assign('_captcha_', recaptcha_get_html($this->_sPublicKey, $this->_sError));

{'fraction_non_alphanumeric': 0.13884266962469957, 'fraction_numerical': 0.0014790164540580515, 'mean_word_length': 2.9402767662053897, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4208464', 'n_tokens_mistral': 1954, 'n_tokens_neox': 1872, 'n_words': 385}