From 7cc618507614230d16fe88bf643f3e037c34187d Mon Sep 17 00:00:00 2001 From: phpnut Date: Fri, 23 Mar 2007 09:20:14 +0000 Subject: [PATCH] Adding fix for Ticket #2239 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4658 3807eeeb-6ff5-0310-8944-8be069107fe0 --- app/webroot/css.php | 54 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/app/webroot/css.php b/app/webroot/css.php index ec9e16450..7585b4299 100644 --- a/app/webroot/css.php +++ b/app/webroot/css.php @@ -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');