Contact Form & SMTP Plugin for WordPress by PirateForms - Version 1.0.17

Version Description

  • Fixed IP issue when using web server behind a reverse proxy
  • Fixed W3C compatibility issues
  • Remove pcf=1#contact from url when theme is different then Zerif
  • Removed blacklist option and made it default set to true
  • Display site key and secret key fields only if recaptcha option is selected
  • New attachment option
  • New thank you URL option
  • New option to make the nonce optional
Download this release

Release Info

Developer codeinwp
Plugin Icon 128x128 Contact Form & SMTP Plugin for WordPress by PirateForms
Version 1.0.17
Comparing to
See all releases

Code changes from version 1.0.16 to 1.0.17

CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
 
 
 
 
2
- Fixed IP issue when using web server behind a reverse proxy
3
- Fixed W3C compatibility issues
4
- Remove pcf=1#contact from url when theme is different then Zerif
5
- Removed blacklist option and made it default set to true
6
- Display site key and secret key fields only if recaptcha option is selected
7
- New attachment option
8
- New thank you URL option
9
- New option to make the nonce optional
10
 
11
 
12
 
13
- #89 textarea field not saving
1
 
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
 
14
 
15
 
 
css/wp-admin.css CHANGED
@@ -190,3 +190,5 @@
190
  }
191
 
192
  .ajaxAnimation { background: url("../img/loader.gif") no-repeat center center, rgba(255,255,255,0.8); position: absolute;top: 0; left: 0; right: 0; bottom: 0; display: none;}
 
 
190
  }
191
 
192
  .ajaxAnimation { background: url("../img/loader.gif") no-repeat center center, rgba(255,255,255,0.8); position: absolute;top: 0; left: 0; right: 0; bottom: 0; display: none;}
193
+
194
+ .pirate-forms-hidden { display:none !important; }
img/preview.png ADDED
Binary file
inc/PhpFormBuilder.php CHANGED
@@ -21,11 +21,21 @@ class PhpFormBuilder {
21
  */
22
  function __construct( $action = '', $args = false ) {
23
 
 
 
 
 
 
 
 
 
 
 
24
  // Default form attributes
25
  $defaults = array(
26
  'action' => $action,
27
  'method' => 'post',
28
- 'enctype' => 'application/x-www-form-urlencoded',
29
  'class' => array(),
30
  'id' => '',
31
  'markup' => 'html',
@@ -325,6 +335,10 @@ class PhpFormBuilder {
325
  $element = 'div';
326
  $end = ' class="g-recaptcha pirate-forms-g-recaptcha" data-sitekey="' .$val['value'] . '"></div>';
327
  break;
 
 
 
 
328
  case 'radio':
329
  case 'checkbox':
330
 
@@ -360,11 +374,18 @@ class PhpFormBuilder {
360
  endif;
361
  case 'submit':
362
  $element = 'div class="col-xs-12 col-sm-6 col-lg-6 form_field_wrap contact_submit_wrap"><button';
363
- $end .= ' class="" type="' . $val['type'] . '">' . $val['value'] . '</button></div>';
364
  break;
365
  default :
366
  $element = 'input';
367
- $end .= ' class="form-control" type="' . $val['type'] . '" value="' . $val['value'] . '" placeholder="'.$val['placeholder'].'"';
 
 
 
 
 
 
 
368
  $end .= $val['checked'] ? ' checked' : '';
369
  $end .= $this->field_close();
370
  break;
@@ -407,7 +428,12 @@ class PhpFormBuilder {
407
  $field = '
408
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end .
409
  $field;
410
- } else {
 
 
 
 
 
411
  $field .= '
412
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end;
413
  }
21
  */
22
  function __construct( $action = '', $args = false ) {
23
 
24
+ /* if the form has an attachment option change the enctype to multipart/form-data */
25
+
26
+ $pirateformsopt_attachment_field = pirate_forms_get_key('pirateformsopt_attachment_field');
27
+ if( !empty($pirateformsopt_attachment_field) && ($pirateformsopt_attachment_field == 'yes') ) {
28
+ $pirate_forms_enctype = 'multipart/form-data';
29
+ }
30
+ else {
31
+ $pirate_forms_enctype = 'application/x-www-form-urlencoded';
32
+ }
33
+
34
  // Default form attributes
35
  $defaults = array(
36
  'action' => $action,
37
  'method' => 'post',
38
+ 'enctype' => $pirate_forms_enctype,
39
  'class' => array(),
40
  'id' => '',
41
  'markup' => 'html',
335
  $element = 'div';
336
  $end = ' class="g-recaptcha pirate-forms-g-recaptcha" data-sitekey="' .$val['value'] . '"></div>';
337
  break;
338
+ case 'file':
339
+ $element = 'input';
340
+ $end = ' class="" type="' . $val['type'] . '">';
341
+ break;
342
  case 'radio':
343
  case 'checkbox':
344
 
374
  endif;
375
  case 'submit':
376
  $element = 'div class="col-xs-12 col-sm-6 col-lg-6 form_field_wrap contact_submit_wrap"><button';
377
+ $end .= ' type="' . $val['type'] . '">' . $val['value'] . '</button></div>';
378
  break;
379
  default :
380
  $element = 'input';
381
+
382
+ /* don't add a placeholder attribute for input type=hidden */
383
+ if( !empty($val['type']) && ($val['type'] == 'hidden' ) ) {
384
+ $end .= ' class="form-control" type="' . $val['type'] . '" value="' . $val['value'] . '"';
385
+ }
386
+ else {
387
+ $end .= ' class="form-control" type="' . $val['type'] . '" value="' . $val['value'] . '" placeholder="' . $val['placeholder'] . '"';
388
+ }
389
  $end .= $val['checked'] ? ' checked' : '';
390
  $end .= $this->field_close();
391
  break;
428
  $field = '
429
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end .
430
  $field;
431
+ }
432
+ elseif ( $val['type'] === 'captcha' ) { /* don't add name attribute to div's holding recaptcha keys */
433
+ $field .= '
434
+ <' . $element . $id . ' ' . $min_max_range . $class . $attr . $end;
435
+ }
436
+ else {
437
  $field .= '
438
  <' . $element . $id . ' name="' . $val['name'] . '"' . $min_max_range . $class . $attr . $end;
439
  }
inc/settings.php CHANGED
@@ -23,6 +23,30 @@ function pirate_forms_from_email() {
23
  return 'wordpress@' . $sitename;
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /*
27
  *
28
  * OPTIONS
@@ -102,19 +126,26 @@ function pirate_forms_plugin_options() {
102
  __( 'Store submissions in the database','pirate-forms' ),
103
  __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved in Contacts on the left (appears after this option is activated).','pirate-forms' ),
104
  'checkbox',
105
- '',
106
  ),
107
- 'pirateformsopt_blacklist' => array(
108
- __( 'Use the comments blacklist to restrict submissions','pirate-forms' ),
109
- __( 'Should form submission IP and email addresses be compared against the Comment Blacklist, found in','pirate-forms').'<strong>'.__('wp-admin > Settings > Discussion > Comment Blacklist?','pirate-forms').'</strong>',
110
  'checkbox',
111
  'yes',
112
  ),
113
  'pirateformsopt_confirm_email' => array(
114
  __( 'Send email confirmation to form submitter','pirate-forms' ),
115
- __( 'Adding text here will send an email to the form submitter. The email uses the "Text to show when form is submitted..." field below as the subject line. Plain text only here, no HTML.','pirate-forms' ),
116
  'textarea',
117
  '',
 
 
 
 
 
 
 
118
  )
119
  ),
120
  'first_tab' => array(
@@ -193,6 +224,13 @@ function pirate_forms_plugin_options() {
193
  'text',
194
  $pirate_forms_contactus_secretkey,
195
  ),
 
 
 
 
 
 
 
196
 
197
  ),
198
  'second_tab' => array(
@@ -358,6 +396,29 @@ function pirate_forms_save_callback() {
358
 
359
  if( !empty($params) ):
360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  update_option( 'pirate_forms_settings_array', $params );
362
 
363
  $pirate_forms_zerif_lite_mods = get_option('theme_mods_zerif-lite');
@@ -525,28 +586,43 @@ function pirate_forms_admin() {
525
  break;
526
 
527
  case "text":
 
 
 
 
 
 
 
 
 
 
 
528
  ?>
529
 
530
- <div class="pirate-forms-grouped">
531
 
532
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
533
 
534
- if(!empty($opt_desc)) {
535
 
536
- if( ($opt_id == "pirateformsopt_email") || ($opt_id == "pirateformsopt_email_recipients") || ($opt_id == "pirateformsopt_confirm_email") ) {
537
 
538
  echo '<span class="dashicons dashicons-editor-help"></span>';
539
 
540
  }
541
 
542
- echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>'; } ?>
 
543
 
544
  </label>
545
 
546
- <input name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>" type="<?php echo $opt_type; ?>" value="<?php echo stripslashes( $opt_val ); ?>" class="widefat">
 
 
547
  </div>
548
 
549
  <?php
 
550
  break;
551
 
552
  case "textarea":
@@ -582,7 +658,15 @@ function pirate_forms_admin() {
582
 
583
  if(!empty($opt_desc)) {
584
 
585
- echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>'; } ?>
 
 
 
 
 
 
 
 
586
 
587
  </label>
588
 
@@ -604,6 +688,7 @@ function pirate_forms_admin() {
604
  <?php
605
  break;
606
  case "checkbox":
 
607
  ?>
608
  <div class="pirate-forms-grouped">
609
 
@@ -611,7 +696,7 @@ function pirate_forms_admin() {
611
 
612
  if(!empty($opt_desc)) {
613
 
614
- if( ($opt_id == "pirateformsopt_store") || ($opt_id == "pirateformsopt_blacklist") ) {
615
 
616
  echo '<span class="dashicons dashicons-editor-help"></span>';
617
 
@@ -624,7 +709,7 @@ function pirate_forms_admin() {
624
  <?php
625
 
626
  $checked = '';
627
- if ( array_key_exists( $opt_id,$pirate_forms_options ) ) {
628
  $checked = 'checked';
629
  }
630
  ?>
23
  return 'wordpress@' . $sitename;
24
  }
25
 
26
+ if ( ! function_exists( 'pirate_forms_get_pages_array' ) ) {
27
+ function pirate_forms_get_pages_array( $type = 'page' ) {
28
+
29
+ $content = array(
30
+ '' => __( 'None', 'pirate_forms' )
31
+ );
32
+
33
+ $items = get_posts( array(
34
+ 'post_type' => $type,
35
+ 'numberposts' => - 1
36
+ ) );
37
+
38
+
39
+ if ( ! empty( $items ) ) :
40
+ foreach ( $items as $item ) :
41
+ $content[$item->ID] = $item->post_title;
42
+ endforeach;
43
+ endif;
44
+
45
+ return $content;
46
+
47
+ }
48
+ }
49
+
50
  /*
51
  *
52
  * OPTIONS
126
  __( 'Store submissions in the database','pirate-forms' ),
127
  __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved in Contacts on the left (appears after this option is activated).','pirate-forms' ),
128
  'checkbox',
129
+ 'yes',
130
  ),
131
+ 'pirateformsopt_nonce' => array(
132
+ __( 'Add a nonce to the contact form:','pirate-forms' ),
133
+ __( 'Should the form use a WordPress nonce? This helps reduce spam by ensuring that the form submittor is on the site when submitting the form rather than submitting remotely. This could, however, cause problems with sites using a page caching plugin. Turn this off if you are getting complaints about forms not being able to be submitted with an error of "Nonce failed!"','pirate-forms' ),
134
  'checkbox',
135
  'yes',
136
  ),
137
  'pirateformsopt_confirm_email' => array(
138
  __( 'Send email confirmation to form submitter','pirate-forms' ),
139
+ __( 'Adding text here will send an email to the form submitter. The email uses the "Successful form submission text" field from the "Alert Messages" tab as the subject line. Plain text only here, no HTML.','pirate-forms' ),
140
  'textarea',
141
  '',
142
+ ),
143
+ 'pirateformsopt_thank_you_url' => array(
144
+ __( '"Thank You" URL','pirate-forms' ),
145
+ __( 'Select the post-submit page for all forms submitted','pirate-forms' ),
146
+ 'select',
147
+ '',
148
+ pirate_forms_get_pages_array()
149
  )
150
  ),
151
  'first_tab' => array(
224
  'text',
225
  $pirate_forms_contactus_secretkey,
226
  ),
227
+ /* Attachment */
228
+ 'pirateformsopt_attachment_field' => array(
229
+ __( 'Add an attachment field','pirate-forms' ),
230
+ '',
231
+ 'checkbox',
232
+ '',
233
+ ),
234
 
235
  ),
236
  'second_tab' => array(
396
 
397
  if( !empty($params) ):
398
 
399
+ /*****************************************************************/
400
+ /******** Important fix for saving inputs of type checkbox *******/
401
+ /*****************************************************************/
402
+
403
+ if( !isset($params['pirateformsopt_store']) ) {
404
+ $params['pirateformsopt_store'] = '';
405
+ }
406
+ if( !isset($params['pirateformsopt_recaptcha_field']) ) {
407
+ $params['pirateformsopt_recaptcha_field'] = '';
408
+ }
409
+ if( !isset($params['pirateformsopt_nonce']) ) {
410
+ $params['pirateformsopt_nonce'] = '';
411
+ }
412
+ if( !isset($params['pirateformsopt_attachment_field']) ) {
413
+ $params['pirateformsopt_attachment_field'] = '';
414
+ }
415
+ if( !isset($params['pirateformsopt_use_smtp']) ) {
416
+ $params['pirateformsopt_use_smtp'] = '';
417
+ }
418
+ if( !isset($params['pirateformsopt_use_smtp_authentication']) ) {
419
+ $params['pirateformsopt_use_smtp_authentication'] = '';
420
+ }
421
+
422
  update_option( 'pirate_forms_settings_array', $params );
423
 
424
  $pirate_forms_zerif_lite_mods = get_option('theme_mods_zerif-lite');
586
  break;
587
 
588
  case "text":
589
+
590
+ /* Display recaptcha secret key and site key only if the Add a reCAPTCHA option is checked */
591
+
592
+ $pirateformsopt_recaptcha_field = pirate_forms_get_key('pirateformsopt_recaptcha_field');
593
+
594
+ if( !empty( $opt_id ) && (( $opt_id != 'pirateformsopt_recaptcha_sitekey' ) && ( $opt_id != 'pirateformsopt_recaptcha_secretkey' )) || (!empty($pirateformsopt_recaptcha_field) && ($pirateformsopt_recaptcha_field == 'yes') && (( $opt_id == 'pirateformsopt_recaptcha_sitekey' ) || ( $opt_id == 'pirateformsopt_recaptcha_secretkey' )) ) ) {
595
+ $pirate_forms_is_hidden_class = '';
596
+ }
597
+ else {
598
+ $pirate_forms_is_hidden_class = 'pirate-forms-hidden';
599
+ }
600
  ?>
601
 
602
+ <div class="pirate-forms-grouped <?php echo $pirate_forms_is_hidden_class; ?>">
603
 
604
  <label for="<?php echo $opt_id ?>"><?php echo $opt_name;
605
 
606
+ if ( ! empty( $opt_desc ) ) {
607
 
608
+ if ( ( $opt_id == "pirateformsopt_email" ) || ( $opt_id == "pirateformsopt_email_recipients" ) || ( $opt_id == "pirateformsopt_confirm_email" ) ) {
609
 
610
  echo '<span class="dashicons dashicons-editor-help"></span>';
611
 
612
  }
613
 
614
+ echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
615
+ } ?>
616
 
617
  </label>
618
 
619
+ <input name="<?php echo $opt_id; ?>" id="<?php echo $opt_id ?>"
620
+ type="<?php echo $opt_type; ?>"
621
+ value="<?php echo stripslashes( $opt_val ); ?>" class="widefat">
622
  </div>
623
 
624
  <?php
625
+
626
  break;
627
 
628
  case "textarea":
658
 
659
  if(!empty($opt_desc)) {
660
 
661
+ if ( ( $opt_id == "pirateformsopt_thank_you_url" ) ) {
662
+
663
+ echo '<span class="dashicons dashicons-editor-help"></span>';
664
+
665
+ }
666
+
667
+ echo '<div class="pirate_forms_option_description">'.$opt_desc.'</div>';
668
+
669
+ } ?>
670
 
671
  </label>
672
 
688
  <?php
689
  break;
690
  case "checkbox":
691
+
692
  ?>
693
  <div class="pirate-forms-grouped">
694
 
696
 
697
  if(!empty($opt_desc)) {
698
 
699
+ if( ($opt_id == "pirateformsopt_store") || ($opt_id == "pirateformsopt_nonce") ) {
700
 
701
  echo '<span class="dashicons dashicons-editor-help"></span>';
702
 
709
  <?php
710
 
711
  $checked = '';
712
+ if( ($opt_val == 'yes') ) {
713
  $checked = 'checked';
714
  }
715
  ?>
js/scripts-admin.js CHANGED
@@ -48,4 +48,15 @@ jQuery(document).ready(function() {
48
  function endAjaxIntro() {
49
  jQuery(".ajaxAnimation").fadeOut();
50
  }
 
 
 
 
 
 
 
 
 
 
 
51
  });
48
  function endAjaxIntro() {
49
  jQuery(".ajaxAnimation").fadeOut();
50
  }
51
+
52
+ /* Recaptcha site key and secret key should appear only when Add a recaptcha is selected */
53
+ jQuery('input#pirateformsopt_recaptcha_field').change(function(){
54
+ jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().addClass('pirate-forms-hidden');
55
+ jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().addClass('pirate-forms-hidden');
56
+ if( jQuery(this).is(':checked') ) {
57
+ jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_sitekey').parent().removeClass('pirate-forms-hidden');
58
+ jQuery('.pirate-forms-grouped #pirateformsopt_recaptcha_secretkey').parent().removeClass('pirate-forms-hidden');
59
+ }
60
+ });
61
+
62
  });
pirate-forms.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Free & Simple Contact Form Plugin - PirateForms
4
  Plugin URI: http://themeisle.com/plugins/pirate-forms/
5
  Description: Easily creates a nice looking, simple contact form on your WP site.
6
- Version: 1.0.16
7
  Author: Themeisle
8
  Author URI: http://themeisle.com
9
  Text Domain: pirate-forms
@@ -51,7 +51,7 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
51
  /* thank you message */
52
  $pirate_forms_thankyou_message = '';
53
 
54
- if ( isset( $_GET['pcf'] ) && $_GET['pcf'] == 1 ) {
55
  $pirate_forms_thankyou_message .= '
56
  <div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap">
57
  <p>' . sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_label_submit' ) ) . '</p>
@@ -70,7 +70,10 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
70
 
71
  $pirate_form->set_att( 'id', 'pirate_forms_' . ( get_the_id() ? get_the_id() : 1 ) );
72
  $pirate_form->set_att( 'class', array( 'pirate_forms' ) );
73
- $pirate_form->set_att( 'add_nonce', get_bloginfo( 'admin_email' ) );
 
 
 
74
 
75
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
76
 
@@ -262,6 +265,23 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
262
 
263
  endif;
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  /********************************/
266
  /******** Submit button ********/
267
  /********************************/
@@ -330,14 +350,104 @@ function pirate_forms_display_form( $atts, $content = NULL ) {
330
 
331
  }
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  /**
334
  * Process the incoming contact form data, if any
335
  */
336
  add_action( 'template_redirect', 'pirate_forms_process_contact' );
337
  function pirate_forms_process_contact() {
338
 
339
- // If POST, nonce and honeypot are not set, beat it
340
- if ( empty( $_POST ) || empty( $_POST['wordpress-nonce'] ) || !isset( $_POST['honeypot'] )) {
341
  return false;
342
  }
343
 
@@ -345,9 +455,12 @@ function pirate_forms_process_contact() {
345
  $_SESSION['pirate_forms_contact_errors'] = array();
346
 
347
  // If nonce is not valid, beat it
348
- if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) ) ) {
349
- $_SESSION['pirate_forms_contact_errors']['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
350
- return false;
 
 
 
351
  }
352
 
353
  // If the honeypot caught a bear, beat it
@@ -471,6 +584,11 @@ function pirate_forms_process_contact() {
471
 
472
  $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
473
 
 
 
 
 
 
474
  // If valid and present, create a link to an IP search
475
  if ( ! empty( $contact_ip ) ) {
476
  $body .= __( 'IP address: ','pirate-forms' ). $contact_ip ."\r ".__( 'IP search:','pirate-forms' )." http://whatismyipaddress.com/ip/$contact_ip \n\n";
@@ -574,7 +692,61 @@ function pirate_forms_process_contact() {
574
  endif;
575
  }
576
 
577
- wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
  // Should a confirm email be sent?
580
  $confirm_body = stripslashes( trim( pirate_forms_get_key( 'pirateformsopt_confirm_email' ) ) );
@@ -615,11 +787,19 @@ function pirate_forms_process_contact() {
615
  }
616
  }
617
 
 
618
 
619
- $redirect = $_SERVER["HTTP_REFERER"] . ( strpos( $_SERVER["HTTP_REFERER"], '?' ) === FALSE ? '?' : '&' ) . 'pcf=1#contact';
620
-
621
-
622
- wp_safe_redirect( $redirect );
 
 
 
 
 
 
 
623
 
624
  }
625
 
3
  Plugin Name: Free & Simple Contact Form Plugin - PirateForms
4
  Plugin URI: http://themeisle.com/plugins/pirate-forms/
5
  Description: Easily creates a nice looking, simple contact form on your WP site.
6
+ Version: 1.0.17
7
  Author: Themeisle
8
  Author URI: http://themeisle.com
9
  Text Domain: pirate-forms
51
  /* thank you message */
52
  $pirate_forms_thankyou_message = '';
53
 
54
+ if( ( isset( $_GET['pcf'] ) && $_GET['pcf'] == 1 ) || ( isset($_POST['pirate-forms-contact-submit']) ) ) {
55
  $pirate_forms_thankyou_message .= '
56
  <div class="col-sm-12 col-lg-12 pirate_forms_thankyou_wrap">
57
  <p>' . sanitize_text_field( pirate_forms_get_key( 'pirateformsopt_label_submit' ) ) . '</p>
70
 
71
  $pirate_form->set_att( 'id', 'pirate_forms_' . ( get_the_id() ? get_the_id() : 1 ) );
72
  $pirate_form->set_att( 'class', array( 'pirate_forms' ) );
73
+
74
+ if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
75
+ $pirate_form->set_att( 'add_nonce', get_bloginfo( 'admin_email' ) );
76
+ }
77
 
78
  $pirate_forms_options = get_option( 'pirate_forms_settings_array' );
79
 
265
 
266
  endif;
267
 
268
+ /*********************************/
269
+ /********** Attachment ***********/
270
+ /*********************************/
271
+
272
+ if( !empty($pirate_forms_options['pirateformsopt_attachment_field']) && ($pirate_forms_options['pirateformsopt_attachment_field'] == 'yes') ) {
273
+
274
+ $pirate_form->add_input(
275
+ '',
276
+ array(
277
+ 'wrap_class' => $wrap_classes,
278
+ 'type' => 'file'
279
+ ),
280
+ 'pirate-forms-attachment'
281
+ );
282
+
283
+ }
284
+
285
  /********************************/
286
  /******** Submit button ********/
287
  /********************************/
350
 
351
  }
352
 
353
+ /**
354
+ * Functions to Process uploaded files
355
+ */
356
+ function pirate_forms_canonicalize( $text ) {
357
+ if ( function_exists( 'mb_convert_kana' )
358
+ && 'UTF-8' == get_option( 'blog_charset' ) ) {
359
+ $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
360
+ }
361
+
362
+ $text = strtolower( $text );
363
+ $text = trim( $text );
364
+ return $text;
365
+ }
366
+
367
+ function pirate_forms_antiscript_file_name( $filename ) {
368
+ $filename = basename( $filename );
369
+ $parts = explode( '.', $filename );
370
+
371
+ if ( count( $parts ) < 2 )
372
+ return $filename;
373
+
374
+ $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
375
+
376
+ $filename = array_shift( $parts );
377
+ $extension = array_pop( $parts );
378
+
379
+ foreach ( (array) $parts as $part ) {
380
+ if ( preg_match( $script_pattern, $part ) )
381
+ $filename .= '.' . $part . '_';
382
+ else
383
+ $filename .= '.' . $part;
384
+ }
385
+
386
+ if ( preg_match( $script_pattern, $extension ) )
387
+ $filename .= '.' . $extension . '_.txt';
388
+ else
389
+ $filename .= '.' . $extension;
390
+
391
+ return $filename;
392
+ }
393
+
394
+ function pirate_forms_upload_dir( $type = false ) {
395
+ $uploads = wp_upload_dir();
396
+
397
+ $uploads = apply_filters( 'pirate_forms_upload_dir', array(
398
+ 'dir' => $uploads['basedir'],
399
+ 'url' => $uploads['baseurl'] ) );
400
+
401
+ if ( 'dir' == $type )
402
+ return $uploads['dir'];
403
+ if ( 'url' == $type )
404
+ return $uploads['url'];
405
+
406
+ return $uploads;
407
+ }
408
+
409
+ function pirate_forms_upload_tmp_dir() {
410
+ return pirate_forms_upload_dir( 'dir' ) . '/pirate_forms_uploads';
411
+ }
412
+
413
+ function pirate_forms_init_uploads() {
414
+ $dir = pirate_forms_upload_tmp_dir();
415
+ wp_mkdir_p( $dir );
416
+
417
+ $htaccess_file = trailingslashit( $dir ) . '.htaccess';
418
+
419
+ if ( file_exists( $htaccess_file ) ) {
420
+ return;
421
+ }
422
+
423
+ if ( $handle = @fopen( $htaccess_file, 'w' ) ) {
424
+ fwrite( $handle, "Deny from all\n" );
425
+ fclose( $handle );
426
+ }
427
+ }
428
+
429
+ function pirate_forms_maybe_add_random_dir( $dir ) {
430
+ do {
431
+ $rand_max = mt_getrandmax();
432
+ $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) );
433
+ $dir_new = path_join( $dir, $rand );
434
+ } while ( file_exists( $dir_new ) );
435
+
436
+ if ( wp_mkdir_p( $dir_new ) ) {
437
+ return $dir_new;
438
+ }
439
+
440
+ return $dir;
441
+ }
442
+
443
  /**
444
  * Process the incoming contact form data, if any
445
  */
446
  add_action( 'template_redirect', 'pirate_forms_process_contact' );
447
  function pirate_forms_process_contact() {
448
 
449
+ // If POST and honeypot are not set, beat it
450
+ if ( empty( $_POST ) || !isset( $_POST['honeypot'] )) {
451
  return false;
452
  }
453
 
455
  $_SESSION['pirate_forms_contact_errors'] = array();
456
 
457
  // If nonce is not valid, beat it
458
+ if ( 'yes' === pirate_forms_get_key( 'pirateformsopt_nonce' ) ) {
459
+ if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) ) ) {
460
+ $_SESSION['pirate_forms_contact_errors']['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
461
+
462
+ return false;
463
+ }
464
  }
465
 
466
  // If the honeypot caught a bear, beat it
584
 
585
  $contact_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
586
 
587
+ /* for the case of a Web server behind a reverse proxy */
588
+ if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
589
+ $contact_ip = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
590
+ }
591
+
592
  // If valid and present, create a link to an IP search
593
  if ( ! empty( $contact_ip ) ) {
594
  $body .= __( 'IP address: ','pirate-forms' ). $contact_ip ."\r ".__( 'IP search:','pirate-forms' )." http://whatismyipaddress.com/ip/$contact_ip \n\n";
692
  endif;
693
  }
694
 
695
+ /*******************************************/
696
+ /********* Validate Attachment *************/
697
+ /*******************************************/
698
+
699
+ $attachments = '';
700
+
701
+ $pirate_forms_attach_file = isset( $_FILES['pirate-forms-attachment'] ) ? $_FILES['pirate-forms-attachment'] : '';
702
+
703
+ if( !empty($pirate_forms_attach_file) && !empty($pirate_forms_attach_file['name']) ) {
704
+
705
+ /* Validate file type */
706
+ $pirate_forms_file_types_allowed = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
707
+
708
+ $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
709
+ $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
710
+ $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
711
+
712
+ if ( ! preg_match( $pirate_forms_file_types_allowed, $pirate_forms_attach_file['name'] ) ) {
713
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-type'] = __( 'Uploaded file is not allowed for file type', 'pirate-forms' );
714
+ }
715
+
716
+ /* Validate file size */
717
+ $pirate_forms_file_size_allowed = 1048576; // default size 1 MB
718
+
719
+ if ( $pirate_forms_attach_file['size'] > $pirate_forms_file_size_allowed ) {
720
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-size'] = __( 'Uploaded file is too large', 'pirate-forms' );
721
+ }
722
+
723
+ pirate_forms_init_uploads();
724
+ $uploads_dir = pirate_forms_upload_tmp_dir();
725
+ $uploads_dir = pirate_forms_maybe_add_random_dir( $uploads_dir );
726
+
727
+ $filename = $pirate_forms_attach_file['name'];
728
+ $filename = pirate_forms_canonicalize( $filename );
729
+ $filename = sanitize_file_name( $filename );
730
+ $filename = pirate_forms_antiscript_file_name( $filename );
731
+ $filename = wp_unique_filename( $uploads_dir, $filename );
732
+
733
+ $new_file = trailingslashit( $uploads_dir ) . $filename;
734
+
735
+
736
+ if ( false === @move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
737
+ $_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-general'] = __( 'There was an unknown error uploading the file.', 'pirate-forms' );
738
+ }
739
+
740
+ // Make sure the uploaded file is only readable for the owner process
741
+ @chmod( $new_file, 0400 );
742
+
743
+ if( !empty($new_file) ) {
744
+ $attachments = $new_file;
745
+ }
746
+
747
+ }
748
+
749
+ wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers, $attachments );
750
 
751
  // Should a confirm email be sent?
752
  $confirm_body = stripslashes( trim( pirate_forms_get_key( 'pirateformsopt_confirm_email' ) ) );
787
  }
788
  }
789
 
790
+ $pirate_forms_current_theme = wp_get_theme();
791
 
792
+ /* If a Thank you page is selected, redirect to that page */
793
+ if ( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) ) {
794
+ $redirect_id = intval( pirate_forms_get_key( 'pirateformsopt_thank_you_url' ) );
795
+ $redirect = get_permalink( $redirect_id );
796
+ wp_safe_redirect( $redirect );
797
+ }
798
+ /* Redirect to ?pcf=1#contact only if the theme is Zerif */
799
+ elseif( ( 'Zerif Lite' == $pirate_forms_current_theme->name ) || ('Zerif Lite' == $pirate_forms_current_theme->parent_theme ) || ( 'Zerif PRO' == $pirate_forms_current_theme->name ) || ('Zerif PRO' == $pirate_forms_current_theme->parent_theme ) ) {
800
+ $redirect = $_SERVER["HTTP_REFERER"] . ( strpos( $_SERVER["HTTP_REFERER"], '?' ) === FALSE ? '?' : '&' ) . 'pcf=1#contact';
801
+ wp_safe_redirect( $redirect );
802
+ }
803
 
804
  }
805
 
readme.txt CHANGED
@@ -11,7 +11,7 @@ Makes your contact form page more engaging by creating a good-looking simple Wor
11
 
12
  == Description ==
13
 
14
- Stay in touch with your visitors very easily. <a href="http://themeisle.com/plugins/pirate-forms/" rel="friend">Pirate Contact Forms</a> offers you a great and friendly contact form for your website.
15
  This is an easy-to-use WordPress contact form with captcha plugin. To create a contact form you just need to use the [pirate_forms] shortcode or the 'Pirate Forms' widget.
16
 
17
  **Why use our responsive WordPress Contact Form:**
@@ -31,7 +31,7 @@ Avoid spam messages and make sure the e-mails you receive are entirely addressed
31
  - Comes with SMTP
32
 
33
  With the SMTP option, you can be sure you won’t miss any e-mail from your visitors. The messages will be safely delivered from the source to your personal e-mail address.
34
- If you were using Mandrill's SMTP for transactional emails and contact forms, you should take a look at these <a href="http://www.codeinwp.com/blog/mandrill-alternatives/" rel="friend" target="_blank">Mandrill Alternatives</a>.
35
 
36
  - Stores contacts in special databases
37
 
@@ -40,7 +40,7 @@ You can keep all the contacts in an archive by saving their e-mail addresses. Pi
40
  A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' widget.
41
 
42
 
43
- We've also built some fantastic <a href="http://themeisle.com/wordpress-themes/free/" rel="friend" target="_blank">free themes</a> that work well with Pirate Contact Form, check them out.
44
 
45
  **Features:**
46
 
@@ -50,7 +50,7 @@ We've also built some fantastic <a href="http://themeisle.com/wordpress-themes/f
50
  - reCAPTCHA
51
  - Store the contacts in the database
52
 
53
- If are you looking for other alternatives check-out our article on <a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" rel="friend" target="_blank">best contact form plugins</a>.
54
 
55
 
56
 
@@ -77,6 +77,16 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
 
80
  = 1.0.16 =
81
  * textarea field not saving
82
 
11
 
12
  == Description ==
13
 
14
+ Stay in touch with your visitors very easily. <a href="http://themeisle.com/plugins/pirate-forms/" rel="nofollow">Pirate Contact Forms</a> offers you a great and friendly contact form for your website.
15
  This is an easy-to-use WordPress contact form with captcha plugin. To create a contact form you just need to use the [pirate_forms] shortcode or the 'Pirate Forms' widget.
16
 
17
  **Why use our responsive WordPress Contact Form:**
31
  - Comes with SMTP
32
 
33
  With the SMTP option, you can be sure you won’t miss any e-mail from your visitors. The messages will be safely delivered from the source to your personal e-mail address.
34
+ If you were using Mandrill's SMTP for transactional emails and contact forms, you should take a look at these <a href="http://www.codeinwp.com/blog/mandrill-alternatives/" rel="nofollow" target="_blank">Mandrill Alternatives</a>.
35
 
36
  - Stores contacts in special databases
37
 
40
  A simple to use contact form plugin for creating a clean contact form using the [pirate_forms] shortcode or the 'Pirate Forms' widget.
41
 
42
 
43
+ We've also built some fantastic <a href="http://themeisle.com/wordpress-themes/free/" rel="nofollow" target="_blank">free themes</a> that work well with Pirate Contact Form, check them out.
44
 
45
  **Features:**
46
 
50
  - reCAPTCHA
51
  - Store the contacts in the database
52
 
53
+ If are you looking for other alternatives check-out our article on <a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" rel="nofollow" target="_blank">best contact form plugins</a>.
54
 
55
 
56
 
77
 
78
  == Changelog ==
79
 
80
+ = 1.0.17 =
81
+ * Fixed IP issue when using web server behind a reverse proxy
82
+ * Fixed W3C compatibility issues
83
+ * Remove pcf=1#contact from url when theme is different then Zerif
84
+ * Removed blacklist option and made it default set to true
85
+ * Display site key and secret key fields only if recaptcha option is selected
86
+ * New attachment option
87
+ * New thank you URL option
88
+ * New option to make the nonce optional
89
+
90
  = 1.0.16 =
91
  * textarea field not saving
92