PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/FrmEntryValidate.php +153 -837 6.295.0 View file →
@@ -3,22 +3,8 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmEntryValidate {
7 -
8 - /**
9 - * @since 6.17
10 - *
11 - * @var array|null
12 - */
13 - private static $name_text_fields;
14 -
15 - /**
16 - * @param array $values
17 - * @param bool|string[] $exclude
18 - *
19 - * @return array
20 - */
21 7 public static function validate( $values, $exclude = false ) {
22 8 FrmEntry::sanitize_entry_post( $values );
23 9 $errors = array();
24 10
@@ -23,17 +9,16 @@
23 9 $errors = array();
24 10
25 11 if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
26 12 $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
13 +
27 14 return $errors;
28 15 }
29 16
30 - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
31 - $frm_settings = FrmAppHelper::get_settings();
32 - $errors['form'] = $frm_settings->admin_permission;
17 + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
18 + $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
33 19 }
34 20
35 - self::maybe_fix_item_meta();
36 21 self::set_item_key( $values );
37 22
38 23 $posted_fields = self::get_fields_to_validate( $values, $exclude );
39 24
@@ -44,69 +29,25 @@
44 29 self::validate_field( $posted_field, $errors, $values, $args );
45 30 unset( $posted_field );
46 31 }
47 32
48 - if ( ! $errors ) {
33 + if ( empty( $errors ) ) {
49 34 self::spam_check( $exclude, $values, $errors );
50 35 }
51 36
52 - /**
53 - * Allows modifying the validation errors after validating all fields.
54 - *
55 - * @since 5.0.04 Added `posted_fields` to the third param.
56 - *
57 - * @param array $errors Errors data.
58 - * @param array $values Value data of the form.
59 - * @param array $args Custom arguments. Contains `exclude` and `posted_fields`.
60 - */
61 - $filtered_errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude', 'posted_fields' ) );
37 + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
62 38
63 - if ( is_array( $filtered_errors ) ) {
64 - $errors = $filtered_errors;
65 - } else {
66 - _doing_it_wrong( __METHOD__, 'Only arrays should be returned when using the frm_validate_entry filter.', '6.3' );
67 - }
68 -
69 39 return $errors;
70 40 }
71 41
72 - /**
73 - * In case $_POST['item_meta'] is not an array, change it to an empty array.
74 - * This helps to avoid some warnings and errors when $_POST['item_meta'] is updated.
75 - *
76 - * @since 6.6
77 - *
78 - * @return void
79 - */
80 - private static function maybe_fix_item_meta() {
81 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
82 - if ( ! isset( $_POST['item_meta'] ) || ! is_array( $_POST['item_meta'] ) ) {
83 - $_POST['item_meta'] = array();
84 - }
85 - }
86 -
87 - /**
88 - * @param array $values
89 - *
90 - * @return void
91 - */
92 42 private static function set_item_key( &$values ) {
93 - // phpcs:ignore Universal.Operators.StrictComparisons
94 - if ( isset( $values['item_key'] ) && $values['item_key'] != '' ) {
95 - return;
43 + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
44 + global $wpdb;
45 + $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
46 + $_POST['item_key'] = $values['item_key'];
96 47 }
97 -
98 - global $wpdb;
99 - $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
100 - $_POST['item_key'] = $values['item_key'];
101 48 }
102 49
103 - /**
104 - * @param array $values
105 - * @param array|string $exclude
106 - *
107 - * @return array
108 - */
109 50 private static function get_fields_to_validate( $values, $exclude ) {
110 51 $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
111 52
112 53 // Don't get subfields
@@ -112,46 +53,30 @@
112 53 // Don't get subfields
113 54 $where['fr.parent_form_id'] = array( null, 0 );
114 55
115 56 // Don't get excluded fields (like file upload fields in the ajax validation)
116 - if ( $exclude ) {
57 + if ( ! empty( $exclude ) ) {
117 58 $where['fi.type not'] = $exclude;
118 59 }
119 60
120 - $fields = FrmField::getAll( $where, 'field_order' );
121 -
122 - /**
123 - * Allows modifying fields to validate.
124 - *
125 - * @since 5.0.06
126 - *
127 - * @param array $fields List of fields.
128 - * @param array $args Includes `values`, `exclude`, `where`.
129 - */
130 - return apply_filters( 'frm_fields_to_validate', $fields, compact( 'values', 'exclude', 'where' ) );
61 + return FrmField::getAll( $where, 'field_order' );
131 62 }
132 63
133 - /**
134 - * @param object $posted_field
135 - * @param array $errors
136 - * @param array $values
137 - * @param array $args
138 - *
139 - * @return void
140 - */
141 64 public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
142 65 $defaults = array(
143 66 'id' => $posted_field->id,
144 - // The id of the repeat or embed form.
145 - 'parent_field_id' => '',
146 - // The pointer in the posted array.
147 - 'key_pointer' => '',
148 - // Exclude these field types from validation.
149 - 'exclude' => array(),
67 + 'parent_field_id' => '', // the id of the repeat or embed form
68 + 'key_pointer' => '', // the pointer in the posted array
69 + 'exclude' => array(), // exclude these field types from validation
70 + );
71 + $args = wp_parse_args( $args, $defaults );
150 72
151 - );
152 - $args = wp_parse_args( $args, $defaults );
153 - $value = ! empty( $args['parent_field_id'] ) ? $values : ( $values['item_meta'][ $args['id'] ] ?? '' );
73 + if ( empty( $args['parent_field_id'] ) ) {
74 + $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
75 + } else {
76 + // value is from a nested form
77 + $value = $values;
78 + }
154 79
155 80 // Check for values in "Other" fields
156 81 FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
157 82
@@ -156,10 +81,9 @@
156 81 FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
157 82
158 83 self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
159 84
160 - $should_trim = is_array( $value ) && count( $value ) === 1 && isset( $value[0] ) && $posted_field->type !== 'checkbox';
161 -
85 + $should_trim = is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) && $posted_field->type !== 'checkbox';
162 86 if ( $should_trim ) {
163 87 $value = reset( $value );
164 88 }
165 89
@@ -166,18 +90,16 @@
166 90 if ( ! is_array( $value ) ) {
167 91 $value = trim( $value );
168 92 }
169 93
170 - // phpcs:ignore Universal.Operators.StrictComparisons
171 94 if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) {
172 95 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
173 - } elseif ( ! isset( $_POST['item_name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
174 - self::maybe_add_item_name( $value, $posted_field );
96 + } elseif ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok.
97 + $_POST['item_name'] = $value;
175 98 }
176 99
177 100 FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
178 101
179 - self::validate_options( $errors, $posted_field, $value, $args );
180 102 self::validate_field_types( $errors, $posted_field, $value, $args );
181 103
182 104 // Field might want to modify value before other parts of the system
183 105 // e.g. trim off excess values like in the case of fields with limit.
@@ -182,9 +104,8 @@
182 104 // Field might want to modify value before other parts of the system
183 105 // e.g. trim off excess values like in the case of fields with limit.
184 106 $value = apply_filters( 'frm_modify_posted_field_value', $value, $errors, $posted_field, $args );
185 107
186 - // phpcs:ignore Universal.Operators.StrictComparisons
187 108 if ( $value != '' ) {
188 109 self::validate_phone_field( $errors, $posted_field, $value, $args );
189 110 }
190 111
@@ -189,236 +110,18 @@
189 110 }
190 111
191 112 $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
192 113 $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
193 -
194 - if ( ! FrmAppHelper::pro_is_installed() && empty( $args['other'] ) ) {
195 - FrmEntriesHelper::get_posted_value( $posted_field, $value, $args );
196 - }
197 114 }
198 115
199 116 /**
200 - * @since 6.21
201 - *
202 - * @param array $errors
203 - * @param object $posted_field
204 - * @param array|string $value
205 - * @param array $args
206 - *
207 - * @return void
208 - */
209 - private static function validate_options( &$errors, $posted_field, $value, $args ) {
210 - if ( empty( $posted_field->options ) ) {
211 - return;
212 - }
213 -
214 - $option_is_valid = self::option_is_valid( $posted_field, $value, $posted_field->options );
215 -
216 - /**
217 - * @since 6.21
218 - *
219 - * @param bool $option_is_valid
220 - * @param array|string $value
221 - * @param object $field
222 - */
223 - $option_is_valid = (bool) apply_filters( 'frm_option_is_valid', $option_is_valid, $value, $posted_field );
224 -
225 - if ( ! $option_is_valid ) {
226 - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' );
227 - }
228 - }
229 -
230 - /**
231 - * Validate that value matches one of the options for the field.
232 - *
233 - * @since 6.21
234 - *
235 - * @param stdClass $field
236 - * @param array|string $value
237 - * @param array $options
238 - *
239 - * @return bool
240 - */
241 - private static function option_is_valid( $field, $value, $options ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
242 - if ( '' === $value ) {
243 - return true;
244 - }
245 -
246 - $field_object = FrmFieldFactory::get_field_type( $field->type, $field );
247 -
248 - if ( ! $field_object->field_type_has_options_settings() ) {
249 - return true;
250 - }
251 -
252 - if ( in_array( $field->type, array( 'likert', 'ranking' ), true ) ) {
253 - // Ignore these field types automatically.
254 - return true;
255 - }
256 -
257 - if ( 'product' === $field->type && 'user_def' === FrmField::get_option( $field, 'data_type' ) ) {
258 - return true;
259 - }
260 -
261 - if ( ! empty( $field->field_options['post_field'] ) ) {
262 - return true;
263 - }
264 -
265 - $value = (array) $value;
266 -
267 - foreach ( $value as $current_value ) {
268 - $match = false;
269 -
270 - foreach ( $options as $key => $option ) {
271 - if ( str_starts_with( $key, 'other_' ) ) {
272 - // Always return true if an other option is found.
273 - return true;
274 - }
275 -
276 - if ( is_array( $option ) ) {
277 - $separate_value = FrmField::get_option( $field, 'separate_value' );
278 - $option_value = $separate_value ? $option['value'] : $option['label'];
279 - } else {
280 - $option_value = $option;
281 - }
282 -
283 - /**
284 - * @var string $current_value
285 - */
286 - $match = trim( $current_value ) === trim( $option_value );
287 -
288 - if ( $match ) {
289 - break;
290 - }
291 -
292 - $match = trim( $current_value ) === trim( do_shortcode( $option_value ) );
293 -
294 - if ( $match ) {
295 - break;
296 - }
297 -
298 - $match = self::is_filtered_match( $current_value, $option_value );
299 -
300 - if ( $match ) {
301 - break;
302 - }
303 -
304 - if ( ! is_numeric( $current_value ) ) {
305 - continue;
306 - }
307 -
308 - $match = (int) $current_value === (int) $option_value;
309 -
310 - if ( $match ) {
311 - break;
312 - }
313 - }//end foreach
314 -
315 - if ( ! $match ) {
316 - return self::options_are_dynamic_based_on_hook( $field, $value );
317 - }
318 - }//end foreach
319 -
320 - return true;
321 - }
322 -
323 - /**
324 - * Make an extra check after passing $option_value through the_content filter.
325 - * This is to help catch cases where the option's formatting has been modified using
326 - * the_content filter.
327 - *
328 - * @since 6.22
329 - *
330 - * @param string $value
331 - * @param string $option_value
332 - *
333 - * @return bool
334 - */
335 - private static function is_filtered_match( $value, $option_value ) {
336 - // First remove the wpautop filter so it doesn't add extra tags to $option_value.
337 - $filter_priority = has_filter( 'the_content', 'wpautop' );
338 -
339 - if ( is_numeric( $filter_priority ) ) {
340 - remove_filter( 'the_content', 'wpautop', $filter_priority );
341 - }
342 -
343 - $filtered_option = apply_filters( 'the_content', $option_value );
344 -
345 - if ( is_numeric( $filter_priority ) ) {
346 - add_filter( 'the_content', 'wpautop', $filter_priority );
347 - }
348 -
349 - return trim( $value ) === trim( $filtered_option );
350 - }
351 -
352 - /**
353 - * Do not validate options if they have been modified with a hook.
354 - * This is to help avoid issues where the options could be based on a URL param for example.
355 - *
356 - * @since 6.21
357 - *
358 - * @param object $field_object The field object.
359 - * @param array|string $value The value to validate.
360 - *
361 - * @return bool
362 - */
363 - private static function options_are_dynamic_based_on_hook( $field_object, $value ) {
364 - $values = (array) $field_object;
365 - $values['value'] = $value;
366 - FrmFieldsHelper::prepare_new_front_field( $values, $field_object );
367 -
368 - $separate_value = FrmField::get_option( $field_object, 'separate_value' );
369 - $map_callback = function ( $option ) use ( $separate_value ) {
370 - if ( is_array( $option ) ) {
371 - $option_value = $separate_value ? $option['value'] : $option['label'];
372 - } else {
373 - $option_value = $option;
374 - }
375 - return do_shortcode( $option_value );
376 - };
377 -
378 - $values_options = array_map( $map_callback, $values['options'] );
379 - $field_object_options = array_map( $map_callback, $field_object->options );
380 -
381 - return $values_options !== $field_object_options;
382 - }
383 -
384 - /**
385 - * Maybe add item_name to $_POST to save it in items table.
386 - *
387 - * @since 5.2.02
388 - *
389 - * @param array|string $value Field value.
390 - * @param object $field Field object.
391 - *
392 - * @return void
393 - */
394 - private static function maybe_add_item_name( $value, $field ) {
395 - $item_name = false;
396 -
397 - if ( 'name' === $field->type ) {
398 - $field_obj = FrmFieldFactory::get_field_object( $field );
399 - $item_name = $field_obj->get_display_value( $value );
400 - } elseif ( 'text' === $field->type ) {
401 - $item_name = $value;
402 - }
403 -
404 - if ( false !== $item_name ) {
405 - // Item name has a max length of 255 characters so truncate it so it doesn't fail to save in the database.
406 - $_POST['item_name'] = substr( $item_name, 0, 255 );
407 - }
408 - }
409 -
410 - /**
411 117 * Set $value to an empty string if it matches its label
412 118 *
413 119 * @param object $field
414 120 * @param string $value
415 - *
416 - * @return void
417 121 */
418 122 private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
419 123 $position = FrmField::get_option( $field, 'label' );
420 -
421 124 if ( ! $position ) {
422 125 $position = FrmStylesController::get_style_val( 'position', $field->form_id );
423 126 }
424 127
@@ -426,16 +129,8 @@
426 129 $value = '';
427 130 }
428 131 }
429 132
430 - /**
431 - * @param array $errors
432 - * @param object $posted_field
433 - * @param mixed $value
434 - * @param array $args
435 - *
436 - * @return void
437 - */
438 133 public static function validate_field_types( &$errors, $posted_field, $value, $args ) {
439 134 $field_obj = FrmFieldFactory::get_field_object( $posted_field );
440 135 $args['value'] = $value;
441 136 $args['errors'] = $errors;
@@ -440,41 +135,24 @@
440 135 $args['value'] = $value;
441 136 $args['errors'] = $errors;
442 137
443 138 $new_errors = $field_obj->validate( $args );
444 -
445 - if ( $new_errors ) {
139 + if ( ! empty( $new_errors ) ) {
446 140 $errors = array_merge( $errors, $new_errors );
447 141 }
448 142 }
449 143
450 - /**
451 - * @param array $errors
452 - * @param object $field
453 - * @param string $value
454 - * @param array $args
455 - *
456 - * @return void
457 - */
458 144 public static function validate_phone_field( &$errors, $field, $value, $args ) {
459 - $format_value = FrmField::get_option( $field, 'format' );
145 + if ( $field->type == 'phone' || ( $field->type == 'text' && FrmField::is_option_true_in_object( $field, 'format' ) ) ) {
460 146
461 - if ( $field->type !== 'phone' && ( $field->type !== 'text' || ! $format_value || FrmCurrencyHelper::is_currency_format( $format_value ) ) ) {
462 - return;
463 - }
147 + $pattern = self::phone_format( $field );
464 148
465 - $pattern = self::phone_format( $field );
466 -
467 - if ( ! preg_match( $pattern, $value ) ) {
468 - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
149 + if ( ! preg_match( $pattern, $value ) ) {
150 + $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
151 + }
469 152 }
470 153 }
471 154
472 - /**
473 - * @param object $field
474 - *
475 - * @return string
476 - */
477 155 public static function phone_format( $field ) {
478 156 if ( FrmField::is_option_empty( $field, 'format' ) ) {
479 157 $pattern = self::default_phone_format();
480 158 } else {
@@ -480,25 +158,22 @@
480 158 } else {
481 159 $pattern = FrmField::get_option( $field, 'format' );
482 160 }
483 161
484 - // Ampersands are saved as &.
485 - // Reverse it here so we are checking for the correct character.
486 - $pattern = html_entity_decode( $pattern );
487 162 $pattern = apply_filters( 'frm_phone_pattern', $pattern, $field );
488 163
489 164 // Create a regexp if format is not already a regexp
490 - if ( ! str_starts_with( $pattern, '^' ) ) {
165 + if ( strpos( $pattern, '^' ) !== 0 ) {
491 166 $pattern = self::create_regular_expression_from_format( $pattern );
492 167 }
493 168
494 - return '/' . $pattern . '/';
169 + $pattern = '/' . $pattern . '/';
170 +
171 + return $pattern;
495 172 }
496 173
497 174 /**
498 175 * @since 3.01
499 - *
500 - * @return string
501 176 */
502 177 private static function default_phone_format() {
503 178 return '^((\+\d{1,3}(-|.| )?\(?\d\)?(-| |.)?\d{1,5})|(\(?\d{2,6}\)?))(-|.| )?(\d{3,4})(-|.| )?(\d{4})(( x| ext)\d{1,5}){0,1}$';
504 179 }
@@ -524,89 +199,52 @@
524 199 $pattern = str_replace( 'a', '[a-zA-Z]', $pattern );
525 200 $pattern = str_replace( '*', 'w', $pattern );
526 201 $pattern = str_replace( '/', '\/', $pattern );
527 202
528 - if ( str_contains( $pattern, '\?' ) ) {
203 + if ( strpos( $pattern, '\?' ) !== false ) {
529 204 $parts = explode( '\?', $pattern );
530 205 $pattern = '';
531 -
532 206 foreach ( $parts as $part ) {
533 - if ( $pattern ) {
207 + if ( empty( $pattern ) ) {
208 + $pattern .= $part;
209 + } else {
534 210 $pattern .= '(' . $part . ')?';
535 - } else {
536 - $pattern .= $part;
537 211 }
538 212 }
539 213 }
214 + $pattern = '^' . $pattern . '$';
540 215
541 - return '^' . $pattern . '$';
216 + return $pattern;
542 217 }
543 218
544 219 /**
545 - * Check for spam.
220 + * Check for spam
546 221 *
547 - * @param bool $exclude
222 + * @param boolean $exclude
548 223 * @param array $values
549 - * @param array $errors By reference.
550 - *
551 - * @return void
224 + * @param array $errors by reference
552 225 */
553 226 public static function spam_check( $exclude, $values, &$errors ) {
554 - if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
555 - // Do not check spam on importing.
227 + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
228 + // only check spam if there are no other errors
556 229 return;
557 230 }
558 231
559 - if ( $exclude || empty( $values['item_meta'] ) || $errors ) {
560 - // Only check spam if there are no other errors
561 - return;
562 - }
563 -
564 232 $antispam_check = self::is_antispam_check( $values['form_id'] );
565 - $spam_msg = FrmAntiSpamController::get_default_spam_message();
566 -
567 233 if ( is_string( $antispam_check ) ) {
568 234 $errors['spam'] = $antispam_check;
569 235 } elseif ( self::is_honeypot_spam( $values ) || self::is_spam_bot() ) {
570 - $errors['spam'] = $spam_msg;
571 - } else {
572 - $is_spam = FrmAntiSpamController::is_spam( $values );
573 -
574 - if ( $is_spam ) {
575 - $errors['spam'] = $is_spam;
576 - }
577 - }
578 -
579 - if ( isset( $errors['spam'] ) || self::form_is_in_progress( $values ) ) {
580 - return;
581 - }
582 -
583 - if ( self::is_akismet_enabled_for_user( $values['form_id'] ) && self::is_akismet_spam( $values ) ) {
584 236 $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
237 + } elseif ( self::blacklist_check( $values ) ) {
238 + $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' );
239 + } elseif ( self::is_akismet_spam( $values ) && self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
240 + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
585 241 }
586 242 }
587 243
588 244 /**
589 - * Checks if form is in progress.
590 - *
591 - * @since 5.0.13
592 - *
593 - * @param array $values The values.
594 - *
595 - * @return bool
596 - */
597 - private static function form_is_in_progress( $values ) {
598 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
599 - return FrmAppHelper::pro_is_installed() &&
600 - ( isset( $values[ 'frm_page_order_' . $values['form_id'] ] ) || FrmAppHelper::get_post_param( 'frm_next_page' ) ) &&
601 - FrmField::get_all_types_in_form( $values['form_id'], 'break' );
602 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
603 - }
604 -
605 - /**
606 245 * @param int $form_id
607 - *
608 - * @return bool|string
246 + * @return boolean
609 247 */
610 248 private static function is_antispam_check( $form_id ) {
611 249 $aspm = new FrmAntiSpam( $form_id );
612 250 return $aspm->validate();
@@ -613,10 +251,9 @@
613 251 }
614 252
615 253 /**
616 254 * @param array $values
617 - *
618 - * @return bool
255 + * @return boolean
619 256 */
620 257 private static function is_honeypot_spam( $values ) {
621 258 $honeypot = new FrmHoneypot( $values['form_id'] );
622 259 return ! $honeypot->validate();
@@ -622,101 +259,117 @@
622 259 return ! $honeypot->validate();
623 260 }
624 261
625 262 /**
626 - * @return bool
263 + * @return boolean
627 264 */
628 265 private static function is_spam_bot() {
629 - return ! FrmAppHelper::get_ip_address();
266 + $ip = FrmAppHelper::get_ip_address();
267 +
268 + return empty( $ip );
630 269 }
631 270
632 271 /**
633 272 * @param array $values
634 - *
635 - * @return bool
273 + * @return boolean
636 274 */
637 275 private static function is_akismet_spam( $values ) {
638 276 global $wpcom_api_key;
639 - return is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values );
277 +
278 + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
640 279 }
641 280
642 281 /**
643 282 * @param int $form_id
644 - *
645 283 * @return bool
646 284 */
647 285 private static function is_akismet_enabled_for_user( $form_id ) {
648 286 $form = FrmForm::getOne( $form_id );
649 - return ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() );
287 +
288 + return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() ) );
650 289 }
651 290
291 + public static function blacklist_check( $values ) {
292 + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
293 + return false;
294 + }
295 +
296 + $mod_keys = trim( self::get_disallowed_words() );
297 + if ( empty( $mod_keys ) ) {
298 + return false;
299 + }
300 +
301 + $content = FrmEntriesHelper::entry_array_to_string( $values );
302 + if ( empty( $content ) ) {
303 + return false;
304 + }
305 +
306 + $ip = FrmAppHelper::get_ip_address();
307 + $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
308 + $user_info = self::get_spam_check_user_info( $values );
309 +
310 + return self::check_disallowed_words( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
311 + }
312 +
652 313 /**
653 - * Checks spam using WordPress disallowed words and Frm denylist.
314 + * For WP 5.5 compatibility.
654 315 *
655 - * @param array $values Entry values.
316 + * @since 4.06.02
317 + */
318 + private static function check_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) {
319 + if ( function_exists( 'wp_check_comment_disallowed_list' ) ) {
320 + return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent );
321 + } else {
322 + return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent );
323 + }
324 + }
325 +
326 + /**
327 + * For WP 5.5 compatibility.
656 328 *
657 - * @return bool
329 + * @since 4.06.02
658 330 */
659 - public static function blacklist_check( $values ) {
660 - return FrmAntiSpamController::contains_wp_disallowed_words( $values ) || FrmAntiSpamController::is_denylist_spam( $values );
331 + private static function get_disallowed_words() {
332 + $keys = get_option( 'disallowed_keys' );
333 + if ( false === $keys ) {
334 + // Fallback for WP < 5.5.
335 + $keys = get_option( 'blacklist_keys' );
336 + }
337 + return $keys;
661 338 }
662 339
663 340 /**
664 341 * Check entries for Akismet spam
665 342 *
666 - * @param array $values Entry values.
667 - *
668 - * @return bool true if is spam
343 + * @return boolean true if is spam
669 344 */
670 345 public static function akismet( $values ) {
671 - if ( empty( $values['item_meta'] ) ) {
346 + $content = FrmEntriesHelper::entry_array_to_string( $values );
347 + if ( empty( $content ) ) {
672 348 return false;
673 349 }
674 350
675 351 $datas = array(
676 - 'comment_type' => 'formidable',
352 + 'comment_type' => 'formidable',
353 + 'comment_content' => $content,
677 354 );
678 355 self::parse_akismet_array( $datas, $values );
679 356
680 - /**
681 - * Allows modifying the values sent to Akismet.
682 - *
683 - * @since 5.0.07
684 - *
685 - * @param array $datas The array of values being sent to Akismet.
686 - */
687 - $datas = apply_filters( 'frm_akismet_values', $datas );
688 -
689 357 $query_string = _http_build_query( $datas, '', '&' );
690 358 $response = Akismet::http_post( $query_string, 'comment-check' );
691 359
692 - return is_array( $response ) && $response[1] === 'true';
360 + return ( is_array( $response ) && $response[1] == 'true' );
693 361 }
694 362
695 363 /**
696 364 * @since 2.0
697 - *
698 - * @param array $datas The array of values being sent to Akismet.
699 - * @param array $values Entry values.
700 - *
701 - * @return void
702 365 */
703 366 private static function parse_akismet_array( &$datas, $values ) {
704 367 self::add_site_info_to_akismet( $datas );
368 + self::add_user_info_to_akismet( $datas, $values );
705 369 self::add_server_values_to_akismet( $datas );
706 -
707 - self::prepare_values_for_spam_check( $values );
708 - self::skip_adding_values_to_akismet( $values );
709 -
710 - self::add_user_info_to_akismet( $datas, $values );
711 - self::add_comment_content_to_akismet( $datas, $values );
712 370 }
713 371
714 - /**
715 - * @param array $datas
716 - *
717 - * @return void
718 - */
719 372 private static function add_site_info_to_akismet( &$datas ) {
720 373 $datas['blog'] = FrmAppHelper::site_url();
721 374 $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
722 375 $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
@@ -728,14 +381,8 @@
728 381 $datas['is_test'] = 'true';
729 382 }
730 383 }
731 384
732 - /**
733 - * @param array $datas
734 - * @param array $values
735 - *
736 - * @return void
737 - */
738 385 private static function add_user_info_to_akismet( &$datas, $values ) {
739 386 $user_info = self::get_spam_check_user_info( $values );
740 387 $datas = $datas + $user_info;
741 388
@@ -743,196 +390,45 @@
743 390 $datas['user_role'] = Akismet::get_user_roles( $user_info['user_ID'] );
744 391 }
745 392 }
746 393
747 - /**
748 - * Gets user info for Akismet spam check.
749 - *
750 - * @since 5.0.13 Separate code for guest. Handle value of embedded|repeater.
751 - * @since 6.21 This changed from private to public.
752 - *
753 - * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}.
754 - *
755 - * @return array
756 - */
757 - public static function get_spam_check_user_info( $values ) {
758 - if ( ! is_user_logged_in() ) {
759 - return self::get_spam_check_user_info_for_guest( $values );
760 - }
394 + private static function get_spam_check_user_info( $values ) {
395 + $datas = array();
761 396
762 - $user = wp_get_current_user();
397 + if ( is_user_logged_in() ) {
398 + $user = wp_get_current_user();
763 399
764 - return array(
765 - 'user_ID' => $user->ID,
766 - 'user_id' => $user->ID,
767 - 'comment_author' => $user->display_name,
768 - 'comment_author_email' => $user->user_email,
769 - 'comment_author_url' => $user->user_url,
770 - );
771 - }
400 + $datas['user_ID'] = $user->ID;
401 + $datas['user_id'] = $user->ID;
402 + $datas['comment_author'] = $user->display_name;
403 + $datas['comment_author_email'] = $user->user_email;
404 + $datas['comment_author_url'] = $user->user_url;
405 + } else {
406 + $datas['comment_author'] = '';
407 + $datas['comment_author_email'] = '';
408 + $datas['comment_author_url'] = '';
772 409
773 - /**
774 - * Gets user info for Akismet spam check for guest.
775 - *
776 - * @since 5.0.13
777 - *
778 - * @param array $values Entry values after flattened.
779 - *
780 - * @return array
781 - */
782 - private static function get_spam_check_user_info_for_guest( $values ) {
783 - $datas = array(
784 - 'comment_author' => '',
785 - 'comment_author_email' => '',
786 - 'comment_author_url' => '',
787 - 'name_field_ids' => $values['name_field_ids'],
788 - 'missing_keys' => array( 'comment_author_email', 'comment_author_url', 'comment_author' ),
789 - 'frm_duplicated' => array(),
790 - );
791 -
792 - if ( isset( $values['item_meta'] ) ) {
793 - $values = $values['item_meta'];
794 - }
795 -
796 - $values = array_filter( $values );
797 -
798 - self::recursive_add_akismet_guest_info( $datas, $values );
799 - unset( $datas['name_field_ids'] );
800 - unset( $datas['missing_keys'] );
801 -
802 - return $datas;
803 - }
804 -
805 - /**
806 - * Recursive adds akismet guest info.
807 - *
808 - * @since 5.0.13
809 - *
810 - * @param array $datas Guest data.
811 - * @param array $values The values.
812 - * @param int|null $custom_index Custom index (or field ID).
813 - *
814 - * @return void
815 - */
816 - private static function recursive_add_akismet_guest_info( &$datas, $values, $custom_index = null ) {
817 - foreach ( $values as $index => $value ) {
818 - if ( ! $datas['missing_keys'] ) {
819 - // Found all info.
820 - return;
410 + if ( isset( $values['item_meta'] ) ) {
411 + $values = $values['item_meta'];
821 412 }
822 413
823 - if ( is_array( $value ) ) {
824 - self::recursive_add_akismet_guest_info( $datas, $value, $index );
825 - continue;
826 - }
827 -
828 - $field_id = ! is_null( $custom_index ) ? $custom_index : $index;
829 -
830 - foreach ( $datas['missing_keys'] as $key_index => $key ) {
831 - $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values );
832 -
833 - if ( ! $found ) {
834 - continue;
414 + $values = array_filter( $values );
415 + foreach ( $values as $value ) {
416 + if ( ! is_array( $value ) ) {
417 + if ( $datas['comment_author_email'] == '' && strpos( $value, '@' ) && is_email( $value ) ) {
418 + $datas['comment_author_email'] = $value;
419 + } elseif ( $datas['comment_author_url'] == '' && strpos( $value, 'http' ) === 0 ) {
420 + $datas['comment_author_url'] = $value;
421 + } elseif ( $datas['comment_author'] == '' && ! is_numeric( $value ) && strlen( $value ) < 200 ) {
422 + $datas['comment_author'] = $value;
423 + }
835 424 }
836 -
837 - $datas[ $key ] = $value;
838 - $datas['frm_duplicated'][] = $field_id;
839 - unset( $datas['missing_keys'][ $key_index ] );
840 425 }
841 - }//end foreach
842 - }
843 -
844 - /**
845 - * Checks if given value is an akismet guest info.
846 - *
847 - * @since 5.0.13
848 - *
849 - * @param string $key Guest info key.
850 - * @param string $value Value to check.
851 - * @param int $field_id Field ID.
852 - * @param array $name_field_ids Name field IDs.
853 - * @param array $values Array of posted values.
854 - *
855 - * @return bool
856 - */
857 - private static function is_akismet_guest_info_value( $key, &$value, $field_id, $name_field_ids, $values ) {
858 - if ( ! $value || is_numeric( $value ) ) {
859 - return false;
860 426 }
861 427
862 - switch ( $key ) {
863 - case 'comment_author_email':
864 - return str_contains( $value, '@' ) && is_email( $value );
865 -
866 - case 'comment_author_url':
867 - return str_starts_with( $value, 'http' );
868 -
869 - case 'comment_author':
870 - if ( $name_field_ids && in_array( $field_id, $name_field_ids, true ) ) {
871 - // If there is name field in the form, we should always use it as author name.
872 - return true;
873 - }
874 -
875 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
876 - $fields = self::get_name_text_fields( $form_id );
877 -
878 - foreach ( $fields as $index => $field ) {
879 - if ( 'Name' !== $field->name ) {
880 - continue;
881 - }
882 -
883 - if ( isset( $fields[ $index + 1 ] ) && 'Last' === $fields[ $index + 1 ]->name ) {
884 - if ( empty( $values[ absint( $fields[ $index + 1 ]->id ) ] ) ) {
885 - continue;
886 - }
887 -
888 - $value .= ' ' . $values[ $fields[ $index + 1 ]->id ];
889 - return true;
890 - }
891 - }
892 - }//end switch
893 -
894 - return false;
428 + return $datas;
895 429 }
896 430
897 - /**
898 - * Returns fields that have 'Name' and 'Last' as their name.
899 - *
900 - * @since 6.17
901 - *
902 - * @param int $form_id
903 - *
904 - * @return array
905 - */
906 - private static function get_name_text_fields( $form_id ) {
907 - $name_text_fields_is_initialized = is_array( self::$name_text_fields );
908 -
909 - if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[ $form_id ] ) ) {
910 - return self::$name_text_fields[ $form_id ];
911 - }
912 -
913 - if ( ! $name_text_fields_is_initialized ) {
914 - self::$name_text_fields = array();
915 - }
916 - self::$name_text_fields[ $form_id ] = FrmDb::get_results(
917 - 'frm_fields',
918 - array(
919 - 'form_id' => $form_id,
920 - 'type' => 'text',
921 - 'name' => array( 'Name', 'Last' ),
922 - ),
923 - 'id,name',
924 - array( 'order_by' => 'field_order ASC' )
925 - );
926 -
927 - return self::$name_text_fields[ $form_id ];
928 - }
929 -
930 - /**
931 - * @param array $datas
932 - *
933 - * @return void
934 - */
935 431 private static function add_server_values_to_akismet( &$datas ) {
936 432 foreach ( $_SERVER as $key => $value ) {
937 433 $include_value = is_string( $value ) && ! preg_match( '/^HTTP_COOKIE/', $key ) && preg_match( '/^(HTTP_|REMOTE_ADDR|REQUEST_URI|DOCUMENT_URI)/', $key );
938 434
@@ -944,215 +440,35 @@
944 440 }
945 441 }
946 442
947 443 /**
948 - * Adds comment content to Akismet data.
949 - *
950 - * @since 5.0.09
951 - *
952 - * @param array $datas The array of values being sent to Akismet.
953 - * @param array $values Entry values.
954 - *
955 - * @return void
444 + * @deprecated 3.0
445 + * @codeCoverageIgnore
956 446 */
957 - private static function add_comment_content_to_akismet( &$datas, $values ) {
958 - if ( isset( $datas['frm_duplicated'] ) ) {
959 - foreach ( $datas['frm_duplicated'] as $index ) {
960 - if ( isset( $values['item_meta'][ $index ] ) ) {
961 - unset( $values['item_meta'][ $index ] );
962 - } else {
963 - unset( $values[ $index ] );
964 - }
965 - }
966 - unset( $datas['frm_duplicated'] );
967 - }
968 -
969 - $datas['comment_content'] = FrmEntriesHelper::entry_array_to_string( $values );
447 + public static function validate_url_field( &$errors, $field, $value, $args ) {
448 + FrmDeprecated::validate_url_field( $errors, $field, $value, $args );
970 449 }
971 450
972 451 /**
973 - * Skips adding field values to Akismet.
974 - *
975 - * @since 5.0.09
976 - *
977 - * @param array $values Entry values.
978 - *
979 - * @return void
452 + * @deprecated 3.0
453 + * @codeCoverageIgnore
980 454 */
981 - private static function skip_adding_values_to_akismet( &$values ) {
982 - $skipped_fields = self::get_akismet_skipped_field_ids( $values );
983 -
984 - foreach ( $skipped_fields as $skipped_field ) {
985 - if ( ! isset( $values['item_meta'][ $skipped_field->id ] ) ) {
986 - continue;
987 - }
988 -
989 - if ( ! self::should_really_skip_field( $skipped_field, $values ) ) {
990 - continue;
991 - }
992 -
993 - unset( $values['item_meta'][ $skipped_field->id ] );
994 -
995 - if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) {
996 - unset( $values['item_meta']['other'][ $skipped_field->id ] );
997 - }
998 - }
455 + public static function validate_email_field( &$errors, $field, $value, $args ) {
456 + FrmDeprecated::validate_email_field( $errors, $field, $value, $args );
999 457 }
1000 458
1001 459 /**
1002 - * Checks if a skip field should be really skipped.
1003 - *
1004 - * @since 5.02.04
1005 - *
1006 - * @param object $field_data Object contains `id` and `options`.
1007 - * @param array $values Entry values.
1008 - *
1009 - * @return bool
460 + * @deprecated 3.0
461 + * @codeCoverageIgnore
1010 462 */
1011 - private static function should_really_skip_field( $field_data, $values ) {
1012 - if ( empty( $field_data->options ) ) {
1013 - // This is skipped field types.
1014 - return true;
1015 - }
1016 -
1017 - FrmAppHelper::unserialize_or_decode( $field_data->options );
1018 -
1019 - if ( ! $field_data->options ) {
1020 - // Check if an error happens when unserializing, or empty options.
1021 - return true;
1022 - }
1023 -
1024 - $last_key = array_key_last( $field_data->options );
1025 -
1026 - // If a choice field has no Other option.
1027 - if ( is_numeric( $last_key ) || ! str_starts_with( $last_key, 'other_' ) ) {
1028 - return true;
1029 - }
1030 -
1031 - // If a choice field has Other option, but Other is not selected.
1032 - if ( empty( $values['item_meta']['other'][ $field_data->id ] ) ) {
1033 - return true;
1034 - }
1035 -
1036 - // Check if submitted value is same as one of field option.
1037 - foreach ( $field_data->options as $option ) {
1038 - $option_value = is_array( $option ) ? ( $option['value'] ?? '' ) : $option;
1039 -
1040 - if ( $values['item_meta']['other'][ $field_data->id ] === $option_value ) {
1041 - return true;
1042 - }
1043 - }
1044 -
1045 - return false;
463 + public static function validate_number_field( &$errors, $field, $value, $args ) {
464 + FrmDeprecated::validate_number_field( $errors, $field, $value, $args );
1046 465 }
1047 466
1048 467 /**
1049 - * Gets field IDs that are skipped from sending to Akismet spam check.
1050 - *
1051 - * @since 5.0.09
1052 - * @since 5.0.13 Move out get_all_form_ids_and_flatten_meta() call and get `form_ids` from `$values`.
1053 - * @since 5.2.04 This method returns array of object contains `id` and `options` instead of array of `id` only.
1054 - *
1055 - * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}.
1056 - *
1057 - * @return array
468 + * @deprecated 3.0
469 + * @codeCoverageIgnore
1058 470 */
1059 - private static function get_akismet_skipped_field_ids( $values ) {
1060 - if ( empty( $values['form_ids'] ) ) {
1061 - return array();
1062 - }
1063 -
1064 - $skipped_types = array( 'divider', 'form', 'hidden', 'user_id', 'file', 'date', 'time', 'scale', 'star', 'range', 'toggle', 'data', 'lookup', 'likert', 'nps' );
1065 - $has_other_types = array( 'radio', 'checkbox', 'select' );
1066 -
1067 - $where = array(
1068 - array(
1069 - 'form_id' => $values['form_ids'],
1070 - 'type' => array_merge( $skipped_types, $has_other_types ),
1071 - ),
1072 - );
1073 -
1074 - return FrmDb::get_results( 'frm_fields', $where, 'id,options' );
1075 - }
1076 -
1077 - /**
1078 - * Prepares values array for spam check.
1079 - *
1080 - * @since 5.0.13
1081 - * @since 6.21 This changed from private to public.
1082 - *
1083 - * @param array $values Entry values.
1084 - *
1085 - * @return void
1086 - */
1087 - public static function prepare_values_for_spam_check( &$values ) {
1088 - $values['form_ids'] = self::get_all_form_ids_and_flatten_meta( $values );
1089 - }
1090 -
1091 - /**
1092 - * Gets all form IDs (include child form IDs) and flatten item_meta array. Used for skipping values sent to Akismet.
1093 - * This also removes some unused data from the item_meta.
1094 - *
1095 - * @since 5.0.09
1096 - * @since 5.0.13 Convert name field value to string.
1097 - *
1098 - * @param array $values Entry values.
1099 - *
1100 - * @return array Form IDs.
1101 - */
1102 - private static function get_all_form_ids_and_flatten_meta( &$values ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
1103 - $values['name_field_ids'] = array();
1104 -
1105 - // Blacklist check for File field in the old version doesn't contain `form_id`.
1106 - $form_ids = isset( $values['form_id'] ) ? array( absint( $values['form_id'] ) ) : array();
1107 -
1108 - foreach ( $values['item_meta'] as $field_id => $value ) {
1109 - if ( ! is_numeric( $field_id ) ) {
1110 - // Maybe `other`.
1111 - continue;
1112 - }
1113 -
1114 - // Convert name array to string.
1115 - if ( isset( $value['first'] ) && isset( $value['last'] ) ) {
1116 - $values['item_meta'][ $field_id ] = trim( implode( ' ', $value ) );
1117 - $values['name_field_ids'][] = $field_id;
1118 - continue;
1119 - }
1120 -
1121 - if ( ! is_array( $value ) || empty( $value['form'] ) ) {
1122 - continue;
1123 - }
1124 -
1125 - $form_ids[] = absint( $value['form'] );
1126 -
1127 - foreach ( $value as $subindex => $subvalue ) {
1128 - if ( ! is_numeric( $subindex ) || ! is_array( $subvalue ) ) {
1129 - continue;
1130 - }
1131 -
1132 - foreach ( $subvalue as $subsubindex => $subsubvalue ) {
1133 - if ( ! $subsubvalue ) {
1134 - continue;
1135 - }
1136 -
1137 - if ( ! isset( $values['item_meta'][ $subsubindex ] ) ) {
1138 - $values['item_meta'][ $subsubindex ] = array();
1139 - }
1140 -
1141 - // Convert name array to string.
1142 - if ( isset( $subsubvalue['first'] ) && isset( $subsubvalue['last'] ) ) {
1143 - $subsubvalue = trim( implode( ' ', $subsubvalue ) );
1144 - $values['name_field_ids'][] = $subsubindex;
1145 - }
1146 -
1147 - if ( is_array( $values['item_meta'][ $subsubindex ] ) ) {
1148 - $values['item_meta'][ $subsubindex ][] = $subsubvalue;
1149 - }
1150 - }
1151 - }//end foreach
1152 -
1153 - unset( $values['item_meta'][ $field_id ] );
1154 - }//end foreach
1155 -
1156 - return $form_ids;
471 + public static function validate_recaptcha( &$errors, $field, $args ) {
472 + FrmDeprecated::validate_recaptcha( $errors, $field, $args );
1157 473 }
1158 474 }