| 1 |
<?php exit; |
| 2 |
|
| 3 |
//Check everything exists before using it |
| 4 |
if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
| 5 |
$_SERVER['HTTP_ACCEPT_ENCODING'] = ''; |
| 6 |
if(!isset($_SERVER['HTTP_USER_AGENT'])) |
| 7 |
$_SERVER['HTTP_USER_AGENT'] = ''; |
| 8 |
|
| 9 |
// Determine supported compression method |
| 10 |
$gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
| 11 |
$deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate'); |
| 12 |
|
| 13 |
// Determine used compression method |
| 14 |
$encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none'); |
| 15 |
|
| 16 |
// Check for buggy versions of Internet Explorer |
| 17 |
if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && |
| 18 |
preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) |
| 19 |
{ |
| 20 |
$version = floatval($matches[1]); |
| 21 |
|
| 22 |
if ($version < 6) |
| 23 |
$encoding = 'none'; |
| 24 |
|
| 25 |
if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) |
| 26 |
$encoding = 'none'; |
| 27 |
} |
| 28 |
|
| 29 |
//Some servers compress the output of PHP - Don't break in those cases |
| 30 |
if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) |
| 31 |
$encoding = 'none'; |
| 32 |
|
| 33 |
//Get data |
| 34 |
$contents = file_get_contents(__FILE__.'.'.$encoding); |
| 35 |
|
| 36 |
if(isset($encoding) && $encoding != 'none') |
| 37 |
{ |
| 38 |
// Send compressed contents |
| 39 |
header('Content-Encoding: '.$encoding); |
| 40 |
} |
| 41 |
header('Vary: Accept-Encoding'); |
| 42 |
header('Content-Length: '.strlen($contents)); |
| 43 |
|
| 44 |
header('Content-type: %%CONTENT%%; charset=utf-8'); |
| 45 |
header('Cache-Control: max-age=315360000, public, must-revalidate'); |
| 46 |
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 315360000).' GMT'); //10 years |
| 47 |
|
| 48 |
echo $contents; |
| 49 |
|