Browse Source

add MINIFY_SOURCES config const, to enable or disable minifying sources (it's too CPU intensive). Default disabled

tags/v1.5.5
Adam Bukowski 8 years ago
parent
commit
1fa4eaf56d
3 changed files with 23 additions and 5 deletions
  1. +1
    -0
      include/config.php
  2. +13
    -4
      serve.php
  3. +9
    -1
      setup.php

+ 1
- 0
include/config.php View File

@@ -27,6 +27,7 @@ if(!defined('GZIP_HISTORY')) define("GZIP_HISTORY",0);
if(!defined('REDUCING_TRANSFER')) define("REDUCING_TRANSFER",1);
if(!defined('CACHE_COMMON_FILES')) define("CACHE_COMMON_FILES",0);
if(!defined('MINIFY_ENCODE')) define('MINIFY_ENCODE',1);
if(!defined('MINIFY_SOURCES')) define('MINIFY_SOURCES',0);
if(!defined('MEMCACHE_SESSION_SERVER')) define('MEMCACHE_SESSION_SERVER','');

if(!defined('SUGGEST_DONATION')) define('SUGGEST_DONATION',0);


+ 13
- 4
serve.php View File

@@ -18,6 +18,7 @@
*/
$serveExtensions = array('css', 'js');
set_time_limit(0);
// serve
if (isset($_GET['f'])) {
$filename = $_GET['f']; // remove any naughty bits
@@ -30,10 +31,10 @@ if (isset($_GET['f'])) {
if(isset($arr)) {
$arr2 = array();
$this_file_dir_pattern = '/'.preg_quote(dirname(__FILE__),'/').'/i';
$this_file_dir_pattern = '/'.preg_quote(dirname(__FILE__),'/').'/i';
foreach($arr as $k=>$v) {
if (preg_match($filenamePattern, $v) &&
file_exists($v) && preg_match($this_file_dir_pattern,realpath($v)))
file_exists($v) && preg_match($this_file_dir_pattern,realpath($v)))
$arr2[] = $v;
}
@@ -50,14 +51,22 @@ if (isset($_GET['f'])) {
Minify::setCache($cache_dir);
$opts = array( 'files' => $arr2,
'setExpires' => time() + 86400 * 365,
'maxAge' => 86400 * 365,
'rewriteCssUris'=>false
);
if (!MINIFY_ENCODE) {
$opts['encodeOutput'] = false;
$opts['encodeMethod'] = '';
}
// The Files controller can serve an array of files, but here we just
if (!MINIFY_SOURCES) {
$opts['minifiers'] = array(
Minify::TYPE_CSS => '',
Minify::TYPE_HTML => '',
Minify::TYPE_JS => ''
);
}
// The Files controller can serve an array of files, but here we just
// need one.
Minify::serve('Files', $opts);


+ 9
- 1
setup.php View File

@@ -334,11 +334,19 @@ define(\'REPORT_ALL_ERRORS\',1);
define(\'GZIP_HISTORY\',1);

/*
* Minify compression
* Compress HTTP output
*/
define(\'MINIFY_ENCODE\',1);

/*
* Apply sources minifying algorithms.
*
* If enabled CPU usage may raise, but amount
* of transferred data is smaller.
*/
define(\'MINIFY_SOURCES\',0);

/*
* Show donation links in EPESI
*/
define(\'SUGGEST_DONATION\',1);


Loading…
Cancel
Save