/controller/compressor.php
PHP | 4401 lines | 3986 code | 31 blank | 384 comment | 620 complexity | 93e1035a585d931b99fe8efa4fe67a25 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * File from WEBO Site SpeedUp, WEBO Software (http://www.webogroup.com/)
- * Gzips and minifies the JavaScript and CSS within the head tags of a page.
- * Can also gzip and minify the page itself
- * and 100+ other cool web performance optimization techniques
- * Based on Web Optimizer, which was based on PHP Speedy
- *
- **/
- class web_optimizer {
- /**
- * Constructor
- * Sets the options and defines the gzip headers
- **/
- function web_optimizer ($options = false) {
- $currency = empty($_COOKIE['WSS_CURRENCY']) ? $options['options']['currency'] : $_COOKIE['WSS_CURRENCY'];
- $rurl = empty($options['uri']) ? empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'] : $options['uri'];
- $homepage = empty($options['options']['html_cache']['ignore_list']) && empty($options['options']['restricted']) ? '' :
- in_array($rurl, array('/', '/index.php', '/index.html', '/#' . $currency));
- /* skip processing if disabled or restricted */
- if (!empty($_GET['web_optimizer_disabled']) || (!empty($options['options']['restricted']) &&
- (preg_match("@" . preg_replace("/ /", "|", preg_replace("/([\?!\^\$\|\(\)\[\]\{\}])/", "\\\\$1", $options['options']['restricted'])) . "@", $rurl))) ||
- (strpos($options['options']['restricted'], '#') !== false && $homepage)) {
- $this->options['active'] = 0;
- return;
- }
- /* A/B testing, */
- if (!empty($options['options']['footer']['ab'])) {
- if (empty($_COOKIE['WSS_DISABLED']) && empty($_COOKIE['WSS_ENABLED'])) {
- $ab = (microtime()*100)%100 < round($options['options']['footer']['ab']);
- setcookie($ab ? "WSS_ENABLED" : "WSS_DISABLED", 1, time() + 60*60, '/', $_SERVER['HTTP_HOST'], false, true);
- if (!$ab) {
- $_COOKIE['WSS_DISABLED'] = 1;
- }
- }
- }
- /* initialize chained optimization */
- $this->web_optimizer_stage = round(empty($_GET['web_optimizer_stage']) ? 0 : $_GET['web_optimizer_stage']);
- $this->debug_mode = empty($_GET['web_optimizer_debug']) && empty($_COOKIE['web_optimizer_debug']) ? 0 : 1;
- /* allow merging of other classes with this one */
- foreach ($options as $key => $value) {
- $this->$key = $value;
- }
- /* get chained optimization params */
- if (!empty($this->web_optimizer_stage)) {
- $this->username = htmlspecialchars(empty($_GET['username']) ? '' :
- $_GET['username']);
- $this->password = htmlspecialchars(empty($_GET['password']) ? '' :
- $_GET['password']);
- $this->auto_rewrite = round(empty($_GET['auto_rewrite']) ? '' :
- $_GET['auto_rewrite']);
- $this->chained_redirect = 'http://' .
- $this->options['host'] .
- str_replace($this->options['document_root'], '/', $this->options['html_cachedir']) .
- 'optimizing.php';
- $this->cache_version = round(empty($_GET['cache_version']) ? '' :
- $_GET['cache_version']);
- /* get major stage number, all stages:
- -1 - system, envelope all <script> to try-catch-document.write
- 0-9 - inilialization, starts in administrative interface
- 10-13 - JS file generation, 1st major stage (common browsers)
- 14-19 - CSS Sprites / data:URI generation, 1st major stage
- 20-24 - CSS file generation + page parsing, 1st major stage
- 25-28 - JS file generation, 2nd major stage (IE 6.0)
- 29-34 - CSS Sprites / mhtml generation, 2nd major stage
- 35-39 - CSS file generation + page parsing, 2nd major stage
- 40-43 - JS file generation, 3rd major stage (IE 7.0)
- 44-49 - CSS Sprites / mhtml generation, 2nd major stage
- 50-54 - CSS file generation + page parsing, 2nd major stage
- 55-58 - JS file generation, 4th major stage (IE 8.0)
- 59-64 - CSS Sprites / data:URI generation, 4th major stage
- 65-69 - CSS file generation + page parsing, 4th major stage
- 70-73 - JS file generation, 5th major stage (IE 7.0 @ Vista)
- 74-79 - CSS Sprites generation, 5th major stage
- 80-84 - CSS file generation + page parsing, 5th major stage
- */
- $this->cache_stage = floor(($this->web_optimizer_stage - 10) / 15);
- }
- $this->options['active'] = $this->debug_mode ? 1 : $this->options['active'];
- /* disable any actions if not active */
- if (empty($this->options['active'])) {
- return;
- }
- /* define head of the webpage for scripts / styles */
- $this->head = '';
- /* remember current time */
- $this->time = empty($_SERVER['REQUEST_TIME']) ? time() : $_SERVER['REQUEST_TIME'];
- /* skip buffering (need for integration as plugin) */
- $this->buffered = $this->options['buffered'];
- /* Sets User Agent to differ IE from non-IE */
- $this->ua = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
- /* HTTPS or not ? */
- $this->https = empty($_SERVER['HTTPS']) ? '' : 's';
- /* Set list of outdated IE */
- $this->ies = array('.ie4', '.ie5', '.ie6', '.ie7');
- /* Set options */
- $this->set_options();
- /* Include base plugin class */
- if (is_array($this->options['plugins'])) {
- include_once($this->options['css']['installdir'] . 'libs/php/class.plugin.php');
- }
- /* Remember current page encoding */
- $this->encoding = '';
- /* Define the gzip headers */
- $this->set_gzip_headers();
- /* Deal with flushed content or not? */
- $this->flushed = false;
- $excluded_html_pages = '';
- $included_user_agents = '';
- $restricted_cookie = 0;
- if (!empty($this->options['page']['cache'])) {
- $this->start_cache_engine();
- if (!empty($this->clear_cache_key)) {
- $this->clear_html_cache($this->clear_cache_key);
- }
- /* HTML cache ? */
- if (!empty($this->options['page']['cache_ignore'])) {
- $excluded_html_pages = preg_replace("/ /", "|", preg_replace("/([\?!\^\$\|\(\)\[\]\{\}])/", "\\\\$1", str_replace(array('# ', '#'), '', $this->options['page']['cache_ignore'])));
- }
- if (!empty($this->options['page']['allowed_user_agents'])) {
- $included_user_agents = preg_replace("/ /", "|", preg_replace("/([\?!\^\$\|\(\)\[\]\{\}])/", "\\\\$1", $this->options['page']['allowed_user_agents']));
- }
- if (!empty($this->options['page']['exclude_cookies'])) {
- $cookies = explode(" ", $this->options['page']['exclude_cookies']);
- foreach ($cookies as $cookie) {
- if ($e = strpos($cookie, '=')) {
- $c = substr($cookie, 0, $e);
- $e = substr($cookie, $e+1);
- if (isset($_COOKIE[$c]) && $_COOKIE[$c] == $e) {
- $restricted_cookie = 1;
- }
- } else {
- if (isset($_COOKIE[$cookie])) {
- $restricted_cookie = 1;
- }
- }
- }
- }
- }
- /* cache if
- - option is enabled,
- - don't parse excluded pages (including home page),
- - or parse included USER AGENTS,
- - don't parse pages with excluded coockies,
- - flush or gzip for HTML are disabled,
- - headers have not been sent,
- - page is requested by GET,
- - no chained optimization,
- - no debug mode,
- - external cache restriction,
- - exclude domains except the activated one for non-corporate licenses,
- - disable cache in case of negative A/B test.
- */
- $this->cache_me = !empty($this->options['page']['cache']) &&
- ((empty($this->options['page']['cache_ignore']) && !$this->options['page']['ignore_include']) ||
- (!$this->options['page']['ignore_include'] &&
- (!$excluded_html_pages || !preg_match("!" . $excluded_html_pages . "!is", $this->uri)) &&
- (strpos($this->options['page']['cache_ignore'], '#') === false || !$homepage)) ||
- ($this->options['page']['ignore_include'] &&
- (($excluded_html_pages && preg_match("!" . $excluded_html_pages . "!is", $this->uri)) ||
- (strpos($this->options['page']['cache_ignore'], '#') !== false && $homepage))) ||
- !$this->ua ||
- ($included_user_agents && preg_match("!" . $included_user_agents . "!is", $this->ua))) &&
- !$restricted_cookie &&
- (empty($this->options['page']['gzip']) ||
- empty($this->options['page']['flush'])) &&
- !headers_sent() &&
- (getenv('REQUEST_METHOD') == 'GET') &&
- empty($this->web_optimizer_stage) &&
- !$this->debug_mode &&
- empty($this->no_cache) &&
- ($this->premium == 3 || strpos($this->options['host'], $this->host) !== false) &&
- (empty($this->options['page']['ab']) || empty($_COOKIE['WSS_DISABLED']));
- /* check if we can get out cached page */
- if (!empty($this->cache_me)) {
- $this->uri = $this->convert_request_uri(empty($this->uri) ? '' : $this->uri);
- $jutility = class_exists('JUtility', false);
- $jsession = class_exists('JSession', false);
- /* gzip cached content before output? (plugins have onCache), JUtility must parse content */
- $gzip_me = is_array($this->options['plugins']) || $jutility || $jsession;
- $cache_plain_key = $this->view->ensure_trailing_slash($this->uri) .
- 'index' .
- $this->ua_mod .
- '.html' .
- ($this->options['page']['https_separate'] ? $this->https : '');
- $cache_key = $cache_plain_key .
- ($this->options['page']['flush'] ||
- empty($this->encoding_ext) ||
- $gzip_me ? '' : $this->encoding_ext);
- $timestamp_ajax = 0;
- $cache_key_ajax = $cache_plain_key . '.ajax';
- if (defined('WSS_CACHE_MISS')) {
- $timestamp = 0;
- } else {
- $timestamp = $this->cache_engine->get_mtime($cache_key);
- if ($this->options['page']['ajax_timeout']) {
- $timestamp_ajax = $this->cache_engine->get_mtime($cache_key_ajax);
- }
- }
- /* try to get from cache non-gzipped page if gzipped one doesn't exist */
- if (!$timestamp && !$this->options['page']['flush'] && !empty($this->encoding_ext) && !$gzip_me) {
- $timestamp = $this->cache_engine->get_mtime($cache_plain_key);
- $gzip_me = 1;
- }
- if (!$timestamp && !$timestamp_ajax && !defined('WSS_CACHE_MISS')) {
- define('WSS_CACHE_MISS', 1);
- }
- if (($timestamp &&
- $this->time - $timestamp < $this->options['page']['cache_timeout'] &&
- ($content = $this->cache_engine->get_entry($gzip_me ? $cache_plain_key : $cache_key))) ||
- ($timestamp_ajax &&
- $this->time - $timestamp_ajax < $this->options['page']['ajax_timeout'] &&
- ($content = $this->cache_engine->get_entry($cache_key_ajax)))) {
- if ($jutility) {
- $token = JUtility::getToken();
- }
- elseif ($jsession) {
- $token = JSession::getFormToken();
- }
- if (!empty($token)) {
- $content = str_replace('##WSS_JTOKEN_WSS##', $token, $content);
- }
- /* execute plugin-specific logic */
- if (is_array($this->options['plugins'])) {
- foreach ($this->options['plugins'] as $plugin) {
- $plugin_file = $this->options['css']['installdir'] . 'plugins/' . $plugin . '.php';
- if (@is_file($plugin_file)) {
- include_once($plugin_file);
- $web_optimizer_plugin = new $plugin;
- $content = $web_optimizer_plugin->onAfterOptimization($content);
- }
- }
- }
- $hash = crc32($content) . (empty($this->encoding) ? '' : '-' . str_replace("x-", "", $this->encoding));
- /* check for return visits */
- if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
- stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == '"' . $hash . '"') ||
- (isset($_SERVER['HTTP_IF_MATCH']) &&
- stripslashes($_SERVER['HTTP_IF_MATCH']) == '"' . $hash . '"')) {
- /* return visit and no modifications, so do not send anything */
- @header ("HTTP/1.0 304 Not Modified");
- @header ("Content-Length: 0");
- $this->di();
- }
- /* define gzip headers */
- $this->set_gzip_header();
- if ($gzip_me && $this->encoding) {
- $cnt = $this->create_gz_compress($content, in_array($this->encoding, array('gzip', 'x-gzip')));
- if (!empty($cnt)) {
- $content = $cnt;
- /* skip gzip if we can't compress content */
- } else {
- $this->options['page']['gzip'] = 0;
- $this->encoding = '';
- }
- }
- /* set ETag, thx to merzmarkus */
- @header("ETag: \"" . $hash . "\"");
- if ($gzip_me && ($this->encoding || empty($this->gzip_set)) && (empty($_SERVER['SERVER_PROTOCOL']) || $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0')) {
- @header("Content-Length: " . strlen($content));
- }
- /* set content-type */
- if (!empty($this->options['charset'])) {
- @header("Content-Type: text/html; charset=" . $this->options['charset']);
- }
- if (empty($this->web_optimizer_stage) &&
- $this->options['page']['clientside_cache']) {
- /* not really GMT but is valid locally */
- $ExpStr = date("D, d M Y H:i:s",
- $this->time + $this->options['page']['clientside_timeout']) . " GMT";
- @header("Cache-Control: " .
- ($this->options['page']['gzip'] ? 'private' : 'public') .
- ", max-age=" .
- $this->options['page']['clientside_timeout']);
- @header("Expires: " . $ExpStr);
- }
- while (@ob_end_clean());
- @header('WEBO: cache hit');
- echo $content;
- /* content is a head part, flush it after */
- if ($this->options['page']['flush']) {
- flush();
- $this->flushed = true;
- } else {
- $this->di(1);
- }
- } else {
- @header('WEBO: cache miss');
- }
- } elseif (!empty($this->options['page']['cache'])) {
- @header('WEBO: cache miss');
- }
- /* remember Joomla! caching (VirtueMart) */
- $this->joomla_cache = $this->options['page']['cache'] && (class_exists('JUtility', false) || class_exists('JSession', false));
- /* remember WordPress caching (WP Digi Cart) */
- $this->wp_cache = defined('WP_CACHE') && @is_dir($this->options['document_root'] . 'wp-content/plugins/wp-cart-for-digital-products/');
- /* remember Generic caching for other carts */
- $this->generic_cache = !$this->joomla_cache && !$this->wp_cache && $this->options['page']['cache'];
- /* change some hosts if HTTPS is used */
- if ($this->https && !empty($this->options['page']['parallel_https'])) {
- $this->options['javascript']['host'] =
- $this->options['css']['host'] =
- $this->options['page']['parallel_hosts'] =
- $this->options['page']['parallel_https'];
- }
- /* number of external files calls to process */
- $this->initial_files = array();
- /* set internal encoding */
- $this->charset = empty($wss_encoding) ? 'utf8' : $wss_encoding;
- /* prepare escaped host */
- $this->host_escaped = str_replace('.', '\.', $this->host);
- /* activate application */
- $this->options['active'] = 1;
- if ($this->buffered) {
- /* Start things off */
- $this->start();
- }
- }
- /**
- * Write installation progress to JavaScript file
- *
- **/
- function write_progress ($progress) {
- $this->write_file($this->options['javascript']['cachedir'] . 'progress.php', $progress);
- }
- /**
- * Options are read from config.webo.php
- **/
- function set_options () {
- /* Set paths with new options */
- $this->options['document_root'] = empty($this->options['document_root']) ? '' : $this->options['document_root'];
- $this->view->set_paths($this->options['document_root']);
- /* Set local root if chained optimization */
- if (!empty($this->web_optimizer_stage)) {
- $this->view->paths['full']['current_directory'] = $this->view->paths['full']['document_root'];
- $this->view->paths['relative']['current_directory'] = $this->view->paths['relative']['document_root'];
- $_SERVER['REQUEST_URI'] = '/';
- /* force User Agent on chained optimization */
- $mods = array(
- /* all common browsers except IE */
- '',
- /* IE 6.0, when will it die? */
- '.ie6',
- /* IE 7.0 */
- '.ie7',
- /* IE 8.0 */
- '.ie8',
- /* Mobile Agents */
- '.ma',
- /* dummy UA, thx to peterbowey */
- '.end'
- );
- $this->ua_mod = $mods[$this->cache_stage];
- }
- $this->premium = $this->view->validate_license($this->options['license'], $this->options['html_cachedir'], $this->options['host']);
- $this->set_user_agent();
- $webo_cachedir = $this->view->unify_dir_separator(realpath(dirname(__FILE__) . '/../') . '/');
- /* ensure trailing slashes */
- $this->options['html_cachedir'] = $this->view->ensure_trailing_slash($this->options['html_cachedir']);
- $this->options['css_cachedir'] = $this->view->ensure_trailing_slash($this->options['css_cachedir']);
- $this->options['javascript_cachedir'] = $this->view->ensure_trailing_slash($this->options['javascript_cachedir']);
- /* normalize host */
- if (!empty($this->options['host'])) {
- $this->options['host'] = preg_replace("!^https?://!", "", $this->options['host']);
- }
- /* Read in options */
- $full_options = array(
- "javascript" => array(
- "cachedir" => $this->options['javascript_cachedir'],
- "cachedir_relative" => str_replace($this->options['document_root'], "/", $this->options['javascript_cachedir']),
- "installdir" => $webo_cachedir,
- "gzip" => $this->options['gzip']['javascript'] &&
- ((!$this->options['htaccess']['mod_gzip'] &&
- !$this->options['htaccess']['mod_deflate'] &&
- (!$this->options['htaccess']['mod_rewrite'] ||
- !$this->options['htaccess']['mod_mime'] ||
- !$this->options['htaccess']['mod_expires'])) ||
- !$this->options['htaccess']['enabled']),
- "gzip_level" => round($this->options['gzip']['javascript_level']),
- "minify" => $this->options['minify']['javascript'],
- "minify_body" => $this->options['minify']['javascript_body'],
- "minify_with" => $this->options['minify']['with_jsmin'] ?
- 'jsmin' : ($this->options['minify']['with_yui'] && $this->premium > 1 ?
- 'yui' : ($this->options['minify']['with_packer'] && $this->premium ?
- 'packer' : ($this->options['minify']['with_google'] && $this->premium > 1 ?
- 'google' : ''))),
- "minify_try" => $this->options['external_scripts']['include_try'] &&
- $this->premium,
- "minify_exclude" => $this->options['external_scripts']['minify_exclude'],
- "remove_duplicates" => $this->options['external_scripts']['duplicates'] &&
- $this->premium,
- "far_future_expires" => $this->options['far_future_expires']['javascript'] &&
- !$this->options['htaccess']['mod_expires'],
- "far_future_expires_php" => $this->options['far_future_expires']['javascript'],
- "far_future_expires_rewrite" => $this->options['htaccess']['mod_rewrite'] &&
- $this->options['htaccess']['enabled'] &&
- $this->options['far_future_expires']['javascript'],
- "far_future_expires_static" => ((!($this->options['htaccess']['mod_rewrite'] ||
- $this->options['htaccess']['mod_expires']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['far_future_expires']['javascript']) ||
- ((!($this->options['htaccess']['mod_rewrite'] ||
- $this->options['htaccess']['mod_deflate'] ||
- $this->options['htaccess']['mod_gzip']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['gzip']['javascript']),
- "unobtrusive_body" => $this->premium && $this->options['unobtrusive']['body'] &&
- !$this->options['unobtrusive']['all'],
- "external_scripts" => $this->options['external_scripts']['on'],
- "inline_scripts" => $this->options['external_scripts']['inline'] &&
- ($this->options['minify']['javascript'] || $this->options['rocket']['reorder']),
- "inline_scripts_body" => $this->options['external_scripts']['inline_body'] &&
- ($this->options['minify']['javascript'] || $this->options['rocket']['reorder']),
- "external_scripts_head_end" => $this->options['external_scripts']['head_end'],
- "external_scripts_exclude" => $this->options['external_scripts']['ignore_list'],
- "external_scripts_mask" => $this->premium > 1 ? $this->options['external_scripts']['include_mask'] : '',
- "remove_list" => $this->premium > 1 ? $this->options['external_scripts']['remove_list'] : '',
- "dont_check_file_mtime" => $this->options['performance']['mtime'],
- "file" => $this->premium > 1 ? $this->options['minify']['javascript_file'] : '',
- "host" => $this->premium ? $this->options['minify']['javascript_host'] : '',
- "https" => $this->premium > 1 ? $this->options['parallel']['https'] : '',
- "rocket" => $this->options['rocket']['javascript'] && !$this->options['minify']['javascript'],
- "rocket_external" => $this->options['rocket']['javascript_external'] && !$this->options['minify']['javascript'],
- "reorder" => $this->options['rocket']['reorder']
- ),
- "css" => array(
- "cachedir" => $this->options['css_cachedir'],
- "cachedir_relative" => str_replace($this->options['document_root'], "/", $this->options['css_cachedir']),
- "installdir" => $webo_cachedir,
- "gzip" => $this->options['gzip']['css'] &&
- ((!$this->options['htaccess']['mod_gzip'] &&
- !$this->options['htaccess']['mod_deflate'] &&
- (!$this->options['htaccess']['mod_rewrite'] ||
- !$this->options['htaccess']['mod_mime'] ||
- !$this->options['htaccess']['mod_expires'])) ||
- !$this->options['htaccess']['enabled']),
- "gzip_level" => round($this->options['gzip']['css_level']),
- "minify" => $this->options['minify']['css'],
- "minify_body" => $this->options['minify']['css_body'],
- "minify_with" => $this->premium > 1 && $this->options['minify']['css_min'] == 2 ?
- 'tidy' :
- ($this->premium > 1 && $this->options['minify']['css_min'] == 3 ? 'cssmin' :
- ($this->options['minify']['css_min'] ? 'basic' : '')),
- "far_future_expires" => $this->options['far_future_expires']['css'] &&
- !$this->options['htaccess']['mod_expires'],
- "far_future_expires_php" => $this->options['far_future_expires']['css'],
- "far_future_expires_rewrite" => $this->options['htaccess']['mod_rewrite'] &&
- $this->options['htaccess']['enabled'] &&
- $this->options['far_future_expires']['css'],
- "far_future_expires_static" => ((!($this->options['htaccess']['mod_rewrite'] ||
- $this->options['htaccess']['mod_expires']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['far_future_expires']['css']) ||
- ((!($this->options['htaccess']['mod_rewrite'] ||
- $this->options['htaccess']['mod_deflate'] ||
- $this->options['htaccess']['mod_gzip']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['gzip']['css']),
- "data_uris" => $this->options['data_uris']['on'],
- /* disable mhtml for IE7- under HTTPS */
- "data_uris_mhtml" => $this->options['data_uris']['mhtml'] && !$this->https,
- "data_uris_separate" => $this->premium > 1 && $this->options['data_uris']['separate'] &&
- ((in_array($this->ua_mod, $this->ies) &&
- $this->options['data_uris']['mhtml']) ||
- (!in_array($this->ua_mod, $this->ies) &&
- $this->options['data_uris']['on'])),
- "data_uris_domloaded" => $this->options['unobtrusive']['background'] &&
- $this->premium > 1,
- "data_uris_size" => round($this->options['data_uris']['size']),
- "data_uris_mhtml_size" => round($this->options['data_uris']['mhtml_size']),
- "data_uris_exclude" => $this->options['data_uris']['ignore_list'],
- "data_uris_exclude_mhtml" => $this->options['data_uris']['additional_list'],
- "css_sprites" => $this->premium && $this->options['css_sprites']['enabled'],
- "css_sprites_expires_rewrite" => (!($this->options['htaccess']['mod_rewrite'] &&
- $this->options['htaccess']['mod_expires']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['far_future_expires']['images'],
- "css_sprites_ignore" => $this->options['css_sprites']['ignore'],
- "css_sprites_exclude" => $this->options['css_sprites']['ignore_list'],
- "truecolor_in_jpeg" => $this->premium > 1 && $this->options['css_sprites']['truecolor_in_jpeg'],
- "aggressive" => $this->premium > 1 && $this->options['css_sprites']['aggressive'],
- "no_ie6" => $this->premium > 1 && $this->options['css_sprites']['no_ie6'],
- "dimensions_limited" => $this->premium ? round($this->options['css_sprites']['dimensions_limited']) : 0,
- "css_sprites_extra_space" => $this->premium && $this->options['css_sprites']['extra_space'],
- "punypng" => $this->premium > 1 ? $this->options['punypng'] : '',
- "css_restore_properties" => $this->options['performance']['restore_properties'] &&
- $this->premium > 1,
- "unobtrusive_body" => false,
- "parallel" => $this->options['parallel']['enabled'],
- "parallel_hosts" => $this->options['parallel']['allowed_list'],
- "external_scripts" => $this->options['external_scripts']['css'],
- "inline_scripts" => $this->options['external_scripts']['css_inline'],
- "external_scripts_exclude" => $this->options['external_scripts']['additional_list'],
- "include_code" => $this->options['external_scripts']['include_code'],
- "remove_list" => $this->premium > 1 ? $this->options['external_scripts']['remove_list_css'] : '',
- "dont_check_file_mtime" => $this->options['performance']['mtime'],
- "file" => $this->premium > 1 ? $this->options['minify']['css_file'] : '',
- "host" => $this->premium ? $this->options['minify']['css_host'] : '',
- "https" => $this->premium > 1 ? $this->options['parallel']['https'] : '',
- "rocket" => $this->options['rocket']['css'] && !$this->options['minify']['css'],
- "reorder" => $this->options['rocket']['reorder']
- ),
- "page" => array(
- "cachedir" => $this->options['html_cachedir'],
- "cache_engine" => $this->premium ? $this->options['performance']['cache_engine'] : 0,
- "cache_engine_options" => $this->premium ? $this->options['performance']['cache_engine_options'] : '',
- "cachedir_relative" => str_replace($this->options['document_root'], "/", $this->options['html_cachedir']),
- "installdir" => $webo_cachedir,
- "host" => $this->options['host'],
- "gzip" => $this->options['gzip']['page'] &&
- ((!$this->options['htaccess']['mod_gzip'] &&
- !$this->options['htaccess']['mod_deflate']) ||
- !$this->options['htaccess']['enabled']),
- "zlib" => $this->options['gzip']['zlib'],
- "gzip_noie" => $this->options['gzip']['noie'] &&
- $this->premium > 1,
- "gzip_level" => round($this->options['gzip']['page_level']),
- "gzip_cookie" => $this->options['gzip']['cookie'] &&
- $this->premium > 1,
- "minify" => $this->options['minify']['page'],
- "minify_aggressive" => $this->options['minify']['html_one_string'] &&
- $this->premium,
- "remove_comments" => $this->options['minify']['html_comments'] &&
- $this->premium,
- "dont_check_file_mtime" => $this->options['performance']['mtime'],
- "cache_images" => $this->options['far_future_expires']['images'],
- "far_future_expires_rewrite" => (!($this->options['htaccess']['mod_rewrite'] ||
- $this->options['htaccess']['mod_expires']) ||
- !$this->options['htaccess']['enabled']) &&
- $this->options['far_future_expires']['images'],
- "far_future_expires_external" => $this->options['far_future_expires']['external'],
- "clientside_cache" => $this->premium > 1 && $this->options['far_future_expires']['html'],
- "clientside_timeout" => $this->options['far_future_expires']['html_timeout'],
- "cache" => $this->options['html_cache']['enabled'] &&
- $this->premium,
- "cache_timeout" => $this->options['html_cache']['timeout'],
- "cart_timeout" => $this->premium > 1 ? $this->options['html_cache']['timeout_cart'] : $this->options['html_cache']['timeout'],
- "ajax_timeout" => $this->premium > 1 ? $this->options['html_cache']['timeout_ajax'] : $this->options['html_cache']['timeout'],
- "flush" => $this->options['html_cache']['flush_only'] &&
- $this->premium > 1,
- "flush_size" => $this->options['html_cache']['flush_size'],
- "cache_ignore" => $this->premium ? $this->options['html_cache']['ignore_list'] : '',
- "ignore_include" => $this->premium ? $this->options['html_cache']['ignore'] : '',
- "cache_params" => $this->premium > 1 ? $this->options['html_cache']['params'] : '',
- "allowed_user_agents" => $this->premium > 1 ? $this->options['html_cache']['allowed_list'] : '',
- "exclude_cookies" => $this->premium > 1 ? $this->options['html_cache']['additional_list'] : '',
- "parallel" => $this->options['parallel']['enabled'] && !empty($this->options['parallel']['allowed_list']),
- "parallel_regexp" => $this->premium > 1 ? $this->options['parallel']['regexp'] : '',
- "parallel_hosts" => $this->options['parallel']['allowed_list'],
- "parallel_satellites" => $this->options['parallel']['additional'],
- "parallel_satellites_hosts" => $this->options['parallel']['additional_list'],
- "parallel_ignore" => $this->options['parallel']['ignore_list'],
- "parallel_css" => $this->options['parallel']['css'] && !empty($this->options['parallel']['allowed_list']),
- "parallel_javascript" => $this->options['parallel']['javascript'] && !empty($this->options['parallel']['allowed_list']),
- "parallel_ftp" => $this->premium ? $this->options['parallel']['ftp'] : '',
- "parallel_https" => $this->premium > 1 ? $this->options['parallel']['https'] : '',
- "unobtrusive_informers" => $this->options['unobtrusive']['informers'] &&
- ($this->premium > 1),
- "unobtrusive_counters" => $this->options['unobtrusive']['counters'] &&
- ($this->premium > 1),
- "unobtrusive_ads" => $this->options['unobtrusive']['ads'] &&
- ($this->premium > 1),
- "unobtrusive_all" => $this->options['unobtrusive']['all'] &&
- $this->premium,
- "unobtrusive_iframes" => $this->options['unobtrusive']['iframes'] &&
- ($this->premium > 1),
- "unobtrusive_onload" => $this->options['unobtrusive']['on'] &&
- ($this->premium > 1),
- "unobtrusive_inline" => $this->options['unobtrusive']['on'] == 2 &&
- ($this->premium > 1),
- "unobtrusive_configuration" => $this->premium > 1 ? explode(" ", $this->options['unobtrusive']['configuration']) : array(),
- "postload" => $this->premium > 1 ? $this->options['unobtrusive']['postload'] : '',
- "postload_frames" => $this->premium > 1 ? $this->options['unobtrusive']['frames'] : '',
- "footer" => $this->options['footer']['text'],
- "footer_image" => $this->options['footer']['image'],
- "footer_text" => $this->options['footer']['link'],
- "footer_style" => $this->options['footer']['css_code'],
- "spot" => $this->premium ? $this->options['footer']['spot'] : 1,
- "counter" => $this->premium > 1 ? $this->options['footer']['counter'] : '',
- "ab" => $this->options['footer']['ab'] &&
- $this->premium > 1,
- "htaccess_username" => $this->premium > 1 ? $this->options['external_scripts']['user'] : '',
- "htaccess_password" => $this->premium > 1 ? $this->options['external_scripts']['pass'] : '',
- "html_tidy" => $this->options['performance']['plain_string'] &&
- $this->premium,
- "sprites" => $this->premium && $this->options['css_sprites']['html_sprites'],
- "sprites_domloaded" => $this->options['unobtrusive']['background'] &&
- $this->premium > 1,
- "dimensions_limited" => $this->premium ? round($this->options['css_sprites']['html_limit']) : 0,
- "per_page" => $this->premium && $this->options['css_sprites']['html_page'],
- "https_separate" => $this->premium > 1 ? $this->options['performance']['https'] : 0,
- "scale_images" => $this->premium > 1 ? $this->options['performance']['scale'] : 0,
- "scale_restriction" => $this->premium > 1 ? $this->options['performance']['scale_restriction'] : 0,
- ),
- "document_root" => $this->options['document_root'],
- "document_root_relative" => str_replace("//", "/", str_replace($this->options['document_root'], "/", $this->options['website_root'])),
- "website_root" => $this->options['website_root'],
- "cache_version" => round($this->options['performance']['cache_version']) &&
- $this->premium > 1,
- "uniform_cache" => $this->options['performance']['uniform_cache'] &&
- $this->premium > 1,
- "plugins" => !empty($this->options['plugins']) &&
- $this->premium > 1 ? explode(" ", $this->options['plugins']) : '',
- "days_to_delete" => $this->premium > 1 ? round($this->options['performance']['delete_old']) : 0,
- "charset" => $this->options['charset'],
- "currency" => $this->premium > 1 ? $this->options['currency'] : '',
- 'host' => $this->options['host'],
- "clean_html_cache" => $this->options['html_cache']['cleanup'] &&
- $this->premium > 1 ? $this->options['html_cache']['timeout'] : 0
- );
- $this->lc = $this->options['license'];
- /* overwrite other options array that we passed in */
- $this->options = $full_options;
- /* some additional checks */
- if ($this->options['page']['parallel_css'] && empty($this->options['css']['host'])) {
- if ($this->options['page']['parallel_hosts']) {
- $hosts = explode(" ", $this->options['page']['parallel_hosts']);
- $this->options['css']['host'] = $hosts[0];
- } else {
- $this->options['page']['parallel_css'] = 0;
- }
- }
- if ($this->options['page']['parallel_javascript'] && empty($this->options['javascript']['host'])) {
- if ($this->options['page']['parallel_hosts']) {
- $hosts = explode(" ", $this->options['page']['parallel_hosts']);
- $this->options['javascript']['host'] = $hosts[0];
- } else {
- $this->options['page']['parallel_javascript'] = 0;
- }
- }
- }
- /**
- * Start saving the output buffer
- *
- **/
- function start () {
- ob_start();
- ob_start();
- ob_implicit_flush(0);
- }
- /**
- * Compress passes content directly
- *
- **/
- function compress ($content) {
- $this->finish($content);
- }
- /**
- * Do work and return output buffer
- *
- **/
- function finish ($content = false) {
- /* disable any actions if not active */
- if (empty($this->options['active'])) {
- return $content;
- }
- @ini_set("max_execution_time", 600);
- if ($content === false) {
- $this->content = @ob_get_clean();
- /* clear all other buffers */
- while (@ob_end_clean());
- } else {
- $this->content = $content;
- }
- /* execute plugin-specific logic, BeforeOptimization event */
- if (is_array($this->options['plugins'])) {
- foreach ($this->options['plugins'] as $plugin) {
- $plugin_file =
- $this->options['css']['installdir'] .
- 'plugins/' . $plugin . '.php';
- if (@is_file($plugin_file)) {
- include_once($plugin_file);
- $web_optimizer_plugin = new $plugin;
- $this->content =
- $web_optimizer_plugin->onBeforeOptimization($this->content);
- }
- }
- }
- $skip = 0;
- $ajax = 0;
- if (function_exists('headers_list')) {
- $headers = headers_list();
- /* define if Content-Type is text/html and allow it */
- foreach ($headers as $head) {
- $header = strtolower($head);
- if (strpos($header, 'content-type:') !== false || (strpos($header, 'location:') !== false && strpos($header, '-location:') === false)) {
- $skip++;
- }
- if (strpos($header, 'text/html') || strpos($header, 'application/xhtml+xml')) {
- $skip--;
- }
- if (strpos($header, 'application/json')) {
- $skip++;
- $ajax = 1;
- }
- if (strpos($header, 'content-base') !== false) {
- $this->basehref = substr($head, 14);
- }
- if ($this->ua_mod && strpos($header, 'x-ua-compatible') !== false) {
- $this->ua_mod = '.ie' . substr($head, 20);
- }
- }
- }
- /* also skip AJAX requests with X-Requested-With: XMLHttpRequest */
- if (!$skip &&
- !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
- $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
- $skip = 1;
- $ajax = 1;
- }
- /* also skip some CMS-related parameters */
- if (!$skip && !empty($_GET['no_html'])) {
- $skip = 1;
- $ajax = 1;
- }
- /* skip some extensions */
- if (!$skip && !empty($_SERVER['QUERY_STRING'])) {
- $query = explode('.', $_SERVER['QUERY_STRING']);
- $ext = strtolower($query[count($query) - 1]);
- if (in_array($ext, array('pdf', 'doc', 'xls', 'docx', 'xlsx'))) {
- $skip = 1;
- }
- }
- /* skip some known cases of non-HTML content */
- if (!$skip) {
- /* reduce amount of viewing content, accelerate 'fast check' by 1% */
- $spot = substr($this->content, 0, 200);
- if (strpos($spot, '<methodResponse') !== false ||
- strpos($spot, '<rss') !== false ||
- strpos($spot, '<feed') !== false ||
- strpos($spot, '<urlset') !== false ||
- strpos($spot, '<smf') !== false ||
- strlen($spot) < 200) {
- $skip = 1;
- /* mark AJAX requests */
- } elseif (strpos($spot, '{') === 0 || !preg_match("!<h(tml|ead)!is", $spot)) {
- $skip = 1;
- $ajax = 1;
- }
- }
- /* enable A/B testing */
- if (!$skip && !empty($this->options['page']['ab']) && !empty($_COOKIE['WSS_DISABLED'])) {
- $this->content = preg_replace("!(<head[^>]*>)!i", "$1" . '<script type="text/javascript">//<![CDATA[' .
- "\n" . 'var _gaq=_gaq||[];_gaq.push(["_setCustomVar",1,"WEBOSiteSpeedUp","0"])' . "\n//]]></script>", $this->content);
- $skip = 1;
- }
- /* skip RSS, SMF xml format */
- if (!$skip) {
- /* define gzip headers at the end */
- $this->set_gzip_header();
- /* Add UA-Compatible support */
- if ($this->ua_mod && strpos($this->content, 'X-UA-Compatible') && !strpos($this->content, 'IE=edge')) {
- $this->ua_mod = '.ie' . preg_replace("!.*<meta[^>]+content=['\"]?IE=([0-9]+).*!is", "$1", $this->content);
- }
- /* create DOMready chunk of JavaScript code, is required for different tasks */
- $this->domready_include = $this->domready_include2 = $this->domready_include3 = '';
- if ($this->options['css']['data_uris_separate'] || $this->options['page']['sprites_domloaded'] || $this->joomla_cache || $this->wp_cache || $this->generic_cache) {
- $this->domready_include = '__WSSLOADED=0;function _weboptimizer_load(){if(__WSSLOADED){return}';
- if ($this->options['page']['sprites_domloaded']) {
- $this->domready_include .= '_webo_hsprites();';
- }
- $cart_class = $this->generic_cache ? 'wss_cart' : ($this->joomla_cache ? 'vmCartModule' : 'widget_wp_digi_cart');
- if ($this->options['page']['cache'] && $this->cache_me) {
- $this->domready_include .= 'var g,x=document,f,h,j;if(typeof x.getElementsByClassName!="undefined"){g=x.getElementsByClassName("' .
- $cart_class .
- '")[0];f=x.getElementsByClassName("wss_cart_qty")[0];h=x.getElementsByClassName("wss_cart2")[0];j=x.getElementsByClassName("wss_cart2_qty")[0]}else{var b=x.getElementsByTagName("*"),c,d=0;while(c=b[d++]){if(c.className){if(/(^|\s)' .
- $cart_class .
- '(\s|$)/.test(c.className)){g=c}if(/(^|\s)wss_cart_qty(\s|$)/.test(c.className)){f=c}if(/(^|\s)wss_cart2(\s|$)/.test(c.className)){h=c}if(/(^|\s)wss_cart2_qty(\s|$)/.test(c.className)){j=c}}}}if(g&&!(f&&(parseInt(f.innerHTML)))&&!(j&&(parseInt(j.innerHTML)))){var a,a1;if(typeof window.localStorage!="undefined"){a=window.localStorage.wss_cart||"";a1=window.localStorage.wss_cart2||"";if(x.cookie.indexOf("WSS_CART=0")!==-1){delete window.localStorage["wss_cart"];delete window.localStorage["wss_cart2"]}}else{var b=x.cookie.split(";"),c,d=0,e;while(c=b[d++]){e=c.indexOf("wss_cart=");if(!e||e==1){a=c.substr(e+11).replace(/@#/g,";")}e=c.indexOf("wss_cart2=");if(!e||e==1){a1=c.substr(e+11).replace(/@#/g,";")}}}if(x.cookie.indexOf("WSS_CART=1")!==-1'.
- ($this->wp_cache ? '&&x.location.pathname!="/cart/"' : '') .
- '){if(a&&a!="undefined"){WSS_CART=g.innerHTML=a}if(a1&&a1!="undefined"){WSS_CART2=h.innerHTML=a1}}}';
- }
- $this->domready_include .= '__WSSLOADED=1}(function(){var d=document;if(d.addEventListener){d.addEventListener("DOMContentLoaded",_weboptimizer_load,false)}';
- if (!empty($this->ua_mod) && substr($this->ua_mod, 3, 1) < 8) {
- $this->domready_include .= 'd.write("\x3cscript id=\"_weboptimizer\" defer=\"defer\" src=\"\">\x3c\/script>");(d.getElementById("_weboptimizer")).onreadystatechange=function(){if(this.readyState=="complete"){setTimeout(function(){if(typeof _weboptimizer_load!=="undefined"){_weboptimizer_load()}},0)}};';
- } else {
- $this->domready_include .= 'if(/WebK/i.test(navigator.userAgent)){var wssload=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(wssload);if(typeof _weboptimizer_load!=="undefined"){_weboptimizer_load()}}},10)}';
- }
- $this->domready_include .= 'window[/*@cc_on !@*/0?"attachEvent":"addEventListener"](/*@cc_on "on"+@*/"load",_weboptimizer_load,false)}());';
- if ($this->options['page']['cache']) {
- /* clean-up all localStorage values */
- if ($this->logged) {
- $this->domready_include2 .= 'if(typeof window.localStorage!="undefined"){window.localStorage.wss_cart="";window.localStorage.wss_cart2=""}else{document.cookie="wss_cart=;path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString());document.cookie="wss_cart2=;path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString())}';
- /* store user-specific values into localStorage */
- } else {
- $this->domready_include2 .= '(function(){var a=window;if(a.parent===a)a[/*@cc_on !@*/0?"attachEvent":"addEventListener"](/*@cc_on "on"+@*/"unload",function(){var a,x=document,y,z,r;if(typeof x.getElementsByClassName!="undefined"){a=x.getElementsByClassName("' .
- $cart_class .
- '")[0]||0;y=x.getElementsByClassName("wss_cart_qty")[0]||0;z=x.getElementsByClassName("wss_cart2")[0]||0;r=x.getElementsByClassName("wss_cart2_qty")[0]||0}else{var b=x.getElementsByTagName("*"),c,d=0;while(c=b[d++]){if(c.className){if(/(^|\s)' .
- $cart_class .
- '(\s|$)/.test(c.className)){a=c}if(/(^|\s)wss_cart_qty(\s|$)/.test(c.className)){y=c}if(/(^|\s)wss_cart2(\s|$)/.test(c.className)){z=c}if(/(^|\s)wss_cart2_qty(\s|$)/.test(c.className)){r=c}}}}y=y||a.getElementsByTagName("b")[0];if(a||z){if(a){a=a.innerHTML.replace(/[\r\n]/g," ").replace(/\s+/g," ").replace(/;">/g,"\">").replace(/&/,"&")}if(z){z=z.innerHTML.replace(/[\r\n]/g," ").replace(/\s+/g," ").replace(/;">/g,"\">").replace(/&/,"&")}if(typeof window.localStorage!="undefined"){window.localStorage.wss_cart=a;window.localStorage.wss_cart2=z}else{document.cookie="wss_cart="+a.replace(/;/g,"@#")+";path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString());document.cookie="wss_cart2="+z.replace(/;/g,"@#")+";path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString())}document.cookie="WSS_CART="+(((a&&y&&parseInt(y.innerHTML))||(z&&r&&parseInt(r.innerHTML)))?1:0)+";path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString())}},false)})();';
- $this->domready_include3 = '(function(){var a=window;if(a.parent===a)a[/*@cc_on !@*/0?"attachEvent":"addEventListener"](/*@cc_on "on"+@*/"unload",function(){var a,x=document,y,z,r;document.cookie="WSS_CART=0;path=/;expires="+(new Date(new Date().getTime()+' .
- ($this->options['page']['cart_timeout'] * 1000) .
- ').toGMTString())},false)})();';
- }
- }
- }
- /* find all files in head to process */
- $this->get_script_array();
- /* Run the functions specified in options */
- if (is_array($this->options)) {
- foreach ($this->options as $func => $option) {
- if (method_exists($this, $func)) {
- if (!empty($option['gzip']) ||
- !empty($option['minify']) ||
- !empty($option['far_future_expires']) ||
- !empty($option['parallel']) ||
- !empty($option['unobtrusive_onload']) ||
- !empty($option['unobtrusive_all']) ||
- !empty($option['unobtrusive_ads']) ||
- !empty($option['unobtrusive_counters']) ||
- !empty($option['unobtrusive_informers']) ||
- !empty($option['unobtrusive_iframes']) ||
- !empty($option['postload']) ||
- !empty($option['postload_frames']) ||
- !empty($option['cache']) ||
- !empty($option['sprites']) ||
- !empty($option['counter']) ||
- !empty($option['scale_images']) ||
- !empty($option['ab']) ||
- !empty($this->domready_include)) {
- if (!empty($this->web_optimizer_stage)) {
- $this->write_progress($this->web_optimizer_stage++);
- }
- $this->$func($option, $func);
- }
- }
- if ($func == 'page') {
- $this->clear_trash();
- }
- }
- }
- if (!empty($this->web_optimizer_stage)) {
- $this->write_progress($this->web_optimizer_stage);
- /* redirect to installation page if chained optimization if finished */
- if ($this->web_optimizer_stage > 85) {
- $this->write_progress(97);
- @header('Location: http://' .
- $this->host .
- str_replace($this->options['document_root'], '/', realpath(dirname(__FILE__) . '/../')) .
- '/index.php?page=install_stage_3&Submit=1&web_optimizer_stage=97&wss__password=' .
- $this->password);
- /* else redirect to the next stage */
- } else {
- @header('Location: ' . $this->chained_redirect . '?web_optimizer_stage=' .
- $this->web_optimizer_stage .
- '&password=' .
- $this->password .
- '&web_optimizer_debug=1');
- }
- $this->di();
- }
- }
- if ($ajax && $this->options['page']['ajax_timeout']) {
- $this->options['page']['cache_timeout'] = $this->options['page']['ajax_timeout'];
- $this->cache_generic(1);
- }
- /* Return content to requestor */
- if ($content) {
- return $this->content;
- /* or echo content to the browser */
- } else {
- /* HTTP/1.0 needs Content-Length */
- if (($this->encoding || empty($this->gzip_set)) && (empty($_SERVER['SERVER_PROTOCOL']) || $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0')) {
- @header('Content-Length: ' . strlen($this->content));
- }
- echo $this->content;
- /* It's obvious to send anything right after gzipped content */
- if (!empty($this->encoding)) {
- $this->di();
- }
- }
- }
- /**
- * GZIP and minify the javascript as required
- *
- **/
- function javascript ($options,$type) {
- /* prepare list of files to process */
- $script_files = array();
- foreach ($this->initial_files as $file) {
- if (!empty($file['tag']) && $file['tag'] == 'script') {
- $script_files[] = $file;
- }
- }
- if (!empty($options['minify']) && !empty($script_files)) {
- $this->content = $this->do_compress(
- array(
- 'cachedir' => $options['cachedir'],
- 'cachedir_relative' => $options['cachedir_relative'],
- 'installdir' => $options['installdir'],
- 'host' => $options['host'],
- 'tag' => 'script',
- 'type' => 'text/javascript',
- 'ext' => 'js',
- 'src' => 'src',
- 'self_close' => 0,
- 'gzip' => $options['gzip'],
- 'gzip_level' => $options['gzip_level'],
- 'minify' => $options['minify'],
- 'minify_body' => $options['minify_body'],
- 'minify_with' => $options['minify_with'],
- 'minify_try' => $options['minify_try'],
- 'minify_exclude' => $options['minify_exclude'],
- 'remove_duplicates' => $options['remove_duplicates'],
- 'far_future_expires' => $options['far_future_expires'],
- 'far_future_expires_php' => $options['far_future_expires_php'],
- 'far_future_expires_rewrite' => $options['far_future_expires_rewrite'],
- 'header' => $type,
- 'css_sprites' => 0,
- 'css_sprites_exclude' => 0,
- 'parallel' => 0,
- 'aggressive' => 0,
- 'no_ie6' => 0,
- 'dimensions_limited' => 0,
- 'css_sprites_extra_space' => 0,
- 'data_uris' => 0,
- 'mhtml' => 0,
- 'unobtrusive_body' => $options['unobtrusive_body'],
- 'external_scripts' => $options['external_scripts'],
- 'inline_scripts' => $options['inline_scripts'],
- 'inline_scripts_body' => $options['inline_scripts_body'],
- 'external_scripts_head_end' => $options['external_scripts_head_end'],
- 'external_scripts_exclude' => $options['external_scripts_exclude'],
- 'remove_list' => $options['remove_list'],
- 'dont_check_file_mtime' => $options['dont_check_file_mtime'],
- 'file' => $options['file'],
- 'https' => $options['https'],
- 'rocket' => $options['rocket'],
- 'rocket_external' => $options['rocket_external'],
- 'reorder' => $options['reorder']
- ),
- $this->content,
- $script_files
- );
- }
- }
- /**
- * GZIP and minify the CSS as required
- *
- **/
- function css ($options, $type) {
- /* prepare list of files to process */
- $link_files = array();
- foreach ($this->initial_files as $file) {
- if (!empty($file['tag']) && $file['tag'] == 'link') {
- $link_files[] = $file;
- }
- }
- if (!empty($options['minify']) && !empty($link_files)) {
- /* Compress separately for each media type*/
- $this->content = $this->do_compress(
- array(
- 'cachedir' => $options['cachedir'],
- 'cachedir_relative' => $options['cachedir_relative'],
- 'installdir' => $options['installdir'],
- 'host' => $options['host'],
- 'tag' => 'link',
- 'type' => 'text/css',
- 'ext' => 'css',
- 'src' => 'href',
- 'rel' => 'stylesheet',
- 'data_uris' => $options['data_uris'],
- 'mhtml' => $options['data_uris_mhtml'],
- 'data_uris_separate' => $options['data_uris_separate'],
- 'data_uris_domloaded' => $options['data_uris_domloaded'],
- 'data_uris_size' => $options['data_uris_size'],
- 'data_uris_exclude' => $options['data_uris_exclude'],
- 'mhtml' => $options['data_uris_mhtml'],
- 'mhtml_size' => $options['data_uris_mhtml_size'],
- 'mhtml_exclude' => $options['data_uris_exclude_mhtml'],
- 'css_sprites' => $options['css_sprites'],
- 'css_sprites_ignore' => $options['css_sprites_ignore'],
- 'css_sprites_exclude' => $options['css_sprites_exclude'],
- 'truecolor_in_jpeg' => $options['truecolor_in_jpeg'],
- 'aggressive' => $options['aggressive'],
- 'no_ie6' => $options['no_ie6'],
- 'dimensions_limited' => $options['dimensions_limited'],
- 'css_sprites_extra_space' => $options['css_sprites_extra_space'],
- 'css_sprites_expires_rewrite' => $options['css_sprites_expires_rewrite'],
- 'punypng' => $options['punypng'],
- 'css_restore_properties' => $options['css_restore_properties'],
- 'self_close' => 1,
- 'gzip' => $options['gzip'],
- 'gzip_level' => $options['gzip_level'],
- 'minify' => $options['minify'],
- 'minify_body' => $options['minify_body'],
- 'minify_with' => $options['minify_with'],
- 'far_future_expires' => $options['far_future_expires'],
- 'far_future_expires_php' => $options['far_future_expires_php'],
- 'far_future_expires_rewrite' => $options['far_future_expires_rewrite'],
- 'header' => $type,
- 'unobtrusive_body' => $options['unobtrusive_body'],
- 'parallel' => $options['parallel'],
- 'parallel_hosts' => $options['parallel_hosts'],
- 'external_scripts' => $options['external_scripts'],
- 'inline_scripts' => $options['inline_scripts'],
- 'external_scripts_exclude' => $options['external_scripts_exclude'],
- 'include_code' => $options['include_code'],
- 'remove_list' => $options['remove_list'],
- 'dont_check_file_mtime' => $options['dont_check_file_mtime'],
- 'file' => $options['file'],
- 'https' => $options['https'],
- 'rocket' => $options['rocket'],
- 'rocket_external' => $options['rocket'],
- 'reorder' => $options['reorder']
- ),
- $this->content,
- $link_files
- );
- }
- }
- /**
- * GZIP and minify the page itself as required
- *…
Large files files are truncated, but you can click here to view the full file