PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.17
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.17
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmUsage.php +14 -158 6.286.17 View file →
@@ -17,14 +17,11 @@
17 17 if ( ! $this->tracking_allowed() ) {
18 18 return;
19 19 }
20 20
21 - $snapshot = $this->snapshot();
22 - $this->clean_before_send( $snapshot );
23 -
24 21 $ep = 'aHR0cHM6Ly91c2FnZTIuZm9ybWlkYWJsZWZvcm1zLmNvbS9zbmFwc2hvdA==';
25 22 // $ep = base64_encode( 'http://localhost:4567/snapshot' ); // Uncomment for testing
26 - $body = json_encode( $snapshot );
23 + $body = json_encode( $this->snapshot() );
27 24
28 25 // Setup variable for wp_remote_request.
29 26 $post = array(
30 27 'method' => 'POST',
@@ -47,11 +44,8 @@
47 44 }
48 45
49 46 /**
50 47 * @since 3.06.04
51 - *
52 - * @param bool $regenerate
53 - *
54 48 * @return string
55 49 */
56 50 public function uuid( $regenerate = false ) {
57 51 $uuid_key = 'frm-usage-uuid';
@@ -56,13 +50,13 @@
56 50 public function uuid( $regenerate = false ) {
57 51 $uuid_key = 'frm-usage-uuid';
58 52 $uuid = get_option( $uuid_key );
59 53
60 - if ( $regenerate || ! $uuid ) {
54 + if ( $regenerate || empty( $uuid ) ) {
61 55 // Definitely not cryptographically secure but
62 - // close enough to provide a unique id
56 + // close enough to provide an unique id
63 57 $uuid = md5( uniqid() . site_url() );
64 - update_option( $uuid_key, $uuid, false );
58 + update_option( $uuid_key, $uuid, 'no' );
65 59 }
66 60
67 61 return $uuid;
68 62 }
@@ -68,9 +62,8 @@
68 62 }
69 63
70 64 /**
71 65 * @since 3.06.04
72 - *
73 66 * @return array
74 67 */
75 68 public function snapshot() {
76 69 global $wpdb, $wp_version;
@@ -79,8 +72,10 @@
79 72 $form_counts = FrmForm::get_count();
80 73
81 74 $snap = array(
82 75 'uuid' => $this->uuid(),
76 + // Let's keep it anonymous.
77 + 'admin_email' => '',
83 78 'wp_version' => $wp_version,
84 79 'php_version' => phpversion(),
85 80 'mysql_version' => $wpdb->db_version(),
86 81 'os' => FrmAppHelper::get_server_os(),
@@ -100,9 +95,8 @@
100 95 'fields' => $this->fields(),
101 96 'actions' => $this->actions(),
102 97
103 98 'onboarding-wizard' => $this->onboarding_wizard(),
104 - 'welcome-tour' => FrmWelcomeTourController::get_usage_data(),
105 99 'flows' => FrmUsageController::get_flows_data(),
106 100 'payments' => $this->payments(),
107 101 'subscriptions' => $this->payments( 'frm_subscriptions' ),
108 102 );
@@ -114,115 +108,8 @@
114 108 return apply_filters( 'frm_usage_snapshot', $snap );
115 109 }
116 110
117 111 /**
118 - * Cleans the snapshot data before sending.
119 - *
120 - * @param array $data Snapshot data.
121 - *
122 - * @return void
123 - */
124 - private function clean_before_send( &$data ) {
125 - $skip_keys = array(
126 - 'plan_id',
127 - 'paypal_item_name',
128 - 'account_num',
129 - 'routing_num',
130 - 'bank_name',
131 - 'business_email',
132 -
133 - // Form action settings.
134 - 'quiz',
135 - 'email_to',
136 - 'cc',
137 - 'bcc',
138 - 'from',
139 - 'email_subject',
140 - 'email_msg',
141 - 'email_message',
142 - 'success_msg',
143 - 'success_url',
144 - 'success_page_id',
145 - 'redirect_msg',
146 - 'conditions',
147 - 'list_id',
148 - 'api_key',
149 - 'url',
150 - 'data_fields',
151 - 'reg_email_msg',
152 -
153 - // Form settings.
154 - 'form_id',
155 - 'description',
156 - 'submit_conditions-hide_field',
157 - 'submit_conditions-hide_field_cond',
158 - 'submit_conditions-hide_opt',
159 - 'submit_conditions-show_hide',
160 - 'submit_conditions-any_all',
161 -
162 - // Field settings.
163 - 'show_hide',
164 - 'any_all',
165 - 'hide_field',
166 - 'hide_field_cond',
167 - 'hide_opt',
168 - 'custom_html',
169 - 'blank',
170 - 'required_indicator',
171 - 'invalid',
172 - 'unique_msg',
173 - 'edit_text',
174 - 'start_over_label',
175 - 'add_label',
176 - 'remove_label',
177 - 'draft',
178 - );
179 -
180 - /**
181 - * Filter the keys to skip when cleaning the snapshot data before sending.
182 - *
183 - * @since 6.28
184 - *
185 - * @param array $skip_keys Data keys.
186 - */
187 - $skip_keys = apply_filters( 'frm_usage_skip_keys', $skip_keys );
188 -
189 - $long_text_keys = array( 'description' );
190 -
191 - /**
192 - * Filter the keys to replace with a long text placeholder before sending.
193 - *
194 - * @since 6.28
195 - *
196 - * @paramm array $long_text_keys Data keys.
197 - */
198 - $long_text_keys = apply_filters( 'frm_usage_long_text_keys', $long_text_keys );
199 -
200 - foreach ( $data as $key => &$value ) {
201 - if ( ! $value || in_array( $key, $skip_keys, true ) || str_ends_with( $key, '_url' ) ) {
202 - continue;
203 - }
204 -
205 - if ( is_array( $value ) ) {
206 - $this->clean_before_send( $value );
207 - continue;
208 - }
209 -
210 - if ( in_array( $key, $long_text_keys, true ) || str_ends_with( $key, '_msg' ) ) {
211 - // Replace it with a placeholder.
212 - $value = '{{long_text}}';
213 - continue;
214 - }
215 -
216 - // If key ends with `_email`, or value contains `@`, this might contain an email address.
217 - if ( str_ends_with( $key, '_email' ) || str_contains( $value, '@' ) ) {
218 - // Replace it with a placeholder.
219 - $value = '{{contain_email}}';
220 - }
221 - }//end foreach
222 - }
223 -
224 - /**
225 112 * Gets onboarding wizard data.
226 113 *
227 114 * @since 6.16.1
228 115 *
@@ -250,14 +137,12 @@
250 137 *
251 138 * @since 6.16.1
252 139 *
253 140 * @param string $table Database table name.
254 - *
255 141 * @return array
256 142 */
257 143 private function payments( $table = 'frm_payments' ) {
258 144 $allowed_tables = array( 'frm_payments', 'frm_subscriptions' );
259 -
260 145 if ( ! in_array( $table, $allowed_tables, true ) ) {
261 146 return array();
262 147 }
263 148
@@ -273,9 +158,8 @@
273 158 )
274 159 );
275 160
276 161 $payments = array();
277 -
278 162 foreach ( $rows as $row ) {
279 163 $payments[] = array(
280 164 'amount' => (float) $row->amount,
281 165 'status' => $row->status,
@@ -288,15 +172,14 @@
288 172 }
289 173
290 174 /**
291 175 * @since 3.06.04
292 - *
293 176 * @return array
294 177 */
295 178 private function plugins() {
296 179 $plugin_list = FrmAppHelper::get_plugins();
297 - $plugins = array();
298 180
181 + $plugins = array();
299 182 foreach ( $plugin_list as $slug => $info ) {
300 183 $plugins[] = array(
301 184 'name' => $info['Name'],
302 185 'slug' => $slug,
@@ -311,9 +194,8 @@
311 194 /**
312 195 * Add global settings to tracking data.
313 196 *
314 197 * @since 3.06.04
315 - *
316 198 * @return array
317 199 */
318 200 private function settings() {
319 201 $settings_list = FrmAppHelper::get_settings();
@@ -330,19 +212,13 @@
330 212 'menu',
331 213 'mu_menu',
332 214 'no_ips',
333 215 'custom_header_ip',
334 - 'enable_gdpr',
335 - 'no_gdpr_cookies',
336 216 'btsp_css',
337 217 'btsp_version',
338 218 'admin_bar',
339 219 'summary_emails',
340 220 'active_captcha',
341 - 'honeypot',
342 - 'wp_spam_check',
343 - 'denylist_check',
344 - 'email_style',
345 221 );
346 222
347 223 foreach ( $pass_settings as $setting ) {
348 224 if ( isset( $settings_list->$setting ) ) {
@@ -363,9 +239,8 @@
363 239 *
364 240 * @since 3.06.04
365 241 *
366 242 * @param FrmSettings $settings_list
367 - *
368 243 * @return array
369 244 */
370 245 private function messages( $settings_list ) {
371 246 $messages = array(
@@ -378,13 +253,11 @@
378 253 'login_msg',
379 254 'admin_permission',
380 255 );
381 256
382 - $default = $settings_list->default_options();
383 257 $message_settings = array();
384 -
385 258 foreach ( $messages as $message ) {
386 - $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
259 + $message_settings[ $message ] = $settings_list->$message;
387 260 }
388 261
389 262 return $message_settings;
390 263 }
@@ -394,9 +267,8 @@
394 267 *
395 268 * @since 3.06.04
396 269 *
397 270 * @param FrmSettings $settings_list
398 - *
399 271 * @return array
400 272 */
401 273 private function permissions( $settings_list ) {
402 274 $permissions = array();
@@ -412,9 +284,8 @@
412 284 }
413 285
414 286 /**
415 287 * @since 3.06.04
416 - *
417 288 * @return array
418 289 */
419 290 private function forms() {
420 291 $s_query = array(
@@ -429,10 +300,10 @@
429 300 $forms = array();
430 301 $settings = array(
431 302 'form_class',
432 303 'akismet',
304 + 'honeypot',
433 305 'antispam',
434 - 'stopforumspam',
435 306 'custom_style',
436 307 'success_action',
437 308 'show_form',
438 309 'no_save',
@@ -462,9 +333,8 @@
462 333 'submit_conditions',
463 334 );
464 335
465 336 $style = new FrmStyle();
466 -
467 337 foreach ( $saved_forms as $form ) {
468 338 $new_form = array(
469 339 'form_id' => $form->id,
470 340 'description' => $form->description,
@@ -505,11 +375,8 @@
505 375 }
506 376
507 377 /**
508 378 * @since 3.06.04
509 - *
510 - * @param int|string $form_id Form ID.
511 - *
512 379 * @return int
513 380 */
514 381 private function form_field_count( $form_id ) {
515 382 global $wpdb;
@@ -526,11 +393,8 @@
526 393 }
527 394
528 395 /**
529 396 * @since 3.06.04
530 - *
531 - * @param int|string $form_id Form ID.
532 - *
533 397 * @return int
534 398 */
535 399 private function form_action_count( $form_id ) {
536 400 $args = array(
@@ -546,9 +410,8 @@
546 410 /**
547 411 * Get the last 100 fields created.
548 412 *
549 413 * @since 3.06.04
550 - *
551 414 * @return array
552 415 */
553 416 private function fields() {
554 417 $args = array(
@@ -555,21 +418,18 @@
555 418 'limit' => 50,
556 419 'order_by' => 'id DESC',
557 420 );
558 421
559 - $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
560 -
422 + $fields = FrmDb::get_results( 'frm_fields', array(), 'form_id, name, type, field_options', $args );
561 423 foreach ( $fields as $k => $field ) {
562 424 FrmAppHelper::unserialize_or_decode( $field->field_options );
563 - $fields[ $k ]->field_options = $field->field_options;
425 + $fields[ $k ]->field_options = json_encode( $field->field_options );
564 426 }
565 -
566 427 return $fields;
567 428 }
568 429
569 430 /**
570 431 * @since 3.06.04
571 - *
572 432 * @return array
573 433 */
574 434 private function actions() {
575 435 $args = array(
@@ -576,17 +436,17 @@
576 436 'post_type' => FrmFormActionsController::$action_post_type,
577 437 'numberposts' => 100,
578 438 );
579 439
580 - $actions = array();
440 + $actions = array();
441 +
581 442 $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
582 -
583 443 foreach ( $saved_actions as $action ) {
584 444 $actions[] = array(
585 445 'form_id' => $action->menu_order,
586 446 'type' => $action->post_excerpt,
587 447 'status' => $action->post_status,
588 - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ),
448 + 'settings' => $action->post_content,
589 449 );
590 450 }
591 451
592 452 return $actions;
@@ -593,9 +453,8 @@
593 453 }
594 454
595 455 /**
596 456 * @since 3.06.04
597 - *
598 457 * @return bool
599 458 */
600 459 private function tracking_allowed() {
601 460 return FrmUsageController::tracking_allowed();
@@ -602,11 +461,8 @@
602 461 }
603 462
604 463 /**
605 464 * @since 3.06.04
606 - *
607 - * @param mixed $value Value.
608 - *
609 465 * @return string
610 466 */
611 467 private function maybe_json( $value ) {
612 468 return is_array( $value ) ? json_encode( $value ) : $value;