544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 1
<?php
545
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 2
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 3
/*
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 5
* Version 1.1.6 (Caoineag beta 1)
545
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 6
* Copyright (C) 2006-2008 Dan Fuhry
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 7
* tiny_mce_gzip.php - TinyMCE gzip and caching script, stock from MoxieCode with one modification
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 8
*
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 9
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 10
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 11
*
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 13
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 14
*/
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 15
544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 16
/**
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 17
* $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 18
*
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 19
* @author Moxiecode
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 20
* @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 21
*
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 22
* This file compresses the TinyMCE JavaScript using GZip and
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 23
* enables the browser to do two requests instead of one for each .js file.
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 24
* Notice: This script defaults the button_tile_map option to true for extra performance.
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 25
*/
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 26
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 27
// Set the error reporting to minimal.
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 28
@error_reporting(E_ERROR | E_WARNING | E_PARSE);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 29
545
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 30
// 5/5/2008 - load Enano, but only get the root directory
544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 31
define('ENANO_COMMON_ROOTONLY', 1);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 32
require('../../common.php');
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 33
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 34
// Get input
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 35
$plugins = explode(',', getParam("plugins", ""));
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 36
$languages = explode(',', getParam("languages", ""));
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 37
$themes = explode(',', getParam("themes", ""));
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 38
$diskCache = getParam("diskcache", "") == "true";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 39
$isJS = getParam("js", "") == "true";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 40
$compress = getParam("compress", "true") == "true";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 41
$core = getParam("core", "true") == "true";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 42
$suffix = getParam("suffix", "_src") == "_src" ? "_src" : "";
545
e4c8e706f167
Add standard header comment block and date of changes to tiny_mce_gzip to conform to GPL/LGPL
Dan
diff
changeset
+ − 43
// 5/5/2008 - set cache path to Enano's usual directory
544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 44
$cachePath = realpath(ENANO_ROOT . "/cache"); // Cache path, this is where the .gz files will be stored
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 45
$expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 46
$content = "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 47
$encodings = array();
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 48
$supportsGzip = false;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 49
$enc = "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 50
$cacheKey = "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 51
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 52
// Custom extra javascripts to pack
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 53
$custom = array(/*
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 54
"some custom .js file",
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 55
"some custom .js file"
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 56
*/);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 57
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 58
// Headers
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 59
header("Content-type: text/javascript");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 60
header("Vary: Accept-Encoding"); // Handle proxies
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 61
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 62
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 63
// Is called directly then auto init with default settings
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 64
if (!$isJS) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 65
echo getFileContents("tiny_mce_gzip.js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 66
echo "tinyMCE_GZ.init({});";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 67
die();
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 68
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 69
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 70
// Setup cache info
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 71
if ($diskCache) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 72
if (!$cachePath)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 73
die("alert('Real path failed.');");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 74
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 75
$cacheKey = getParam("plugins", "") . getParam("languages", "") . getParam("themes", "") . $suffix;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 76
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 77
foreach ($custom as $file)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 78
$cacheKey .= $file;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 79
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 80
$cacheKey = md5($cacheKey);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 81
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 82
if ($compress)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 83
$cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".gz";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 84
else
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 85
$cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".js";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 86
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 87
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 88
// Check if it supports gzip
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 89
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 90
$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 91
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 92
if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 93
$enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 94
$supportsGzip = true;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 95
}
547
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 96
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 97
// Send an ETag (Enano modification 5/5/2008)
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 98
if ( isset($cacheKey) )
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 99
{
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 100
$etag =& $cacheKey;
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 101
header("ETag: \"$etag\"");
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 102
if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 103
{
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 104
if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] )
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 105
{
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 106
header('HTTP/1.1 304 Not Modified');
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 107
exit();
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 108
}
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 109
}
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 110
}
544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 111
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 112
// Use cached file disk cache
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 113
if ($diskCache && $supportsGzip && file_exists($cacheFile)) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 114
if ($compress)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 115
header("Content-Encoding: " . $enc);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 116
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 117
echo getFileContents($cacheFile);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 118
die();
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 119
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 120
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 121
// Add core
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 122
if ($core == "true") {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 123
$content .= getFileContents("tiny_mce" . $suffix . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 124
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 125
// Patch loading functions
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 126
$content .= "tinyMCE_GZ.start();";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 127
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 128
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 129
// Add core languages
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 130
foreach ($languages as $lang)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 131
$content .= getFileContents("langs/" . $lang . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 132
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 133
// Add themes
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 134
foreach ($themes as $theme) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 135
$content .= getFileContents( "themes/" . $theme . "/editor_template" . $suffix . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 136
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 137
foreach ($languages as $lang)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 138
$content .= getFileContents("themes/" . $theme . "/langs/" . $lang . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 139
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 140
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 141
// Add plugins
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 142
foreach ($plugins as $plugin) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 143
$content .= getFileContents("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 144
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 145
foreach ($languages as $lang)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 146
$content .= getFileContents("plugins/" . $plugin . "/langs/" . $lang . ".js");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 147
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 148
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 149
// Add custom files
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 150
foreach ($custom as $file)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 151
$content .= getFileContents($file);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 152
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 153
// Restore loading functions
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 154
if ($core == "true")
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 155
$content .= "tinyMCE_GZ.end();";
547
0a2c1ce32d91
Added ETag on TinyMCE gzip; changed ETag format for standard pages so as to include user and login info to control caching when logged in or out
Dan
diff
changeset
+ − 156
544
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 157
// Generate GZIP'd content
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 158
if ($supportsGzip) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 159
if ($compress) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 160
header("Content-Encoding: " . $enc);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 161
$cacheData = gzencode($content, 9, FORCE_GZIP);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 162
} else
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 163
$cacheData = $content;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 164
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 165
// Write gz file
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 166
if ($diskCache && $cacheKey != "")
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 167
putFileContents($cacheFile, $cacheData);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 168
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 169
// Stream to client
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 170
echo $cacheData;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 171
} else {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 172
// Stream uncompressed content
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 173
echo $content;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 174
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 175
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 176
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 177
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 178
function getParam($name, $def = false) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 179
if (!isset($_GET[$name]))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 180
return $def;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 181
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 182
return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]); // Remove anything but 0-9,a-z,-_
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 183
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 184
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 185
function getFileContents($path) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 186
$path = realpath($path);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 187
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 188
if (!$path || !@is_file($path))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 189
return "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 190
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 191
if (function_exists("file_get_contents"))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 192
return @file_get_contents($path);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 193
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 194
$content = "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 195
$fp = @fopen($path, "r");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 196
if (!$fp)
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 197
return "";
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 198
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 199
while (!feof($fp))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 200
$content .= fgets($fp);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 201
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 202
fclose($fp);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 203
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 204
return $content;
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 205
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 206
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 207
function putFileContents($path, $content) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 208
if (function_exists("file_put_contents"))
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 209
return @file_put_contents($path, $content);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 210
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 211
$fp = @fopen($path, "wb");
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 212
if ($fp) {
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 213
fwrite($fp, $content);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 214
fclose($fp);
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 215
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 216
}
81b4499a963e
Added TinyMCE compression support and made some supporting modifications to common.php
Dan
parents:
diff
changeset
+ − 217
?>