1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: if (!defined('CON_FRAMEWORK')) {
18: define('CON_FRAMEWORK', true);
19: }
20:
21:
22: include_once('../../../../../includes/startup.php');
23:
24: $backendPath = cRegistry::getBackendPath();
25:
26: $cfg['debug']['backend_exectime']['fullstart'] = getmicrotime();
27:
28: cInclude('includes', 'functions.api.php');
29:
30: cRegistry::bootstrap(array(
31: 'sess' => 'cSession',
32: 'auth' => 'cAuthHandlerBackend',
33: 'perm' => 'cPermission'
34: ));
35:
36: i18nInit($cfg['path']['contenido_locale'], $belang);
37:
38: require_once($backendPath . $cfg['path']['includes'] . 'functions.includePluginConf.php');
39:
40: require_once($cfg['path']['contenido_config'] . 'cfg_actions.inc.php');
41:
42:
43: @error_reporting(E_ERROR | E_WARNING | E_PARSE);
44:
45:
46: $plugins = explode(',', getParam("plugins", ""));
47: $languages = explode(',', getParam("languages", ""));
48: $themes = explode(',', getParam("themes", ""));
49: $diskCache = getParam("diskcache", "") == "true";
50: $isJS = getParam("js", "") == "true";
51: $compress = getParam("compress", "true") == "true";
52: $core = getParam("core", "true") == "true";
53: $suffix = getParam("suffix", "_src") == "_src" ? "_src" : "";
54: $cachePath = realpath(".");
55: $expiresOffset = 3600 * 24 * 10;
56: $content = "";
57: $encodings = array();
58: $supportsGzip = false;
59: $enc = "";
60: $cacheKey = "";
61:
62:
63: $custom = array( 64: 65: 66: );
67:
68:
69: header("Content-type: text/javascript");
70: header("Vary: Accept-Encoding");
71: header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
72:
73:
74: if (!$isJS) {
75: echo getFileContents("tiny_mce_gzip.js");
76: echo "tinyMCE_GZ.init({});";
77: die();
78: }
79:
80:
81: if ($diskCache) {
82: if (!$cachePath) {
83: die("alert('Real path failed.');");
84: }
85:
86: $cacheKey = getParam("plugins", "") . getParam("languages", "") . getParam("themes", "") . $suffix;
87:
88: foreach ($custom as $file) {
89: $cacheKey .= $file;
90: }
91:
92: $cacheKey = md5($cacheKey);
93:
94: if ($compress) {
95: $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".gz";
96: } else {
97: $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".js";
98: }
99: }
100:
101:
102: if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
103: $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
104:
105: if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
106: $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
107: $supportsGzip = true;
108: }
109:
110:
111: if ($diskCache && $supportsGzip && file_exists($cacheFile)) {
112: if ($compress) {
113: header("Content-Encoding: " . $enc);
114: }
115:
116: echo getFileContents($cacheFile);
117: die();
118: }
119:
120:
121: if ($core == "true") {
122: $content .= getFileContents("tiny_mce" . $suffix . ".js");
123:
124:
125: $content .= "tinyMCE_GZ.start();";
126: }
127:
128:
129: foreach ($languages as $lang) {
130: $content .= getFileContents("langs/" . $lang . ".js");
131: }
132:
133:
134: foreach ($themes as $theme) {
135: $content .= getFileContents( "themes/" . $theme . "/editor_template" . $suffix . ".js");
136:
137: foreach ($languages as $lang) {
138: $content .= getFileContents("themes/" . $theme . "/langs/" . $lang . ".js");
139: }
140: }
141:
142:
143: foreach ($plugins as $plugin) {
144: $content .= getFileContents("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
145:
146: foreach ($languages as $lang) {
147: $content .= getFileContents("plugins/" . $plugin . "/langs/" . $lang . ".js");
148: }
149: }
150:
151:
152: foreach ($custom as $file) {
153: $content .= getFileContents($file);
154: }
155:
156:
157: if ($core == "true")
158: $content .= "tinyMCE_GZ.end();";
159:
160:
161: if ($supportsGzip) {
162: if ($compress) {
163: header("Content-Encoding: " . $enc);
164: $cacheData = gzencode($content, 9, FORCE_GZIP);
165: } else
166: $cacheData = $content;
167:
168:
169: if ($diskCache && $cacheKey != "") {
170: putFileContents($cacheFile, $cacheData);
171: }
172:
173:
174: echo $cacheData;
175: } else {
176:
177: echo $content;
178: }
179:
180: 181: 182: 183: 184: 185:
186: function getParam($name, $def = false) {
187:
188: if (!isset($_GET[$name])) {
189: return $def;
190: }
191:
192:
193: return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]);
194:
195: }
196:
197: 198: 199: 200: 201:
202: function getFileContents($path) {
203:
204: $path = realpath($path);
205:
206: if (!$path || !@is_file($path)) {
207: return "";
208: }
209:
210: if (function_exists("file_get_contents")) {
211: return @file_get_contents($path);
212: }
213:
214: $content = "";
215: $fp = @fopen($path, "r");
216: if (!$fp) {
217: return "";
218: }
219:
220: while (!feof($fp)) {
221: $content .= fgets($fp);
222: }
223:
224: fclose($fp);
225:
226: return $content;
227:
228: }
229:
230: 231: 232: 233: 234: 235: 236: 237:
238: function putFileContents($path, $content) {
239:
240: if (function_exists("file_put_contents")) {
241: return @file_put_contents($path, $content);
242: }
243:
244: $fp = @fopen($path, "wb");
245: if ($fp) {
246: fwrite($fp, $content);
247: fclose($fp);
248: }
249:
250: }
251:
252: ?>