/var/www/hkosl.com/aga/wp-content/plugins/contact-form-7/includes/functions.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<?php

function wpcf7_plugin_path$path '' ) {
    return 
path_joinWPCF7_PLUGIN_DIRtrim$path'/' ) );
}

function 
wpcf7_plugin_url$path '' ) {
    
$url plugins_url$pathWPCF7_PLUGIN );

    if ( 
is_ssl()
    and 
'http:' == substr$url0) ) {
        
$url 'https:' substr$url);
    }

    return 
$url;
}

function 
wpcf7_upload_dir$type false ) {
    
$uploads wp_get_upload_dir();

    
$uploads apply_filters'wpcf7_upload_dir', array(
        
'dir' => $uploads['basedir'],
        
'url' => $uploads['baseurl'],
    ) );

    if ( 
'dir' == $type ) {
        return 
$uploads['dir'];
    } if ( 
'url' == $type ) {
        return 
$uploads['url'];
    }

    return 
$uploads;
}

function 
wpcf7_verify_nonce$nonce$action 'wp_rest' ) {
    return 
wp_verify_nonce$nonce$action );
}

function 
wpcf7_create_nonce$action 'wp_rest' ) {
    return 
wp_create_nonce$action );
}

function 
wpcf7_blacklist_check$target ) {
    
$mod_keys trimget_option'blacklist_keys' ) );

    if ( empty( 
$mod_keys ) ) {
        return 
false;
    }

    
$words explode"\n"$mod_keys );

    foreach ( (array) 
$words as $word ) {
        
$word trim$word );

        if ( empty( 
$word )
        or 
256 strlen$word ) ) {
            continue;
        }

        
$pattern sprintf'#%s#i'preg_quote$word'#' ) );

        if ( 
preg_match$pattern$target ) ) {
            return 
true;
        }
    }

    return 
false;
}

function 
wpcf7_array_flatten$input ) {
    if ( ! 
is_array$input ) ) {
        return array( 
$input );
    }

    
$output = array();

    foreach ( 
$input as $value ) {
        
$output array_merge$outputwpcf7_array_flatten$value ) );
    }

    return 
$output;
}

function 
wpcf7_flat_join$input ) {
    
$input wpcf7_array_flatten$input );
    
$output = array();

    foreach ( (array) 
$input as $value ) {
        
$output[] = trim( (string) $value );
    }

    return 
implode', '$output );
}

function 
wpcf7_support_html5() {
    return (bool) 
apply_filters'wpcf7_support_html5'true );
}

function 
wpcf7_support_html5_fallback() {
    return (bool) 
apply_filters'wpcf7_support_html5_fallback'false );
}

function 
wpcf7_use_really_simple_captcha() {
    return 
apply_filters'wpcf7_use_really_simple_captcha',
        
WPCF7_USE_REALLY_SIMPLE_CAPTCHA );
}

function 
wpcf7_validate_configuration() {
    return 
apply_filters'wpcf7_validate_configuration',
        
WPCF7_VALIDATE_CONFIGURATION );
}

function 
wpcf7_autop_or_not() {
    return (bool) 
apply_filters'wpcf7_autop_or_not'WPCF7_AUTOP );
}

function 
wpcf7_load_js() {
    return 
apply_filters'wpcf7_load_js'WPCF7_LOAD_JS );
}

function 
wpcf7_load_css() {
    return 
apply_filters'wpcf7_load_css'WPCF7_LOAD_CSS );
}

function 
wpcf7_format_atts$atts ) {
    
$html '';

    
$prioritized_atts = array( 'type''name''value' );

    foreach ( 
$prioritized_atts as $att ) {
        if ( isset( 
$atts[$att] ) ) {
            
$value trim$atts[$att] );
            
$html .= sprintf' %s="%s"'$attesc_attr$value ) );
            unset( 
$atts[$att] );
        }
    }

    foreach ( 
$atts as $key => $value ) {
        
$key strtolowertrim$key ) );

        if ( ! 
preg_match'/^[a-z_:][a-z_:.0-9-]*$/'$key ) ) {
            continue;
        }

        
$value trim$value );

        if ( 
'' !== $value ) {
            
$html .= sprintf' %s="%s"'$keyesc_attr$value ) );
        }
    }

    
$html trim$html );

    return 
$html;
}

function 
wpcf7_link$url$anchor_text$args '' ) {
    
$defaults = array(
        
'id' => '',
        
'class' => '',
    );

    
$args wp_parse_args$args$defaults );
    
$args array_intersect_key$args$defaults );
    
$atts wpcf7_format_atts$args );

    
$link sprintf'<a href="%1$s"%3$s>%2$s</a>',
        
esc_url$url ),
        
esc_html$anchor_text ),
        
$atts ? ( ' ' $atts ) : '' );

    return 
$link;
}

function 
wpcf7_get_request_uri() {
    static 
$request_uri '';

    if ( empty( 
$request_uri ) ) {
        
$request_uri add_query_arg( array() );
    }

    return 
esc_url_raw$request_uri );
}

function 
wpcf7_register_post_types() {
    if ( 
class_exists'WPCF7_ContactForm' ) ) {
        
WPCF7_ContactForm::register_post_type();
        return 
true;
    } else {
        return 
false;
    }
}

function 
wpcf7_version$args '' ) {
    
$defaults = array(
        
'limit' => -1,
        
'only_major' => false,
    );

    
$args wp_parse_args$args$defaults );

    if ( 
$args['only_major'] ) {
        
$args['limit'] = 2;
    }

    
$args['limit'] = (int) $args['limit'];

    
$ver WPCF7_VERSION;
    
$ver strtr$ver'_-+''...' );
    
$ver preg_replace'/[^0-9.]+/'".$0."$ver );
    
$ver preg_replace'/[.]+/'"."$ver );
    
$ver trim$ver'.' );
    
$ver explode'.'$ver );

    if ( -
$args['limit'] ) {
        
$ver array_slice$ver0$args['limit'] );
    }

    
$ver implode'.'$ver );

    return 
$ver;
}

function 
wpcf7_version_grep$version, array $input ) {
    
$pattern '/^' preg_quote( (string) $version'/' ) . '(?:\.|$)/';

    return 
preg_grep$pattern$input );
}

function 
wpcf7_enctype_value$enctype ) {
    
$enctype trim$enctype );

    if ( empty( 
$enctype ) ) {
        return 
'';
    }

    
$valid_enctypes = array(
        
'application/x-www-form-urlencoded',
        
'multipart/form-data',
        
'text/plain',
    );

    if ( 
in_array$enctype$valid_enctypes ) ) {
        return 
$enctype;
    }

    
$pattern '%^enctype="(' implode'|'$valid_enctypes ) . ')"$%';

    if ( 
preg_match$pattern$enctype$matches ) ) {
        return 
$matches[1]; // for back-compat
    
}

    return 
'';
}

function 
wpcf7_rmdir_p$dir ) {
    if ( 
is_file$dir ) ) {
        
$file $dir;

        if ( @
unlink$file ) ) {
            return 
true;
        }

        
$stat stat$file );

        if ( @
chmod$file$stat['mode'] | 0200 ) ) { // add write for owner
            
if ( @unlink$file ) ) {
                return 
true;
            }

            @
chmod$file$stat['mode'] );
        }

        return 
false;
    }

    if ( ! 
is_dir$dir ) ) {
        return 
false;
    }

    if ( 
$handle opendir$dir ) ) {
        while ( 
false !== ( $file readdir$handle ) ) ) {
            if ( 
$file == "."
            
or $file == ".." ) {
                continue;
            }

            
wpcf7_rmdir_ppath_join$dir$file ) );
        }

        
closedir$handle );
    }

    if ( 
false !== ( $files scandir$dir ) )
    and ! 
array_diff$files, array( '.''..' ) ) ) {
        return 
rmdir$dir );
    }

    return 
false;
}

/* From _http_build_query in wp-includes/functions.php */
function wpcf7_build_query$args$key '' ) {
    
$sep '&';
    
$ret = array();

    foreach ( (array) 
$args as $k => $v ) {
        
$k urlencode$k );

        if ( ! empty( 
$key ) ) {
            
$k $key '%5B' $k '%5D';
        }

        if ( 
null === $v ) {
            continue;
        } elseif ( 
false === $v ) {
            
$v '0';
        }

        if ( 
is_array$v ) or is_object$v ) ) {
            
array_push$retwpcf7_build_query$v$k ) );
        } else {
            
array_push$ret$k '=' urlencode$v ) );
        }
    }

    return 
implode$sep$ret );
}

/**
 * Returns the number of code units in a string.
 *
 * @see http://www.w3.org/TR/html5/infrastructure.html#code-unit-length
 *
 * @return int|bool The number of code units, or false if mb_convert_encoding is not available.
 */
function wpcf7_count_code_units$string ) {
    static 
$use_mb null;

    if ( 
is_null$use_mb ) ) {
        
$use_mb function_exists'mb_convert_encoding' );
    }

    if ( ! 
$use_mb ) {
        return 
false;
    }

    
$string = (string) $string;
    
$string str_replace"\r\n""\n"$string );

    
$encoding mb_detect_encoding$stringmb_detect_order(), true );

    if ( 
$encoding ) {
        
$string mb_convert_encoding$string'UTF-16'$encoding );
    } else {
        
$string mb_convert_encoding$string'UTF-16''UTF-8' );
    }

    
$byte_count mb_strlen$string'8bit' );

    return 
floor$byte_count );
}

function 
wpcf7_is_localhost() {
    
$server_name strtolower$_SERVER['SERVER_NAME'] );
    return 
in_array$server_name, array( 'localhost''127.0.0.1' ) );
}

function 
wpcf7_deprecated_function$function$version$replacement ) {
    
$trigger_error apply_filters'deprecated_function_trigger_error'true );

    if ( 
WP_DEBUG and $trigger_error ) {
        if ( 
function_exists'__' ) ) {
            
trigger_errorsprintf__'%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.''contact-form-7' ), $function$version$replacement ) );
        } else {
            
trigger_errorsprintf'%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.'$function$version$replacement ) );
        }
    }
}

function 
wpcf7_log_remote_request$url$request$response ) {
    
$log sprintf(
        
/* translators: 1: response code, 2: message, 3: body, 4: URL */
        
__'HTTP Response: %1$s %2$s %3$s from %4$s''contact-form-7' ),
        (int) 
wp_remote_retrieve_response_code$response ),
        
wp_remote_retrieve_response_message$response ),
        
wp_remote_retrieve_body$response ),
        
$url
    
);

    
$log apply_filters'wpcf7_log_remote_request',
        
$log$url$request$response
    
);

    if ( 
$log ) {
        
trigger_error$log );
    }
}

function 
wpcf7_anonymize_ip_addr$ip_addr ) {
    if ( ! 
function_exists'inet_ntop' )
    or ! 
function_exists'inet_pton' ) ) {
        return 
$ip_addr;
    }

    
$packed inet_pton$ip_addr );

    if ( 
false === $packed ) {
        return 
$ip_addr;
    }

    if ( 
== strlen$packed ) ) { // IPv4
        
$mask '255.255.255.0';
    } elseif ( 
16 == strlen$packed ) ) { // IPv6
        
$mask 'ffff:ffff:ffff:0000:0000:0000:0000:0000';
    } else {
        return 
$ip_addr;
    }

    return 
inet_ntop$packed inet_pton$mask ) );
}

function 
wpcf7_is_file_path_in_content_dir$path ) {
    if ( 
=== strposrealpath$path ), realpathWP_CONTENT_DIR ) ) ) {
        return 
true;
    }

    if ( 
defined'UPLOADS' )
    and 
=== strposrealpath$path ), realpathABSPATH UPLOADS ) ) ) {
        return 
true;
    }

    return 
false;
}