mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Optimizer를 개량하여 IE6를 제외한 브라우저라면 gzip 전송이 되도록 하고 불필요한 정규표현식을 정리
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3534 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
4937f8c223
commit
04827948ea
4 changed files with 31 additions and 23 deletions
|
|
@ -3,6 +3,7 @@ RewriteEngine On
|
||||||
# image...
|
# image...
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/files/attach/images/(.*) ./files/attach/images/$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/files/attach/images/(.*) ./files/attach/images/$2 [L]
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/files/member_extra_info/(.*) ./files/member_extra_info/$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/files/member_extra_info/(.*) ./files/member_extra_info/$2 [L]
|
||||||
|
RewriteRule ^([a-zA-Z0-9_]+)/files/cache/(.*) ./files/cache/$2 [L]
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/modules/(.*) ./modules/$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/modules/(.*) ./modules/$2 [L]
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/common/(.*) ./common/$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/common/(.*) ./common/$2 [L]
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/widgets/(.*) ./widgets/$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/widgets/(.*) ./widgets/$2 [L]
|
||||||
|
|
|
||||||
|
|
@ -864,17 +864,8 @@
|
||||||
// body 내의 <style ..></style>를 header로 이동
|
// body 내의 <style ..></style>를 header로 이동
|
||||||
$content = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'moveStyleToHeader'), $content);
|
$content = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'moveStyleToHeader'), $content);
|
||||||
|
|
||||||
// <br> 코드 변환
|
// <img|br> 코드 변환
|
||||||
$content = preg_replace('/<br([^>\/]*)(\/>|>)/i','<br$1 />', $content);
|
$content = preg_replace('/<(img|br)([^>\/]*)(\/>|>)/i','<$1$2 />', $content);
|
||||||
|
|
||||||
// 몇가지 대문자 태그를 소문자로 변경
|
|
||||||
//$content = preg_replace_callback('!<(\/){0,1}([A-Z]+)([^>]*?)>!s',array($this,'transTagToLowerCase'), $content);
|
|
||||||
|
|
||||||
// <img ...> 코드를 <img ... /> 코드로 변환
|
|
||||||
$content = preg_replace('/<img(.*?)(\/){0,1}>/i','<img$1 />', $content);
|
|
||||||
|
|
||||||
// blogapi tool에서 삽입된 코드 삭제
|
|
||||||
//$content = str_replace('atomicselection="true"','',$content);
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,16 +87,9 @@
|
||||||
function display($content) {
|
function display($content) {
|
||||||
$content .= $this->_debugOutput();
|
$content .= $this->_debugOutput();
|
||||||
|
|
||||||
$path = getScriptPath();
|
|
||||||
|
|
||||||
// commons/modules/files/widgets/layouts/addons 로 시작되는 src나 href의 값을 절대경로로 변경
|
|
||||||
$content = preg_replace('!(href|src)=("|\'){0,1}(commons|modules|widgets|layouts|addons|files)!is', '\\1=\\2'.$path.'\\3', $content);
|
|
||||||
$content = preg_replace('!(href|src)=("|\'){0,1}\.\/([a-zA-Z0-9\_^\/]+)\/!is', '\\1=\\2'.$path.'\\3/', $content);
|
|
||||||
|
|
||||||
// 출력하기 전에 trigger 호출 (after)
|
// 출력하기 전에 trigger 호출 (after)
|
||||||
ModuleHandler::triggerCall('display', 'after', $content);
|
ModuleHandler::triggerCall('display', 'after', $content);
|
||||||
|
|
||||||
|
|
||||||
if($this->gz_enabled) print ob_gzhandler($content, 5);
|
if($this->gz_enabled) print ob_gzhandler($content, 5);
|
||||||
else print $content;
|
else print $content;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,8 @@
|
||||||
$size = filesize($content_file);
|
$size = filesize($content_file);
|
||||||
$mtime = filemtime($content_file);
|
$mtime = filemtime($content_file);
|
||||||
$class_mtime = filemtime("./classes/optimizer/Optimizer.class.php");
|
$class_mtime = filemtime("./classes/optimizer/Optimizer.class.php");
|
||||||
|
|
||||||
|
// js, css 파일을 php를 통해서 출력하고 이 출력시에 헤더값을 조작하여 캐싱과 압축전송이 되도록 함 (IE6는 CSS파일일 경우 gzip압축하지 않음)
|
||||||
$header_buff = '<?php
|
$header_buff = '<?php
|
||||||
$content_filename = "'.$content_filename.'";
|
$content_filename = "'.$content_filename.'";
|
||||||
$mtime = '.$mtime.';
|
$mtime = '.$mtime.';
|
||||||
|
|
@ -137,15 +139,33 @@ if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
|
||||||
$cached = true;
|
$cached = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( preg_match("/MSIE 6.0/i",$_SERVER["HTTP_USER_AGENT"]) || strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip")===false || !function_exists("ob_gzhandler") ) {
|
||||||
|
$size = filesize($content_filename);
|
||||||
|
} else {
|
||||||
|
$f = fopen($content_filename,"r");
|
||||||
|
$buff = fread($f, filesize($content_filename));
|
||||||
|
fclose($f);
|
||||||
|
$buff = ob_gzhandler($buff, 5);
|
||||||
|
$size = strlen($buff);
|
||||||
|
header("Content-Encoding: gzip");
|
||||||
|
}
|
||||||
|
|
||||||
header("Content-Type: '.$content_type.'; charset=utf-8");
|
header("Content-Type: '.$content_type.'; charset=utf-8");
|
||||||
header("Date: '.substr(gmdate('r'), 0, -5).'GMT");
|
header("Date: '.substr(gmdate('r'), 0, -5).'GMT");
|
||||||
header("Expires: '.substr(gmdate('r', strtotime('+1 MONTH')), 0, -5).'GMT");
|
header("Expires: '.substr(gmdate('r', strtotime('+1 MONTH')), 0, -5).'GMT");
|
||||||
header("Cache-Control: private, max-age=86400");
|
header("Cache-Control: private, max-age=2592000");
|
||||||
header("Pragma: cache");
|
header("Pragma: cache");
|
||||||
header("Last-Modified: '.substr(gmdate('r', $mtime), 0, -5).'GMT");
|
header("Last-Modified: '.substr(gmdate('r', $mtime), 0, -5).'GMT");
|
||||||
header("ETag: '.dechex($unique).'-'.dechex($size).'-'.dechex($mtime).'");
|
header("ETag: \"'.dechex($unique).'-".dechex($size)."-'.dechex($mtime).'\"");
|
||||||
if(!$cached && file_exists($content_filename)) print file_get_contents($content_filename);
|
|
||||||
exit();
|
if(!$cached) {
|
||||||
|
if(!$buff) {
|
||||||
|
$f = fopen($content_filename,"r");
|
||||||
|
fpassthru($f);
|
||||||
|
} else print $buff;
|
||||||
|
}
|
||||||
|
|
||||||
?>';
|
?>';
|
||||||
FileHandler::writeFile($filename, $header_buff);
|
FileHandler::writeFile($filename, $header_buff);
|
||||||
}
|
}
|
||||||
|
|
@ -154,11 +174,14 @@ exit();
|
||||||
* @brief css의 경우 import/ background 등의 속성에서 사용되는 url내의 경로를 변경시켜줌
|
* @brief css의 경우 import/ background 등의 속성에서 사용되는 url내의 경로를 변경시켜줌
|
||||||
**/
|
**/
|
||||||
function replaceCssPath($file, $str) {
|
function replaceCssPath($file, $str) {
|
||||||
|
// css 파일의 위치를 구함
|
||||||
$this->tmp_css_path = Context::getRequestUri().preg_replace("/^\.\//is","",dirname($file))."/";
|
$this->tmp_css_path = Context::getRequestUri().preg_replace("/^\.\//is","",dirname($file))."/";
|
||||||
$str = preg_replace_callback('!url\(("|\')?([^\)]+)("|\')?\)!is', array($this, '_replaceCssPath'), $str);
|
|
||||||
|
|
||||||
|
// url() 로 되어 있는 css 파일의 경로를 변경
|
||||||
|
$str = preg_replace_callback('!url\(("|\')?([^\)]+)("|\')?\)!is', array($this, '_replaceCssPath'), $str);
|
||||||
$str = preg_replace('!\/([^\/]*)\/\.\.\/!is','/', $str);
|
$str = preg_replace('!\/([^\/]*)\/\.\.\/!is','/', $str);
|
||||||
|
|
||||||
|
// charset 지정 문구를 제거
|
||||||
$str = preg_replace('!@charset([^;]*?);!is','',$str);
|
$str = preg_replace('!@charset([^;]*?);!is','',$str);
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue