= filemtime($filename) && filemtime($cachefilename) >= filemtime(__FILE__)) { header("Content-type: text/css"); header("Last-Modified: ".gmdate('D, d M Y H:i:s \G\M\T', filemtime($cachefilename))); header("Expires: ".gmdate('D, d M Y H:i:s \G\M\T', time() + 1800)); readfile($cachefilename); exit; } if(file_exists($filename)) { $css = file_get_contents($filename); /* Variable substitution */ if(preg_match_all('/\$([a-zA-Z][a-zA-Z0-9]*)\s+=\s+([^;]+);/', $css, $matches)) { $css = preg_replace('/\$[a-zA-Z][a-zA-Z0-9]*\s+=\s+([^;]+);/', '', $css); for($i = 0; $i < count($matches[1]); $i++) { $v{$matches[1][$i]} = $matches[2][$i]; } foreach($v as $key => $val) { $css = preg_replace('/\$'.$key.'/', $val, $css); } } $css = preg_replace(',/\*(.*?)\*/,s','',$css); $css = preg_replace(',(\n+|\s+),', ' ', $css); $css = preg_replace(',\s*([}{]+)\s*,', '\\1', $css); $css = preg_replace('/([;:,]+)\s*/', '\\1', $css); $css = trim($css); header("Content-type: text/css"); header("Last-Modified: ".gmdate('D, d M Y H:i:s \G\M\T', filemtime($filename))); header("Expires: ".gmdate('D, d M Y H:i:s \G\M\T', time() + 1800)); print $css."\n"; $fd = fopen($cachefilename, "w"); fwrite($fd, $css."\n"); fclose($fd); } ?>