15 $file.=
DS.request::get(
'text');
17 'name'=>
'module'.
DS.nyro::getCfg()->compressModule.DS.
'css'.
DS.$file,
23 protected function execJs($prm=null) {
41 $conf = $this->cfg->all;
43 }
else if ($type ==
'css') {
44 $conf = $this->cfg->all;
48 $key = $type.
'--'.md5(serialize($prm)).
'--'.md5(serialize($conf));
49 $supportsGzip =
false;
50 if ($conf[
'compress']) {
51 $encodings = isset($_SERVER[
'HTTP_ACCEPT_ENCODING']) ? explode(
',', strtolower(preg_replace(
"/\s+/",
"", $_SERVER[
'HTTP_ACCEPT_ENCODING']))) : array();
52 if ($conf[
'gzip_compress'] && (in_array(
'gzip', $encodings) || in_array(
'x-gzip', $encodings) || isset($_SERVER[
'---------------'])) && function_exists(
'gzencode') && !ini_get(
'zlib.output_compression')) {
53 $enc = in_array(
'x-gzip', $encodings) ?
'x-gzip' :
'gzip';
60 $cacheDate = $cache->get($content, array(
'id'=>$key));
62 if (!$conf[
'disk_cache'] || !$cacheDate) {
63 foreach($prm as $file) {
65 'name'=>
'module_'.
nyro::getCfg()->compressModule.
'_'.$type.
'_'.$file,
77 if ($conf[
'compress']) {
80 $content = JSMin::minify($content);
81 }
else if ($type ==
'css') {
83 $content = CssMin::minify($content, $conf[
'filters'], $conf[
'plugins']);
86 $content = gzencode($content, 9, FORCE_GZIP);
89 }
else if ($cacheDate) {
90 $resp->addHeader(
'Age', time() - $cacheDate);
94 if ($conf[
'compress']) {
95 $resp->setCompress(
false);
96 $resp->addHeader(
'Vary',
'Accept-Encoding');
97 if ($conf[
'etags'] || preg_match(
'/MSIE/i', $_SERVER[
'HTTP_USER_AGENT'])) {
99 $resp->addHeader(
'ETag', md5($content));
101 $parseTime = $this->
_parseTime($conf[
'expires_offset']);
102 $resp->addHeader(
'Expires', gmdate(
'D, d M Y H:i:s', time() + $parseTime).
' GMT');
103 $resp->addHeader(
'Cache-Control',
'public, max-age='.$parseTime);
107 if (!isset($_GET[
'gz']) && $supportsGzip && $conf[
'patch_ie'] && strpos($_SERVER[
'HTTP_USER_AGENT'],
'MSIE') !==
false) {
109 $url = $_SERVER[
'REQUEST_URI'];
111 if (isset($_SERVER[
'QUERY_STRING']) && $_SERVER[
'QUERY_STRING'])
112 $url.=
'?'.$_SERVER[
'QUERY_STRING'].
'&gz=1';
117 echo
'var gz;try {gz = new XMLHttpRequest();} catch(gz) { try {gz = new ActiveXObject("Microsoft.XMLHTTP");}';
118 echo
'catch (gz) {gz = new ActiveXObject("Msxml2.XMLHTTP");}}';
119 echo
'gz.open("GET", "'.$url.
'", false);gz.send(null);eval(gz.responseText);';
125 $resp->addHeader(
'Content-Encoding', $enc);
128 $resp->sendText($content);
135 if (strpos($time,
"h") !=
false)
139 if (strpos($time,
"d") !=
false)
140 $multipel = 24 * 60 * 60;
143 if (strpos($time,
"m") !=
false)
144 $multipel = 24 * 60 * 60 * 30;
147 return intval($time) * $multipel;
static getInstance(array $cfg=array())
if(!defined('NYROROOT')) define('NYROROOT' ROOT DS
static mergeCfg(array &$prm, array $cfg)
static fetch($file, array $vars=array())