ob_start ('ob_gzhandler');
if( isset($_REQUEST['file']) ){
$fl = $_REQUEST['file'];
$extention = end(explode('.', $fl));
switch($extention){
case 'css':$contenttype = 'css';break;
case 'js':$contenttype = 'javascript';break;
default:die();break;
}
header('Content-type: text/'.$contenttype.'; charset: UTF-8');
header ('cache-control: must-revalidate');
$ost = 60 * 60;
$expr = 'expires: ' . gmdate ('D, d M Y H:i:s', time() + $ost) . ' GMT';
header ($expr);
$gzdata = file_get_contents($fl);
$gzdata = compress($gzdata);
echo $gzdata;
}
exit;
function compress($buf) {
$buf = str_replace(array("\r\n", "\r", "\n", "\t", " ", " ", " "), "", $buf);
return $buf;
}