[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/form/field_types/recaptcha/ -> recaptcha.php (source)

   1  <?php
   2  
   3  class MP_Form_field_type_recaptcha extends MP_form_field_type_
   4  {
   5      var $file    = __FILE__;
   6  
   7      var $id     = 'recaptcha';
   8  
   9      var $category = 'composite';
  10      var $order    = 92;
  11  
  12  	function submitted($field)
  13      {
  14          require_once ('captcha/recaptchalib.php');
  15  
  16          $resp = recaptcha_check_answer ($field->settings['keys']['privatekey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  17  
  18          if (!$resp->is_valid) 
  19          {
  20              // set the error code so that we can display it
  21              // $error = $resp->error;
  22              $field->submitted['on_error'] = $resp->error;
  23              return $field;
  24          }
  25  
  26          $field->submitted['value'] = 1;
  27          $field->submitted['text']  = __('ok', MP_TXTDOM);
  28  
  29          return $field;
  30      }
  31  
  32  	function attributes_filter($no_reset)
  33      {
  34          if (!$no_reset) return;
  35          
  36          $this->attributes_filter_css();
  37      }
  38  
  39  	function build_tag()
  40      {
  41          require_once ('captcha/recaptchalib.php');
  42  
  43          $tag = recaptcha_get_html($this->field->settings['keys']['publickey'], (isset($this->field->submitted['on_error'])) ? $this->field->submitted['on_error'] : null);
  44          $id  = $this->get_id($this->field);
  45  
  46          $form_format =  '{{img}}';
  47  
  48          $form_formats = $this->get_formats($form_formats);
  49  
  50          $search[] = '{{img}}';        $replace[] = '%1$s';
  51          $search[] = '{{id}}';         $replace[] = '%2$s';
  52  
  53          $html = str_replace($search, $replace,  $form_format);
  54  
  55          return sprintf($html, $tag, $id);
  56      }
  57  }
  58  new MP_Form_field_type_recaptcha(__('ReCaptcha', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1