21 $this->_sJsDir = $sJsDir;
23 $this->_sCacheDir = $sCacheDir;
24 $this->_bCache = $sCacheDir ?
true :
false;
25 $this->_sCacheFilename =
'';
27 $this->_bGzip =
false;
43 if (
'ja' == $this->_sType) {
44 foreach ($this->_p
as $sJsFile) {
45 $this->_a[] = $this->_sJsDir . $sJsFile;
46 $this->_sCacheFilename .= $sJsFile;
48 $this->_sCacheFilename = md5 ($this->_sCacheFilename);
52 if (
'd' == $this->_sType && is_dir ($this->_p)) {
54 if (!($dh = opendir($this->_p)))
return;
56 while (($sJsFile = readdir($dh)) !==
false) {
57 if (strtolower(substr($sJsFile, -3)) !=
'.js')
continue;
58 $this->_a[] = $this->_p . $sJsFile;
59 $this->_sCacheFilename .= $sJsFile;
62 $this->_sCacheFilename = md5 ($this->_sCacheFilename);
68 die (
"alert ('Wrong js directory')");
77 $encodings = array ();
78 if (isset($_SERVER[
'HTTP_ACCEPT_ENCODING']))
79 $encodings = explode(
',', strtolower(preg_replace(
"/\s+/",
"", $_SERVER[
'HTTP_ACCEPT_ENCODING'])));
81 if ((in_array(
'gzip', $encodings) || in_array(
'x-gzip', $encodings) || isset($_SERVER[
'---------------'])) && function_exists(
'ob_gzhandler') && !ini_get(
'zlib.output_compression') && ini_get(
'output_handler') !=
'ob_gzhandler') {
82 $this->_sEnc = in_array(
'x-gzip', $encodings) ?
"x-gzip" :
"gzip";
90 $this->_c .= $this->
getFile($sFile);
100 header(
"Content-Encoding: " . $this->_sEnc);
101 $this->_cz = gzencode ($this->_c, 9, FORCE_GZIP);
116 if (function_exists(
"file_get_contents"))
117 return @file_get_contents(
$path);
120 $fp = @fopen(
$path,
"r");
125 $content .= fgets($fp);
134 if (function_exists(
"file_put_contents"))
135 return @file_put_contents(
$s, $c);
137 $f = @fopen(
$s,
"wb");
146 header(
"Content-type: text/javascript");
147 header(
"Vary: Accept-Encoding");
148 header(
"Expires: " . gmdate(
"D, d M Y H:i:s",
time() + $expiresOffset) .
" GMT");
153 if (!$this->_bGzip)
return false;
155 if (!$this->_bCache)
return false;
157 $fn = $this->_sCacheDir . $this->_sCacheFilename;
159 if (!file_exists($fn))
return false;
161 header(
"Content-Encoding: " . $this->_sEnc);
170 if (!$this->_bCache)
return;
172 $fn = $this->_sCacheDir . $this->_sCacheFilename;
174 $this->
putFile($fn, $this->_cz);