[ Index ]

MailPress 7.1

[ 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    = 110;
  11  
  12  	function submitted( $field )
  13      {
  14          $this->field = $field;
  15  
  16          require_once ( 'captcha/recaptchalib.php' );
  17  
  18          $post_ = filter_input_array( INPUT_POST );
  19  
  20          $resp = recaptcha_check_answer ( $this->field->settings['keys']['privatekey'], filter_input( INPUT_SERVER, 'REMOTE_ADDR' ), $post_["recaptcha_challenge_field"], $post_["recaptcha_response_field"] );
  21  
  22          if ( !$resp->is_valid ) 
  23          {
  24              // set the error code so that we can display it
  25              // $error = $resp->error;
  26              $this->field->submitted['on_error'] = $resp->error;
  27              return $this->field;
  28          }
  29  
  30          $this->field->submitted['value'] = 1;
  31          $this->field->submitted['text']  = __( 'ok', 'MailPress' );
  32  
  33          return $this->field;
  34      }
  35  
  36  	function attributes_filter( $no_reset )
  37      {
  38          if ( !$no_reset ) return;
  39          
  40          $this->attributes_filter_css();
  41      }
  42  
  43  	function build_tag()
  44      {
  45          require_once ( 'captcha/recaptchalib.php' );
  46  
  47          $tag = recaptcha_get_html( $this->field->settings['keys']['publickey'], ( isset( $this->field->submitted['on_error'] ) ) ? $this->field->submitted['on_error'] : null );
  48          $id  = $this->get_id( $this->field );
  49  
  50          $form_format =  '{{img}}';
  51  
  52          $form_formats = $this->get_formats( $form_formats );
  53  
  54          $search[] = '{{img}}';        $replace[] = '%1$s';
  55          $search[] = '{{id}}';         $replace[] = '%2$s';
  56  
  57          $html = str_replace( $search, $replace,  $form_format );
  58  
  59          return sprintf( $html, $tag, $id );
  60      }
  61  }
  62  new MP_Form_field_type_recaptcha( __( 'ReCaptcha', 'MailPress' ) );


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1