PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.20
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.20
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 -154 6.286.20 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();
@@ -337,12 +219,8 @@
337 219 'btsp_version',
338 220 'admin_bar',
339 221 'summary_emails',
340 222 'active_captcha',
341 - 'honeypot',
342 - 'wp_spam_check',
343 - 'denylist_check',
344 - 'email_style',
345 223 );
346 224
347 225 foreach ( $pass_settings as $setting ) {
348 226 if ( isset( $settings_list->$setting ) ) {
@@ -363,9 +241,8 @@
363 241 *
364 242 * @since 3.06.04
365 243 *
366 244 * @param FrmSettings $settings_list
367 - *
368 245 * @return array
369 246 */
370 247 private function messages( $settings_list ) {
371 248 $messages = array(
@@ -378,11 +255,11 @@
378 255 'login_msg',
379 256 'admin_permission',
380 257 );
381 258
382 - $default = $settings_list->default_options();
259 + $default = $settings_list->default_options();
260 +
383 261 $message_settings = array();
384 -
385 262 foreach ( $messages as $message ) {
386 263 $message_settings[ 'changed-' . $message ] = $settings_list->$message === $default[ $message ] ? 0 : 1;
387 264 }
388 265
@@ -394,9 +271,8 @@
394 271 *
395 272 * @since 3.06.04
396 273 *
397 274 * @param FrmSettings $settings_list
398 - *
399 275 * @return array
400 276 */
401 277 private function permissions( $settings_list ) {
402 278 $permissions = array();
@@ -412,9 +288,8 @@
412 288 }
413 289
414 290 /**
415 291 * @since 3.06.04
416 - *
417 292 * @return array
418 293 */
419 294 private function forms() {
420 295 $s_query = array(
@@ -429,10 +304,10 @@
429 304 $forms = array();
430 305 $settings = array(
431 306 'form_class',
432 307 'akismet',
308 + 'honeypot',
433 309 'antispam',
434 - 'stopforumspam',
435 310 'custom_style',
436 311 'success_action',
437 312 'show_form',
438 313 'no_save',
@@ -462,9 +337,8 @@
462 337 'submit_conditions',
463 338 );
464 339
465 340 $style = new FrmStyle();
466 -
467 341 foreach ( $saved_forms as $form ) {
468 342 $new_form = array(
469 343 'form_id' => $form->id,
470 344 'description' => $form->description,
@@ -505,11 +379,8 @@
505 379 }
506 380
507 381 /**
508 382 * @since 3.06.04
509 - *
510 - * @param int|string $form_id Form ID.
511 - *
512 383 * @return int
513 384 */
514 385 private function form_field_count( $form_id ) {
515 386 global $wpdb;
@@ -526,11 +397,8 @@
526 397 }
527 398
528 399 /**
529 400 * @since 3.06.04
530 - *
531 - * @param int|string $form_id Form ID.
532 - *
533 401 * @return int
534 402 */
535 403 private function form_action_count( $form_id ) {
536 404 $args = array(
@@ -546,9 +414,8 @@
546 414 /**
547 415 * Get the last 100 fields created.
548 416 *
549 417 * @since 3.06.04
550 - *
551 418 * @return array
552 419 */
553 420 private function fields() {
554 421 $args = array(
@@ -556,20 +423,17 @@
556 423 'order_by' => 'id DESC',
557 424 );
558 425
559 426 $fields = FrmDb::get_results( 'frm_fields', array(), 'id, form_id, name, type, field_options', $args );
560 -
561 427 foreach ( $fields as $k => $field ) {
562 428 FrmAppHelper::unserialize_or_decode( $field->field_options );
563 - $fields[ $k ]->field_options = $field->field_options;
429 + $fields[ $k ]->field_options = json_encode( $field->field_options );
564 430 }
565 -
566 431 return $fields;
567 432 }
568 433
569 434 /**
570 435 * @since 3.06.04
571 - *
572 436 * @return array
573 437 */
574 438 private function actions() {
575 439 $args = array(
@@ -576,17 +440,17 @@
576 440 'post_type' => FrmFormActionsController::$action_post_type,
577 441 'numberposts' => 100,
578 442 );
579 443
580 - $actions = array();
444 + $actions = array();
445 +
581 446 $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
582 -
583 447 foreach ( $saved_actions as $action ) {
584 448 $actions[] = array(
585 449 'form_id' => $action->menu_order,
586 450 'type' => $action->post_excerpt,
587 451 'status' => $action->post_status,
588 - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ),
452 + 'settings' => $action->post_content,
589 453 );
590 454 }
591 455
592 456 return $actions;
@@ -593,9 +457,8 @@
593 457 }
594 458
595 459 /**
596 460 * @since 3.06.04
597 - *
598 461 * @return bool
599 462 */
600 463 private function tracking_allowed() {
601 464 return FrmUsageController::tracking_allowed();
@@ -602,11 +465,8 @@
602 465 }
603 466
604 467 /**
605 468 * @since 3.06.04
606 - *
607 - * @param mixed $value Value.
608 - *
609 469 * @return string
610 470 */
611 471 private function maybe_json( $value ) {
612 472 return is_array( $value ) ? json_encode( $value ) : $value;