/** * Convert cookie name and value back to header string. * * @access public * @since 2.8.0 * * @return string Header encoded cookie name and value. */ function getHeaderValue() { if (empty($this->name) || empty($this->value)) { return ''; } return $this->name . '=' . EasyHttp::applyFilters('wp_http_cookie_value', $this->value, $this->name); }
/** * Whether this class can be used for retrieving an URL. * * @since 2.7.0 * @static * @return boolean False means this class can not be used, true means it can. */ public static function test($args = array()) { if (!function_exists('fsockopen')) { return false; } //不支持这个自动disable的功能 //if ( false !== ($option = EasyHttp::getOption( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours // return false; $is_ssl = isset($args['ssl']) && $args['ssl']; if ($is_ssl && !extension_loaded('openssl')) { return false; } return EasyHttp::applyFilters('use_fsockopen_transport', true, $args); }
/** * Whether this class can be used for retrieving an URL. * * @static * @since 2.7.0 * * @return boolean False means this class can not be used, true means it can. */ public static function test($args = array()) { if (!function_exists('curl_init') || !function_exists('curl_exec')) { return false; } $is_ssl = isset($args['ssl']) && $args['ssl']; if ($is_ssl) { $curl_version = curl_version(); if (!(CURL_VERSION_SSL & $curl_version['features'])) { // Does this cURL version support SSL requests? return false; } } return EasyHttp::applyFilters('use_curl_transport', true, $args); }
/** * Block requests through the proxy. * * Those who are behind a proxy and want to prevent access to certain hosts may do so. This will * prevent plugins from working and core functionality, if you don't include api.wordpress.org. * * You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php * file and this will only allow localhost and your blog to make requests. The constant * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. * * @since 2.8.0 * @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS * * @param string $uri URI of url. * @return bool True to block, false to allow. */ function block_request($uri) { // We don't need to block requests, because nothing is blocked. if (!isset(self::$blockExternal) || !self::$blockExternal) { return false; } // parse_url() only handles http, https type URLs, and will emit E_WARNING on failure. // This will be displayed on blogs, which is not reasonable. $check = @parse_url($uri); /* Malformed URL, can not process, but this could mean ssl, so let through anyway. * * This isn't very security sound. There are instances where a hacker might attempt * to bypass the proxy and this check. However, the reason for this behavior is that * WordPress does not do any checking currently for non-proxy requests, so it is keeps with * the default unsecure nature of the HTTP request. */ if ($check === false) { return false; } $home = parse_url(EasyHttp::getOption('siteurl')); // Don't block requests back to ourselves by default if ($check['host'] == 'localhost' || $check['host'] == $home['host']) { return EasyHttp::applyFilters('block_local_requests', false); } if (!isset(self::$accessibleHosts)) { return true; } static $accessible_hosts; static $wildcard_regex = false; if (null == $accessible_hosts) { $accessible_hosts = preg_split('|,\\s*|', self::$accessibleHosts); if (false !== strpos(self::$accessibleHosts, '*')) { $wildcard_regex = array(); foreach ($accessible_hosts as $host) { $wildcard_regex[] = str_replace('\\*', '[\\w.]+?', preg_quote($host, '/')); } $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; } } if (!empty($wildcard_regex)) { return !preg_match($wildcard_regex, $check['host']); } else { return !in_array($check['host'], $accessible_hosts); } //Inverse logic, If its in the array, then we can't access it. }
/** * Whether this class can be used for retrieving an URL. * * @static * @access public * @since 2.7.0 * * @return boolean False means this class can not be used, true means it can. */ public static function test($args = array()) { if (!function_exists('fopen')) { return false; } if (!function_exists('ini_get') || true != ini_get('allow_url_fopen')) { return false; } $is_ssl = isset($args['ssl']) && $args['ssl']; if ($is_ssl && !extension_loaded('openssl')) { return false; } return EasyHttp::applyFilters('use_streams_transport', true, $args); }