No regular expressions were active.
1 |
|
<?php
|
|
1 |
|
<?php
|
2 |
|
/**
|
|
2 |
|
/**
|
3 |
|
*
$Id:
tiny_mce_g
zip.php
15
8
200
6
-1
2
-2
1
14:
3
2
:
19
Z
spocke
$
|
|
3 |
|
*
$Id:
tiny_mce_g
zip.php
3
15
200
7
-1
0
-2
5
14:
0
3
:
43
Z
spocke
$
|
4 |
|
*
|
|
4 |
|
*
|
5 |
|
* @author
Moxiecode
|
|
5 |
|
* @author
Moxiecode
|
6 |
|
* @copyri
ght Copyri
ght © 2005
-2006, Mox
iecode Sys
tems AB, A
ll rights
reserved.
|
|
6 |
|
* @copyri
ght Copyri
ght © 2005
-2006, Mox
iecode Sys
tems AB, A
ll rights
reserved.
|
7 |
|
*
|
|
7 |
|
*
|
8 |
|
* This fi
le compres
ses the Ti
nyMCE Java
Script usi
ng GZip an
d
|
|
8 |
|
* This fi
le compres
ses the Ti
nyMCE Java
Script usi
ng GZip an
d
|
9 |
|
* enables
the brows
er to do t
wo request
s instead
of one for
each .js
file.
|
|
9 |
|
* enables
the brows
er to do t
wo request
s instead
of one for
each .js
file.
|
10 |
|
* Notice:
This scri
pt default
s the butt
on_tile_ma
p option t
o true for
extra per
formance.
|
|
10 |
|
* Notice:
This scri
pt default
s the butt
on_tile_ma
p option t
o true for
extra per
formance.
|
11 |
|
*/
|
|
11 |
|
*/
|
12 |
|
|
|
12 |
|
|
13 |
|
// Set
the error
reporting
to minima
l.
|
|
13 |
|
// Set
the error
reporting
to minima
l.
|
14 |
|
@error
_reporting
(E_ERROR |
E_WARNING
| E_PARSE
);
|
|
14 |
|
@error
_reporting
(E_ERROR |
E_WARNING
| E_PARSE
);
|
15 |
|
|
|
15 |
|
|
16 |
|
// Get
input
|
|
16 |
|
// Get
input
|
17 |
|
$plugi
ns = explo
de(',', ge
tParam("pl
ugins", ""
));
|
|
17 |
|
$plugi
ns = explo
de(',', ge
tParam("pl
ugins", ""
));
|
18 |
|
$langu
ages = exp
lode(',',
getParam("
languages"
, ""));
|
|
18 |
|
$langu
ages = exp
lode(',',
getParam("
languages"
, ""));
|
19 |
|
$theme
s = explod
e(',', get
Param("the
mes", ""))
;
|
|
19 |
|
$theme
s = explod
e(',', get
Param("the
mes", ""))
;
|
20 |
|
$diskC
ache = get
Param("dis
kcache", "
") == "tru
e";
|
|
20 |
|
$diskC
ache = get
Param("dis
kcache", "
") == "tru
e";
|
21 |
|
$isJS
= getParam
("js", "")
== "true"
;
|
|
21 |
|
$isJS
= getParam
("js", "")
== "true"
;
|
22 |
|
$compr
ess = getP
aram("comp
ress", "tr
ue") == "t
rue";
|
|
22 |
|
$compr
ess = getP
aram("comp
ress", "tr
ue") == "t
rue";
|
|
|
23 |
|
$core
= getParam
("core", "
true") ==
"true";
|
23 |
|
$suffi
x = getPar
am("suffix
", "_src")
== "_src"
? "_src"
: "";
|
|
24 |
|
$suffi
x = getPar
am("suffix
", "_src")
== "_src"
? "_src"
: "";
|
24 |
|
$cachePath
=
realpath("
.
./../cache
/
");
//
Cache
path,
this
is
where
the
.gz
files
will
be
stored
|
|
25 |
|
$cachePath
=
realpath("
.
");
//
Cache
path,
this
is
where
the
.gz
files
will
be
stored
|
25 |
|
$expir
esOffset =
3600 * 24
* 10; //
Cache for
10 days in
browser c
ache
|
|
26 |
|
$expir
esOffset =
3600 * 24
* 10; //
Cache for
10 days in
browser c
ache
|
26 |
|
$conte
nt = "";
|
|
27 |
|
$conte
nt = "";
|
27 |
|
$encod
ings = arr
ay();
|
|
28 |
|
$encod
ings = arr
ay();
|
28 |
|
$suppo
rtsGzip =
false;
|
|
29 |
|
$suppo
rtsGzip =
false;
|
29 |
|
$enc =
"";
|
|
30 |
|
$enc =
"";
|
30 |
|
$cache
Key = "";
|
|
31 |
|
$cache
Key = "";
|
31 |
|
|
|
32 |
|
|
32 |
|
// Cus
tom extra
javascript
s to pack
|
|
33 |
|
// Cus
tom extra
javascript
s to pack
|
33 |
|
$custo
m = array(
/*
|
|
34 |
|
$custo
m = array(
/*
|
34 |
|
"s
ome custom
.js file"
,
|
|
35 |
|
"s
ome custom
.js file"
,
|
35 |
|
"s
ome custom
.js file"
|
|
36 |
|
"s
ome custom
.js file"
|
36 |
|
*/);
|
|
37 |
|
*/);
|
37 |
|
|
|
38 |
|
|
38 |
|
// Hea
ders
|
|
39 |
|
// Hea
ders
|
39 |
|
header
("Content-
type: text
/javascrip
t");
|
|
40 |
|
header
("Content-
type: text
/javascrip
t");
|
40 |
|
header
("Vary: Ac
cept-Encod
ing"); //
Handle pr
oxies
|
|
41 |
|
header
("Vary: Ac
cept-Encod
ing"); //
Handle pr
oxies
|
41 |
|
header
("Expires:
" . gmdat
e("D, d M
Y H:i:s",
time() + $
expiresOff
set) . " G
MT");
|
|
42 |
|
header
("Expires:
" . gmdat
e("D, d M
Y H:i:s",
time() + $
expiresOff
set) . " G
MT");
|
42 |
|
|
|
43 |
|
|
43 |
|
// Is
called dir
ectly then
auto init
with defa
ult settin
gs
|
|
44 |
|
// Is
called dir
ectly then
auto init
with defa
ult settin
gs
|
44 |
|
if (!$
isJS) {
|
|
45 |
|
if (!$
isJS) {
|
45 |
|
ec
ho getFile
Contents("
tiny_mce_g
zip.js");
|
|
46 |
|
ec
ho getFile
Contents("
tiny_mce_g
zip.js");
|
46 |
|
ec
ho "tinyMC
E_GZ.init(
{});";
|
|
47 |
|
ec
ho "tinyMC
E_GZ.init(
{});";
|
47 |
|
di
e();
|
|
48 |
|
di
e();
|
48 |
|
}
|
|
49 |
|
}
|
49 |
|
|
|
50 |
|
|
50 |
|
// Set
up cache i
nfo
|
|
51 |
|
// Set
up cache i
nfo
|
51 |
|
if ($d
iskCache)
{
|
|
52 |
|
if ($d
iskCache)
{
|
52 |
|
if
(!$cacheP
ath)
|
|
53 |
|
if
(!$cacheP
ath)
|
53 |
|
die("ale
rt('Real p
ath failed
.');");
|
|
54 |
|
die("ale
rt('Real p
ath failed
.');");
|
54 |
|
|
|
55 |
|
|
55 |
|
$cacheKey
=
getParam("
plugins",
"")
.
getParam("
languages"
,
"")
.
getParam("
themes",
"")
;
|
|
56 |
|
$cacheKey
=
getParam("
plugins",
"")
.
getParam("
languages"
,
"")
.
getParam("
themes",
"")
.
$suffix
;
|
56 |
|
|
|
57 |
|
|
57 |
|
fo
reach ($cu
stom as $f
ile)
|
|
58 |
|
fo
reach ($cu
stom as $f
ile)
|
58 |
|
$cacheKe
y .= $file
;
|
|
59 |
|
$cacheKe
y .= $file
;
|
59 |
|
|
|
60 |
|
|
60 |
|
$c
acheKey =
md5($cache
Key);
|
|
61 |
|
$c
acheKey =
md5($cache
Key);
|
61 |
|
|
|
62 |
|
|
62 |
|
if
($compres
s)
|
|
63 |
|
if
($compres
s)
|
63 |
|
$cacheFi
le = $cach
ePath . "/
tiny_mce_"
. $cacheK
ey . ".gz"
;
|
|
64 |
|
$cacheFi
le = $cach
ePath . "/
tiny_mce_"
. $cacheK
ey . ".gz"
;
|
64 |
|
el
se
|
|
65 |
|
el
se
|
65 |
|
$cacheFi
le = $cach
ePath . "/
tiny_mce_"
. $cacheK
ey . ".js"
;
|
|
66 |
|
$cacheFi
le = $cach
ePath . "/
tiny_mce_"
. $cacheK
ey . ".js"
;
|
66 |
|
}
|
|
67 |
|
}
|
67 |
|
|
|
68 |
|
|
68 |
|
// Che
ck if it s
upports gz
ip
|
|
69 |
|
// Che
ck if it s
upports gz
ip
|
69 |
|
if (is
set($_SERV
ER['HTTP_A
CCEPT_ENCO
DING']))
|
|
70 |
|
if (is
set($_SERV
ER['HTTP_A
CCEPT_ENCO
DING']))
|
70 |
|
$e
ncodings =
explode('
,', strtol
ower(preg_
replace("/
\s+/", "",
$_SERVER[
'HTTP_ACCE
PT_ENCODIN
G'])));
|
|
71 |
|
$e
ncodings =
explode('
,', strtol
ower(preg_
replace("/
\s+/", "",
$_SERVER[
'HTTP_ACCE
PT_ENCODIN
G'])));
|
71 |
|
|
|
72 |
|
|
72 |
|
if ((i
n_array('g
zip', $enc
odings) ||
in_array(
'x-gzip',
$encodings
) || isset
($_SERVER[
'---------
------']))
&& functi
on_exists(
'ob_gzhand
ler') && !
ini_get('z
lib.output
_compressi
on')) {
|
|
73 |
|
if ((i
n_array('g
zip', $enc
odings) ||
in_array(
'x-gzip',
$encodings
) || isset
($_SERVER[
'---------
------']))
&& functi
on_exists(
'ob_gzhand
ler') && !
ini_get('z
lib.output
_compressi
on')) {
|
73 |
|
$e
nc = in_ar
ray('x-gzi
p', $encod
ings) ? "x
-gzip" : "
gzip";
|
|
74 |
|
$e
nc = in_ar
ray('x-gzi
p', $encod
ings) ? "x
-gzip" : "
gzip";
|
74 |
|
$s
upportsGzi
p = true;
|
|
75 |
|
$s
upportsGzi
p = true;
|
75 |
|
}
|
|
76 |
|
}
|
76 |
|
|
|
77 |
|
|
77 |
|
// Use
cached fi
le disk ca
che
|
|
78 |
|
// Use
cached fi
le disk ca
che
|
78 |
|
if ($d
iskCache &
& $support
sGzip && f
ile_exists
($cacheFil
e)) {
|
|
79 |
|
if ($d
iskCache &
& $support
sGzip && f
ile_exists
($cacheFil
e)) {
|
79 |
|
if
($compres
s)
|
|
80 |
|
if
($compres
s)
|
80 |
|
header("
Content-En
coding: "
. $enc);
|
|
81 |
|
header("
Content-En
coding: "
. $enc);
|
81 |
|
|
|
82 |
|
|
82 |
|
ec
ho getFile
Contents($
cacheFile)
;
|
|
83 |
|
ec
ho getFile
Contents($
cacheFile)
;
|
83 |
|
di
e();
|
|
84 |
|
di
e();
|
84 |
|
}
|
|
85 |
|
}
|
85 |
|
|
|
86 |
|
|
86 |
|
// Add
core
|
|
87 |
|
// Add
core
|
|
|
88 |
|
if ($c
ore == "tr
ue") {
|
87 |
|
$conte
nt .= getF
ileContent
s("tiny_mc
e" . $suff
ix . ".js"
);
|
|
89 |
|
$c
ontent .=
getFileCon
tents("tin
y_mce" . $
suffix . "
.js");
|
88 |
|
|
|
90 |
|
|
89 |
|
// Pat
ch loading
functions
|
|
91 |
|
//
Patch loa
ding funct
ions
|
90 |
|
$conte
nt .= "tin
yMCE_GZ.st
art();";
|
|
92 |
|
$c
ontent .=
"tinyMCE_G
Z.start();
";
|
|
|
93 |
|
}
|
91 |
|
|
|
94 |
|
|
92 |
|
// Add
core lang
uages
|
|
95 |
|
// Add
core lang
uages
|
93 |
|
foreac
h ($langua
ges as $la
ng)
|
|
96 |
|
foreac
h ($langua
ges as $la
ng)
|
94 |
|
$c
ontent .=
getFileCon
tents("lan
gs/" . $la
ng . ".js"
);
|
|
97 |
|
$c
ontent .=
getFileCon
tents("lan
gs/" . $la
ng . ".js"
);
|
95 |
|
|
|
98 |
|
|
96 |
|
// Add
themes
|
|
99 |
|
// Add
themes
|
97 |
|
foreac
h ($themes
as $theme
) {
|
|
100 |
|
foreac
h ($themes
as $theme
) {
|
98 |
|
$c
ontent .=
getFileCon
tents( "th
emes/" . $
theme . "/
editor_tem
plate" . $
suffix . "
.js");
|
|
101 |
|
$c
ontent .=
getFileCon
tents( "th
emes/" . $
theme . "/
editor_tem
plate" . $
suffix . "
.js");
|
99 |
|
|
|
102 |
|
|
100 |
|
fo
reach ($la
nguages as
$lang)
|
|
103 |
|
fo
reach ($la
nguages as
$lang)
|
101 |
|
$content
.= getFil
eContents(
"themes/"
. $theme .
"/langs/"
. $lang .
".js");
|
|
104 |
|
$content
.= getFil
eContents(
"themes/"
. $theme .
"/langs/"
. $lang .
".js");
|
102 |
|
}
|
|
105 |
|
}
|
103 |
|
|
|
106 |
|
|
104 |
|
// Add
plugins
|
|
107 |
|
// Add
plugins
|
105 |
|
foreac
h ($plugin
s as $plug
in) {
|
|
108 |
|
foreac
h ($plugin
s as $plug
in) {
|
106 |
|
$c
ontent .=
getFileCon
tents("plu
gins/" . $
plugin . "
/editor_pl
ugin" . $s
uffix . ".
js");
|
|
109 |
|
$c
ontent .=
getFileCon
tents("plu
gins/" . $
plugin . "
/editor_pl
ugin" . $s
uffix . ".
js");
|
107 |
|
|
|
110 |
|
|
108 |
|
fo
reach ($la
nguages as
$lang)
|
|
111 |
|
fo
reach ($la
nguages as
$lang)
|
109 |
|
$content
.= getFil
eContents(
"plugins/"
. $plugin
. "/langs
/" . $lang
. ".js");
|
|
112 |
|
$content
.= getFil
eContents(
"plugins/"
. $plugin
. "/langs
/" . $lang
. ".js");
|
110 |
|
}
|
|
113 |
|
}
|
111 |
|
|
|
114 |
|
|
112 |
|
// Add
custom fi
les
|
|
115 |
|
// Add
custom fi
les
|
113 |
|
foreac
h ($custom
as $file)
|
|
116 |
|
foreac
h ($custom
as $file)
|
114 |
|
$c
ontent .=
getFileCon
tents($fil
e);
|
|
117 |
|
$c
ontent .=
getFileCon
tents($fil
e);
|
115 |
|
|
|
118 |
|
|
116 |
|
// Res
tore loadi
ng functio
ns
|
|
119 |
|
// Res
tore loadi
ng functio
ns
|
|
|
120 |
|
if ($c
ore == "tr
ue")
|
117 |
|
$conte
nt .= "tin
yMCE_GZ.en
d();";
|
|
121 |
|
$c
ontent .=
"tinyMCE_G
Z.end();";
|
118 |
|
|
|
122 |
|
|
119 |
|
// Gen
erate GZIP
'd content
|
|
123 |
|
// Gen
erate GZIP
'd content
|
120 |
|
if ($s
upportsGzi
p) {
|
|
124 |
|
if ($s
upportsGzi
p) {
|
121 |
|
if
($compres
s) {
|
|
125 |
|
if
($compres
s) {
|
122 |
|
header("
Content-En
coding: "
. $enc);
|
|
126 |
|
header("
Content-En
coding: "
. $enc);
|
123 |
|
$cacheDa
ta = gzenc
ode($conte
nt, 9, FOR
CE_GZIP);
|
|
127 |
|
$cacheDa
ta = gzenc
ode($conte
nt, 9, FOR
CE_GZIP);
|
124 |
|
}
else
|
|
128 |
|
}
else
|
125 |
|
$cacheDa
ta = $cont
ent;
|
|
129 |
|
$cacheDa
ta = $cont
ent;
|
126 |
|
|
|
130 |
|
|
127 |
|
//
Write gz
file
|
|
131 |
|
//
Write gz
file
|
128 |
|
if
($diskCac
he && $cac
heKey != "
")
|
|
132 |
|
if
($diskCac
he && $cac
heKey != "
")
|
129 |
|
putFileC
ontents($c
acheFile,
$cacheData
);
|
|
133 |
|
putFileC
ontents($c
acheFile,
$cacheData
);
|
130 |
|
|
|
134 |
|
|
131 |
|
//
Stream to
client
|
|
135 |
|
//
Stream to
client
|
132 |
|
ec
ho $cacheD
ata;
|
|
136 |
|
ec
ho $cacheD
ata;
|
133 |
|
} else
{
|
|
137 |
|
} else
{
|
134 |
|
//
Stream un
compressed
content
|
|
138 |
|
//
Stream un
compressed
content
|
135 |
|
ec
ho $conten
t;
|
|
139 |
|
ec
ho $conten
t;
|
136 |
|
}
|
|
140 |
|
}
|
137 |
|
|
|
141 |
|
|
138 |
|
/* * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * */
|
|
142 |
|
/* * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * */
|
139 |
|
|
|
143 |
|
|
140 |
|
functi
on getPara
m($name, $
def = fals
e) {
|
|
144 |
|
functi
on getPara
m($name, $
def = fals
e) {
|
141 |
|
if
(!isset($
_GET[$name
]))
|
|
145 |
|
if
(!isset($
_GET[$name
]))
|
142 |
|
return $
def;
|
|
146 |
|
return $
def;
|
143 |
|
|
|
147 |
|
|
144 |
|
re
turn preg_
replace("/
[^0-9a-z\-
_,]+/i", "
", $_GET[$
name]); //
Remove an
ything but
0-9,a-z,-
_
|
|
148 |
|
re
turn preg_
replace("/
[^0-9a-z\-
_,]+/i", "
", $_GET[$
name]); //
Remove an
ything but
0-9,a-z,-
_
|
145 |
|
}
|
|
149 |
|
}
|
146 |
|
|
|
150 |
|
|
147 |
|
functi
on getFile
Contents($
path) {
|
|
151 |
|
functi
on getFile
Contents($
path) {
|
148 |
|
$p
ath = real
path($path
);
|
|
152 |
|
$p
ath = real
path($path
);
|
149 |
|
|
|
153 |
|
|
150 |
|
if
(!$path |
| !@is_fil
e($path))
|
|
154 |
|
if
(!$path |
| !@is_fil
e($path))
|
151 |
|
return "
";
|
|
155 |
|
return "
";
|
152 |
|
|
|
156 |
|
|
153 |
|
if
(function
_exists("f
ile_get_co
ntents"))
|
|
157 |
|
if
(function
_exists("f
ile_get_co
ntents"))
|
154 |
|
return @
file_get_c
ontents($p
ath);
|
|
158 |
|
return @
file_get_c
ontents($p
ath);
|
155 |
|
|
|
159 |
|
|
156 |
|
$c
ontent = "
";
|
|
160 |
|
$c
ontent = "
";
|
157 |
|
$f
p = @fopen
($path, "r
");
|
|
161 |
|
$f
p = @fopen
($path, "r
");
|
158 |
|
if
(!$fp)
|
|
162 |
|
if
(!$fp)
|
159 |
|
return "
";
|
|
163 |
|
return "
";
|
160 |
|
|
|
164 |
|
|
161 |
|
wh
ile (!feof
($fp))
|
|
165 |
|
wh
ile (!feof
($fp))
|
162 |
|
$content
.= fgets(
$fp);
|
|
166 |
|
$content
.= fgets(
$fp);
|
163 |
|
|
|
167 |
|
|
164 |
|
fc
lose($fp);
|
|
168 |
|
fc
lose($fp);
|
165 |
|
|
|
169 |
|
|
166 |
|
re
turn $cont
ent;
|
|
170 |
|
re
turn $cont
ent;
|
167 |
|
}
|
|
171 |
|
}
|
168 |
|
|
|
172 |
|
|
169 |
|
functi
on putFile
Contents($
path, $con
tent) {
|
|
173 |
|
functi
on putFile
Contents($
path, $con
tent) {
|
170 |
|
if
(function
_exists("f
ile_put_co
ntents"))
|
|
174 |
|
if
(function
_exists("f
ile_put_co
ntents"))
|
171 |
|
return @
file_put_c
ontents($p
ath, $cont
ent);
|
|
175 |
|
return @
file_put_c
ontents($p
ath, $cont
ent);
|
172 |
|
|
|
176 |
|
|
173 |
|
$f
p = @fopen
($path, "w
b");
|
|
177 |
|
$f
p = @fopen
($path, "w
b");
|
174 |
|
if
($fp) {
|
|
178 |
|
if
($fp) {
|
175 |
|
fwrite($
fp, $conte
nt);
|
|
179 |
|
fwrite($
fp, $conte
nt);
|
176 |
|
fclose($
fp);
|
|
180 |
|
fclose($
fp);
|
177 |
|
}
|
|
181 |
|
}
|
178 |
|
}
|
|
182 |
|
}
|
179 |
|
?>
|
|
183 |
|
?>
|