解析错误:语法错误,第1137行/wp-includes/class-http.php中的意外$结束

时间:2014-10-21 21:58:04

标签: php wordpress

所以我已经梳理了论坛,似乎我很可能有一个支架或缺少的东西。

这是我的wordpress网站。如果这有任何区别,它实际上是一个多站点。

有趣的是我之前已经修复了这个问题,只需用最新的Wordpress下载替换这个class-http.php文件。但是在这里我大约一个半星期后再次发生同样的错误,所以也许还有别的东西让人知道呢?

---Line 1137是最重要的代码 - 我的未经训练的眼睛似乎已经错过了一些东西。但更重要的是,什么在以后剥夺了这一点?

另外,我刚查看了全新的class-http.php文件,它似乎有2174行,而不是1137。我想知道也许是一个插件?或者什么可以不断弃用这个文件?

            fclose( $stream_handle );
        } else {
            $header_length = 0;
            while ( ! feof( $handle ) && $keep_reading ) {
                $block = fread( $handle, $block_size );
                $strResponse .= $block;
                if ( ! $bodyStarted && strpos( $strResponse, "\r\n\r\n" ) ) {
                    $header_length = strpos( $strResponse, "\r\n\r\n" ) + 4;
                    $bodyStarted = true;
                }
                $keep_reading = ( ! $bodyStarted || !isset( $r['limit_response_size'] ) || strlen( $strResponse ) < ( $header_length + $r['limit_response_size'] ) );
            }

            $process = WP_Http::processResponse( $strResponse );
            unset( $strResponse );

        }

        fclose( $handle );

        $arrHeaders = WP_Http::processHeaders( $process['headers'], $url );

        $response = array(
            'headers' => $arrHeaders['headers'],
            // Not yet processed.
            'body' => null,
            'response' => $arrHeaders['response'],
            'cookies' => $arrHeaders['cookies'],
            'filename' => $r['filename']
        );

        // Handle redirects.
        if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) )
            return $redirect_response;

        // If the body was chunk encoded, then decode it.
        if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] )
            $process['body'] = WP_Http::chunkTransferDecode($process['body']);

        if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) )
            $process['body'] = WP_Http_Encoding::decompress( $process['body'] );

        if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] )
            $process['body'] = substr( $process['body'], 0, $r['limit_response_size'] );

        $response['body'] = $process['body'];

        return $response;
    }

    /**
     * Verifies the received SSL certificate against it's Common Names and subjectAltName fields
     *
     * PHP's SSL verifications only verify that it's a valid Certificate, it doesn't verify if
     * the certificate is valid for the hostname which was requested.
     * This function verifies the requested hostname against certificate's subjectAltName field,
     * if that is empty, or contains no DNS entries, a fallback to the Common Name field is used.
     *
     * IP Address support is included if the request is being made to an IP address.
     *
     * @since 3.7.0
     * @static
     *
     * @param stream $stream The PHP Stream which the SSL request is being made over
     * @param string $host The hostname being requested
     * @return bool If the cerficiate presented in $stream is valid for $host
     */
    public static function verify_ssl_certificate( $stream, $host ) {
        $context_options = stream_context_get_options( $stream );

        if ( empty( $context_options['ssl']['peer_certificate'] ) )
            return false;

        $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] );
        if ( ! $cert )
            return false;

        /*
         * If the request is being made to an IP address, we'll validate against IP fields
         * in the cert (if they exist)
         */
        $host_type = ( WP_HTTP::is_ip_address( $host ) ? 'ip' : 'dns' );

        $certificate_hostnames = array();
        if ( ! empty( $cert['extensions']['subjectAltName'] ) ) {
            $match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] );
            foreach ( $match_against as $match ) {
                list( $match_type, $match_host ) = explode( ':', $match );
                if ( $host_type == strtolower( trim( $match_type ) ) ) // IP: or DNS:
                    $certificate_hostnames[] = strtolower( trim( $match_host ) );
            }
        } elseif ( !empty( $cert['subject']['CN'] ) ) {
            // Only use the CN when the certificate includes no subjectAltName extension.
            $certificate_hostnames[] = strtolower( $cert['subject']['CN'] );
        }

        // Exact hostname/IP matches.
        if ( in_array( strtolower( $host ), $certificat

0 个答案:

没有答案