includes/clientside/jsres.php
author Dan Fuhry <dan@enanocms.org>
Fri, 30 Jul 2010 21:31:30 -0400
changeset 1279 0bc945385d74
parent 1252 e34c23a35dc9
child 1281 36c389769d88
permissions -rw-r--r--
Enabled content-length in Special:DownloadFile even when gzip is on. Should probably check the http spec to see if Content-Length should match the decoded or encoded length
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 1068
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 * jsres.php - the Enano client-side runtime, a.k.a. AJAX on steroids
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
1252
e34c23a35dc9 Rewrote category editor. This breaks the JSON API. Also fixed a few bugs with how Wiki Mode is set in $paths. (Hopefully that doesn't cause infinite loops, heh). Fixes issue 20.
Dan
parents: 1227
diff changeset
    15
define('ENANO_JS_DEBUG', 1);
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 587
diff changeset
    16
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    17
// if Enano's already loaded, we've been included from a helper script
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    18
if ( defined('ENANO_CONFIG_FETCHED') )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    19
	define('ENANO_JSRES_SETUP_ONLY', 1);
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    20
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    21
if ( !defined('ENANO_JSRES_SETUP_ONLY') ):
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    22
586
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    23
/**
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    24
 * Returns a floating-point number with the current UNIX timestamp in microseconds. Defined very early because we gotta call it
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    25
 * from very early on in the script to measure the starting time of Enano.
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    26
 * @return float
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    27
 */
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    28
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    29
// First check to see if something already declared this function.... it happens often.
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    30
if ( !function_exists('microtime_float') )
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    31
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    32
	function microtime_float()
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    33
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    34
		list($usec, $sec) = explode(" ", microtime());
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    35
		return ((float)$usec + (float)$sec);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    36
	}
586
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    37
}
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    38
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    39
$local_start = microtime_float();
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
    40
430
ec90736b9cb9 Started (but disabled) work on the new theme manager, 1.1.2 is being released with this thing halfway done.
Dan
parents: 421
diff changeset
    41
// Disable for IE, it causes problems.
1046
cfc6c30c5e2d Fixed a series of infinite loops with preloading components and placeholders
Dan
parents: 865
diff changeset
    42
$disable_compress = ( strstr(@$_SERVER['HTTP_USER_AGENT'], 'MSIE') || defined('ENANO_JS_DEBUG') ) && !isset($_GET['early']);
430
ec90736b9cb9 Started (but disabled) work on the new theme manager, 1.1.2 is being released with this thing halfway done.
Dan
parents: 421
diff changeset
    43
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    44
// Setup Enano
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    46
//
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    47
// Determine the location of Enano as an absolute path.
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    48
//
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    50
// We need to see if this is a specially marked Enano development server. You can create an Enano
865
7f8262b2004a New template feature: template hooks (<!-- HOOK foo -->)
Dan
parents: 801
diff changeset
    51
// development server using the script found on hg.enanocms.org.
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    52
if ( strpos(__FILE__, '/repo/') && ( file_exists('../../.enanodev') || file_exists('../../../.enanodev') ) )
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    53
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    54
	// We have a development directory. Remove /repo/ from the picture.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    55
	$filename = str_replace('/repo/', '/', __FILE__);
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    56
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    57
else
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    58
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    59
	// Standard Enano installation
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    60
	$filename = __FILE__;
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    61
}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    62
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    63
// ENANO_ROOT is sometimes defined by plugins like AjIM that need the constant before the Enano API is initialized
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    64
if ( !defined('ENANO_ROOT') )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    65
	define('ENANO_ROOT', dirname(dirname(dirname($filename))));
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    66
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    67
chdir(ENANO_ROOT);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    68
613
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 594
diff changeset
    69
// fetch only the site config
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 594
diff changeset
    70
define('ENANO_EXIT_AFTER_CONFIG', 1);
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 594
diff changeset
    71
require('includes/common.php');
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 594
diff changeset
    72
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    73
endif; // ENANO_JSRES_SETUP_ONLY
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
    74
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    75
// CONFIG
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    77
// Files safe to run full (aggressive) compression on
421
dbae4d327846 Optimized JS aggressive-compression list a little more
Dan
parents: 420
diff changeset
    78
$full_compress_safe = array(
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    79
	// Sorted by file size, descending (du -b *.js | sort -n)
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    80
	'crypto.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    81
	'ajax.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    82
	'editor.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    83
	'functions.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    84
	'login.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    85
	'acl.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    86
	'misc.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    87
	'comments.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    88
	'autofill.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    89
	'dropdown.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    90
	'paginate.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    91
	'enano-lib-basic.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    92
	'pwstrength.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    93
	'flyin.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    94
	'rank-manager.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    95
	'userpage.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    96
	'template-compiler.js',
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
    97
	'toolbar.js',
421
dbae4d327846 Optimized JS aggressive-compression list a little more
Dan
parents: 420
diff changeset
    98
);
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
    99
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   100
// Files that should NOT be compressed due to already being compressed, licensing, or invalid produced code
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 685
diff changeset
   101
$compress_unsafe = array('json.js', 'fat.js', 'admin-menu.js', 'autofill.js', 'jquery.js', 'jquery-ui.js');
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   102
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   103
require_once('includes/js-compressor.php');
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   104
542
5841df0ab575 Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents: 536
diff changeset
   105
// try to gzip the output
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   106
if ( !defined('ENANO_JSRES_SETUP_ONLY') ):
542
5841df0ab575 Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents: 536
diff changeset
   107
$do_gzip = false;
1226
de56132c008d Introduced configurability for gzip compression. Fixes issue 18.
Dan
parents: 1136
diff changeset
   108
if ( isset($_SERVER['HTTP_ACCEPT_ENCODING']) && getConfig('gzip_output', false) == 1 )
542
5841df0ab575 Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents: 536
diff changeset
   109
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   110
	$acceptenc = str_replace(' ', '', strtolower($_SERVER['HTTP_ACCEPT_ENCODING']));
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   111
	$acceptenc = explode(',', $acceptenc);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   112
	if ( in_array('gzip', $acceptenc) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   113
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   114
		$do_gzip = true;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   115
		ob_start();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   116
	}
542
5841df0ab575 Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents: 536
diff changeset
   117
}
5841df0ab575 Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents: 536
diff changeset
   118
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   119
// Output format will always be JS
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   120
header('Content-type: text/javascript');
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   121
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   122
endif; // ENANO_JSRES_SETUP_ONLY
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   123
587
705ed7162315 Oops, scriptPath isn't defined in jsres.php.
Dan
parents: 586
diff changeset
   124
$everything = "/* The code represented in this file is compressed for optimization purposes. The full source code is available in includes/clientside/static/. */\n\nvar ENANO_JSRES_COMPRESSED = true;\n\n";
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
568
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   126
// if we only want the tiny version of the API (just enough to get by until the full one is loaded), send that
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   127
// with a simple ETag and far future expires header
594
738c61b498a6 A little more optimization work, client-side this time. I lied, no librijnadel2 here, but it's about to be merged in...
Dan
parents: 588
diff changeset
   128
738c61b498a6 A little more optimization work, client-side this time. I lied, no librijnadel2 here, but it's about to be merged in...
Dan
parents: 588
diff changeset
   129
// note - obfuscated for optimization purposes. The exact same code except properly indented is in enano-lib-basic.
568
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   130
if ( isset($_GET['early']) )
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   131
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   132
	header('ETag: enanocms-lib-early-r3');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   133
	header('Expires: Wed, 1 Jan 2020 00:00:00 GMT');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   134
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   135
	echo <<<JSEOF
1046
cfc6c30c5e2d Fixed a series of infinite loops with preloading components and placeholders
Dan
parents: 865
diff changeset
   136
window.loaded_components = window.loaded_components || {};
cfc6c30c5e2d Fixed a series of infinite loops with preloading components and placeholders
Dan
parents: 865
diff changeset
   137
window.onload_complete = false;
594
738c61b498a6 A little more optimization work, client-side this time. I lied, no librijnadel2 here, but it's about to be merged in...
Dan
parents: 588
diff changeset
   138
var onload_hooks = new Array();function addOnloadHook(func){if ( typeof ( func ) == 'function' ){if ( typeof(onload_hooks.push) == 'function' ){onload_hooks.push(func);}else{onload_hooks[onload_hooks.length] = func;};};}
568
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   139
JSEOF;
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   140
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   141
	exit();
568
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   142
}
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 559
diff changeset
   143
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   144
// Load and parse enano_lib_basic
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   145
$file = @file_get_contents('includes/clientside/static/enano-lib-basic.js');
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   146
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   147
$pos_start_includes = strpos($file, '/*!START_INCLUDER*/');
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   148
$pos_end_includes = strpos($file, '/*!END_INCLUDER*/');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   149
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   150
if ( !$pos_start_includes || !$pos_end_includes )
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   151
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   152
	die('// Error: enano-lib-basic does not have required metacomments');
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   153
}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   154
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   155
$pos_end_includes += strlen('/*!END_INCLUDER*/');
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   156
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   157
preg_match('/var thefiles = (\[([^\]]+?)\]);/', $file, $match);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   158
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   159
if ( empty($match) )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   160
	die('// Error: could not retrieve file list from enano-lib-basic');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   162
// Decode file list
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   163
try
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   164
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   165
	$file_list = enano_json_decode($match[1]);
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   166
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   167
catch ( Exception $e )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   168
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   169
	die("// Exception caught during file list parsing");
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   170
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   171
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   172
$apex = filemtime('includes/clientside/static/enano-lib-basic.js');
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   173
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   174
$before_includes = substr($file, 0, $pos_start_includes);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   175
$after_includes = substr($file, $pos_end_includes);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   176
586
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   177
if ( isset($_GET['f']) )
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   178
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   179
	// requested a single file
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   180
	$js_file =& $_GET['f'];
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   181
	if ( strstr($js_file, ',') )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   182
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   183
		$filelist = explode(',', $js_file);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   184
		unset($js_file);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   185
		$everything = '';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   186
		foreach ( $filelist as $js_file )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   187
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   188
			if ( !preg_match('/^[a-z0-9_-]+\.js$/i', $js_file) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   189
			{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   190
				header('HTTP/1.1 404 Not Found');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   191
				exit('Not found');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   192
			}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   193
			
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   194
			$apex = filemtime("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   195
			
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   196
			$file_contents = file_get_contents("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   197
			$everything .= jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true;';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   198
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   199
		$everything .= 'if ( onload_complete ) { runOnloadHooks(); onload_hooks = []; };';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   200
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   201
	else
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   202
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   203
		if ( !preg_match('/^[a-z0-9_-]+\.js$/i', $js_file) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   204
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   205
			header('HTTP/1.1 404 Not Found');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   206
			exit('Not found');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   207
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   208
		
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   209
		$apex = filemtime("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   210
		
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   211
		$file_contents = file_get_contents("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   212
		$everything = jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true; if ( onload_complete ) { runOnloadHooks(); onload_hooks = []; };';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   213
	}
586
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   214
}
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   215
else
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   216
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   217
	// compress enano-lib-basic
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   218
	$libbasic = "$before_includes\n$after_includes";
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   219
	$libbasic = jsres_cache_check('enano-lib-basic.js', $libbasic);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   220
	$everything .= $libbasic;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   221
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   222
	// $everything .= $before_includes;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   223
	// $everything .= $after_includes;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   224
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   225
	foreach ( $file_list as $js_file )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   226
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   227
		$file_contents = file_get_contents("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   228
		$time = filemtime("includes/clientside/static/$js_file");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   229
		if ( $time > $apex )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   230
			$apex = $time;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   231
		
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   232
		$file_contents = jsres_cache_check($js_file, $file_contents);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   233
		
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   234
		$everything .= "\n\n// $js_file\n";
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   235
		$everything .= "\n" . $file_contents;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   236
	}
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   237
}
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   238
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   239
// generate ETag
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   240
$etag = base64_encode(hexdecode(sha1($everything)));
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   241
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   242
if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   243
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   244
	if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   245
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   246
		header('HTTP/1.1 304 Not Modified');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   247
		exit();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   248
	}
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   249
}
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   250
559
cfdc0aa8af50 [YSlow] Added Expires header on jsres.php
Dan
parents: 555
diff changeset
   251
// generate expires header
798
ddfc1b554a08 Redid error handler (it was causing some problems with gzip enabled)
Dan
parents: 780
diff changeset
   252
$expires = date('r', mktime(0, 0, 0, intval(date('m')), intval(date('d')), intval(date('y'))+1));
559
cfdc0aa8af50 [YSlow] Added Expires header on jsres.php
Dan
parents: 555
diff changeset
   253
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   254
$everything = str_replace('/* JavaScriptCompressor 0.8 [www.devpro.it], thanks to Dean Edwards for idea [dean.edwards.name] */' . "\r\n", '', $everything);
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   255
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   256
$date = date('r', $apex);
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   257
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   258
if ( defined('ENANO_JSRES_SETUP_ONLY') )
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   259
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   260
	return; // we're done setting up, break out
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   261
}
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 613
diff changeset
   262
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   263
header("Date: $date");
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   264
header("Last-Modified: $date");
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   265
header("ETag: \"$etag\"");
559
cfdc0aa8af50 [YSlow] Added Expires header on jsres.php
Dan
parents: 555
diff changeset
   266
header("Expires: $expires");
800
9cdfe82c56cd Major underlying changes to namespace handling. Each namespace is handled by its own class which extends Namespace_Default. Much greater customization/pluggability potential, at the possible expense of some code reusing (though code reusing has been avoided thus far). Also a bit better handling of page passwords [SECURITY].
Dan
parents: 798
diff changeset
   267
if ( !$do_gzip )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   268
	header("Content-Length: " . strlen($everything));
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   269
586
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   270
$local_end = microtime_float();
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   271
$local_gentime = $local_end - $local_start;
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   272
$local_gentime = round($local_gentime, 5);
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   273
header("X-Performance: generated in $local_gentime seconds");
234ddd896555 Made encryption work in form-based logon again; modified load_component() to fetch compressed versions when possible
Dan
parents: 582
diff changeset
   274
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   275
echo $everything;
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   276
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   277
if ( $do_gzip )
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   278
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   279
	gzip_output();
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   280
}
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   281
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   282
/**
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   283
 * Check the cache for the given JS file and return the best-compressed version.
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   284
 * @param string Javascript file (acl.js)
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   285
 * @param string Default/current contents
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   286
 * @return string
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   287
 */
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   288
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   289
function jsres_cache_check($js_file, $file_contents)
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 542
diff changeset
   290
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   291
	global $full_compress_safe, $compress_unsafe;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   292
	global $disable_compress;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   293
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   294
	if ( $disable_compress )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   295
		return $file_contents;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   296
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   297
	$file_md5 = md5($file_contents);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   298
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   299
	// Is this file cached?
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   300
	$cache_path = ENANO_ROOT . "/cache/jsres_$js_file.json";
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   301
	$loaded_cache = false;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   302
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   303
	if ( file_exists($cache_path) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   304
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   305
		// Load the cache file and parse it.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   306
		$cache_file = file_get_contents($cache_path);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   307
		try
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   308
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   309
			$cache_file = enano_json_decode($cache_file);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   310
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   311
		catch ( Exception $e )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   312
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   313
			// Don't do anything - let our fallbacks come into place
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   314
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   315
		if ( is_array($cache_file) && isset($cache_file['md5']) && isset($cache_file['src']) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   316
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   317
			if ( $cache_file['md5'] === $file_md5 )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   318
			{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   319
				@header("X-Cache-Status: cache HIT, hash $file_md5");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   320
				$loaded_cache = true;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   321
				$file_contents = $cache_file['src'];
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   322
			}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   323
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   324
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   325
	if ( !$loaded_cache && getConfig('cache_thumbs') == '1' )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   326
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   327
		// Try to open the cache file and write to it. If we can't do that, just don't compress the code.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   328
		$handle = @fopen($cache_path, 'w');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   329
		if ( $handle )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   330
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   331
			$aggressive = in_array($js_file, $full_compress_safe);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   332
			if ( !in_array($js_file, $compress_unsafe) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   333
				$file_contents = perform_js_compress($file_contents, $aggressive);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   334
			
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   335
			$payload = enano_json_encode(array(
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   336
					'md5' => $file_md5,
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   337
					'src' => $file_contents
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   338
				));
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   339
			fwrite($handle, $payload);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   340
			fclose($handle);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   341
			@header("X-Cache-Status: cache MISS, new generated");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   342
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   343
		else
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   344
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   345
			@header("X-Cache-Status: cache MISS, not generated");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   346
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   347
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   348
	else if ( !$loaded_cache )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   349
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   350
		@header("X-Cache-Status: cache MISS, not generated");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   351
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   352
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1226
diff changeset
   353
	return $file_contents;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   354
}
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 411
diff changeset
   355