JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
made css_mangler.php handle versioning (strips numerical postfixes) and made contract...
[contractor-progress.git] / css_mangler.php
1 <?php
2
3 require_once('code/wfpl/file.php');
4 require_once('code/ie_detect.php');
5
6 # this file is meant to act as a filter for .css files. it removes all lines
7 # containing "remove this line for IE 5.5 and 6"
8
9 # see also: .htaccess style.css
10
11 function css_mangler() {
12         $file = $_SERVER['REDIRECT_URL'];
13
14         $file = substr($file, 1);
15
16         $file = ereg_replace('_[0-9]*[.]css', '.css', $file);
17
18         $mtime = filemtime($file);
19         if($mtime === false) {
20                 header('Content-Type: text/plain');
21                 print("cannot stat $file");
22                 return;
23         }
24
25         header('Content-Type: text/css');
26         header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mtime) . ' GMT');
27         header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mtime) . ' GMT');
28
29         if(ie5or6()) {
30                 echo(ereg_replace("\n[^\n]*remove this line for IE 5.5 and 6[^\n]*\n", "\n", read_whole_file($file)));
31         } else {
32                 readfile($file);
33         }
34 }
35
36 css_mangler();
37
38 ?>