Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-files.php

    r38662 r42343  
    1212require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    1313
    14 if ( !is_multisite() )
     14if ( ! is_multisite() ) {
    1515        die( 'Multisite support not enabled' );
     16}
    1617
    1718ms_file_constants();
     
    2425}
    2526
    26 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
    27 if ( !is_file( $file ) ) {
     27$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] );
     28if ( ! is_file( $file ) ) {
    2829        status_header( 404 );
    2930        die( '404 — File not found.' );
     
    3132
    3233$mime = wp_check_filetype( $file );
    33 if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
    34         $mime[ 'type' ] = mime_content_type( $file );
     34if ( false === $mime['type'] && function_exists( 'mime_content_type' ) ) {
     35        $mime['type'] = mime_content_type( $file );
     36}
    3537
    36 if ( $mime[ 'type' ] )
    37         $mimetype = $mime[ 'type' ];
    38 else
     38if ( $mime['type'] ) {
     39        $mimetype = $mime['type'];
     40} else {
    3941        $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
     42}
    4043
    4144header( 'Content-Type: ' . $mimetype ); // always send this
    42 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
     45if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) {
    4346        header( 'Content-Length: ' . filesize( $file ) );
     47}
    4448
    4549// Optional support for X-Sendfile and X-Accel-Redirect
     
    5357
    5458$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
    55 $etag = '"' . md5( $last_modified ) . '"';
     59$etag          = '"' . md5( $last_modified ) . '"';
    5660header( "Last-Modified: $last_modified GMT" );
    5761header( 'ETag: ' . $etag );
     
    6165$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
    6266
    63 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
     67if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
    6468        $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
     69}
    6570
    6671$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
     
    6974
    7075// Make a timestamp for our most recent modification...
    71 $modified_timestamp = strtotime($last_modified);
     76$modified_timestamp = strtotime( $last_modified );
    7277
    7378if ( ( $client_last_modified && $client_etag )
    74         ? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
    75         : ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
     79        ? ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) )
     80        : ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) )
    7681        ) {
    7782        status_header( 304 );
Note: See TracChangeset for help on using the changeset viewer.