diff --git a/compiler.php b/compiler.php new file mode 100755 index 0000000..93a7cab --- /dev/null +++ b/compiler.php @@ -0,0 +1,61 @@ + + + +
+';
+ $html .= '
+ ';
+ $html .= 'a
+ b
+ c
+ d
+ e
+ f
+ | ';
+ $html .= ' '; + $html .= ''; + $html .= ''; + $value = json_decode($this->value, true); + $html .= ' '; + $html .= ' '; + $html .= ' |
';
+ $html .= '
+ ';
+ $html .= 'a
+ b
+ c
+ d
+ e
+ f
+ | '; + $html .= ''; + $html .= ''; + $value = json_decode($this->value, true); + $html .= ' | '; + + $html .= ' '; + $html .= '
HTTP digest authentication can be used with the URI router. + * HTTP digest is much more recommended over the use of HTTP Basic auth which doesn't provide any encryption. + * If you are running PHP on Apache in CGI/FastCGI mode, you would need to + * add the following line to your .htaccess for digest auth to work correctly.
+ *RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
+ *
+ * This class is tested under Apache 2.2 and Cherokee web server. It should work in both mod_php and cgi mode.
+ * + * @author Leng Sheng HongHTTP Digest Authentication doesn't work with PHP in CGI mode,
+ * you have to add this into your .htaccess RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
+ * HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
+ * echo $content;
+ *
+ *
+ * E.g. Content from DB with no update time:
+ *
+ * $content = getContentFromDB();
+ * $cg = new HTTP_ConditionalGet(array(
+ * 'contentHash' => md5($content)
+ * ));
+ * $cg->sendHeaders();
+ * if ($cg->cacheIsValid) {
+ * exit();
+ * }
+ * echo $content;
+ *
+ *
+ * E.g. Static content with some static includes:
+ *
+ * // before content
+ * $cg = new HTTP_ConditionalGet(array(
+ * 'lastUpdateTime' => max(
+ * filemtime(__FILE__)
+ * ,filemtime('/path/to/header.inc')
+ * ,filemtime('/path/to/footer.inc')
+ * )
+ * ));
+ * $cg->sendHeaders();
+ * if ($cg->cacheIsValid) {
+ * exit();
+ * }
+ *
+ * @package Minify
+ * @subpackage HTTP
+ * @author Stephen Clay
+ * array(
+ * 'Cache-Control' => 'max-age=0, public'
+ * ,'ETag' => '"foobar"'
+ * )
+ *
+ *
+ * @return array
+ */
+ public function getHeaders()
+ {
+ return $this->_headers;
+ }
+
+ /**
+ * Set the Content-Length header in bytes
+ *
+ * With most PHP configs, as long as you don't flush() output, this method
+ * is not needed and PHP will buffer all output and set Content-Length for
+ * you. Otherwise you'll want to call this to let the client know up front.
+ *
+ * @param int $bytes
+ *
+ * @return int copy of input $bytes
+ */
+ public function setContentLength($bytes)
+ {
+ return $this->_headers['Content-Length'] = $bytes;
+ }
+
+ /**
+ * Send headers
+ *
+ * @see getHeaders()
+ *
+ * Note this doesn't "clear" the headers. Calling sendHeaders() will
+ * call header() again (but probably have not effect) and getHeaders() will
+ * still return the headers.
+ *
+ * @return null
+ */
+ public function sendHeaders()
+ {
+ $headers = $this->_headers;
+ if (array_key_exists('_responseCode', $headers)) {
+ // FastCGI environments require 3rd arg to header() to be set
+ list(, $code) = explode(' ', $headers['_responseCode'], 3);
+ header($headers['_responseCode'], true, $code);
+ unset($headers['_responseCode']);
+ }
+ foreach ($headers as $name => $val) {
+ header($name . ': ' . $val);
+ }
+ }
+
+ /**
+ * Exit if the client's cache is valid for this resource
+ *
+ * This is a convenience method for common use of the class
+ *
+ * @param int $lastModifiedTime if given, both ETag AND Last-Modified headers
+ * will be sent with content. This is recommended.
+ *
+ * @param bool $isPublic (default false) if true, the Cache-Control header
+ * will contain "public", allowing proxies to cache the content. Otherwise
+ * "private" will be sent, allowing only browser caching.
+ *
+ * @param array $options (default empty) additional options for constructor
+ */
+ public static function check($lastModifiedTime = null, $isPublic = false, $options = array())
+ {
+ if (null !== $lastModifiedTime) {
+ $options['lastModifiedTime'] = (int)$lastModifiedTime;
+ }
+ $options['isPublic'] = (bool)$isPublic;
+ $cg = new HTTP_ConditionalGet($options);
+ $cg->sendHeaders();
+ if ($cg->cacheIsValid) {
+ exit();
+ }
+ }
+
+
+ /**
+ * Get a GMT formatted date for use in HTTP headers
+ *
+ *
+ * header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
+ *
+ *
+ * @param int $time unix timestamp
+ *
+ * @return string
+ */
+ public static function gmtDate($time)
+ {
+ return gmdate('D, d M Y H:i:s \G\M\T', $time);
+ }
+
+ protected $_headers = array();
+ protected $_lmTime = null;
+ protected $_etag = null;
+ protected $_stripEtag = false;
+
+ /**
+ * @param string $hash
+ *
+ * @param string $scope
+ */
+ protected function _setEtag($hash, $scope)
+ {
+ $this->_etag = '"' . substr($scope, 0, 3) . $hash . '"';
+ $this->_headers['ETag'] = $this->_etag;
+ }
+
+ /**
+ * @param int $time
+ */
+ protected function _setLastModified($time)
+ {
+ $this->_lmTime = (int)$time;
+ $this->_headers['Last-Modified'] = self::gmtDate($time);
+ }
+
+ /**
+ * Determine validity of client cache and queue 304 header if valid
+ *
+ * @return bool
+ */
+ protected function _isCacheValid()
+ {
+ if (null === $this->_etag) {
+ // lmTime is copied to ETag, so this condition implies that the
+ // server sent neither ETag nor Last-Modified, so the client can't
+ // possibly has a valid cache.
+ return false;
+ }
+ $isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified());
+ if ($isValid) {
+ $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
+ }
+ return $isValid;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function resourceMatchedEtag()
+ {
+ if (!isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
+ return false;
+ }
+ $clientEtagList = get_magic_quotes_gpc()
+ ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
+ : $_SERVER['HTTP_IF_NONE_MATCH'];
+ $clientEtags = explode(',', $clientEtagList);
+
+ $compareTo = $this->normalizeEtag($this->_etag);
+ foreach ($clientEtags as $clientEtag) {
+ if ($this->normalizeEtag($clientEtag) === $compareTo) {
+ // respond with the client's matched ETag, even if it's not what
+ // we would've sent by default
+ $this->_headers['ETag'] = trim($clientEtag);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param string $etag
+ *
+ * @return string
+ */
+ protected function normalizeEtag($etag) {
+ $etag = trim($etag);
+ return $this->_stripEtag
+ ? preg_replace('/;\\w\\w"$/', '"', $etag)
+ : $etag;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function resourceNotModified()
+ {
+ if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+ return false;
+ }
+ // strip off IE's extra data (semicolon)
+ list($ifModifiedSince) = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE'], 2);
+ if (strtotime($ifModifiedSince) >= $this->_lmTime) {
+ // Apache 2.2's behavior. If there was no ETag match, send the
+ // non-encoded version of the ETag value.
+ $this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/core/utilities/min/lib/HTTP/Encoder.php b/core/utilities/min/lib/HTTP/Encoder.php
new file mode 100755
index 0000000..8f34779
--- /dev/null
+++ b/core/utilities/min/lib/HTTP/Encoder.php
@@ -0,0 +1,335 @@
+
+ * // Send a CSS file, compressed if possible
+ * $he = new HTTP_Encoder(array(
+ * 'content' => file_get_contents($cssFile)
+ * ,'type' => 'text/css'
+ * ));
+ * $he->encode();
+ * $he->sendAll();
+ *
+ *
+ *
+ * // Shortcut to encoding output
+ * header('Content-Type: text/css'); // needed if not HTML
+ * HTTP_Encoder::output($css);
+ *
+ *
+ *
+ * // Just sniff for the accepted encoding
+ * $encoding = HTTP_Encoder::getAcceptedEncoding();
+ *
+ *
+ * For more control over headers, use getHeaders() and getData() and send your
+ * own output.
+ *
+ * Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
+ * and gzcompress functions for gzip, deflate, and compress-encoding
+ * respectively.
+ *
+ * @package Minify
+ * @subpackage HTTP
+ * @author Stephen Clay
+ * array(
+ * 'Content-Length' => '615'
+ * ,'Content-Encoding' => 'x-gzip'
+ * ,'Vary' => 'Accept-Encoding'
+ * )
+ *
+ *
+ * @return array
+ */
+ public function getHeaders()
+ {
+ return $this->_headers;
+ }
+
+ /**
+ * Send output headers
+ *
+ * You must call this before headers are sent and it probably cannot be
+ * used in conjunction with zlib output buffering / mod_gzip. Errors are
+ * not handled purposefully.
+ *
+ * @see getHeaders()
+ */
+ public function sendHeaders()
+ {
+ foreach ($this->_headers as $name => $val) {
+ header($name . ': ' . $val);
+ }
+ }
+
+ /**
+ * Send output headers and content
+ *
+ * A shortcut for sendHeaders() and echo getContent()
+ *
+ * You must call this before headers are sent and it probably cannot be
+ * used in conjunction with zlib output buffering / mod_gzip. Errors are
+ * not handled purposefully.
+ */
+ public function sendAll()
+ {
+ $this->sendHeaders();
+ echo $this->_content;
+ }
+
+ /**
+ * Determine the client's best encoding method from the HTTP Accept-Encoding
+ * header.
+ *
+ * If no Accept-Encoding header is set, or the browser is IE before v6 SP2,
+ * this will return ('', ''), the "identity" encoding.
+ *
+ * A syntax-aware scan is done of the Accept-Encoding, so the method must
+ * be non 0. The methods are favored in order of gzip, deflate, then
+ * compress. Deflate is always smallest and generally faster, but is
+ * rarely sent by servers, so client support could be buggier.
+ *
+ * @param bool $allowCompress allow the older compress encoding
+ *
+ * @param bool $allowDeflate allow the more recent deflate encoding
+ *
+ * @return array two values, 1st is the actual encoding method, 2nd is the
+ * alias of that method to use in the Content-Encoding header (some browsers
+ * call gzip "x-gzip" etc.)
+ */
+ public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
+ {
+ // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+
+ if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
+ || self::isBuggyIe())
+ {
+ return array('', '');
+ }
+ $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
+ // gzip checks (quick)
+ if (0 === strpos($ae, 'gzip,') // most browsers
+ || 0 === strpos($ae, 'deflate, gzip,') // opera
+ ) {
+ return array('gzip', 'gzip');
+ }
+ // gzip checks (slow)
+ if (preg_match(
+ '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
+ ,$ae
+ ,$m)) {
+ return array('gzip', $m[1]);
+ }
+ if ($allowDeflate) {
+ // deflate checks
+ $aeRev = strrev($ae);
+ if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
+ || 0 === strpos($aeRev, 'etalfed,') // gecko
+ || 0 === strpos($ae, 'deflate,') // opera
+ // slow parsing
+ || preg_match(
+ '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
+ return array('deflate', 'deflate');
+ }
+ }
+ if ($allowCompress && preg_match(
+ '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
+ ,$ae
+ ,$m)) {
+ return array('compress', $m[1]);
+ }
+ return array('', '');
+ }
+
+ /**
+ * Encode (compress) the content
+ *
+ * If the encode method is '' (none) or compression level is 0, or the 'zlib'
+ * extension isn't loaded, we return false.
+ *
+ * Then the appropriate gz_* function is called to compress the content. If
+ * this fails, false is returned.
+ *
+ * The header "Vary: Accept-Encoding" is added. If encoding is successful,
+ * the Content-Length header is updated, and Content-Encoding is also added.
+ *
+ * @param int $compressionLevel given to zlib functions. If not given, the
+ * class default will be used.
+ *
+ * @return bool success true if the content was actually compressed
+ */
+ public function encode($compressionLevel = null)
+ {
+ if (! self::isBuggyIe()) {
+ $this->_headers['Vary'] = 'Accept-Encoding';
+ }
+ if (null === $compressionLevel) {
+ $compressionLevel = self::$compressionLevel;
+ }
+ if ('' === $this->_encodeMethod[0]
+ || ($compressionLevel == 0)
+ || !extension_loaded('zlib'))
+ {
+ return false;
+ }
+ if ($this->_encodeMethod[0] === 'deflate') {
+ $encoded = gzdeflate($this->_content, $compressionLevel);
+ } elseif ($this->_encodeMethod[0] === 'gzip') {
+ $encoded = gzencode($this->_content, $compressionLevel);
+ } else {
+ $encoded = gzcompress($this->_content, $compressionLevel);
+ }
+ if (false === $encoded) {
+ return false;
+ }
+ $this->_headers['Content-Length'] = $this->_useMbStrlen
+ ? (string)mb_strlen($encoded, '8bit')
+ : (string)strlen($encoded);
+ $this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
+ $this->_content = $encoded;
+ return true;
+ }
+
+ /**
+ * Encode and send appropriate headers and content
+ *
+ * This is a convenience method for common use of the class
+ *
+ * @param string $content
+ *
+ * @param int $compressionLevel given to zlib functions. If not given, the
+ * class default will be used.
+ *
+ * @return bool success true if the content was actually compressed
+ */
+ public static function output($content, $compressionLevel = null)
+ {
+ if (null === $compressionLevel) {
+ $compressionLevel = self::$compressionLevel;
+ }
+ $he = new HTTP_Encoder(array('content' => $content));
+ $ret = $he->encode($compressionLevel);
+ $he->sendAll();
+ return $ret;
+ }
+
+ /**
+ * Is the browser an IE version earlier than 6 SP2?
+ *
+ * @return bool
+ */
+ public static function isBuggyIe()
+ {
+ if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ return false;
+ }
+ $ua = $_SERVER['HTTP_USER_AGENT'];
+ // quick escape for non-IEs
+ if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
+ || false !== strpos($ua, 'Opera')) {
+ return false;
+ }
+ // no regex = faaast
+ $version = (float)substr($ua, 30);
+ return self::$encodeToIe6
+ ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
+ : ($version < 7);
+ }
+
+ protected $_content = '';
+ protected $_headers = array();
+ protected $_encodeMethod = array('', '');
+ protected $_useMbStrlen = false;
+}
diff --git a/core/utilities/min/lib/JSMin.php b/core/utilities/min/lib/JSMin.php
new file mode 100755
index 0000000..b6879f3
--- /dev/null
+++ b/core/utilities/min/lib/JSMin.php
@@ -0,0 +1,385 @@
+
+ * $minifiedJs = JSMin::minify($js);
+ *
+ *
+ * This is a modified port of jsmin.c. Improvements:
+ *
+ * Does not choke on some regexp literals containing quote characters. E.g. /'/
+ *
+ * Spaces are preserved after some add/sub operators, so they are not mistakenly
+ * converted to post-inc/dec. E.g. a + ++b -> a+ ++b
+ *
+ * Preserves multi-line comments that begin with /*!
+ *
+ * PHP 5 or higher is required.
+ *
+ * Permission is hereby granted to use this version of the library under the
+ * same terms as jsmin.c, which has the following license:
+ *
+ * --
+ * Copyright (c) 2002 Douglas Crockford (www.crockford.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * --
+ *
+ * @package JSMin
+ * @author Ryan Grove
+ * echo $b->uri('/site.js');
+ * // outputs "/site.js?1678242"
+ *
+ * echo $b->uri('/scriptaculous.js?load=effects');
+ * // outputs "/scriptaculous.js?load=effects&1678242"
+ *
+ *
+ * @param string $uri
+ * @param boolean $forceAmpersand (default = false) Force the use of ampersand to
+ * append the timestamp to the URI.
+ * @return string
+ */
+ public function uri($uri, $forceAmpersand = false) {
+ $sep = ($forceAmpersand || strpos($uri, '?') !== false)
+ ? self::$ampersand
+ : '?';
+ return "{$uri}{$sep}{$this->lastModified}";
+ }
+
+ /**
+ * Create a build object
+ *
+ * @param array $sources array of Minify_Source objects and/or file paths
+ *
+ * @return null
+ */
+ public function __construct($sources)
+ {
+ $max = 0;
+ foreach ((array)$sources as $source) {
+ if ($source instanceof Minify_Source) {
+ $max = max($max, $source->lastModified);
+ } elseif (is_string($source)) {
+ if (0 === strpos($source, '//')) {
+ $source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
+ }
+ if (is_file($source)) {
+ $max = max($max, filemtime($source));
+ }
+ }
+ }
+ $this->lastModified = $max;
+ }
+}
diff --git a/core/utilities/min/lib/Minify/CSS.php b/core/utilities/min/lib/Minify/CSS.php
new file mode 100755
index 0000000..3241455
--- /dev/null
+++ b/core/utilities/min/lib/Minify/CSS.php
@@ -0,0 +1,99 @@
+
+ * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
+ */
+class Minify_CSS {
+
+ /**
+ * Minify a CSS string
+ *
+ * @param string $css
+ *
+ * @param array $options available options:
+ *
+ * 'preserveComments': (default true) multi-line comments that begin
+ * with "/*!" will be preserved with newlines before and after to
+ * enhance readability.
+ *
+ * 'removeCharsets': (default true) remove all @charset at-rules
+ *
+ * 'prependRelativePath': (default null) if given, this string will be
+ * prepended to all relative URIs in import/url declarations
+ *
+ * 'currentDir': (default null) if given, this is assumed to be the
+ * directory of the current CSS file. Using this, minify will rewrite
+ * all relative URIs in import/url declarations to correctly point to
+ * the desired files. For this to work, the files *must* exist and be
+ * visible by the PHP process.
+ *
+ * 'symlinks': (default = array()) If the CSS file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * target paths, where the link paths are within the document root. Because
+ * paths need to be normalized for this to work, use "//" to substitute
+ * the doc root in the link paths (the array keys). E.g.:
+ *
+ * array('//symlink' => '/real/target/path') // unix
+ * array('//static' => 'D:\\staticStorage') // Windows
+ *
+ *
+ * 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
+ * see Minify_CSS_UriRewriter::rewrite
+ *
+ * @return string
+ */
+ public static function minify($css, $options = array())
+ {
+ $options = array_merge(array(
+ 'compress' => true,
+ 'removeCharsets' => true,
+ 'preserveComments' => true,
+ 'currentDir' => null,
+ 'docRoot' => $_SERVER['DOCUMENT_ROOT'],
+ 'prependRelativePath' => null,
+ 'symlinks' => array(),
+ ), $options);
+
+ if ($options['removeCharsets']) {
+ $css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
+ }
+ if ($options['compress']) {
+ if (! $options['preserveComments']) {
+ $css = Minify_CSS_Compressor::process($css, $options);
+ } else {
+ $css = Minify_CommentPreserver::process(
+ $css
+ ,array('Minify_CSS_Compressor', 'process')
+ ,array($options)
+ );
+ }
+ }
+ if (! $options['currentDir'] && ! $options['prependRelativePath']) {
+ return $css;
+ }
+ if ($options['currentDir']) {
+ return Minify_CSS_UriRewriter::rewrite(
+ $css
+ ,$options['currentDir']
+ ,$options['docRoot']
+ ,$options['symlinks']
+ );
+ } else {
+ return Minify_CSS_UriRewriter::prepend(
+ $css
+ ,$options['prependRelativePath']
+ );
+ }
+ }
+}
diff --git a/core/utilities/min/lib/Minify/CSS/Compressor.php b/core/utilities/min/lib/Minify/CSS/Compressor.php
new file mode 100755
index 0000000..c6cdd8b
--- /dev/null
+++ b/core/utilities/min/lib/Minify/CSS/Compressor.php
@@ -0,0 +1,249 @@
+
+ * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
+ */
+class Minify_CSS_Compressor {
+
+ /**
+ * Minify a CSS string
+ *
+ * @param string $css
+ *
+ * @param array $options (currently ignored)
+ *
+ * @return string
+ */
+ public static function process($css, $options = array())
+ {
+ $obj = new Minify_CSS_Compressor($options);
+ return $obj->_process($css);
+ }
+
+ /**
+ * @var array
+ */
+ protected $_options = null;
+
+ /**
+ * Are we "in" a hack? I.e. are some browsers targetted until the next comment?
+ *
+ * @var bool
+ */
+ protected $_inHack = false;
+
+
+ /**
+ * Constructor
+ *
+ * @param array $options (currently ignored)
+ */
+ private function __construct($options) {
+ $this->_options = $options;
+ }
+
+ /**
+ * Minify a CSS string
+ *
+ * @param string $css
+ *
+ * @return string
+ */
+ protected function _process($css)
+ {
+ $css = str_replace("\r\n", "\n", $css);
+
+ // preserve empty comment after '>'
+ // http://www.webdevout.net/css-hacks#in_css-selectors
+ $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);
+
+ // preserve empty comment between property and value
+ // http://css-discuss.incutio.com/?page=BoxModelHack
+ $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
+ $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);
+
+ // apply callback to all valid comments (and strip out surrounding ws
+ $css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'
+ ,array($this, '_commentCB'), $css);
+
+ // remove ws around { } and last semicolon in declaration block
+ $css = preg_replace('/\\s*{\\s*/', '{', $css);
+ $css = preg_replace('/;?\\s*}\\s*/', '}', $css);
+
+ // remove ws surrounding semicolons
+ $css = preg_replace('/\\s*;\\s*/', ';', $css);
+
+ // remove ws around urls
+ $css = preg_replace('/
+ url\\( # url(
+ \\s*
+ ([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)
+ \\s*
+ \\) # )
+ /x', 'url($1)', $css);
+
+ // remove ws between rules and colons
+ $css = preg_replace('/
+ \\s*
+ ([{;]) # 1 = beginning of block or rule separator
+ \\s*
+ ([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)
+ \\s*
+ :
+ \\s*
+ (\\b|[#\'"-]) # 3 = first character of a value
+ /x', '$1$2:$3', $css);
+
+ // remove ws in selectors
+ $css = preg_replace_callback('/
+ (?: # non-capture
+ \\s*
+ [^~>+,\\s]+ # selector part
+ \\s*
+ [,>+~] # combinators
+ )+
+ \\s*
+ [^~>+,\\s]+ # selector part
+ { # open declaration block
+ /x'
+ ,array($this, '_selectorsCB'), $css);
+
+ // minimize hex colors
+ $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'
+ , '$1#$2$3$4$5', $css);
+
+ // remove spaces between font families
+ $css = preg_replace_callback('/font-family:([^;}]+)([;}])/'
+ ,array($this, '_fontFamilyCB'), $css);
+
+ $css = preg_replace('/@import\\s+url/', '@import url', $css);
+
+ // replace any ws involving newlines with a single newline
+ $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);
+
+ // separate common descendent selectors w/ newlines (to limit line lengths)
+ $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);
+
+ // Use newline after 1st numeric value (to limit line lengths).
+ $css = preg_replace('/
+ ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
+ \\s+
+ /x'
+ ,"$1\n", $css);
+
+ // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
+ $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);
+
+ return trim($css);
+ }
+
+ /**
+ * Replace what looks like a set of selectors
+ *
+ * @param array $m regex matches
+ *
+ * @return string
+ */
+ protected function _selectorsCB($m)
+ {
+ // remove ws around the combinators
+ return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
+ }
+
+ /**
+ * Process a comment and return a replacement
+ *
+ * @param array $m regex matches
+ *
+ * @return string
+ */
+ protected function _commentCB($m)
+ {
+ $hasSurroundingWs = (trim($m[0]) !== $m[1]);
+ $m = $m[1];
+ // $m is the comment content w/o the surrounding tokens,
+ // but the return value will replace the entire comment.
+ if ($m === 'keep') {
+ return '/**/';
+ }
+ if ($m === '" "') {
+ // component of http://tantek.com/CSS/Examples/midpass.html
+ return '/*" "*/';
+ }
+ if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) {
+ // component of http://tantek.com/CSS/Examples/midpass.html
+ return '/*";}}/* */';
+ }
+ if ($this->_inHack) {
+ // inversion: feeding only to one browser
+ if (preg_match('@
+ ^/ # comment started like /*/
+ \\s*
+ (\\S[\\s\\S]+?) # has at least some non-ws content
+ \\s*
+ /\\* # ends like /*/ or /**/
+ @x', $m, $n)) {
+ // end hack mode after this comment, but preserve the hack and comment content
+ $this->_inHack = false;
+ return "/*/{$n[1]}/**/";
+ }
+ }
+ if (substr($m, -1) === '\\') { // comment ends like \*/
+ // begin hack mode and preserve hack
+ $this->_inHack = true;
+ return '/*\\*/';
+ }
+ if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
+ // begin hack mode and preserve hack
+ $this->_inHack = true;
+ return '/*/*/';
+ }
+ if ($this->_inHack) {
+ // a regular comment ends hack mode but should be preserved
+ $this->_inHack = false;
+ return '/**/';
+ }
+ // Issue 107: if there's any surrounding whitespace, it may be important, so
+ // replace the comment with a single space
+ return $hasSurroundingWs // remove all other comments
+ ? ' '
+ : '';
+ }
+
+ /**
+ * Process a font-family listing and return a replacement
+ *
+ * @param array $m regex matches
+ *
+ * @return string
+ */
+ protected function _fontFamilyCB($m)
+ {
+ // Issue 210: must not eliminate WS between words in unquoted families
+ $pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ $out = 'font-family:';
+ while (null !== ($piece = array_shift($pieces))) {
+ if ($piece[0] !== '"' && $piece[0] !== "'") {
+ $piece = preg_replace('/\\s+/', ' ', $piece);
+ $piece = preg_replace('/\\s?,\\s?/', ',', $piece);
+ }
+ $out .= $piece;
+ }
+ return $out . $m[2];
+ }
+}
diff --git a/core/utilities/min/lib/Minify/CSS/UriRewriter.php b/core/utilities/min/lib/Minify/CSS/UriRewriter.php
new file mode 100755
index 0000000..8845f15
--- /dev/null
+++ b/core/utilities/min/lib/Minify/CSS/UriRewriter.php
@@ -0,0 +1,310 @@
+
+ */
+class Minify_CSS_UriRewriter {
+
+ /**
+ * rewrite() and rewriteRelative() append debugging information here
+ *
+ * @var string
+ */
+ public static $debugText = '';
+
+ /**
+ * In CSS content, rewrite file relative URIs as root relative
+ *
+ * @param string $css
+ *
+ * @param string $currentDir The directory of the current CSS file.
+ *
+ * @param string $docRoot The document root of the web site in which
+ * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
+ *
+ * @param array $symlinks (default = array()) If the CSS file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * target paths, where the link paths are within the document root. Because
+ * paths need to be normalized for this to work, use "//" to substitute
+ * the doc root in the link paths (the array keys). E.g.:
+ *
+ * array('//symlink' => '/real/target/path') // unix
+ * array('//static' => 'D:\\staticStorage') // Windows
+ *
+ *
+ * @return string
+ */
+ public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array())
+ {
+ self::$_docRoot = self::_realpath(
+ $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
+ );
+ self::$_currentDir = self::_realpath($currentDir);
+ self::$_symlinks = array();
+
+ // normalize symlinks
+ foreach ($symlinks as $link => $target) {
+ $link = ($link === '//')
+ ? self::$_docRoot
+ : str_replace('//', self::$_docRoot . '/', $link);
+ $link = strtr($link, '/', DIRECTORY_SEPARATOR);
+ self::$_symlinks[$link] = self::_realpath($target);
+ }
+
+ self::$debugText .= "docRoot : " . self::$_docRoot . "\n"
+ . "currentDir : " . self::$_currentDir . "\n";
+ if (self::$_symlinks) {
+ self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
+ }
+ self::$debugText .= "\n";
+
+ $css = self::_trimUrls($css);
+
+ // rewrite
+ $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
+ ,array(self::$className, '_processUriCB'), $css);
+ $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ ,array(self::$className, '_processUriCB'), $css);
+
+ return $css;
+ }
+
+ /**
+ * In CSS content, prepend a path to relative URIs
+ *
+ * @param string $css
+ *
+ * @param string $path The path to prepend.
+ *
+ * @return string
+ */
+ public static function prepend($css, $path)
+ {
+ self::$_prependPath = $path;
+
+ $css = self::_trimUrls($css);
+
+ // append
+ $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
+ ,array(self::$className, '_processUriCB'), $css);
+ $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ ,array(self::$className, '_processUriCB'), $css);
+
+ self::$_prependPath = null;
+ return $css;
+ }
+
+ /**
+ * Get a root relative URI from a file relative URI
+ *
+ *
+ * Minify_CSS_UriRewriter::rewriteRelative(
+ * '../img/hello.gif'
+ * , '/home/user/www/css' // path of CSS file
+ * , '/home/user/www' // doc root
+ * );
+ * // returns '/img/hello.gif'
+ *
+ * // example where static files are stored in a symlinked directory
+ * Minify_CSS_UriRewriter::rewriteRelative(
+ * 'hello.gif'
+ * , '/var/staticFiles/theme'
+ * , '/home/user/www'
+ * , array('/home/user/www/static' => '/var/staticFiles')
+ * );
+ * // returns '/static/theme/hello.gif'
+ *
+ *
+ * @param string $uri file relative URI
+ *
+ * @param string $realCurrentDir realpath of the current file's directory.
+ *
+ * @param string $realDocRoot realpath of the site document root.
+ *
+ * @param array $symlinks (default = array()) If the file is stored in
+ * a symlink-ed directory, provide an array of link paths to
+ * real target paths, where the link paths "appear" to be within the document
+ * root. E.g.:
+ *
+ * array('/home/foo/www/not/real/path' => '/real/target/path') // unix
+ * array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
+ *
+ *
+ * @return string
+ */
+ public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
+ {
+ // prepend path with current dir separator (OS-independent)
+ $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR)
+ . DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
+
+ self::$debugText .= "file-relative URI : {$uri}\n"
+ . "path prepended : {$path}\n";
+
+ // "unresolve" a symlink back to doc root
+ foreach ($symlinks as $link => $target) {
+ if (0 === strpos($path, $target)) {
+ // replace $target with $link
+ $path = $link . substr($path, strlen($target));
+
+ self::$debugText .= "symlink unresolved : {$path}\n";
+
+ break;
+ }
+ }
+ // strip doc root
+ $path = substr($path, strlen($realDocRoot));
+
+ self::$debugText .= "docroot stripped : {$path}\n";
+
+ // fix to root-relative URI
+ $uri = strtr($path, '/\\', '//');
+ $uri = self::removeDots($uri);
+
+ self::$debugText .= "traversals removed : {$uri}\n\n";
+
+ return $uri;
+ }
+
+ /**
+ * Remove instances of "./" and "../" where possible from a root-relative URI
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ public static function removeDots($uri)
+ {
+ $uri = str_replace('/./', '/', $uri);
+ // inspired by patch from Oleg Cherniy
+ do {
+ $uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
+ } while ($changed);
+ return $uri;
+ }
+
+ /**
+ * Defines which class to call as part of callbacks, change this
+ * if you extend Minify_CSS_UriRewriter
+ *
+ * @var string
+ */
+ protected static $className = 'Minify_CSS_UriRewriter';
+
+ /**
+ * Get realpath with any trailing slash removed. If realpath() fails,
+ * just remove the trailing slash.
+ *
+ * @param string $path
+ *
+ * @return mixed path with no trailing slash
+ */
+ protected static function _realpath($path)
+ {
+ $realPath = realpath($path);
+ if ($realPath !== false) {
+ $path = $realPath;
+ }
+ return rtrim($path, '/\\');
+ }
+
+ /**
+ * Directory of this stylesheet
+ *
+ * @var string
+ */
+ private static $_currentDir = '';
+
+ /**
+ * DOC_ROOT
+ *
+ * @var string
+ */
+ private static $_docRoot = '';
+
+ /**
+ * directory replacements to map symlink targets back to their
+ * source (within the document root) E.g. '/var/www/symlink' => '/var/realpath'
+ *
+ * @var array
+ */
+ private static $_symlinks = array();
+
+ /**
+ * Path to prepend
+ *
+ * @var string
+ */
+ private static $_prependPath = null;
+
+ /**
+ * @param string $css
+ *
+ * @return string
+ */
+ private static function _trimUrls($css)
+ {
+ return preg_replace('/
+ url\\( # url(
+ \\s*
+ ([^\\)]+?) # 1 = URI (assuming does not contain ")")
+ \\s*
+ \\) # )
+ /x', 'url($1)', $css);
+ }
+
+ /**
+ * @param array $m
+ *
+ * @return string
+ */
+ private static function _processUriCB($m)
+ {
+ // $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
+ $isImport = ($m[0][0] === '@');
+ // determine URI and the quote character (if any)
+ if ($isImport) {
+ $quoteChar = $m[1];
+ $uri = $m[2];
+ } else {
+ // $m[1] is either quoted or not
+ $quoteChar = ($m[1][0] === "'" || $m[1][0] === '"')
+ ? $m[1][0]
+ : '';
+ $uri = ($quoteChar === '')
+ ? $m[1]
+ : substr($m[1], 1, strlen($m[1]) - 2);
+ }
+ // analyze URI
+ if ('/' !== $uri[0] // root-relative
+ && false === strpos($uri, '//') // protocol (non-data)
+ && 0 !== strpos($uri, 'data:') // data protocol
+ ) {
+ // URI is file-relative: rewrite depending on options
+ if (self::$_prependPath === null) {
+ $uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
+ } else {
+ $uri = self::$_prependPath . $uri;
+ if ($uri[0] === '/') {
+ $root = '';
+ $rootRelative = $uri;
+ $uri = $root . self::removeDots($rootRelative);
+ } elseif (preg_match('@^((https?\:)?//([^/]+))/@', $uri, $m) && (false !== strpos($m[3], '.'))) {
+ $root = $m[1];
+ $rootRelative = substr($uri, strlen($root));
+ $uri = $root . self::removeDots($rootRelative);
+ }
+ }
+ }
+ return $isImport
+ ? "@import {$quoteChar}{$uri}{$quoteChar}"
+ : "url({$quoteChar}{$uri}{$quoteChar})";
+ }
+}
diff --git a/core/utilities/min/lib/Minify/Cache/APC.php b/core/utilities/min/lib/Minify/Cache/APC.php
new file mode 100755
index 0000000..24ab046
--- /dev/null
+++ b/core/utilities/min/lib/Minify/Cache/APC.php
@@ -0,0 +1,133 @@
+
+ * Minify::setCache(new Minify_Cache_APC());
+ *
+ *
+ * @package Minify
+ * @author Chris Edwards
+ **/
+class Minify_Cache_APC {
+
+ /**
+ * Create a Minify_Cache_APC object, to be passed to
+ * Minify::setCache().
+ *
+ *
+ * @param int $expire seconds until expiration (default = 0
+ * meaning the item will not get an expiration date)
+ *
+ * @return null
+ */
+ public function __construct($expire = 0)
+ {
+ $this->_exp = $expire;
+ }
+
+ /**
+ * Write data to cache.
+ *
+ * @param string $id cache id
+ *
+ * @param string $data
+ *
+ * @return bool success
+ */
+ public function store($id, $data)
+ {
+ return apc_store($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
+ }
+
+ /**
+ * Get the size of a cache entry
+ *
+ * @param string $id cache id
+ *
+ * @return int size in bytes
+ */
+ public function getSize($id)
+ {
+ if (! $this->_fetch($id)) {
+ return false;
+ }
+ return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
+ ? mb_strlen($this->_data, '8bit')
+ : strlen($this->_data);
+ }
+
+ /**
+ * Does a valid cache entry exist?
+ *
+ * @param string $id cache id
+ *
+ * @param int $srcMtime mtime of the original source file(s)
+ *
+ * @return bool exists
+ */
+ public function isValid($id, $srcMtime)
+ {
+ return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
+ }
+
+ /**
+ * Send the cached content to output
+ *
+ * @param string $id cache id
+ */
+ public function display($id)
+ {
+ echo $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ /**
+ * Fetch the cached content
+ *
+ * @param string $id cache id
+ *
+ * @return string
+ */
+ public function fetch($id)
+ {
+ return $this->_fetch($id)
+ ? $this->_data
+ : '';
+ }
+
+ private $_exp = null;
+
+ // cache of most recently fetched id
+ private $_lm = null;
+ private $_data = null;
+ private $_id = null;
+
+ /**
+ * Fetch data and timestamp from apc, store in instance
+ *
+ * @param string $id
+ *
+ * @return bool success
+ */
+ private function _fetch($id)
+ {
+ if ($this->_id === $id) {
+ return true;
+ }
+ $ret = apc_fetch($id);
+ if (false === $ret) {
+ $this->_id = null;
+ return false;
+ }
+ list($this->_lm, $this->_data) = explode('|', $ret, 2);
+ $this->_id = $id;
+ return true;
+ }
+}
diff --git a/core/utilities/min/lib/Minify/Cache/File.php b/core/utilities/min/lib/Minify/Cache/File.php
new file mode 100755
index 0000000..27b424a
--- /dev/null
+++ b/core/utilities/min/lib/Minify/Cache/File.php
@@ -0,0 +1,194 @@
+_locking = $fileLocking;
+ $this->_path = $path;
+ }
+
+ /**
+ * Write data to cache.
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @param string $data
+ *
+ * @return bool success
+ */
+ public function store($id, $data)
+ {
+ $flag = $this->_locking
+ ? LOCK_EX
+ : null;
+ $file = $this->_path . '/' . $id;
+ if (! @file_put_contents($file, $data, $flag)) {
+ $this->_log("Minify_Cache_File: Write failed to '$file'");
+ }
+ // write control
+ if ($data !== $this->fetch($id)) {
+ @unlink($file);
+ $this->_log("Minify_Cache_File: Post-write read failed for '$file'");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Get the size of a cache entry
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @return int size in bytes
+ */
+ public function getSize($id)
+ {
+ return filesize($this->_path . '/' . $id);
+ }
+
+ /**
+ * Does a valid cache entry exist?
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @param int $srcMtime mtime of the original source file(s)
+ *
+ * @return bool exists
+ */
+ public function isValid($id, $srcMtime)
+ {
+ $file = $this->_path . '/' . $id;
+ return (is_file($file) && (filemtime($file) >= $srcMtime));
+ }
+
+ /**
+ * Send the cached content to output
+ *
+ * @param string $id cache id (e.g. a filename)
+ */
+ public function display($id)
+ {
+ if ($this->_locking) {
+ $fp = fopen($this->_path . '/' . $id, 'rb');
+ flock($fp, LOCK_SH);
+ fpassthru($fp);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ } else {
+ readfile($this->_path . '/' . $id);
+ }
+ }
+
+ /**
+ * Fetch the cached content
+ *
+ * @param string $id cache id (e.g. a filename)
+ *
+ * @return string
+ */
+ public function fetch($id)
+ {
+ if ($this->_locking) {
+ $fp = fopen($this->_path . '/' . $id, 'rb');
+ flock($fp, LOCK_SH);
+ $ret = stream_get_contents($fp);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ return $ret;
+ } else {
+ return file_get_contents($this->_path . '/' . $id);
+ }
+ }
+
+ /**
+ * Fetch the cache path used
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->_path;
+ }
+
+ /**
+ * Get a usable temp directory
+ *
+ * Adapted from Solar/Dir.php
+ * @author Paul M. Jones _reservePlace("