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