[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  if ( !extension_loaded( 'gd' ) ) return;
   3  
   4  class MP_Form_field_type_captcha_gd1 extends MP_form_field_type_
   5  {
   6      var $file        = __FILE__;
   7  
   8      var $id         = 'captcha_gd1';
   9  
  10      var $category     = 'composite';
  11      var $order        = 120;
  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              include( $_SESSION['cryptogra']['settings'] );
  32              $code = ( $difuplow ) ? $value : strtoupper( $value );
  33  
  34              switch ( strtolower( $cryptsecure ) ) 
  35              {    case 'md5' :
  36                      $code = md5( $code );
  37                  break;
  38                  case 'sha1':
  39                      $code = sha1( $code );
  40                  break;
  41              }
  42              if ( ( !$_SESSION['cryptogra']['code'] ) || ( $_SESSION['cryptogra']['code'] != $code ) )
  43              {
  44                  $this->field->submitted['on_error'] = 1;
  45                  return $this->field;
  46              }
  47          }
  48  
  49          $this->field->submitted['value'] = 1;
  50          $this->field->submitted['text'] = __( 'ok', 'MailPress' );
  51  
  52          return $this->field;
  53      }
  54  
  55  	function attributes_filter( $no_reset )
  56      {
  57          if ( !$no_reset ) return;
  58          
  59          $this->attributes_filter_css();
  60      }
  61  
  62  	function build_tag()
  63      {
  64          $id_input = $this->get_id( $this->field );
  65          $tag_input = parent::build_tag();
  66  
  67          $id_img = $id_input . '_img';
  68          $args = array( 'id' => $this->field->id, 'action' => 'mp_ajax', 'mp_action' => '1ahctpac' );
  69          $tag_img = '<img id="' . $id_img . '" src="' . esc_url( add_query_arg( $args, admin_url( 'admin-ajax.php' ) ) ) . '" alt="" />';
  70  
  71          $this->field->type = $this->id;
  72  
  73          $form_format = '{{img}}<br />{{input}}';
  74  
  75          $form_format = $this->get_formats( $form_format );
  76  
  77          $search[] = '{{img}}';        $replace[] = '%1$s';
  78          $search[] = '{{id_img}}';     $replace[] = '%2$s';
  79          $search[] = '{{input}}';     $replace[] = '%3$s';
  80          $search[] = '{{id_input}}';    $replace[] = '%4$s';
  81  
  82          $html = str_replace( $search, $replace,  $form_format );
  83  
  84          return sprintf( $html, $tag_img, $id_img, $tag_input, $id_input );
  85      }
  86  }
  87  new MP_Form_field_type_captcha_gd1( __( 'Captcha 1', 'MailPress' ) );


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