[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  if ( !extension_loaded( 'gd' ) ) return;
   3  
   4  class MP_Form_field_type_captcha_gd2 extends MP_form_field_type_
   5  {
   6      var $file         = __FILE__;
   7  
   8      var $id         = 'captcha_gd2';
   9  
  10      var $category     = 'composite';
  11      var $order        = 121;
  12  
  13  	function submitted( $field )
  14      {
  15          $this->field = $field;
  16  
  17          $value = $this->get_value();
  18          $value = trim( $value );
  19  
  20          $required     = true;
  21          $empty = empty( $value );
  22  
  23          if ( $empty )
  24          {
  25              $this->field->submitted['on_error'] = 1;
  26              return $this->field;
  27          }
  28          else
  29          {
  30              @session_start();
  31  
  32              if ( ( !$_SESSION['mp_googlelike'] ) || ( strtolower( $_SESSION['mp_googlelike'] ) != strtolower( $value ) ) )
  33              {
  34                  $this->field->submitted['on_error'] = 1;
  35                  return $this->field;
  36              }
  37          }
  38  
  39          $this->field->submitted['value'] = 1;
  40          $this->field->submitted['text']  = __( 'ok', 'MailPress' );
  41  
  42          return $this->field;
  43      }
  44  
  45  	function attributes_filter( $no_reset )
  46      {
  47          if ( !$no_reset ) return;
  48          
  49          $this->attributes_filter_css();
  50      }
  51  
  52  	function build_tag()
  53      {
  54          $id_input     = $this->get_id( $this->field );
  55          $tag_input     = parent::build_tag();
  56  
  57          $id_img     = $id_input . '_img';
  58          $args        = array( 'id' => $this->field->id, 'action' => 'mp_ajax', 'mp_action' => '2ahctpac' );
  59          $tag_img     = '<img id="' . $id_img . '" src="' . esc_url( add_query_arg( $args, admin_url( 'admin-ajax.php' ) ) ) . '" alt="" />';
  60  
  61          $this->field->type = $this->id;
  62  
  63          $form_format =  '{{img}}<br />{{input}}';
  64  
  65          $form_format = $this->get_formats( $form_format );
  66  
  67          $search[] = '{{img}}';        $replace[] = '%1$s';
  68          $search[] = '{{id_img}}';     $replace[] = '%2$s';
  69          $search[] = '{{input}}';     $replace[] = '%3$s';
  70          $search[] = '{{id_input}}';    $replace[] = '%4$s';
  71  
  72          $html = str_replace( $search, $replace,  $form_format );
  73  
  74          return sprintf( $html, $tag_img, $id_img, $tag_input, $id_input );
  75      }
  76  }
  77  new MP_Form_field_type_captcha_gd2( __( 'Captcha 2', 'MailPress' ) );


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