Make WordPress Core


Ignore:
Timestamp:
02/01/2009 09:45:24 AM (16 years ago)
Author:
azaozz
Message:

Detect when the server compresses output, see #8628

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/load-scripts.php

    r10466 r10476  
    8686}
    8787
    88 // Discard any buffers
    89 while ( @ob_end_clean() );
    90 
    91 if ( isset($_GET['test']) && 1 == $_GET['test'] ) {
    92     if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') )
    93         exit('');
    94 
    95     $out = 'var wpCompressionTest = 1;';
    96     $force_gzip = ( isset($_GET['c']) && 'gzip' == $_GET['c'] );
    97 
    98     if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    99         header('Content-Encoding: deflate');
    100         $out = gzdeflate( $out, 3 );
    101     } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
    102         header('Content-Encoding: gzip');
    103         $out = gzencode( $out, 3 );
    104     } else {
    105         exit('');
    106     }
    107 
    108     header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
    109     header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
    110     header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
    111     header( 'Pragma: no-cache' );
    112     header( 'Content-Type: application/x-javascript; charset=UTF-8' );
    113     echo $out;
    114     exit;
    115 }
    116 
    117 $load = preg_replace( '/[^a-z0-9,_-]*/i', '', $_GET['load'] );
     88$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
    11889$load = explode(',', $load);
    11990
     
    143114header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
    144115header("Cache-Control: public, max-age=$expires_offset");
    145    
     116
    146117if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') ) {
    147118    header('Vary: Accept-Encoding'); // Handle proxies
Note: See TracChangeset for help on using the changeset viewer.