Adding fix for Ticket #2239

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4658 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-03-23 09:20:14 +00:00
parent 3b90fdbe2e
commit 7cc6185076

View file

@ -32,10 +32,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
/**
* Enter description here...
*/
require(CONFIGS . 'paths.php');
require(CAKE . 'basics.php');
require(LIBS . 'folder.php');
require(LIBS . 'file.php');
uses('file');
/**
* Enter description here...
*
@ -44,13 +41,13 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
* @return unknown
*/
function make_clean_css($path, $name) {
require(VENDORS . 'csspp' . DS . 'csspp.php');
$data =file_get_contents($path);
$csspp =new csspp();
$output=$csspp->compress($data);
$ratio =100 - (round(strlen($output) / strlen($data), 3) * 100);
$output=" /* file: $name, ratio: $ratio% */ " . $output;
return $output;
require(VENDORS . 'csspp' . DS . 'csspp.php');
$data = file_get_contents($path);
$csspp = new csspp();
$output = $csspp->compress($data);
$ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
$output = " /* file: $name, ratio: $ratio% */ " . $output;
return $output;
}
/**
* Enter description here...
@ -60,15 +57,15 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
* @return unknown
*/
function write_css_cache($path, $content) {
if (!is_dir(dirname($path))) {
mkdir(dirname($path));
}
$cache=new File($path);
return $cache->write($content);
if (!is_dir(dirname($path))) {
mkdir(dirname($path));
}
$cache = new File($path);
return $cache->write($content);
}
if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
die('Wrong file name.');
die('Wrong file name.');
}
$filename = 'css/' . $regs[1];
@ -76,22 +73,23 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
$cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
if (!file_exists($filepath)) {
die('Wrong file name.');
die('Wrong file name.');
}
if (file_exists($cachepath)) {
$templateModified=filemtime($filepath);
$cacheModified =filemtime($cachepath);
$templateModified = filemtime($filepath);
$cacheModified = filemtime($cachepath);
if ($templateModified > $cacheModified) {
$output=make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
} else {
$output = file_get_contents($cachepath);
}
if ($templateModified > $cacheModified) {
$output = make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
} else {
$output = file_get_contents($cachepath);
}
} else {
$output=make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
$output = make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
$templateModified = time();
}
header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');