@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php exit; |
| 2 | 2 | |
| 3 | 3 | //Check everything exists before using it |
| 4 | -if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
| 4 | +if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
| 5 | 5 | $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; |
| 6 | -if(!isset($_SERVER['HTTP_USER_AGENT'])) |
|
| 6 | +if (!isset($_SERVER['HTTP_USER_AGENT'])) |
|
| 7 | 7 | $_SERVER['HTTP_USER_AGENT'] = ''; |
| 8 | 8 | |
| 9 | 9 | // Determine supported compression method |
@@ -27,28 +27,28 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 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) |
|
| 30 | +if (ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) |
|
| 31 | 31 | $encoding = 'none'; |
| 32 | 32 | |
| 33 | 33 | //Get data |
| 34 | 34 | $contents = file_get_contents(__FILE__.'.'.$encoding); |
| 35 | 35 | |
| 36 | 36 | // first check if we have to send 304 |
| 37 | -$eTag=md5($contents); |
|
| 38 | -$modTime=filemtime(__FILE__.'.none'); |
|
| 37 | +$eTag = md5($contents); |
|
| 38 | +$modTime = filemtime(__FILE__.'.none'); |
|
| 39 | 39 | |
| 40 | 40 | date_default_timezone_set("UTC"); |
| 41 | -$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'],$eTag)); |
|
| 41 | +$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'], $eTag)); |
|
| 42 | 42 | $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime); |
| 43 | 43 | |
| 44 | -if (($modTimeMatch)||($eTagMatch)) { |
|
| 44 | +if (($modTimeMatch) || ($eTagMatch)) { |
|
| 45 | 45 | header('HTTP/1.1 304 Not Modified'); |
| 46 | 46 | header('Connection: close'); |
| 47 | 47 | } else { |
| 48 | 48 | // send all sorts of headers |
| 49 | - $expireTime=60*60*24*356; // 1y max according to RFC |
|
| 49 | + $expireTime = 60*60*24*356; // 1y max according to RFC |
|
| 50 | 50 | |
| 51 | - if(isset($encoding) && $encoding != 'none') |
|
| 51 | + if (isset($encoding) && $encoding != 'none') |
|
| 52 | 52 | { |
| 53 | 53 | header('Content-Encoding: '.$encoding); |
| 54 | 54 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | header('Content-type: %%CONTENT%%; charset=utf-8'); |
| 58 | 58 | header('Cache-Control: max-age='.$expireTime.', public, immutable'); |
| 59 | 59 | header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT'); //10 years |
| 60 | - header('ETag: ' . $eTag); |
|
| 60 | + header('ETag: '.$eTag); |
|
| 61 | 61 | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT'); |
| 62 | 62 | |
| 63 | 63 | // send output |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php exit; |
| 2 | 2 | |
| 3 | 3 | //Check everything exists before using it |
| 4 | -if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
| 4 | +if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
| 5 | 5 | $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; |
| 6 | -if(!isset($_SERVER['HTTP_USER_AGENT'])) |
|
| 6 | +if (!isset($_SERVER['HTTP_USER_AGENT'])) |
|
| 7 | 7 | $_SERVER['HTTP_USER_AGENT'] = ''; |
| 8 | 8 | |
| 9 | 9 | // Determine supported compression method |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 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) |
|
| 30 | +if (ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) |
|
| 31 | 31 | $encoding = 'none'; |
| 32 | 32 | |
| 33 | 33 | $iscompressed = file_exists(__FILE__.'.'.$encoding); |
| 34 | -if($encoding != 'none' && $iscompressed == false) |
|
| 34 | +if ($encoding != 'none' && $iscompressed == false) |
|
| 35 | 35 | { |
| 36 | 36 | $flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE); |
| 37 | 37 | $code = file_get_contents(__FILE__.'.none'); |
| 38 | - $contents = gzencode($code,9,$flag); |
|
| 39 | -}else{ |
|
| 38 | + $contents = gzencode($code, 9, $flag); |
|
| 39 | +} else { |
|
| 40 | 40 | //Get data |
| 41 | 41 | $contents = file_get_contents(__FILE__.'.'.$encoding); |
| 42 | 42 | } |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | // first check if we have to send 304 |
| 45 | 45 | // inspired by http://www.jonasjohn.de/snippets/php/caching.htm |
| 46 | 46 | |
| 47 | -$eTag=md5($contents); |
|
| 48 | -$modTime=filemtime(__FILE__.'.none'); |
|
| 47 | +$eTag = md5($contents); |
|
| 48 | +$modTime = filemtime(__FILE__.'.none'); |
|
| 49 | 49 | |
| 50 | 50 | date_default_timezone_set("UTC"); |
| 51 | -$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'],$eTag)); |
|
| 51 | +$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'], $eTag)); |
|
| 52 | 52 | $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime); |
| 53 | 53 | |
| 54 | -if (($modTimeMatch)||($eTagMatch)) { |
|
| 54 | +if (($modTimeMatch) || ($eTagMatch)) { |
|
| 55 | 55 | header('HTTP/1.1 304 Not Modified'); |
| 56 | 56 | header('Connection: close'); |
| 57 | 57 | } else { |
| 58 | 58 | // send all sorts of headers |
| 59 | - $expireTime=60*60*24*355; // 1y max according to RFC |
|
| 59 | + $expireTime = 60*60*24*355; // 1y max according to RFC |
|
| 60 | 60 | if ($encoding != 'none') { |
| 61 | 61 | header('Content-Encoding: '.$encoding); |
| 62 | 62 | } |
@@ -65,22 +65,22 @@ discard block |
||
| 65 | 65 | header('Content-type: %%CONTENT%%; charset=utf-8'); |
| 66 | 66 | header('Cache-Control: max-age='.$expireTime.', public, immutable'); |
| 67 | 67 | header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT'); |
| 68 | - header('ETag: ' . $eTag); |
|
| 68 | + header('ETag: '.$eTag); |
|
| 69 | 69 | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT'); |
| 70 | 70 | |
| 71 | 71 | // send output |
| 72 | 72 | echo $contents; |
| 73 | 73 | |
| 74 | 74 | //And write to filesystem cache if not done yet |
| 75 | - if($encoding != 'none' && $iscompressed == false) |
|
| 75 | + if ($encoding != 'none' && $iscompressed == false) |
|
| 76 | 76 | { |
| 77 | 77 | //Write the content we sent |
| 78 | - file_put_contents(__FILE__.'.'.$encoding,$contents); |
|
| 78 | + file_put_contents(__FILE__.'.'.$encoding, $contents); |
|
| 79 | 79 | |
| 80 | 80 | //And write the new content |
| 81 | 81 | $flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP); |
| 82 | 82 | $ext = ($encoding == 'gzip' ? 'deflate' : 'gzip'); |
| 83 | - $contents = gzencode($code,9,$flag); |
|
| 84 | - file_put_contents(__FILE__.'.'.$ext,$contents); |
|
| 83 | + $contents = gzencode($code, 9, $flag); |
|
| 84 | + file_put_contents(__FILE__.'.'.$ext, $contents); |
|
| 85 | 85 | } |
| 86 | 86 | } |