This articles has been requested to be deleted.
This articles has been flagged as inappropriate.
Saturday, February 13th 2010, 6:24pm
|
|
wcf.bbcode.htaccess.title |
1 2 |
RewriteEngine On RewriteRule (^.+\.(js|css))$ gzip.php?file=$1&mime=$2 [L] |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?php require_once 'HeaderUtil.php'; HeaderUtil::startOutput(); // input params $file = isset($_GET['file']) ? $_GET['file'] : exit; $mime = isset($_GET['mime']) ? $_GET['mime'] : exit; // settings $whitelist = array(); $dirs = array('wiki_files'); $mimes = array( 'js' => 'application/x-javascript', 'css' => 'text/css' ); // supported mimetype? if(!array_key_exists($mime, $mimes)) { exit; } // includes in whitelist foreach($dirs as $dir) { foreach(scandir($dir) as $filename) { $whitelist[] = $dir.'/'.$filename; } } if(!in_array($file, $whitelist)) { exit; } $content = file_get_contents($file); // minify with one of the the two supported minifiers require_once 'minifier/'.$mime.'.php'; $func = "minify_".$mime; $content = $func($content); // ATTENTION: this exits if header timestamp (If-Modified-Since) is file timestamp HeaderUtil::sendLastModified(filemtime($file)); // remember for 30 days in browser cache HeaderUtil::sendMaxAge(86400 * 30); // send content type HeaderUtil::sendContentType($mimes[$mine]); // output echo $content; ?> |
|
|
Diff |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
--- gzip/gzip.php 2009-10-29 21:42:27.000000000 +0100 +++ minify/gzip.php 2009-10-29 21:42:21.000000000 +0100 @@ -32,6 +32,11 @@ $content = file_get_contents($file); +// minify with one of the the two supported minifiers +require_once 'minifier/'.$mime.'.php'; +$func = "minify_".$mime; +$content = $func($content); + // ATTENTION: this exits if header timestamp (If-Modified-Since) is file timestamp HeaderUtil::sendLastModified(filemtime($file)); |