$/', $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; } /** * Verifies that a given file path is under the directories that WordPress * manages for user contents. * * Returns false if the file at the given path doesn't exist yet. * * @param string $path A file path. * @return bool True if the path is under the content directories, * false otherwise. */ function wpcf7_is_file_path_in_content_dir( $path ) { if ( $real_path = realpath( $path ) ) { $path = $real_path; } else { return false; } if ( 0 === strpos( $path, realpath( WP_CONTENT_DIR ) ) ) { return true; } if ( defined( 'UPLOADS' ) and 0 === strpos( $path, realpath( ABSPATH . UPLOADS ) ) ) { return true; } return false; }