Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file compresses the TinyMCE JavaScript using GZip and
  4:  * enables the browser to do two requests instead of one for each .js file.
  5:  * Notice: This script defaults the button_tile_map option to true for extra performance.
  6:  *
  7:  * @package    Core
  8:  * @subpackage Backend
  9:  * @version    SVN Revision $Rev:$
 10:  *
 11:  * @author     Martin Horwath, horwath@dayside.net
 12:  * @copyright  four for business AG <www.4fb.de>
 13:  * @license    http://www.contenido.org/license/LIZENZ.txt
 14:  * @link       http://www.4fb.de
 15:  * @link       http://www.contenido.org
 16:  */
 17: 
 18: if (!defined('CON_FRAMEWORK')) {
 19:     define('CON_FRAMEWORK', true);
 20: }
 21: 
 22: // CONTENIDO startup process
 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:     // Set the error reporting to minimal.
 44:     @error_reporting(E_ERROR | E_WARNING | E_PARSE);
 45: 
 46:     // Get input
 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("."); // Cache path, this is where the .gz files will be stored
 56:     $expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache
 57:     $content = "";
 58:     $encodings = array();
 59:     $supportsGzip = false;
 60:     $enc = "";
 61:     $cacheKey = "";
 62: 
 63:     // Custom extra javascripts to pack
 64:     $custom = array(/*
 65:         "some custom .js file",
 66:         "some custom .js file"
 67:     */);
 68: 
 69:     // Headers
 70:     header("Content-type: text/javascript");
 71:     header("Vary: Accept-Encoding");  // Handle proxies
 72:     header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
 73: 
 74:     // Is called directly then auto init with default settings
 75:     if (!$isJS) {
 76:         echo getFileContents("tiny_mce_gzip.js");
 77:         echo "tinyMCE_GZ.init({});";
 78:         die();
 79:     }
 80: 
 81:     // Setup cache info
 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:     // Check if it supports gzip
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:     // Use cached file disk cache
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:     // Add core
118:     if ($core == "true") {
119:         $content .= getFileContents("tiny_mce" . $suffix . ".js");
120: 
121:         // Patch loading functions
122:         $content .= "tinyMCE_GZ.start();";
123:     }
124: 
125:     // Add core languages
126:     foreach ($languages as $lang)
127:         $content .= getFileContents("langs/" . $lang . ".js");
128: 
129:     // Add themes
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:     // Add plugins
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:     // Add custom files
146:     foreach ($custom as $file)
147:         $content .= getFileContents($file);
148: 
149:     // Restore loading functions
150:     if ($core == "true")
151:         $content .= "tinyMCE_GZ.end();";
152: 
153:     // Generate GZIP'd content
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:         // Write gz file
162:         if ($diskCache && $cacheKey != "")
163:             putFileContents($cacheFile, $cacheData);
164: 
165:         // Stream to client
166:         echo $cacheData;
167:     } else {
168:         // Stream uncompressed content
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]); // Remove anything but 0-9,a-z,-_
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: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen