public function actionIndex()
	{
		$incPath = get_include_path();
		$docRoot = $_SERVER['DOCUMENT_ROOT'];
		$_SERVER['DOCUMENT_ROOT'] = dirname(Yii::app()->request->getScriptFile());
		set_include_path(Yii::app()->getExtensionPath()."/minify" . PATH_SEPARATOR . $incPath);
		require 'Minify.php';
		$option['debug'] = $this->_debug;
		$option['maxAge'] = $this->_maxAge;
		$option['bubbleCssImports'] = $this->_bubbleCssImports;
		$option['encodeOutput'] = $this->_encodeOutput;
		$option['encodeMethod'] = $this->_encodeMethod;
		foreach ($this->_symlinks as $link => $target) {
			$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT'])."/", $link);
			$link = strtr($link, '/', DIRECTORY_SEPARATOR);
			$option['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
		}
		Minify::setCache(Yii::app()->getRuntimePath(), $this->_cacheFileLocking);
		if ($this->_errorLogger) {
			require_once 'Minify/Logger.php';
			require_once 'FirePHP.php';
			Minify_Logger::setLogger(FirePHP::getInstance(true));
		}
		$mgv = Yii::app()->getRuntimePath()."/minifyGroups.var";
		$minifyGroups = unserialize(file_get_contents($mgv));
		$option['files'] = $minifyGroups[$_GET['group']];
		Minify::serve('Files', $option);
		set_include_path($incPath);
		$_SERVER['DOCUMENT_ROOT'] = $docRoot;
	}
Example #2
0
 public function action_minify()
 {
     // load config
     $config = Kohana::config('minify');
     //require  MINIFY_MIN_DIR.'/Minify.php';
     Minify::$uploaderHoursBehind = $config['uploaderHoursBehind'];
     Minify::setCache(isset($config['cachePath']) ? $config['cachePath'] : '', $config['cacheFileLocking']);
     if ($config['documentRoot']) {
         $_SERVER['DOCUMENT_ROOT'] = $config['documentRoot'];
     } elseif (0 === stripos(PHP_OS, 'win')) {
         Minify::setDocRoot();
         // IIS may need help
     }
     $config['serveOptions']['minifierOptions']['text/css']['symlinks'] = $config['symlinks'];
     // auto-add targets to allowDirs
     foreach ($config['symlinks'] as $uri => $target) {
         $config['serveOptions']['minApp']['allowDirs'][] = $target;
     }
     if ($config['allowDebugFlag']) {
         if (!empty($_COOKIE['minDebug'])) {
             foreach (preg_split('/\\s+/', $_COOKIE['minDebug']) as $debugUri) {
                 if (false !== strpos($_SERVER['REQUEST_URI'], $debugUri)) {
                     $config['serveOptions']['debug'] = true;
                     break;
                 }
             }
         }
         // allow GET to override
         if (isset($_GET['debug'])) {
             $config['serveOptions']['debug'] = true;
         }
     }
     if ($config['errorLogger']) {
         //require _once MINIFY_MIN_DIR . '/Minify/Logger.php';
         if (true === $config['errorLogger']) {
             //require _once MINIFY_MIN_DIR . '/FirePHP.php';
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($config['errorLogger']);
         }
     }
     // check for URI versioning
     if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
         $config['serveOptions']['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // well need groups config
         $config['serveOptions']['minApp']['groups'] = $config['groupsConfig'];
     }
     if (isset($_GET['f']) || isset($_GET['g'])) {
         // serve!
         Minify::serve('MinApp', $config['serveOptions']);
         exit;
     }
 }
Example #3
0
 /**
  * Runs minify
  */
 function process()
 {
     require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
     require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
     HTTP_Encoder::$encodeToIe6 = $this->_config->get_boolean('minify.comprss.ie6');
     Minify::$uploaderHoursBehind = $this->_config->get_integer('minify.fixtime');
     Minify::setCache($this->_get_cache());
     $serve_options = $this->_config->get_array('minify.options');
     $serve_options['maxAge'] = $this->_config->get_integer('minify.maxage');
     $serve_options['encodeOutput'] = $this->_config->get_boolean('minify.compress');
     $serve_options['postprocessor'] = array(&$this, 'postprocessor');
     if (stripos(PHP_OS, 'win') === 0) {
         Minify::setDocRoot();
     }
     foreach ($this->_config->get_array('minify.symlinks') as $link => $target) {
         $link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
         $link = strtr($link, '/', DIRECTORY_SEPARATOR);
         $serve_options['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
     }
     if ($this->_config->get_boolean('minify.debug')) {
         $serve_options['debug'] = true;
     }
     if ($this->_config->get('minify.debug')) {
         require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
         Minify_Logger::setLogger($this);
     }
     if (isset($_GET['f']) || isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
         if (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
             $serve_options['minApp']['groups'] = $this->get_groups($_GET['gg'], $_GET['t']);
             if ($_GET['t'] == 'js' && (in_array($_GET['g'], array('include', 'include-nb')) && $this->_config->get_boolean('minify.js.combine.header') || in_array($_GET['g'], array('include-footer', 'include-footer-nb')) && $this->_config->get_boolean('minify.js.combine.footer'))) {
                 $serve_options['minifiers']['application/x-javascript'] = array($this, 'minify_stub');
             }
             /**
              * Setup user-friendly cache ID for disk cache
              */
             if ($this->_config->get_string('minify.engine') == 'file') {
                 $cacheId = sprintf('%s.%s.%s', $_GET['gg'], $_GET['g'], $_GET['t']);
                 Minify::setCacheId($cacheId);
             }
         }
         @header('Pragma: public');
         try {
             Minify::serve('MinApp', $serve_options);
         } catch (Exception $exception) {
             printf('<strong>W3 Total Cache Error:</strong> Minify error: %s', $exception->getMessage());
         }
     } else {
         die('This file cannot be accessed directly');
     }
 }
Example #4
0
 public function serve()
 {
     // Adapted from index.php and config.php in the Minify distribution
     $min_serveOptions = array();
     $min_uploaderHoursBehind = isset($this->_config['min_uploaderHoursBehind']) ? $this->_config['min_uploaderHoursBehind'] : 0;
     Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
     $min_cacheFileLocking = isset($this->_config['min_cacheFileLocking']) ? $this->_config['min_cacheFileLocking'] : true;
     $min_cachePath = $this->_config['cache_dir'];
     Minify::setCache($min_cachePath, $min_cacheFileLocking);
     $min_symlinks = isset($this->_config['min_symlinks']) ? $this->_config['min_symlinks'] : array();
     foreach ($min_symlinks as $link => $target) {
         $link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
         $link = strtr($link, '/', DIRECTORY_SEPARATOR);
         $min_serveOptions['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
     }
     $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
     if (isset($this->_config['debug_minify_logger'])) {
         require_once 'Minify/Logger.php';
         if (true === $this->_config['debug_minify_logger']) {
             require_once 'FirePHP.php';
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($this->_config['debug_minify_logger']);
         }
     }
     // check for URI versioning
     if (!empty($this->_version)) {
         $min_serveOptions['maxAge'] = 31536000;
     } else {
         # don't cache if we are not using a version number
         $min_serveOptions['maxAge'] = 0;
     }
     $min_serveOptions['swift']['files'] = array();
     foreach ($this->_current_modules as $module) {
         if (!empty($this->_config['debug_use_alt_resources']) && !empty($this->_config['modules'][$module]['debug_path'])) {
             $min_serveOptions['swift']['files'][] = $this->_config['modules'][$module]['debug_path'];
         } else {
             $min_serveOptions['swift']['files'][] = $this->_config['modules'][$module]['path'];
         }
     }
     # check what format we're working on by looking at the extension on the first file
     # if we are in debug mode for the current type of files use Minify's debug mode
     if (!empty($this->_config['debug_minify_js_off']) && pathinfo($min_serveOptions['swift']['files'][0], PATHINFO_EXTENSION) == 'js' || !empty($this->_config['debug_minify_css_off']) && pathinfo($min_serveOptions['swift']['files'][0], PATHINFO_EXTENSION) == 'css') {
         $min_serveOptions['debug'] = true;
     }
     Minify::serve('Swift', $min_serveOptions);
 }
Example #5
0
 public function action_index()
 {
     $group = $this->request->param('group');
     if (!empty($group)) {
         $_GET['g'] = $group;
     }
     $config = Kohana::$config->load('minify');
     Minify::$uploaderHoursBehind = $config['uploaderHoursBehind'];
     Minify::setCache(isset($config['cachePath']) ? $config['cachePath'] : '', $config['cacheFileLocking']);
     if ($config['documentRoot']) {
         $_SERVER['DOCUMENT_ROOT'] = $config['documentRoot'];
         Minify::$isDocRootSet = TRUE;
     }
     $serve_options = $config['serveOptions'];
     $serve_options['minifierOptions']['text/css']['symlinks'] = $config['symlinks'];
     foreach ($config['symlinks'] as $uri => $target) {
         $serve_options['minApp']['allowDirs'][] = $target;
     }
     if ($config['allowDebugFlag']) {
         $serve_options['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($config['errorLogger']) {
         if (TRUE === $config['errorLogger']) {
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($config['errorLogger']);
         }
     }
     // Check for URI versioning
     if (preg_match('/&\\d/', Arr::get($_SERVER, 'QUERY_STRING'))) {
         $serve_options['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // well need groups config
         $serve_options['minApp']['groups'] = $config['groupsConfig'];
     }
     if (isset($_GET['f']) or isset($_GET['g'])) {
         $response = Minify::serve(new Minify_Controller_MinApp(), array('quiet' => TRUE) + $serve_options);
         $this->response->headers($response['headers'])->status($response['statusCode'])->body($response['content']);
     }
 }
Example #6
0
 public function action_index()
 {
     extract(Kohana::$config->load('minify')->as_array(), EXTR_SKIP);
     if ($this->request->param('group')) {
         $_GET['g'] = $this->request->param('group');
     }
     Minify::$uploaderHoursBehind = $uploaderHoursBehind;
     Minify::setCache(isset($cachePath) ? $cachePath : '', $cacheFileLocking);
     if ($documentRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $documentRoot;
         Minify::$isDocRootSet = TRUE;
     }
     $serveOptions['minifierOptions']['text/css']['symlinks'] = $symlinks;
     $serveOptions['minApp']['allowDirs'] += array_values($symlinks);
     if ($allowDebugFlag) {
         $serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($errorLogger) {
         if (TRUE === $errorLogger) {
             $errorLogger = FirePHP::getInstance(TRUE);
         }
         Minify_Logger::setLogger($errorLogger);
     }
     // Check for URI versioning
     if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
         $serveOptions['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // Well need groups config
         $serveOptions['minApp']['groups'] = $groupsConfig;
     }
     if (isset($_GET['f']) or isset($_GET['g'])) {
         set_time_limit(0);
         // Serve!
         $response = Minify::serve(new Minify_Controller_MinApp(), array('quiet' => TRUE) + $serveOptions);
         $this->response->headers($response['headers'])->body($response['content'])->status($response['statusCode']);
     }
 }
Example #7
0
File: File.php Project: ahmatjan/lv
 /**
  * Send message to the Minify logger
  * @param string $msg
  * @return null
  */
 protected function _log($msg)
 {
     Minify_Logger::log($msg);
 }
Example #8
0
 /**
  * Runs minify
  *
  * @param string|null $file
  *
  * @return void
  */
 function process($file = NULL)
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     /**
      * Check for rewrite test request
      */
     $rewrite_test = W3_Request::get_boolean('w3tc_rewrite_test');
     if ($rewrite_test) {
         echo 'OK';
         exit;
     }
     $rewrite_test = W3_Request::get_string('test_file');
     if ($rewrite_test) {
         $cache = $this->_get_cache();
         header('Content-type: text/css');
         if ($cache->store(basename($rewrite_test), 'content ok')) {
             if (function_exists('gzencode') && $this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.cssjs.compression')) {
                 if (!$cache->store(basename($rewrite_test) . '.gzip', gzencode('content ok'))) {
                     echo 'error storing';
                     exit;
                 }
             }
             if ($this->_config->get_string('minify.engine') != 'file') {
                 if ($cache->fetch(basename($rewrite_test)) == 'content ok') {
                     echo 'content ok';
                 } else {
                     echo 'error storing';
                 }
             } else {
                 echo 'retry';
             }
         } else {
             echo 'error storing';
         }
         exit;
     }
     if (is_null($file)) {
         $file = W3_Request::get_string('file');
     }
     if (!$file) {
         $this->error('File param is missing', false);
         return;
     }
     // remove blog_id
     $levels = '';
     if (defined('W3TC_BLOG_LEVELS')) {
         for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
             $levels .= '[0-9]+\\/';
         }
     }
     if (preg_match('~^(' . $levels . '[0-9]+)\\/(.+)$~', $file, $matches)) {
         $file = $matches[2];
     }
     // parse file
     $hash = '';
     $matches = null;
     $location = '';
     $type = '';
     if (preg_match('~^' . MINIFY_AUTO_FILENAME_REGEX . '$~', $file, $matches)) {
         list(, $hash, $type) = $matches;
     } elseif (preg_match('~^' . MINIFY_MANUAL_FILENAME_REGEX . '$~', $file, $matches)) {
         list(, $theme, $template, $location, , , $type) = $matches;
     } else {
         $this->error(sprintf('Bad file param format: "%s"', $file), false);
         return;
     }
     w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify.php');
     w3_require_once(W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php');
     /**
      * Fix DOCUMENT_ROOT
      */
     $_SERVER['DOCUMENT_ROOT'] = w3_get_document_root();
     /**
      * Set cache engine
      */
     Minify::setCache($this->_get_cache());
     /**
      * Set cache ID
      */
     $cache_id = $this->get_cache_id($file);
     Minify::setCacheId($cache_id);
     /**
      * Set logger
      */
     w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php');
     Minify_Logger::setLogger(array(&$this, 'error'));
     /**
      * Set options
      */
     $browsercache = $this->_config->get_boolean('browsercache.enabled');
     $serve_options = array_merge($this->_config->get_array('minify.options'), array('debug' => $this->_config->get_boolean('minify.debug'), 'maxAge' => $this->_config->get_integer('browsercache.cssjs.lifetime'), 'encodeOutput' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.compression'), 'bubbleCssImports' => $this->_config->get_string('minify.css.imports') == 'bubble', 'processCssImports' => $this->_config->get_string('minify.css.imports') == 'process', 'cacheHeaders' => array('use_etag' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.etag'), 'expires_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.expires'), 'cacheheaders_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.cache.control'), 'cacheheaders' => $this->_config->get_string('browsercache.cssjs.cache.policy'))));
     /**
      * Set sources
      */
     if ($hash) {
         $_GET['f'] = $this->get_custom_files($hash, $type);
     } else {
         $_GET['g'] = $location;
         $serve_options['minApp']['groups'] = $this->get_groups($theme, $template, $type);
     }
     /**
      * Set minifier
      */
     $w3_minifier = w3_instance('W3_Minifier');
     if ($type == 'js') {
         $minifier_type = 'application/x-javascript';
         switch (true) {
             case ($hash || $location == 'include') && $this->_config->get_boolean('minify.js.combine.header'):
             case $location == 'include-body' && $this->_config->get_boolean('minify.js.combine.body'):
             case $location == 'include-footer' && $this->_config->get_boolean('minify.js.combine.footer'):
                 $engine = 'combinejs';
                 break;
             default:
                 $engine = $this->_config->get_string('minify.js.engine');
                 if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                     $engine = 'js';
                 }
                 break;
         }
     } elseif ($type == 'css') {
         $minifier_type = 'text/css';
         if (($hash || $location == 'include') && $this->_config->get_boolean('minify.css.combine')) {
             $engine = 'combinecss';
         } else {
             $engine = $this->_config->get_string('minify.css.engine');
             if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                 $engine = 'css';
             }
         }
     }
     /**
      * Initialize minifier
      */
     $w3_minifier->init($engine);
     $serve_options['minifiers'][$minifier_type] = $w3_minifier->get_minifier($engine);
     $serve_options['minifierOptions'][$minifier_type] = $w3_minifier->get_options($engine);
     /**
      * Send X-Powered-By header
      */
     if ($browsercache && $this->_config->get_boolean('browsercache.cssjs.w3tc')) {
         @header('X-Powered-By: ' . W3TC_POWERED_BY);
     }
     /**
      * Minify!
      */
     try {
         Minify::serve('MinApp', $serve_options);
     } catch (Exception $exception) {
         $this->error($exception->getMessage());
     }
     if (!$this->_error_occurred && $this->_config_admin->get_boolean('notes.minify_error')) {
         $error_file = $this->_config_admin->get_string('minify.error.file');
         if ($error_file == $file) {
             $this->_config_admin->set('notes.minify_error', false);
             $this->_config_admin->save();
         }
     }
 }
Example #9
0
 /**
  * On IIS, create $_SERVER['DOCUMENT_ROOT']
  * 
  * @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
  * will be unset (it is inconsistent with Apache's setting)
  * 
  * @return null
  */
 public static function setDocRoot($unsetPathInfo = false)
 {
     if (isset($_SERVER['SERVER_SOFTWARE'])
         && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')
     ) {
         $_SERVER['DOCUMENT_ROOT'] = rtrim(substr(
             $_SERVER['PATH_TRANSLATED']
             ,0
             ,strlen($_SERVER['PATH_TRANSLATED']) - strlen($_SERVER['SCRIPT_NAME'])
         ), '\\');
         if ($unsetPathInfo) {
             unset($_SERVER['PATH_INFO']);
         }
         require_once 'Minify/Logger.php';
         Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
     }
 }
Example #10
0
    $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
    Minify::$isDocRootSet = true;
}
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
// auto-add targets to allowDirs
foreach ($min_symlinks as $uri => $target) {
    $min_serveOptions['minApp']['allowDirs'][] = $target;
}
if ($min_allowDebugFlag) {
    $min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
}
if ($min_errorLogger) {
    if (true === $min_errorLogger) {
        $min_errorLogger = FirePHP::getInstance(true);
    }
    Minify_Logger::setLogger($min_errorLogger);
}
// check for URI versioning
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
    $min_serveOptions['maxAge'] = 31536000;
}
if (isset($_GET['g'])) {
    // well need groups config
    $min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
}
if (isset($_GET['f']) || isset($_GET['g'])) {
    // serve!
    if (!isset($min_serveController)) {
        $min_serveController = new Minify_Controller_MinApp();
    }
    Minify::serve($min_serveController, $min_serveOptions);
Example #11
0
 /**
  * Send message to the Minify logger
  * @param string $msg
  * @return null
  */
 public function log($msg)
 {
     //require _once MINIFY_MIN_DIR . '/Minify/Logger.php';
     Minify_Logger::log($msg);
 }
Example #12
0
 /**
  * Runs minify
  *
  * @return void
  */
 function process()
 {
     require_once W3TC_LIB_W3_DIR . '/Request.php';
     /**
      * Check for rewrite test request
      */
     $rewrite_test = W3_Request::get_boolean('w3tc_rewrite_test');
     if ($rewrite_test) {
         echo 'OK';
         exit;
     }
     $file = W3_Request::get_string('file');
     if (!$file) {
         $this->error('File param is missing', false);
         return;
     }
     $hash = '';
     $matches = null;
     if (preg_match('~^([a-f0-9]+)\\.[a-f0-9]+\\.(css|js)$~', $file, $matches)) {
         list(, $hash, $type) = $matches;
     } elseif (preg_match('~^([a-f0-9]+)\\/(.+)\\.(include(\\-(footer|body))?(-nb)?)\\.[a-f0-9]+\\.(css|js)$~', $file, $matches)) {
         list(, $theme, $template, $location, , , , $type) = $matches;
     } else {
         $this->error(sprintf('Bad file param format: "%s"', $file), false);
         return;
     }
     require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
     require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
     /**
      * Fix DOCUMENT_ROOT
      */
     $_SERVER['DOCUMENT_ROOT'] = w3_get_document_root();
     /**
      * Set cache engine
      */
     Minify::setCache($this->_get_cache());
     /**
      * Set cache ID
      */
     $cache_id = $this->get_cache_id($file);
     Minify::setCacheId($cache_id);
     /**
      * Set logger
      */
     require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
     Minify_Logger::setLogger(array(&$this, 'error'));
     /**
      * Set options
      */
     $browsercache = $this->_config->get_boolean('browsercache.enabled');
     $serve_options = array_merge($this->_config->get_array('minify.options'), array('debug' => $this->_config->get_boolean('minify.debug'), 'maxAge' => $this->_config->get_integer('browsercache.cssjs.lifetime'), 'encodeOutput' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.compression'), 'bubbleCssImports' => $this->_config->get_string('minify.css.imports') == 'bubble', 'processCssImports' => $this->_config->get_string('minify.css.imports') == 'process', 'cacheHeaders' => array('use_etag' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.etag'), 'expires_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.expires'), 'cacheheaders_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.cache.control'), 'cacheheaders' => $this->_config->get_string('browsercache.cssjs.cache.policy'))));
     /**
      * Set sources
      */
     if ($hash) {
         $_GET['f'] = $this->get_files($hash, $type);
     } else {
         $_GET['g'] = $location;
         $serve_options['minApp']['groups'] = $this->get_groups($theme, $template, $type);
     }
     /**
      * Set minifier
      */
     $w3_minifier =& w3_instance('W3_Minifier');
     if ($type == 'js') {
         $minifier_type = 'application/x-javascript';
         switch (true) {
             case ($hash || $location == 'include' || $location == 'include-nb') && $this->_config->get_boolean('minify.js.combine.header'):
             case ($location == 'include-body' || $location == 'include-body-nb') && $this->_config->get_boolean('minify.js.combine.body'):
             case ($location == 'include-footer' || $location == 'include-footer-nb') && $this->_config->get_boolean('minify.js.combine.footer'):
                 $engine = 'combinejs';
                 break;
             default:
                 $engine = $this->_config->get_string('minify.js.engine');
                 if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                     $engine = 'js';
                 }
                 break;
         }
     } elseif ($type == 'css') {
         $minifier_type = 'text/css';
         if (($hash || $location == 'include') && $this->_config->get_boolean('minify.css.combine')) {
             $engine = 'combinecss';
         } else {
             $engine = $this->_config->get_string('minify.css.engine');
             if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                 $engine = 'css';
             }
         }
     }
     /**
      * Initialize minifier
      */
     $w3_minifier->init($engine);
     $serve_options['minifiers'][$minifier_type] = $w3_minifier->get_minifier($engine);
     $serve_options['minifierOptions'][$minifier_type] = $w3_minifier->get_options($engine);
     /**
      * Send X-Powered-By header
      */
     if ($browsercache && $this->_config->get_boolean('browsercache.cssjs.w3tc')) {
         @header('X-Powered-By: ' . W3TC_POWERED_BY);
     }
     /**
      * Minify!
      */
     try {
         Minify::serve('MinApp', $serve_options);
     } catch (Exception $exception) {
         $this->error($exception->getMessage());
     }
 }
Example #13
0
 public function indexAction()
 {
     include APP_PATH . '/library/Thirdpart/Minify/bootstrap.php';
     // set config path defaults
     $min_configPaths = array('base' => CONF_PATH . '/minify-config.php', 'test' => CONF_PATH . '/minify-config-test.php');
     // check for custom config paths
     if (!empty($min_customConfigPaths) && is_array($min_customConfigPaths)) {
         $min_configPaths = array_merge($min_configPaths, $min_customConfigPaths);
     }
     // load config
     require $min_configPaths['base'];
     if (isset($_GET['test'])) {
         include $min_configPaths['test'];
     }
     // setup factories
     $defaultFactories = array('minify' => function (Minify_CacheInterface $cache) {
         return new Minify($cache);
     }, 'controller' => function (Minify_Env $env, Minify_Source_Factory $sourceFactory) {
         return new Minify_Controller_MinApp($env, $sourceFactory);
     });
     if (!isset($min_factories)) {
         $min_factories = array();
     }
     $min_factories = array_merge($defaultFactories, $min_factories);
     // use an environment object to encapsulate all input
     $server = $_SERVER;
     if ($min_documentRoot) {
         $server['DOCUMENT_ROOT'] = $min_documentRoot;
     }
     $env = new Minify_Env(array('server' => $server));
     // TODO probably should do this elsewhere...
     $min_serveOptions['minifierOptions']['text/css']['docRoot'] = $env->getDocRoot();
     $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
     // auto-add targets to allowDirs
     foreach ($min_symlinks as $uri => $target) {
         $min_serveOptions['minApp']['allowDirs'][] = $target;
     }
     if ($min_allowDebugFlag) {
         // TODO get rid of static stuff
         $min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($env);
     }
     if (!empty($min_concatOnly)) {
         $min_serveOptions['concatOnly'] = true;
     }
     if ($min_errorLogger) {
         if (true === $min_errorLogger) {
             $min_errorLogger = FirePHP::getInstance(true);
         }
         // TODO get rid of global state
         Minify_Logger::setLogger($min_errorLogger);
     }
     // check for URI versioning
     if (null !== $env->get('v') || preg_match('/&\\d/', $env->server('QUERY_STRING'))) {
         $min_serveOptions['maxAge'] = 31536000;
     }
     // need groups config?
     if (null !== $env->get('g')) {
         // we need groups config
         $min_serveOptions['minApp']['groups'] = \Model\Minify::loadGroupConfig();
     }
     // cache defaults
     if (!isset($min_cachePath)) {
         $min_cachePath = '';
     }
     if (!isset($min_cacheFileLocking)) {
         $min_cacheFileLocking = true;
     }
     if (is_string($min_cachePath)) {
         $cache = new Minify_Cache_File($min_cachePath, $min_cacheFileLocking);
     } else {
         // assume it meets interface.
         $cache = $min_cachePath;
     }
     /* @var Minify_CacheInterface $cache */
     $minify = call_user_func($min_factories['minify'], $cache);
     /* @var Minify $minify */
     if (!$env->get('f') && $env->get('g') === null) {
         // no spec given
         $msg = '<p>No "f" or "g" parameters were detected.</p>';
         $url = 'https://github.com/mrclay/minify/blob/master/docs/CommonProblems.wiki.md#long-url-parameters-are-ignored';
         $defaults = $minify->getDefaultOptions();
         $minify->errorExit($defaults['badRequestHeader'], $url, $msg);
     }
     $sourceFactoryOptions = array();
     // translate legacy setting to option for source factory
     if (isset($min_serveOptions['minApp']['noMinPattern'])) {
         $sourceFactoryOptions['noMinPattern'] = $min_serveOptions['minApp']['noMinPattern'];
     }
     $sourceFactory = new Minify_Source_Factory($env, $sourceFactoryOptions, $cache);
     $controller = call_user_func($min_factories['controller'], $env, $sourceFactory);
     /* @var Minify_ControllerInterface $controller */
     $minify->serve($controller, $min_serveOptions);
     return false;
 }
Example #14
0
 /**
  * Send message to the Minify logger
  * @param string $msg
  * @return null
  */
 protected function _log($msg)
 {
     //require _once MINIFY_MIN_DIR . '/Minify/Logger.php';
     Minify_Logger::log($msg);
 }
}
if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
    $base = trim(getPost('base'));
    if ($base) {
        $textIn = preg_replace('@(<head\\b[^>]*>)@i', '$1<base href="' . h($base) . '" />', $textIn);
    }
    $sourceSpec['content'] = $textIn;
    $sourceSpec['id'] = 'foo';
    if (isset($_POST['minJs'])) {
        $sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
    }
    if (isset($_POST['minCss'])) {
        $sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
    }
    $source = new Minify_Source($sourceSpec);
    Minify_Logger::setLogger(FirePHP::getInstance(true));
    try {
        Minify::serve('Files', array('files' => $source, 'contentType' => Minify::TYPE_HTML));
    } catch (Exception $e) {
        echo h($e->getMessage());
    }
    exit;
}
$tpl = array();
$tpl['classes'] = array('Minify_HTML', 'JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
    $args = array($textIn);
    if ($_POST['method'] === 'Minify_HTML') {
        $args[] = array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify'));
    }
    $func = array($_POST['method'], 'minify');
Example #16
0
 public function enableLogging()
 {
     $min_errorLogger = FirePHP::getInstance(true);
     Minify_Logger::setLogger($min_errorLogger);
 }
Example #17
0
 private function initialize($params = array())
 {
     set_include_path(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'minify' . PATH_SEPARATOR . get_include_path());
     require_once 'Minify/Build.php';
     require_once 'Minify.php';
     if (count($params) > 0) {
         foreach ($params as $key => $val) {
             $this->{$key} = $val;
         }
     }
     if ($this->debug === TRUE) {
         $this->init_debug();
         Minify_Logger::setLogger(FirePHP::getInstance(true));
     }
     $this->set_css_file_path();
     $this->set_js_file_path();
     $this->set_cache_path();
 }
 /**
  * Runs minify
  *
  * @param string|null $file
  *
  * @return void
  */
 function process($file = NULL, $quiet = false)
 {
     /**
      * Check for rewrite test request
      */
     $rewrite_marker = 'rewrite_test.css';
     if (substr($file, strlen($file) - strlen($rewrite_marker)) == $rewrite_marker) {
         echo 'Minify OK';
         exit;
     }
     $filelength_test_marker = 'XXX.css';
     if (substr($file, strlen($file) - strlen($filelength_test_marker)) == $filelength_test_marker) {
         $cache = $this->_get_cache();
         header('Content-type: text/css');
         if (!$cache->store(basename($file), array('content' => 'content ok'))) {
             echo 'error storing';
         } else {
             if (function_exists('gzencode') && $this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.cssjs.compression')) {
                 if (!$cache->store(basename($file) . '.gzip', array('content' => gzencode('content ok')))) {
                     echo 'error storing';
                     exit;
                 }
             }
             $v = $cache->fetch(basename($file));
             if ($v['content'] == 'content ok') {
                 echo 'content ok';
             } else {
                 echo 'error storing';
             }
         }
         exit;
     }
     // remove querystring
     if (preg_match('~(.+)(\\?x[0-9]{5})$~', $file, $m)) {
         $file = $m[1];
     }
     // remove blog_id
     $levels = '';
     if (defined('W3TC_BLOG_LEVELS')) {
         for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
             $levels .= '[0-9]+\\/';
         }
     }
     if (preg_match('~^(' . $levels . '[0-9]+)\\/(.+)$~', $file, $matches)) {
         $file = $matches[2];
     }
     // normalize according to browsercache
     $file = Dispatcher::requested_minify_filename($this->_config, $file);
     // parse file
     $hash = '';
     $matches = null;
     $location = '';
     $type = '';
     if (preg_match('~^' . MINIFY_AUTO_FILENAME_REGEX . '$~', $file, $matches)) {
         list(, $hash, $type) = $matches;
     } elseif (preg_match('~^' . MINIFY_MANUAL_FILENAME_REGEX . '$~', $file, $matches)) {
         list(, $theme, $template, $location, , , $type) = $matches;
     } else {
         return $this->finish_with_error(sprintf('Bad file param format: "%s"', $file), $quiet, false);
     }
     /**
      * Set cache engine
      */
     $cache = $this->_get_cache();
     \Minify0_Minify::setCache($cache);
     /**
      * Set cache ID
      */
     $cache_id = $this->get_cache_id($file);
     \Minify0_Minify::setCacheId($file);
     /**
      * Set logger
      */
     \Minify_Logger::setLogger(array($this, 'debug_error'));
     /**
      * Set options
      */
     $browsercache = $this->_config->get_boolean('browsercache.enabled');
     $serve_options = array_merge($this->_config->get_array('minify.options'), array('debug' => $this->_config->get_boolean('minify.debug'), 'maxAge' => $this->_config->get_integer('browsercache.cssjs.lifetime'), 'encodeOutput' => $browsercache && !defined('W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF') && !$quiet && $this->_config->get_boolean('browsercache.cssjs.compression'), 'bubbleCssImports' => $this->_config->get_string('minify.css.imports') == 'bubble', 'processCssImports' => $this->_config->get_string('minify.css.imports') == 'process', 'cacheHeaders' => array('use_etag' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.etag'), 'expires_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.expires'), 'cacheheaders_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.cache.control'), 'cacheheaders' => $this->_config->get_string('browsercache.cssjs.cache.policy')), 'quiet' => $quiet));
     /**
      * Set sources
      */
     if ($hash) {
         $_GET['f_array'] = $this->minify_filename_to_filenames_for_minification($hash, $type);
         $_GET['ext'] = $type;
     } else {
         $_GET['g'] = $location;
         $serve_options['minApp']['groups'] = $this->get_groups($theme, $template, $type);
     }
     /**
      * Set minifier
      */
     $w3_minifier = Dispatcher::component('Minify_ContentMinifier');
     if ($type == 'js') {
         $minifier_type = 'application/x-javascript';
         switch (true) {
             case ($hash || $location == 'include') && $this->_config->get_boolean('minify.js.combine.header'):
             case $location == 'include-body' && $this->_config->get_boolean('minify.js.combine.body'):
             case $location == 'include-footer' && $this->_config->get_boolean('minify.js.combine.footer'):
                 $engine = 'combinejs';
                 break;
             default:
                 $engine = $this->_config->get_string('minify.js.engine');
                 if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                     $engine = 'js';
                 }
                 break;
         }
     } elseif ($type == 'css') {
         $minifier_type = 'text/css';
         if (($hash || $location == 'include') && $this->_config->get_boolean('minify.css.combine')) {
             $engine = 'combinecss';
         } else {
             $engine = $this->_config->get_string('minify.css.engine');
             if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
                 $engine = 'css';
             }
         }
     }
     /**
      * Initialize minifier
      */
     $w3_minifier->init($engine);
     $serve_options['minifiers'][$minifier_type] = $w3_minifier->get_minifier($engine);
     $serve_options['minifierOptions'][$minifier_type] = $w3_minifier->get_options($engine);
     /**
      * Send X-Powered-By header
      */
     if (!$quiet && $browsercache && $this->_config->get_boolean('browsercache.cssjs.w3tc')) {
         @header('X-Powered-By: ' . Util_Environment::w3tc_header());
     }
     if (empty($_GET['f_array']) && empty($_GET['g'])) {
         return $this->finish_with_error('Nothing to minify', $quiet, false);
     }
     /**
      * Minify!
      */
     $return = array();
     try {
         $return = \Minify0_Minify::serve('MinApp', $serve_options);
     } catch (\Exception $exception) {
         return $this->finish_with_error($exception->getMessage(), $quiet);
     }
     if (!is_null(\Minify0_Minify::$recoverableError)) {
         $this->_handle_error(\Minify0_Minify::$recoverableError);
     }
     $state = Dispatcher::config_state_master();
     if (!$this->_error_occurred && $state->get_boolean('minify.show_note_minify_error')) {
         $error_file = $state->get_string('minify.error.file');
         if ($error_file == $file) {
             $state->set('minify.show_note_minify_error', false);
             $state->save();
         }
     }
     return $return;
 }
Example #19
0
 public function runServe(TBGRequest $request)
 {
     if (!TBGContext::isMinifyEnabled()) {
         $itemarray = array($request['g'] => explode(',', base64_decode($request['files'])));
         if (array_key_exists('js', $itemarray)) {
             header('Content-type: text/javascript');
             foreach ($itemarray['js'] as $file) {
                 $ext = substr($file, -2);
                 if ($ext == 'js' && file_exists($file) && strpos(realpath($file), THEBUGGENIE_PATH) !== false) {
                     echo file_get_contents($file);
                 }
             }
         } else {
             header('Content-type: text/css');
             foreach ($itemarray['css'] as $file) {
                 $ext = substr($file, -3);
                 if ($ext == 'css' && file_exists($file) && strpos(realpath($file), THEBUGGENIE_PATH) !== false) {
                     echo file_get_contents($file);
                 }
             }
         }
         exit;
     }
     $this->getResponse()->setDecoration(TBGResponse::DECORATE_NONE);
     define('MINIFY_MIN_DIR', dirname(__FILE__) . '/../../../core/min');
     // load config
     require MINIFY_MIN_DIR . '/config.php';
     // setup include path
     set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
     require 'Minify.php';
     Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
     Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
     if ($min_documentRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
     } elseif (0 === mb_stripos(PHP_OS, 'win')) {
         Minify::setDocRoot();
         // IIS may need help
     }
     $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
     if ($min_allowDebugFlag && isset($_GET['debug'])) {
         $min_serveOptions['debug'] = true;
     }
     if ($min_errorLogger) {
         require_once 'Minify/Logger.php';
         if (true === $min_errorLogger) {
             require_once 'FirePHP.php';
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($min_errorLogger);
         }
     }
     // check for URI versioning
     if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
         $min_serveOptions['maxAge'] = 31536000;
     }
     $itemarray = array($request['g'] => explode(',', base64_decode($request['files'])));
     $min_serveOptions['minApp']['groups'] = $itemarray;
     ob_end_clean();
     $data = Minify::serve('MinApp', $min_serveOptions);
     header_remove('Pragma');
     foreach ($data['headers'] as $name => $val) {
         header($name . ': ' . $val);
     }
     header('HTTP/1.1 ' . $data['statusCode']);
     if ($data['statusCode'] != 304) {
         echo $data['content'];
     }
     exit;
 }
Example #20
0
 /**
  * Send message to the Minify logger
  * @param string $msg
  * @return null
  */
 protected function log($msg)
 {
     w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php');
     Minify_Logger::log($msg);
 }
Example #21
0
 /**
  * On IIS, create $_SERVER['DOCUMENT_ROOT']
  *
  * @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
  * will be unset (it is inconsistent with Apache's setting)
  *
  * @return null
  */
 public static function setDocRoot($unsetPathInfo = false)
 {
     if (isset($_SERVER['SERVER_SOFTWARE']) && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')) {
         $_SERVER['PATH_TRANSLATED'] = preg_replace('~[/\\\\]+~', '/', $_SERVER['PATH_TRANSLATED']);
         $_SERVER['DOCUMENT_ROOT'] = rtrim(substr($_SERVER['PATH_TRANSLATED'], 0, strlen($_SERVER['PATH_TRANSLATED']) - strlen($_SERVER['SCRIPT_NAME'])), '\\');
         if ($unsetPathInfo) {
             unset($_SERVER['PATH_INFO']);
         }
         w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php');
         Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
     }
 }
Example #22
0
 /**
  * Set logger object. 
  *
  * The object should have a method "log" that accepts a value as 1st argument and
  * an optional string label as the 2nd.
  *
  * @param mixed $obj or a "falsey" value to disable
  * @return null
  */
 public static function setLogger($obj = null)
 {
     self::$_logger = $obj ? $obj : null;
 }
Example #23
0
 /**
  * Analyze sources (if there are any) and set $options 'contentType'
  * and 'lastModifiedTime' if they already aren't.
  *
  * @param array $options options for Minify
  *
  * @return array options for Minify
  */
 protected function analyzeSources($options = array())
 {
     if (!$this->sources) {
         return $options;
     }
     $type = null;
     foreach ($this->sources as $source) {
         $sourceType = $source->getContentType();
         if (!empty($options['contentType'])) {
             // just verify sources have null content type or match the options
             if ($sourceType !== null && $sourceType !== $options['contentType']) {
                 // TODO better logging
                 Minify_Logger::log('ContentType mismatch');
                 $this->sources = array();
                 return $options;
             }
             continue;
         }
         if ($type === null) {
             $type = $sourceType;
         } elseif ($sourceType !== $type) {
             // TODO better logging
             Minify_Logger::log('ContentType mismatch');
             $this->sources = array();
             return $options;
         }
     }
     if (empty($options['contentType'])) {
         if (null === $type) {
             $type = 'text/plain';
         }
         $options['contentType'] = $type;
     }
     // last modified is needed for caching, even if setExpires is set
     if (!isset($options['lastModifiedTime'])) {
         $max = 0;
         foreach ($this->sources as $source) {
             $max = max($source->getLastModified(), $max);
         }
         $options['lastModifiedTime'] = $max;
     }
     return $options;
 }
Example #24
0
 /**
  * Send message to the Minify logger
  * @param string $msg
  * @return null
  */
 protected function _log($msg)
 {
     require_once 'Minify/Logger.php';
     Minify_Logger::log($msg);
 }
Example #25
0
 /**
  * Send message to the Minify logger
  *
  * @param string $msg
  *
  * @return null
  */
 public function log($msg)
 {
     require_once 'Minify/Logger.php';
     Minify_Logger::log($msg);
 }
Example #26
0
 /**
  * Send message to the Minify logger
  *
  * @param string $msg
  *
  * @return null
  */
 public function log($msg)
 {
     Minify_Logger::log($msg);
 }
 /**
  * Serves friendly minify url with minified contents
  *
  * This actually does a remote get from Minify's dir with appropriate `?f`
  * query variable built from persistently stored detected enqueued files.
  * All minified contents as well as headers should be preserved.
  *
  * Serving friendly minify urls like this cause a lot of overheads, but is
  * safer to use than server rewrite rules.
  *
  * @uses wp_remote_get()
  * @return void
  */
 public function serve($query)
 {
     $group_handle = isset($_GET['min_group']) ? $this->_sanitize_request($_GET['min_group']) : '';
     $type = isset($_GET['min_type']) && in_array($_GET['min_type'], array('js', 'css')) ? $_GET['min_type'] : '';
     $bid = isset($_GET['blog']) ? (int) $_GET['blog'] : 0;
     if (empty($group_handle) || empty($type) || empty($bid)) {
         // if missing any important data, do not proceed
         return;
     }
     global $blog_id;
     if ($bid != $blog_id) {
         // if not on the correct blog, do not proceed
         return;
     }
     $group = $this->_detector->get_group($group_handle);
     if (false == $group) {
         // this should not happen, but just in case it does
         echo sprintf(__('Minify group %s not found.', $this->_domain), $group_handle);
         exit;
     }
     // load Minify class based on default or custom Minify directory
     $min_dir = $this->_main->get_min_dir();
     if (empty($min_dir) || !file_exists($min_dir . 'config.php')) {
         // if Minify directory is not valid or Minify library is not found
         // we can not continue
         _e('Invalid Minify directory, please check Minify settings.', $this->_domain);
         exit;
     }
     // prepare input for Minify to handle
     $_GET['f'] = $group['string'];
     if ($this->_options['enable_debug'] == 'yes') {
         // add debug flag if needed
         $_GET['debug'] = 1;
     } else {
         // minified contents are often served compressed so it's best to turn off
         // error reporting to avoid content encoding error, unless debug is
         // enabled. This is useful when Minify doesn't catch all the notices
         // (for example when the cache directory is not writable).
         error_reporting(0);
     }
     // load Minify classes
     define('MINIFY_MIN_DIR', $min_dir);
     require_once MINIFY_MIN_DIR . '/config.php';
     require_once $min_libPath . '/Minify/Loader.php';
     Minify_Loader::register();
     // set some optional for the Minify application based on current settings
     Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
     // set cache file name (id) and cache path if needed
     Minify::setCacheId('minify-b' . $blog_id . '-' . $group_handle . '.' . $type);
     Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
     if ($min_documentRoot) {
         $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
         Minify::$isDocRootSet = true;
     }
     // set serve options for each file type if needed
     $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
     foreach ($min_symlinks as $uri => $target) {
         $min_serveOptions['minApp']['allowDirs'][] = $target;
     }
     if ($min_allowDebugFlag) {
         // allow debugging Minify application
         $min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($min_errorLogger) {
         // log Minify error if allowed
         if (true === $min_errorLogger) {
             $min_errorLogger = FirePHP::getInstance(true);
         }
         Minify_Logger::setLogger($min_errorLogger);
     }
     // serve minified contents, on the fly or from cache
     $min_serveController = new Minify_Controller_MinApp();
     Minify::serve($min_serveController, $min_serveOptions);
     // for a proper response headers
     exit;
 }