Contact Form 7 Database Addon – CFDB7 - Version 1.2.5.3

Version Description

Add index.php in cfdb7_uploads

Download this release

Release Info

Developer arshidkv12
Plugin Icon 128x128 Contact Form 7 Database Addon – CFDB7
Version 1.2.5.3
Comparing to
See all releases

Code changes from version 1.2.4.7 to 1.2.5.3

contact-form-cfdb-7.php CHANGED
@@ -7,7 +7,7 @@ Author: Arshid
7
  Author URI: http://ciphercoin.com/
8
  Text Domain: contact-form-cfdb7
9
  Domain Path: /languages/
10
- Version: 1.2.4.7
11
  */
12
 
13
  function cfdb7_create_table(){
@@ -36,6 +36,9 @@ function cfdb7_create_table(){
36
  $cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
37
  if ( ! file_exists( $cfdb7_dirname ) ) {
38
  wp_mkdir_p( $cfdb7_dirname );
 
 
 
39
  }
40
  add_option( 'cfdb7_view_install_date', date('Y-m-d G:i:s'), '', 'yes');
41
 
@@ -64,6 +67,25 @@ function cfdb7_on_activate( $network_wide ){
64
  register_activation_hook( __FILE__, 'cfdb7_on_activate' );
65
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  function cfdb7_on_deactivate() {
68
 
69
  // Remove custom capability from all roles
@@ -98,16 +120,25 @@ function cfdb7_before_send_mail( $form_tag ) {
98
  $files = $form->uploaded_files();
99
  $uploaded_files = array();
100
 
101
- foreach ($files as $file_key => $file) {
 
 
102
  array_push($uploaded_files, $file_key);
103
- copy($file, $cfdb7_dirname.'/'.$time_now.'-'.basename($file));
 
 
 
104
  }
105
 
106
  $form_data = array();
107
 
108
  $form_data['cfdb7_status'] = 'unread';
109
  foreach ($data as $key => $d) {
110
- if ( !in_array($key, $black_list ) && !in_array($key, $uploaded_files ) ) {
 
 
 
 
111
 
112
  $tmpD = $d;
113
 
@@ -122,7 +153,8 @@ function cfdb7_before_send_mail( $form_tag ) {
122
  $form_data[$key] = $tmpD;
123
  }
124
  if ( in_array($key, $uploaded_files ) ) {
125
- $form_data[$key.'cfdb7_file'] = $time_now.'-'.$d;
 
126
  }
127
  }
128
 
@@ -170,7 +202,7 @@ function cfdb7_init(){
170
 
171
  do_action( 'cfdb7_admin_init' );
172
 
173
- $csv = new Expoert_CSV();
174
  if( isset($_REQUEST['csv']) && ( $_REQUEST['csv'] == true ) && isset( $_REQUEST['nonce'] ) ) {
175
 
176
  $nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
7
  Author URI: http://ciphercoin.com/
8
  Text Domain: contact-form-cfdb7
9
  Domain Path: /languages/
10
+ Version: 1.2.5.3
11
  */
12
 
13
  function cfdb7_create_table(){
36
  $cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
37
  if ( ! file_exists( $cfdb7_dirname ) ) {
38
  wp_mkdir_p( $cfdb7_dirname );
39
+ $fp = fopen( $cfdb7_dirname.'/index.php', 'w');
40
+ fwrite($fp, "<?php \n\t // Silence is golden.");
41
+ fclose( $fp );
42
  }
43
  add_option( 'cfdb7_view_install_date', date('Y-m-d G:i:s'), '', 'yes');
44
 
67
  register_activation_hook( __FILE__, 'cfdb7_on_activate' );
68
 
69
 
70
+ function cfdb7_upgrade_function( $upgrader_object, $options ) {
71
+
72
+ $upload_dir = wp_upload_dir();
73
+ $cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
74
+
75
+ if ( file_exists( $cfdb7_dirname.'/index.php' ) ) return;
76
+
77
+ if ( file_exists( $cfdb7_dirname ) ) {
78
+ $fp = fopen( $cfdb7_dirname.'/index.php', 'w');
79
+ fwrite($fp, "<?php \n\t // Silence is golden.");
80
+ fclose( $fp );
81
+ }
82
+
83
+ }
84
+
85
+ add_action( 'upgrader_process_complete', 'cfdb7_upgrade_function',10, 2);
86
+
87
+
88
+
89
  function cfdb7_on_deactivate() {
90
 
91
  // Remove custom capability from all roles
120
  $files = $form->uploaded_files();
121
  $uploaded_files = array();
122
 
123
+ $rm_underscore = apply_filters('cfdb7_remove_underscore_data', true);
124
+
125
+ foreach ($_FILES as $file_key => $file) {
126
  array_push($uploaded_files, $file_key);
127
+ }
128
+
129
+ foreach ($files as $file_key => $file) {
130
+ copy($file, $cfdb7_dirname.'/'.$time_now.'-'.$file_key.'-'.basename($file));
131
  }
132
 
133
  $form_data = array();
134
 
135
  $form_data['cfdb7_status'] = 'unread';
136
  foreach ($data as $key => $d) {
137
+
138
+ $matches = array();
139
+ if( $rm_underscore ) preg_match('/^_.*$/m', $key, $matches);
140
+
141
+ if ( !in_array($key, $black_list ) && !in_array($key, $uploaded_files ) && empty( $matches[0] ) ) {
142
 
143
  $tmpD = $d;
144
 
153
  $form_data[$key] = $tmpD;
154
  }
155
  if ( in_array($key, $uploaded_files ) ) {
156
+ $file_name = isset( $files[ $key ] ) ? $time_now.'-'.$key.'-'.basename( $files[ $key ]) : '';
157
+ $form_data[$key.'cfdb7_file'] = $file_name;
158
  }
159
  }
160
 
202
 
203
  do_action( 'cfdb7_admin_init' );
204
 
205
+ $csv = new Export_CSV();
206
  if( isset($_REQUEST['csv']) && ( $_REQUEST['csv'] == true ) && isset( $_REQUEST['nonce'] ) ) {
207
 
208
  $nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
inc/admin-form-details.php CHANGED
@@ -25,6 +25,8 @@ class CFdb7_Form_Details
25
  $table_name = $cfdb->prefix.'db7_forms';
26
  $upload_dir = wp_upload_dir();
27
  $cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
 
 
28
 
29
  if ( is_numeric($this->form_post_id) && is_numeric($this->form_id) ) {
30
 
@@ -47,13 +49,18 @@ class CFdb7_Form_Details
47
 
48
  foreach ($form_data as $key => $data):
49
 
 
 
50
  if ( $key == 'cfdb7_status' ) continue;
 
 
51
 
52
  if ( strpos($key, 'cfdb7_file') !== false ){
53
 
54
  $key_val = str_replace('cfdb7_file', '', $key);
55
  $key_val = str_replace('your-', '', $key_val);
56
- $key_val = ucfirst( $key_val );
 
57
  echo '<p><b>'.$key_val.'</b>: <a href="'.$cfdb7_dir_url.'/'.$data.'">'
58
  .$data.'</a></p>';
59
  }else{
@@ -61,8 +68,9 @@ class CFdb7_Form_Details
61
 
62
  if ( is_array($data) ) {
63
 
64
- $key_val = str_replace('your-', '', $key);
65
- $key_val = ucfirst( $key_val );
 
66
  $arr_str_data = implode(', ',$data);
67
  $arr_str_data = esc_html( $arr_str_data );
68
  echo '<p><b>'.$key_val.'</b>: '. nl2br($arr_str_data) .'</p>';
@@ -70,7 +78,9 @@ class CFdb7_Form_Details
70
  }else{
71
 
72
  $key_val = str_replace('your-', '', $key);
73
- $key_val = ucfirst( $key_val );
 
 
74
  $data = esc_html( $data );
75
  echo '<p><b>'.$key_val.'</b>: '.nl2br($data).'</p>';
76
  }
25
  $table_name = $cfdb->prefix.'db7_forms';
26
  $upload_dir = wp_upload_dir();
27
  $cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
28
+ $rm_underscore = apply_filters('cfdb7_remove_underscore_data', true);
29
+
30
 
31
  if ( is_numeric($this->form_post_id) && is_numeric($this->form_id) ) {
32
 
49
 
50
  foreach ($form_data as $key => $data):
51
 
52
+ $matches = array();
53
+
54
  if ( $key == 'cfdb7_status' ) continue;
55
+ if( $rm_underscore ) preg_match('/^_.*$/m', $key, $matches);
56
+ if( ! empty($matches[0]) ) continue;
57
 
58
  if ( strpos($key, 'cfdb7_file') !== false ){
59
 
60
  $key_val = str_replace('cfdb7_file', '', $key);
61
  $key_val = str_replace('your-', '', $key_val);
62
+ $key_val = str_replace( array('-','_'), ' ', $key_val);
63
+ $key_val = ucwords( $key_val );
64
  echo '<p><b>'.$key_val.'</b>: <a href="'.$cfdb7_dir_url.'/'.$data.'">'
65
  .$data.'</a></p>';
66
  }else{
68
 
69
  if ( is_array($data) ) {
70
 
71
+ $key_val = str_replace('your-', '', $key);
72
+ $key_val = str_replace( array('-','_'), ' ', $key_val);
73
+ $key_val = ucwords( $key_val );
74
  $arr_str_data = implode(', ',$data);
75
  $arr_str_data = esc_html( $arr_str_data );
76
  echo '<p><b>'.$key_val.'</b>: '. nl2br($arr_str_data) .'</p>';
78
  }else{
79
 
80
  $key_val = str_replace('your-', '', $key);
81
+ $key_val = str_replace( array('-','_'), ' ', $key_val);
82
+
83
+ $key_val = ucwords( $key_val );
84
  $data = esc_html( $data );
85
  echo '<p><b>'.$key_val.'</b>: '.nl2br($data).'</p>';
86
  }
inc/admin-subpage.php CHANGED
@@ -101,7 +101,7 @@ class CFDB7_List_Table extends WP_List_Table
101
  if ( ! empty($search) ) {
102
 
103
  $totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_value LIKE '%$search%' AND form_post_id = '$form_post_id' ");
104
- }else{
105
 
106
  $totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = '$form_post_id'");
107
  }
@@ -124,23 +124,30 @@ class CFDB7_List_Table extends WP_List_Table
124
 
125
  global $wpdb;
126
  $cfdb = apply_filters( 'cfdb7_database', $wpdb );
127
- $table_name = $cfdb->prefix.'db7_forms';
128
-
129
- $results = $cfdb->get_results( "SELECT * FROM $table_name
130
- WHERE form_post_id = $form_post_id ORDER BY form_id DESC LIMIT 1", OBJECT );
 
131
 
132
  $first_row = isset($results[0]) ? unserialize( $results[0]->form_value ): 0 ;
133
  $columns = array();
 
134
 
135
  if( !empty($first_row) ){
136
  //$columns['form_id'] = $results[0]->form_id;
137
  $columns['cb'] = '<input type="checkbox" />';
138
  foreach ($first_row as $key => $value) {
139
 
 
 
140
  if ( $key == 'cfdb7_status' ) continue;
 
 
141
 
142
  $key_val = str_replace( array('your-', 'cfdb7_file'), '', $key);
143
- $columns[$key] = ucfirst( $key_val );
 
144
 
145
  $this->column_titles[] = $key_val;
146
 
@@ -239,7 +246,7 @@ class CFDB7_List_Table extends WP_List_Table
239
 
240
 
241
 
242
- $fid = $result->form_post_id;
243
  $form_values['form_id'] = $result->form_id;
244
 
245
  foreach ( $this->column_titles as $col_title) {
101
  if ( ! empty($search) ) {
102
 
103
  $totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_value LIKE '%$search%' AND form_post_id = '$form_post_id' ");
104
+ }else{
105
 
106
  $totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = '$form_post_id'");
107
  }
124
 
125
  global $wpdb;
126
  $cfdb = apply_filters( 'cfdb7_database', $wpdb );
127
+ $table_name = $cfdb->prefix.'db7_forms';
128
+ $results = $cfdb->get_results( "
129
+ SELECT * FROM $table_name
130
+ WHERE form_post_id = $form_post_id ORDER BY form_id DESC LIMIT 1", OBJECT
131
+ );
132
 
133
  $first_row = isset($results[0]) ? unserialize( $results[0]->form_value ): 0 ;
134
  $columns = array();
135
+ $rm_underscore = apply_filters('remove_underscore_data', true);
136
 
137
  if( !empty($first_row) ){
138
  //$columns['form_id'] = $results[0]->form_id;
139
  $columns['cb'] = '<input type="checkbox" />';
140
  foreach ($first_row as $key => $value) {
141
 
142
+ $matches = array();
143
+
144
  if ( $key == 'cfdb7_status' ) continue;
145
+ if( $rm_underscore ) preg_match('/^_.*$/m', $key, $matches);
146
+ if( ! empty($matches[0]) ) continue;
147
 
148
  $key_val = str_replace( array('your-', 'cfdb7_file'), '', $key);
149
+ $key_val = str_replace( array('_', '-'), ' ', $key_val);
150
+ $columns[$key] = ucwords( $key_val );
151
 
152
  $this->column_titles[] = $key_val;
153
 
246
 
247
 
248
 
249
+ $fid = $result->form_post_id;
250
  $form_values['form_id'] = $result->form_id;
251
 
252
  foreach ( $this->column_titles as $col_title) {
inc/export-csv.php CHANGED
@@ -5,7 +5,7 @@
5
 
6
  if (!defined( 'ABSPATH')) exit;
7
 
8
- class Expoert_CSV{
9
 
10
  /**
11
  * Download csv file
@@ -42,12 +42,17 @@ class Expoert_CSV{
42
 
43
  $array_keys = array_keys($array);
44
  $heading = array();
45
- $unwanted = array('cfdb7_', 'your-');
46
 
47
  foreach ( $array_keys as $aKeys ) {
 
 
48
  $tmp = str_replace( $unwanted, '', $aKeys );
49
- $heading[] = ucfirst( $tmp );
 
50
  }
 
 
51
  fputcsv( $df, $heading );
52
 
53
  foreach ( $array['form_id'] as $line => $form_id ) {
@@ -80,9 +85,11 @@ class Expoert_CSV{
80
  $heading_row = $cfdb->get_results("SELECT form_id, form_value, form_date FROM $table_name
81
  WHERE form_post_id = '$fid' ORDER BY form_id DESC LIMIT 1",OBJECT);
82
 
83
- $heading_row = reset( $heading_row );
84
- $heading_row = unserialize( $heading_row->form_value );
85
- $heading_key = array_keys( $heading_row );
 
 
86
 
87
  $total_rows = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = '$fid' ");
88
  $per_query = 1000;
@@ -110,9 +117,14 @@ class Expoert_CSV{
110
  $cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
111
 
112
  foreach ($resultTmp as $key => $value):
 
 
113
  if ( ! in_array( $key, $heading_key ) ) continue;
 
 
 
114
  if (strpos($key, 'cfdb7_file') !== false ){
115
- $data[$key][$i] = $cfdb7_dir_url.'/'.$value;
116
  continue;
117
  }
118
  if ( is_array($value) ){
5
 
6
  if (!defined( 'ABSPATH')) exit;
7
 
8
+ class Export_CSV{
9
 
10
  /**
11
  * Download csv file
42
 
43
  $array_keys = array_keys($array);
44
  $heading = array();
45
+ $unwanted = array('cfdb7_file', 'cfdb7_', 'your-');
46
 
47
  foreach ( $array_keys as $aKeys ) {
48
+ if( $aKeys == 'form_date' ) $aKeys = 'Date';
49
+ if( $aKeys == 'form_id' ) $aKeys = 'Id';
50
  $tmp = str_replace( $unwanted, '', $aKeys );
51
+ $tmp = str_replace( array('-','_'), ' ', $tmp );
52
+ $heading[] = ucwords( $tmp );
53
  }
54
+
55
+ fputs( $df, ( chr(0xEF) . chr(0xBB) . chr(0xBF) ) );
56
  fputcsv( $df, $heading );
57
 
58
  foreach ( $array['form_id'] as $line => $form_id ) {
85
  $heading_row = $cfdb->get_results("SELECT form_id, form_value, form_date FROM $table_name
86
  WHERE form_post_id = '$fid' ORDER BY form_id DESC LIMIT 1",OBJECT);
87
 
88
+ $heading_row = reset( $heading_row );
89
+ $heading_row = unserialize( $heading_row->form_value );
90
+ $heading_key = array_keys( $heading_row );
91
+ $rm_underscore = apply_filters('cfdb7_remove_underscore_data', true);
92
+
93
 
94
  $total_rows = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = '$fid' ");
95
  $per_query = 1000;
117
  $cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
118
 
119
  foreach ($resultTmp as $key => $value):
120
+ $matches = array();
121
+
122
  if ( ! in_array( $key, $heading_key ) ) continue;
123
+ if( $rm_underscore ) preg_match('/^_.*$/m', $key, $matches);
124
+ if( ! empty($matches[0]) ) continue;
125
+
126
  if (strpos($key, 'cfdb7_file') !== false ){
127
+ $data[$key][$i] = empty( $value ) ? '' : $cfdb7_dir_url.'/'.$value;
128
  continue;
129
  }
130
  if ( is_array($value) ){
readme.txt CHANGED
@@ -3,11 +3,11 @@ Contributors: arshidkv12
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=H5F3Z6S3MNTXA&lc=IN&item_name=wp%2dlogin%2dlimit&amount=5%2e00&currency_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
4
  Tags: cf7, contact form 7, contact form 7 db, contact form db, contact form seven, contact form storage, export contact form, save contact form, wpcf7
5
  Requires at least: 4.8
6
- Tested up to: 5.2
7
- Stable tag: 1.2.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
- Requires PHP: 5.3
11
 
12
  Save and manage Contact Form 7 messages. Never lose important data. It is lightweight contact form 7 database plugin.
13
 
@@ -56,6 +56,25 @@ Extensions : [Contact form 7 more Add-ons](https://ciphercoin.com/contact-form-7
56
  1. Admin
57
 
58
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  = 1.2.4.7 =
60
  Action hook name changed to cfdb7_before_save
61
 
@@ -68,28 +87,6 @@ Responsive issue fixed
68
  = 1.2.4 =
69
  Fixed admin notification bug
70
 
71
- = 1.2.3 =
72
- Fixed csv export issue
73
-
74
- = 1.2.2 =
75
- Added cfdb7_access capability
76
-
77
- = 1.2.1 =
78
- Multisite network bug fixed
79
-
80
- = 1.2 =
81
- Fixed csv export bug
82
-
83
- = 1.1.9 =
84
- Fixed Sorting bugs
85
-
86
- = 1.1.7 =
87
- Add filter hooks
88
- Multisite support
89
-
90
- = 1.1.6 =
91
- Fixed minor bugs
92
- Add action hooks
93
 
94
  = 1.0.0 =
95
  First version of plugin.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=H5F3Z6S3MNTXA&lc=IN&item_name=wp%2dlogin%2dlimit&amount=5%2e00&currency_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
4
  Tags: cf7, contact form 7, contact form 7 db, contact form db, contact form seven, contact form storage, export contact form, save contact form, wpcf7
5
  Requires at least: 4.8
6
+ Tested up to: 5.6
7
+ Stable tag: 1.2.5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+ Requires PHP: 5.6
11
 
12
  Save and manage Contact Form 7 messages. Never lose important data. It is lightweight contact form 7 database plugin.
13
 
56
  1. Admin
57
 
58
  == Changelog ==
59
+
60
+ = 1.2.5.3 =
61
+ Add index.php in cfdb7_uploads
62
+
63
+ = 1.2.5 =
64
+ Fixed minar file upload bug
65
+ Meaningfull headings
66
+
67
+ = 1.2.4.11 =
68
+ UTF-8 CSV Export Fixed
69
+
70
+ = 1.2.4.10 =
71
+ Solved upload file issue
72
+
73
+ = 1.2.4.8 =
74
+ Removed unwanted data
75
+ Removed data with key underscore (_)
76
+ add_filter cfdb7_remove_underscore_data
77
+
78
  = 1.2.4.7 =
79
  Action hook name changed to cfdb7_before_save
80
 
87
  = 1.2.4 =
88
  Fixed admin notification bug
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  = 1.0.0 =
92
  First version of plugin.