Google Forms - Version 0.94

Version Description

No known upgrade issues.

Download this release

Release Info

Developer mpwalsh8
Plugin Icon wp plugin Google Forms
Version 0.94
Comparing to
See all releases

Code changes from version 0.93 to 0.94

Files changed (5) hide show
  1. index.php +6 -6
  2. readme.txt +8 -1
  3. wpgform-core.php +33 -4
  4. wpgform-logging.php +2 -1
  5. wpgform-options.php +2 -2
index.php CHANGED
@@ -4,9 +4,9 @@
4
  * Plugin Name: Google Forms
5
  * Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
6
  * Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
7
- * Version: 0.93
8
- * Build: 0.93
9
- * Last Modified: 01/04/2018
10
  * Author: Mike Walsh
11
  * Author URI: http://www.michaelwalsh.org
12
  * License: GPL
@@ -17,13 +17,13 @@
17
  * @author Mike Walsh <mpwalsh8@gmail.com>
18
  * @package wpGForm
19
  * @subpackage admin
20
- * @version 0.93
21
- * @lastmodified 01/04/2018
22
  * @lastmodifiedby mpwalsh8
23
  *
24
  */
25
 
26
- define('WPGFORM_VERSION', '0.93') ;
27
 
28
  require_once('wpgform-core.php') ;
29
  require_once('wpgform-post-type.php') ;
4
  * Plugin Name: Google Forms
5
  * Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
6
  * Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
7
+ * Version: 0.94
8
+ * Build: 0.94
9
+ * Last Modified: 02/18/2018
10
  * Author: Mike Walsh
11
  * Author URI: http://www.michaelwalsh.org
12
  * License: GPL
17
  * @author Mike Walsh <mpwalsh8@gmail.com>
18
  * @package wpGForm
19
  * @subpackage admin
20
+ * @version 0.94
21
+ * @lastmodified 02/18/2018
22
  * @lastmodifiedby mpwalsh8
23
  *
24
  */
25
 
26
+ define('WPGFORM_VERSION', '0.94') ;
27
 
28
  require_once('wpgform-core.php') ;
29
  require_once('wpgform-post-type.php') ;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
5
  Requires at least: 4.0
6
  Tested up to: 4.9.1
7
- Stable tag: 0.93
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -381,6 +381,13 @@ No known upgrade issues.
381
 
382
  == Change log ==
383
 
 
 
 
 
 
 
 
384
  = Version 0.93 =
385
  * Retagged to correct version number.
386
 
4
  Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
5
  Requires at least: 4.0
6
  Tested up to: 4.9.1
7
+ Stable tag: 0.94
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
381
 
382
  == Change log ==
383
 
384
+ = Version 0.94 =
385
+ * Added sanitization of user agent field in submission log.
386
+ * Replaced use of eval() in CAPTCHA calculation with alternate solution to address security concerns.
387
+ * Updated jQuery Validate to 1.17.0
388
+ * Updated jQuery UI Themes to 1.12.1
389
+ * Removed http prefix on jQuery UI themes enque to allow https support.
390
+
391
  = Version 0.93 =
392
  * Retagged to correct version number.
393
 
wpgform-core.php CHANGED
@@ -513,6 +513,21 @@ class wpGForm
513
  __('Unable to process Google Form short code.', WPGFORM_I18N_DOMAIN)) ;
514
  }
515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  /**
517
  * Function ProcessShortcode loads HTML from a Google Form URL,
518
  * processes it, and inserts it into a WordPress filter to output
@@ -770,10 +785,24 @@ class wpGForm
770
  // Generate a random value for C only when using 3 terms, use 0 otherwise
771
  $c = ((int)$wpgform_options['captcha_terms'] === 3) ? rand(0, 19) : 0 ;
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  if ((int)$wpgform_options['captcha_terms'] === 2)
774
  $x = eval('return sprintf("%s%s%s", $a, $op1, $b);') ;
775
  else
776
  $x = eval('return sprintf("%s%s%s%s%s", $a, $op1, $b, $op2, $c);') ;
 
777
 
778
  self::$wpgform_captcha = array('a' => $a, 'b' => $b, 'c' => $c, 'x' => $x) ;
779
 
@@ -1438,7 +1467,7 @@ jQuery(document).ready(function($) {
1438
  ,'remote_addr' => array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : $unknown
1439
  ,'remote_host' => array_key_exists('REMOTE_HOST', $_SERVER) ? $_SERVER['REMOTE_HOST'] : $unknown
1440
  ,'http_referer' => array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : $unknown
1441
- ,'http_user_agent' => array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : $unknown
1442
  ,'user_email' => ($u instanceof WP_User) ? $u->user_email : $unknown
1443
  ,'user_login' => ($u instanceof WP_User) ? $u->user_login : $unknown
1444
  ) ;
@@ -1709,7 +1738,7 @@ jQuery(document).ready(function($) {
1709
  ,'remote_addr' => array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : $unknown
1710
  ,'remote_host' => array_key_exists('REMOTE_HOST', $_SERVER) ? $_SERVER['REMOTE_HOST'] : $unknown
1711
  ,'http_referer' => array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : $unknown
1712
- ,'http_user_agent' => array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : $unknown
1713
  ,'form' => array_key_exists('id', $o) ? $o['id'] : null
1714
  ,'post_id' => get_the_ID()
1715
  ) ;
@@ -2192,11 +2221,11 @@ function wpgform_register_scripts()
2192
 
2193
  if (defined('SCRIPT_DEBUG')) {
2194
  wp_register_script('jquery-validate',
2195
- '//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js',
2196
  array('jquery'), false, true) ;
2197
  } else {
2198
  wp_register_script('jquery-validate',
2199
- '//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js',
2200
  array('jquery'), false, true) ;
2201
  }
2202
 
513
  __('Unable to process Google Form short code.', WPGFORM_I18N_DOMAIN)) ;
514
  }
515
 
516
+ /**
517
+ * wpgform_calc2() - perform math form CAPTCHA
518
+ *
519
+ * @since 0.94
520
+ * @see https://wordpress.org/support/topic/warning-about-eval/#post-9941118
521
+ */
522
+ static function wpgform_calc2( $a, $op, $b ) {
523
+ switch( $op ){
524
+ case '+': return $a + $b;
525
+ case '-': return $a - $b;
526
+ case '*': return $a * $b;
527
+ }
528
+ return null;
529
+ }
530
+
531
  /**
532
  * Function ProcessShortcode loads HTML from a Google Form URL,
533
  * processes it, and inserts it into a WordPress filter to output
785
  // Generate a random value for C only when using 3 terms, use 0 otherwise
786
  $c = ((int)$wpgform_options['captcha_terms'] === 3) ? rand(0, 19) : 0 ;
787
 
788
+ /**
789
+ * eval() replacement from Support Forum
790
+ *
791
+ * @see https://wordpress.org/support/topic/warning-about-eval/#post-9941118
792
+ */
793
+ if ((int)$wpgform_options['captcha_terms'] === 2)
794
+ $x = self::wpgform_calc2( $a, $op1, $b );
795
+ else if( $op1 == '*' || $op2 == '-' )
796
+ $x = self::wpgform_calc2( calculate2( $a, $op1, $b ), $op2, $c );
797
+ else
798
+ $x = self::wpgform_calc2( $a, $op1, calculate2( $b, $op2, $c ) );
799
+
800
+ /**
801
  if ((int)$wpgform_options['captcha_terms'] === 2)
802
  $x = eval('return sprintf("%s%s%s", $a, $op1, $b);') ;
803
  else
804
  $x = eval('return sprintf("%s%s%s%s%s", $a, $op1, $b, $op2, $c);') ;
805
+ */
806
 
807
  self::$wpgform_captcha = array('a' => $a, 'b' => $b, 'c' => $c, 'x' => $x) ;
808
 
1467
  ,'remote_addr' => array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : $unknown
1468
  ,'remote_host' => array_key_exists('REMOTE_HOST', $_SERVER) ? $_SERVER['REMOTE_HOST'] : $unknown
1469
  ,'http_referer' => array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : $unknown
1470
+ ,'http_user_agent' => array_key_exists('HTTP_USER_AGENT', $_SERVER) ? esc_html($_SERVER['HTTP_USER_AGENT']) : $unknown
1471
  ,'user_email' => ($u instanceof WP_User) ? $u->user_email : $unknown
1472
  ,'user_login' => ($u instanceof WP_User) ? $u->user_login : $unknown
1473
  ) ;
1738
  ,'remote_addr' => array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : $unknown
1739
  ,'remote_host' => array_key_exists('REMOTE_HOST', $_SERVER) ? $_SERVER['REMOTE_HOST'] : $unknown
1740
  ,'http_referer' => array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : $unknown
1741
+ ,'http_user_agent' => array_key_exists('HTTP_USER_AGENT', $_SERVER) ? esc_html($_SERVER['HTTP_USER_AGENT']) : $unknown
1742
  ,'form' => array_key_exists('id', $o) ? $o['id'] : null
1743
  ,'post_id' => get_the_ID()
1744
  ) ;
2221
 
2222
  if (defined('SCRIPT_DEBUG')) {
2223
  wp_register_script('jquery-validate',
2224
+ '//ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.js',
2225
  array('jquery'), false, true) ;
2226
  } else {
2227
  wp_register_script('jquery-validate',
2228
+ '//ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js',
2229
  array('jquery'), false, true) ;
2230
  }
2231
 
wpgform-logging.php CHANGED
@@ -99,10 +99,11 @@ class wpGForms_List_Table extends WP_List_Table {
99
  case 'remote_addr':
100
  case 'remote_host':
101
  case 'http_referer':
102
- case 'http_user_agent':
103
  case 'form':
104
  case 'post_id':
105
  return $item->$column_name;
 
 
106
  default:
107
  return print_r($item,true); //Show the whole array for troubleshooting purposes
108
  }
99
  case 'remote_addr':
100
  case 'remote_host':
101
  case 'http_referer':
 
102
  case 'form':
103
  case 'post_id':
104
  return $item->$column_name;
105
+ case 'http_user_agent':
106
+ return esc_html($item->$column_name);
107
  default:
108
  return print_r($item,true); //Show the whole array for troubleshooting purposes
109
  }
wpgform-options.php CHANGED
@@ -67,7 +67,7 @@ function wpgform_options_print_styles()
67
  // Load them from Google - should not be an issue since
68
  // this plugin is all about consuming Google content!
69
 
70
- wp_enqueue_style('xtra-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/base/jquery-ui.css') ;
71
  }
72
 
73
  /**
@@ -83,7 +83,7 @@ function wpgform_options_page()
83
  <div class="wrap">
84
 
85
  <?php
86
- if (function_exists('screen_icon')) screen_icon() ;
87
  ?>
88
  <h2><?php _e('WordPress Google Form Plugin Settings') ; ?></h2>
89
  <?php
67
  // Load them from Google - should not be an issue since
68
  // this plugin is all about consuming Google content!
69
 
70
+ wp_enqueue_style('xtra-jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css') ;
71
  }
72
 
73
  /**
83
  <div class="wrap">
84
 
85
  <?php
86
+ if (function_exists('screen_icon') && version_compare(get_bloginfo('version'),'3.8', '<=')) screen_icon() ;
87
  ?>
88
  <h2><?php _e('WordPress Google Form Plugin Settings') ; ?></h2>
89
  <?php