All pastes #254 Raw Edit

Anonymous

public ini v1 · immutable
#254 ·published 2004-07-04 18:27 UTC
rendered paste body
<?php$filename = preg_replace(',^'.$_SERVER["SCRIPT_NAME"].',', '', $_SERVER["PHP_SELF"]);if(!preg_match(',^/[a-zA-Z0-9-]+\.css$,', $filename)) {    header("Content-type: text/css");    print "/* Invalid CSS document requested. */";    exit;}$cachefilename = dirname(__FILE__)."/small-cache".$filename;$filename = dirname(__FILE__).$filename;if(file_exists($cachefilename) && filemtime($cachefilename) >= 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);}?>