JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
really made it so you can put tasks on hold. contractor can switch logins multiple...
[contractor-progress.git] / css_mangler.php
1 <?php
2
3 require_once('code/wfpl/http.php');
4 require_once('code/wfpl/file.php');
5 require_once('code/ie_detect.php');
6
7 # this file is meant to act as a filter for .css files. it removes all lines
8 # containing "remove this line for IE 5.5 and 6"
9
10 # see also: .htaccess style.css
11
12 function css_mangler() {
13         $file = $_SERVER['REDIRECT_URL'];
14
15         $file = substr($file, 1);
16
17         # links like style_77.css will return style.css
18
19         # This feature is used as part of a strategy to make sure that the css
20         # file is not cached longer than the html. Also I can shorten loading times
21         # by allowing caching forever.
22
23         $file = ereg_replace('_[0-9]*[.]css', '.css', $file);
24
25         if(!file_exists($file)) {
26                 header('HTTP/1.0 404 File Not Found');
27                 header('Content-Type: text/plain');
28                 print("File \"$file\" not found.");
29                 return;
30         }
31
32         header('Content-Type: text/css');
33         http_cache_forever('private'); # serves different content for old IE versions, so no sharing the cache
34
35         if(ie5or6()) {
36                 echo(ereg_replace("\n[^\n]*remove this line for IE 5.5 and 6[^\n]*\n", "\n", read_whole_file($file)));
37         } else {
38                 readfile($file);
39         }
40 }
41
42 css_mangler();
43
44 ?>