Export User Data - Version 0.8.1

Version Description

  • Added experimental range limiter for exports
  • Extra input data sanitizing
Download this release

Release Info

Developer qlstudio
Plugin Icon wp plugin Export User Data
Version 0.8.1
Comparing to
See all releases

Code changes from version 0.8 to 0.8.1

Files changed (2) hide show
  1. export-user-data.php +62 -9
  2. readme.txt +5 -1
export-user-data.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Export User Data
5
  Plugin URI: http://qstudio.us/plugins/
6
  Description: Export User data, metadata and BuddyPressX Profile data.
7
- Version: 0.8
8
  Author: Q Studio
9
  Author URI: http://qstudio.us
10
  License: GPL2
@@ -175,10 +175,10 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
175
  // build argument array ##
176
  $args = array(
177
  'fields' => 'all_with_meta',
178
- 'role' => stripslashes( $_POST['role'] )
179
  );
180
 
181
- // did the user request a specific program ? ##
182
  if ( isset( $_POST['program'] ) && $_POST['program'] != '' ) {
183
 
184
  $args['meta_key'] = 'member_of_club';
@@ -187,6 +187,24 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
187
 
188
  }
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  /* pre_user query */
191
  add_action( 'pre_user_query', array( $this, 'pre_user_query' ) );
192
  $users = get_users( $args );
@@ -211,7 +229,7 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
211
  $export_method = 'excel'; // default to Excel export ##
212
  if ( isset( $_POST['format'] ) && $_POST['format'] != '' ) {
213
 
214
- $export_method = $_POST['format'];
215
 
216
  }
217
 
@@ -286,7 +304,7 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
286
  $exclude_data = apply_filters( 'q_eud_exclude_data', array() );
287
 
288
  // check for selected usermeta fields ##
289
- $usermeta = isset( $_POST['usermeta'] ) ? $_POST['usermeta']: '';
290
  $usermeta_fields = array();
291
 
292
  if ( $usermeta && is_array($usermeta) ) {
@@ -296,7 +314,7 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
296
  }
297
 
298
  // check for selected x profile fields ##
299
- $bp_fields = isset( $_POST['bp_fields'] ) ? $_POST['bp_fields'] : '';
300
  $bp_fields_passed = array();
301
  if ( $bp_fields && is_array($bp_fields) ) {
302
 
@@ -313,7 +331,7 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
313
  }
314
 
315
  // cwjordan: check for x profile fields we want update time for ##
316
- $bp_fields_update = isset( $_POST['bp_fields_update_time'] ) ? $_POST['bp_fields_update_time'] : '';
317
  $bp_fields_update_passed = array();
318
  if ( $bp_fields_update && is_array( $bp_fields_update ) ) {
319
 
@@ -719,6 +737,41 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
719
  </select>
720
  </td>
721
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
 
723
  <tr valign="top">
724
  <th scope="row"><label for="q_eud_users_format"><?php _e( 'Format', 'export-user-data' ); ?></label></th>
@@ -765,10 +818,10 @@ if ( ! class_exists( 'Q_EUD_Export_Users' ) )
765
  $where = '';
766
 
767
  if ( ! empty( $_POST['start_date'] ) )
768
- $where .= $wpdb->prepare( " AND $wpdb->users.user_registered >= %s", date( 'Y-m-d', strtotime( $_POST['start_date'] ) ) );
769
 
770
  if ( ! empty( $_POST['end_date'] ) )
771
- $where .= $wpdb->prepare( " AND $wpdb->users.user_registered < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $_POST['end_date'] ) ) ) );
772
 
773
  if ( ! empty( $where ) )
774
  $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 $where", $user_search->query_where );
4
  Plugin Name: Export User Data
5
  Plugin URI: http://qstudio.us/plugins/
6
  Description: Export User data, metadata and BuddyPressX Profile data.
7
+ Version: 0.8.1
8
  Author: Q Studio
9
  Author URI: http://qstudio.us
10
  License: GPL2
175
  // build argument array ##
176
  $args = array(
177
  'fields' => 'all_with_meta',
178
+ 'role' => sanitize_text_field( $_POST['role'] )
179
  );
180
 
181
+ // did they request a specific program ? ##
182
  if ( isset( $_POST['program'] ) && $_POST['program'] != '' ) {
183
 
184
  $args['meta_key'] = 'member_of_club';
187
 
188
  }
189
 
190
+ // is there a range limit in place for this export ? ##
191
+ if ( isset( $_POST['limit_from'] ) && $_POST['limit_from'] != '' && isset( $_POST['limit_to'] ) && $_POST['limit_to'] != '' ) {
192
+
193
+ // let's just make sure they are integer values ##
194
+ $limit_from = (int)$_POST['limit_from'];
195
+ $limit_to = (int)$_POST['limit_to'];
196
+
197
+ if ( is_int( $limit_from ) && is_int( $limit_to ) ) {
198
+
199
+ $args['offset'] = $limit_from;
200
+ $args['number'] = $limit_to - $limit_from;
201
+
202
+ #wp_die(pr($args));
203
+
204
+ }
205
+
206
+ }
207
+
208
  /* pre_user query */
209
  add_action( 'pre_user_query', array( $this, 'pre_user_query' ) );
210
  $users = get_users( $args );
229
  $export_method = 'excel'; // default to Excel export ##
230
  if ( isset( $_POST['format'] ) && $_POST['format'] != '' ) {
231
 
232
+ $export_method = sanitize_text_field( $_POST['format'] );
233
 
234
  }
235
 
304
  $exclude_data = apply_filters( 'q_eud_exclude_data', array() );
305
 
306
  // check for selected usermeta fields ##
307
+ $usermeta = isset( $_POST['usermeta'] ) ? sanitize_text_field ( $_POST['usermeta'] ): '';
308
  $usermeta_fields = array();
309
 
310
  if ( $usermeta && is_array($usermeta) ) {
314
  }
315
 
316
  // check for selected x profile fields ##
317
+ $bp_fields = isset( $_POST['bp_fields'] ) ? sanitize_text_field ( $_POST['bp_fields'] ) : '';
318
  $bp_fields_passed = array();
319
  if ( $bp_fields && is_array($bp_fields) ) {
320
 
331
  }
332
 
333
  // cwjordan: check for x profile fields we want update time for ##
334
+ $bp_fields_update = isset( $_POST['bp_fields_update_time'] ) ? sanitize_text_field ( $_POST['bp_fields_update_time'] ) : '';
335
  $bp_fields_update_passed = array();
336
  if ( $bp_fields_update && is_array( $bp_fields_update ) ) {
337
 
737
  </select>
738
  </td>
739
  </tr>
740
+
741
+ <tr valign="top">
742
+ <th scope="row"><label><?php _e( 'Limit Range', 'export-user-data' ); ?></label></th>
743
+ <td>
744
+ <input name="limit_from" type="text" id="q_eud_users_limit_from" value="" class="regular-text code numeric" style="width: 136px;" placeholder="<?php _e( 'From', 'export-user-data' ); ?>">
745
+ <input name="limit_to" type="text" id="q_eud_users_limit_to" value="" class="regular-text code numeric" style="width: 136px;" placeholder="<?php _e( 'To', 'export-user-data' ); ?>">
746
+ </td>
747
+ </tr>
748
+ <script>
749
+
750
+ // lazy load in some jQuery validation ##
751
+ jQuery(document).ready(function($) {
752
+
753
+ $("input.numeric").blur(function() {
754
+
755
+ //console.log("you entered "+ $(this).val());
756
+
757
+ if ( ! $.isNumeric( $(this).val() ) ) {
758
+
759
+ //console.log("this IS NOT a number");
760
+ $(this).css({ 'background': 'red', 'color': 'white' }); // highlight error ##
761
+ $("p.submit .button-primary").attr('disabled','disabled'); // disable submit ##
762
+
763
+ } else {
764
+
765
+ $(this).css({ 'background': 'white', 'color': '#333' }); // remove error highlighting ##
766
+ $("p.submit .button-primary").removeAttr('disabled'); // enable submit ##
767
+
768
+ }
769
+
770
+ });
771
+
772
+ });
773
+
774
+ </script>
775
 
776
  <tr valign="top">
777
  <th scope="row"><label for="q_eud_users_format"><?php _e( 'Format', 'export-user-data' ); ?></label></th>
818
  $where = '';
819
 
820
  if ( ! empty( $_POST['start_date'] ) )
821
+ $where .= $wpdb->prepare( " AND $wpdb->users.user_registered >= %s", date( 'Y-m-d', strtotime( sanitize_text_field ( $_POST['start_date'] ) ) ) );
822
 
823
  if ( ! empty( $_POST['end_date'] ) )
824
+ $where .= $wpdb->prepare( " AND $wpdb->users.user_registered < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( sanitize_text_field ( $_POST['end_date'] ) ) ) ) );
825
 
826
  if ( ! empty( $where ) )
827
  $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 $where", $user_search->query_where );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: qlstudio
3
  Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  Requires at least: 3.2
5
  Tested up to: 3.8.1
6
- Stable tag: 0.8
7
  License: GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
@@ -58,6 +58,10 @@ Click on the 'Export User Data' link in the 'Users' menu, choose the role and th
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 0.8 =
62
  * moved plugin instatiation to the WP hook: init
63
  * moved bp calls outside export loop
3
  Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  Requires at least: 3.2
5
  Tested up to: 3.8.1
6
+ Stable tag: 0.8.1
7
  License: GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
58
 
59
  == Changelog ==
60
 
61
+ = 0.8.1 =
62
+ * Added experimental range limiter for exports
63
+ * Extra input data sanitizing
64
+
65
  = 0.8 =
66
  * moved plugin instatiation to the WP hook: init
67
  * moved bp calls outside export loop