Skip to content
Browse files

minifying css and js

  • Loading branch information...
1 parent 24f0ce5 commit b977f493b0d3df050260ff2533cf6f2ebb83172e @blackant blackant committed
Showing with 9,357 additions and 5 deletions.
  1. BIN content/.DS_Store
  2. BIN public/docs/js/.DS_Store
  3. +13 −0 public/min/.htaccess
  4. +145 −0 public/min/README.txt
  5. +253 −0 public/min/builder/_index.js
  6. +36 −0 public/min/builder/bm.js
  7. +15 −0 public/min/builder/bm2.js
  8. +251 −0 public/min/builder/index.php
  9. +36 −0 public/min/builder/ocCheck.php
  10. +1 −0 public/min/builder/rewriteTest.js
  11. +43 −0 public/min/builder/test.php
  12. +168 −0 public/min/config.php
  13. +25 −0 public/min/groupsConfig.php
  14. +81 −0 public/min/index.php
  15. +1,370 −0 public/min/lib/FirePHP.php
  16. +347 −0 public/min/lib/HTTP/ConditionalGet.php
  17. +338 −0 public/min/lib/HTTP/Encoder.php
  18. +348 −0 public/min/lib/JSMin.php
  19. +1,872 −0 public/min/lib/JSMinPlus.php
  20. +566 −0 public/min/lib/Minify.php
  21. +103 −0 public/min/lib/Minify/Build.php
  22. +83 −0 public/min/lib/Minify/CSS.php
  23. +250 −0 public/min/lib/Minify/CSS/Compressor.php
  24. +270 −0 public/min/lib/Minify/CSS/UriRewriter.php
  25. +133 −0 public/min/lib/Minify/Cache/APC.php
  26. +139 −0 public/min/lib/Minify/Cache/File.php
  27. +140 −0 public/min/lib/Minify/Cache/Memcache.php
  28. +89 −0 public/min/lib/Minify/CommentPreserver.php
  29. +235 −0 public/min/lib/Minify/Controller/Base.php
  30. +78 −0 public/min/lib/Minify/Controller/Files.php
  31. +94 −0 public/min/lib/Minify/Controller/Groups.php
  32. +210 −0 public/min/lib/Minify/Controller/MinApp.php
  33. +87 −0 public/min/lib/Minify/Controller/Page.php
  34. +118 −0 public/min/lib/Minify/Controller/Version1.php
  35. +245 −0 public/min/lib/Minify/HTML.php
  36. +193 −0 public/min/lib/Minify/HTML/Helper.php
  37. +157 −0 public/min/lib/Minify/ImportProcessor.php
  38. +137 −0 public/min/lib/Minify/Lines.php
  39. +47 −0 public/min/lib/Minify/Logger.php
  40. +37 −0 public/min/lib/Minify/Packer.php
  41. +187 −0 public/min/lib/Minify/Source.php
  42. +142 −0 public/min/lib/Minify/YUICompressor.php
  43. +199 −0 public/min/lib/Solar/Dir.php
  44. +74 −0 public/min/utils.php
  45. +2 −5 templates/index.html
View
BIN content/.DS_Store
Binary file not shown.
View
BIN public/docs/js/.DS_Store
Binary file not shown.
View
13 public/min/.htaccess
@@ -0,0 +1,13 @@
+<IfModule mod_rewrite.c>
+RewriteEngine on
+
+# You may need RewriteBase on some servers
+#RewriteBase /min
+
+# rewrite URLs like "/min/f=..." to "/min/?f=..."
+RewriteRule ^([bfg]=.*) index.php?$1 [L,NE]
+</IfModule>
+<IfModule mod_env.c>
+# In case AddOutputFilterByType has been added
+SetEnv no-gzip
+</IfModule>
View
145 public/min/README.txt
@@ -0,0 +1,145 @@
+The files in this directory represent the default Minify setup designed to ease
+integration with your site. This app will combine and minify your Javascript or
+CSS files and serve them with HTTP compression and cache headers.
+
+
+RECOMMENDED
+
+It's recommended to edit config.php to set $min_cachePath to a writeable
+(by PHP) directory on your system. This will improve performance.
+
+
+GETTING STARTED
+
+The quickest way to get started is to use the Minify URI Builder application
+on your website: http://example.com/min/builder/
+
+
+MINIFYING A SINGLE FILE
+
+Let's say you want to serve this file:
+ http://example.com/wp-content/themes/default/default.css
+
+Here's the "Minify URL" for this file:
+ http://example.com/min/?f=wp-content/themes/default/default.css
+
+In other words, the "f" argument is set to the file path from root without the
+initial "/". As CSS files may contain relative URIs, Minify will automatically
+"fix" these by rewriting them as root relative.
+
+
+COMBINING MULTIPLE FILES IN ONE DOWNLOAD
+
+Separate the paths given to "f" with commas.
+
+Let's say you have CSS files at these URLs:
+ http://example.com/scripts/jquery-1.2.6.js
+ http://example.com/scripts/site.js
+
+You can combine these files through Minify by requesting this URL:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
+
+
+SIMPLIFYING URLS WITH A BASE PATH
+
+If you're combining files that share the same ancestor directory, you can use
+the "b" argument to set the base directory for the "f" argument. Do not include
+the leading or trailing "/" characters.
+
+E.g., the following URLs will serve the exact same content:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
+ http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
+
+
+MINIFY URLS IN HTML
+
+In (X)HTML files, don't forget to replace any "&" characters with "&amp;".
+
+
+SPECIFYING ALLOWED DIRECTORIES
+
+By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
+you'd prefer to limit Minify's access to certain directories, set the
+$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
+to the /js and /themes/default directories, use:
+
+$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
+
+
+GROUPS: NICER URLS
+
+For nicer URLs, edit groupsConfig.php to pre-specify groups of files
+to be combined under preset keys. E.g., here's an example configuration in
+groupsConfig.php:
+
+return array(
+ 'js' => array('//js/Class.js', '//js/email.js')
+);
+
+This pre-selects the following files to be combined under the key "js":
+ http://example.com/js/Class.js
+ http://example.com/js/email.js
+
+You can now serve these files with this simple URL:
+ http://example.com/min/?g=js
+
+
+GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
+
+In the groupsConfig.php array, the "//" in the file paths is a shortcut for
+the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
+or relative to the DOC_ROOT:
+
+return array(
+ 'js' => array(
+ '//js/file.js' // file within DOC_ROOT
+ ,'//../file.js' // file in parent directory of DOC_ROOT
+ ,'C:/Users/Steve/file.js' // file anywhere on filesystem
+ )
+);
+
+
+COMBINE MULTIPLE GROUPS AND FILES IN ONE URL
+
+E.g.: http://example.com/min/?g=js&f=more/scripts.js
+
+Separate group keys with commas:
+ http://example.com/min/?g=baseCss,css1&f=moreStyles.css
+
+
+FAR-FUTURE EXPIRES HEADERS
+
+Minify can send far-future (one year) Expires headers. To enable this you must
+add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
+and alter it whenever a source file is changed. If you have a build process you
+can use a build/source control revision number.
+
+You can alternately use the utility function Minify_getUri() to get a "versioned"
+Minify URI for use in your HTML. E.g.:
+
+<?php
+require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
+
+$jsUri = Minify_getUri('js'); // a key in groupsConfig.php
+echo "<script src='{$jsUri}'></script>";
+
+$cssUri = Minify_getUri(array(
+ '//css/styles1.css'
+ ,'//css/styles2.css'
+)); // a list of files
+echo "<link rel=stylesheet href='{$cssUri}'>";
+
+
+DEBUG MODE
+
+In debug mode, instead of compressing files, Minify sends combined files with
+comments prepended to each line to show the line number in the original source
+file. To enable this, set $min_allowDebugFlag to true in config.php and append
+"&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
+
+Known issue: files with comment-like strings/regexps can cause problems in this mode.
+
+
+QUESTIONS?
+
+http://groups.google.com/group/minify
View
253 public/min/builder/_index.js
@@ -0,0 +1,253 @@
+/*!
+ * Minify URI Builder
+ */
+var MUB = {
+ _uid : 0
+ ,_minRoot : '/min/?'
+ ,checkRewrite : function () {
+ var testUri = location.pathname.replace(/\/[^\/]*$/, '/rewriteTest.js').substr(1);
+ function fail() {
+ $('#minRewriteFailed')[0].className = 'topNote';
+ };
+ $.ajax({
+ url : '../f=' + testUri + '&' + (new Date()).getTime()
+ ,success : function (data) {
+ if (data === '1') {
+ MUB._minRoot = '/min/';
+ $('span.minRoot').html('/min/');
+ } else
+ fail();
+ }
+ ,error : fail
+ });
+ }
+ /**
+ * Get markup for new source LI element
+ */
+ ,newLi : function () {
+ return '<li id="li' + MUB._uid + '">http://' + location.host + '/<input type=text size=20>'
+ + ' <button title="Remove">x</button> <button title="Include Earlier">&uarr;</button>'
+ + ' <button title="Include Later">&darr;</button> <span></span></li>';
+ }
+ /**
+ * Add new empty source LI and attach handlers to buttons
+ */
+ ,addLi : function () {
+ $('#sources').append(MUB.newLi());
+ var li = $('#li' + MUB._uid)[0];
+ $('button[title=Remove]', li).click(function () {
+ $('#results').hide();
+ var hadValue = !!$('input', li)[0].value;
+ $(li).remove();
+ });
+ $('button[title$=Earlier]', li).click(function () {
+ $(li).prev('li').find('input').each(function () {
+ $('#results').hide();
+ // this = previous li input
+ var tmp = this.value;
+ this.value = $('input', li).val();
+ $('input', li).val(tmp);
+ MUB.updateAllTestLinks();
+ });
+ });
+ $('button[title$=Later]', li).click(function () {
+ $(li).next('li').find('input').each(function () {
+ $('#results').hide();
+ // this = next li input
+ var tmp = this.value;
+ this.value = $('input', li).val();
+ $('input', li).val(tmp);
+ MUB.updateAllTestLinks();
+ });
+ });
+ ++MUB._uid;
+ }
+ /**
+ * In the context of a source LI element, this will analyze the URI in
+ * the INPUT and check the URL on the site.
+ */
+ ,liUpdateTestLink : function () { // call in context of li element
+ if (! $('input', this)[0].value)
+ return;
+ var li = this;
+ $('span', this).html('');
+ var url = 'http://' + location.host + '/'
+ + $('input', this)[0].value.replace(/^\//, '');
+ $.ajax({
+ url : url
+ ,complete : function (xhr, stat) {
+ if ('success' == stat)
+ $('span', li).html('&#x2713;');
+ else {
+ $('span', li).html('<button><b>404! </b> recheck</button>')
+ .find('button').click(function () {
+ MUB.liUpdateTestLink.call(li);
+ });
+ }
+ }
+ ,dataType : 'text'
+ });
+ }
+ /**
+ * Check all source URLs
+ */
+ ,updateAllTestLinks : function () {
+ $('#sources li').each(MUB.liUpdateTestLink);
+ }
+ /**
+ * In a given array of strings, find the character they all have at
+ * a particular index
+ * @param Array arr array of strings
+ * @param Number pos index to check
+ * @return mixed a common char or '' if any do not match
+ */
+ ,getCommonCharAtPos : function (arr, pos) {
+ var i
+ ,l = arr.length
+ ,c = arr[0].charAt(pos);
+ if (c === '' || l === 1)
+ return c;
+ for (i = 1; i < l; ++i)
+ if (arr[i].charAt(pos) !== c)
+ return '';
+ return c;
+ }
+ /**
+ * Get the shortest URI to minify the set of source files
+ * @param Array sources URIs
+ */
+ ,getBestUri : function (sources) {
+ var pos = 0
+ ,base = ''
+ ,c;
+ while (true) {
+ c = MUB.getCommonCharAtPos(sources, pos);
+ if (c === '')
+ break;
+ else
+ base += c;
+ ++pos;
+ }
+ base = base.replace(/[^\/]+$/, '');
+ var uri = MUB._minRoot + 'f=' + sources.join(',');
+ if (base.charAt(base.length - 1) === '/') {
+ // we have a base dir!
+ var basedSources = sources
+ ,i
+ ,l = sources.length;
+ for (i = 0; i < l; ++i) {
+ basedSources[i] = sources[i].substr(base.length);
+ }
+ base = base.substr(0, base.length - 1);
+ var bUri = MUB._minRoot + 'b=' + base + '&f=' + basedSources.join(',');
+ //window.console && console.log([uri, bUri]);
+ uri = uri.length < bUri.length
+ ? uri
+ : bUri;
+ }
+ return uri;
+ }
+ /**
+ * Create the Minify URI for the sources
+ */
+ ,update : function () {
+ MUB.updateAllTestLinks();
+ var sources = []
+ ,ext = false
+ ,fail = false;
+ $('#sources input').each(function () {
+ var m, val;
+ if (! fail && this.value && (m = this.value.match(/\.(css|js)$/))) {
+ var thisExt = m[1];
+ if (ext === false)
+ ext = thisExt;
+ else if (thisExt !== ext) {
+ fail = true;
+ return alert('extensions must match!');
+ }
+ this.value = this.value.replace(/^\//, '');
+ if (-1 != $.inArray(this.value, sources)) {
+ fail = true;
+ return alert('duplicate file!');
+ }
+ sources.push(this.value);
+ }
+ });
+ if (fail || ! sources.length)
+ return;
+ $('#groupConfig').val(" 'keyName' => array('//" + sources.join("', '//") + "'),");
+ var uri = MUB.getBestUri(sources)
+ ,uriH = uri.replace(/</, '&lt;').replace(/>/, '&gt;').replace(/&/, '&amp;');
+ $('#uriA').html(uriH)[0].href = uri;
+ $('#uriHtml').val(
+ ext === 'js'
+ ? '<script type="text/javascript" src="' + uriH + '"></script>'
+ : '<link type="text/css" rel="stylesheet" href="' + uriH + '" />'
+ );
+ $('#results').show();
+ }
+ /**
+ * Handler for the "Add file +" button
+ */
+ ,addButtonClick : function () {
+ $('#results').hide();
+ MUB.addLi();
+ MUB.updateAllTestLinks();
+ $('#update').show().click(MUB.update);
+ $('#sources li:last input')[0].focus();
+ }
+ /**
+ * Runs on DOMready
+ */
+ ,init : function () {
+ $('#jsDidntLoad').hide();
+ $('#app').show();
+ $('#sources').html('');
+ $('#add button').click(MUB.addButtonClick);
+ // make easier to copy text out of
+ $('#uriHtml, #groupConfig, #symlinkOpt').click(function () {
+ this.select();
+ }).focus(function () {
+ this.select();
+ });
+ $('a.ext').attr({target:'_blank'});
+ if (location.hash) {
+ // make links out of URIs from bookmarklet
+ $('#getBm').hide();
+ $('#bmUris').html('<p><strong>Found by bookmarklet:</strong> /<a href=#>'
+ + location.hash.substr(1).split(',').join('</a> | /<a href=#>')
+ + '</a></p>'
+ );
+ $('#bmUris a').click(function () {
+ MUB.addButtonClick();
+ $('#sources li:last input').val(this.innerHTML)
+ MUB.liUpdateTestLink.call($('#sources li:last')[0]);
+ $('#results').hide();
+ return false;
+ }).attr({title:'Add file +'});
+ } else {
+ // setup bookmarklet 1
+ $.ajax({
+ url : '../?f=' + location.pathname.replace(/\/[^\/]*$/, '/bm.js').substr(1)
+ ,success : function (code) {
+ $('#bm')[0].href = code
+ .replace('%BUILDER_URL%', location.href)
+ .replace(/\n/g, ' ');
+ }
+ ,dataType : 'text'
+ });
+ $.browser.msie && $('#getBm p:last').append(' Sorry, not supported in MSIE!');
+ MUB.addButtonClick();
+ }
+ // setup bookmarklet 2
+ $.ajax({
+ url : '../?f=' + location.pathname.replace(/\/[^\/]*$/, '/bm2.js').substr(1)
+ ,success : function (code) {
+ $('#bm2')[0].href = code.replace(/\n/g, ' ');
+ }
+ ,dataType : 'text'
+ });
+ MUB.checkRewrite();
+ }
+};
+$(MUB.init);
View
36 public/min/builder/bm.js
@@ -0,0 +1,36 @@
+javascript:(function() {
+ var d = document
+ ,uris = []
+ ,i = 0
+ ,o
+ ,home = (location + '').split('/').splice(0, 3).join('/') + '/';
+ function add(uri) {
+ return (0 === uri.indexOf(home))
+ && (!/[\?&]/.test(uri))
+ && uris.push(escape(uri.substr(home.length)));
+ };
+ function sheet(ss) {
+ // we must check the domain with add() before accessing ss.cssRules
+ // otherwise a security exception will be thrown
+ if (ss.href && add(ss.href) && ss.cssRules) {
+ var i = 0, r;
+ while (r = ss.cssRules[i++])
+ r.styleSheet && sheet(r.styleSheet);
+ }
+ };
+ while (o = d.getElementsByTagName('script')[i++])
+ o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
+ i = 0;
+ while (o = d.styleSheets[i++])
+ /* http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-DocumentStyle-styleSheets
+ document.styleSheet is a list property where [0] accesses the 1st element and
+ [outOfRange] returns null. In IE, styleSheets is a function, and also throws an
+ exception when you check the out of bounds index. (sigh) */
+ sheet(o);
+ if (uris.length)
+ window.open('%BUILDER_URL%#' + uris.join(','));
+ else
+ alert('No js/css files found with URLs within "'
+ + home.split('/')[2]
+ + '".\n(This tool is limited to URLs with the same domain.)');
+})();
View
15 public/min/builder/bm2.js
@@ -0,0 +1,15 @@
+javascript:(function(){
+ var d = document
+ ,c = d.cookie
+ ,m = c.match(/\bminDebug=([^; ]+)/)
+ ,v = m ? decodeURIComponent(m[1]) : ''
+ ,p = prompt('Debug Minify URIs on ' + location.hostname + ' which contain:'
+ + '\n(empty for none, space = OR)', v)
+ ;
+ if (p === null) return;
+ p = p.replace(/^\s+|\s+$/, '');
+ v = (p === '')
+ ? 'minDebug=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
+ : 'minDebug=' + encodeURIComponent(p) + '; path=/';
+ d.cookie = v;
+})();
View
251 public/min/builder/index.php
@@ -0,0 +1,251 @@
+<?php
+
+if (phpversion() < 5) {
+ exit('Minify requires PHP5 or greater.');
+}
+
+// check for auto-encoding
+$encodeOutput = (function_exists('gzdeflate')
+ && !ini_get('zlib.output_compression'));
+
+// recommend $min_symlinks setting for Apache UserDir
+$symlinkOption = '';
+if (0 === strpos($_SERVER["SERVER_SOFTWARE"], 'Apache/')
+ && preg_match('@^/\\~(\\w+)/@', $_SERVER['REQUEST_URI'], $m)
+) {
+ $userDir = DIRECTORY_SEPARATOR . $m[1] . DIRECTORY_SEPARATOR;
+ if (false !== strpos(__FILE__, $userDir)) {
+ $sm = array();
+ $sm["//~{$m[1]}"] = dirname(dirname(__FILE__));
+ $array = str_replace('array (', 'array(', var_export($sm, 1));
+ $symlinkOption = "\$min_symlinks = $array;";
+ }
+}
+
+require dirname(__FILE__) . '/../config.php';
+
+if (! $min_enableBuilder) {
+ header('Location: /');
+ exit();
+}
+
+$setIncludeSuccess = set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . get_include_path());
+// we do it this way because we want the builder to work after the user corrects
+// include_path. (set_include_path returning FALSE is OK).
+try {
+ require_once 'Solar/Dir.php';
+} catch (Exception $e) {
+ if (! $setIncludeSuccess) {
+ echo "Minify: set_include_path() failed. You may need to set your include_path "
+ ."outside of PHP code, e.g., in php.ini.";
+ } else {
+ echo $e->getMessage();
+ }
+ exit();
+}
+require 'Minify.php';
+
+$cachePathCode = '';
+if (! isset($min_cachePath)) {
+ $detectedTmp = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR);
+ $cachePathCode = "\$min_cachePath = " . var_export($detectedTmp, 1) . ';';
+}
+
+ob_start();
+?>
+<!DOCTYPE HTML>
+<title>Minify URI Builder</title>
+<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
+<style>
+body {margin:1em 60px;}
+h1, h2, h3 {margin-left:-25px; position:relative;}
+h1 {margin-top:0;}
+#sources {margin:0; padding:0;}
+#sources li {margin:0 0 0 40px}
+#sources li input {margin-left:2px}
+#add {margin:5px 0 1em 40px}
+.hide {display:none}
+#uriTable {border-collapse:collapse;}
+#uriTable td, #uriTable th {padding-top:10px;}
+#uriTable th {padding-right:10px;}
+#groupConfig {font-family:monospace;}
+b {color:#c00}
+.topNote {background: #ff9; display:inline-block; padding:.5em .6em; margin:0 0 1em;}
+.topWarning {background:#c00; color:#fff; padding:.5em .6em; margin:0 0 1em;}
+.topWarning a {color:#fff;}
+</style>
+<body>
+<?php if ($symlinkOption): ?>
+ <div class=topNote><strong>Note:</strong> It looks like you're running Minify in a user
+ directory. You may need the following option in /min/config.php to have URIs
+ correctly rewritten in CSS output:
+ <br><textarea id=symlinkOpt rows=3 cols=80 readonly><?php echo htmlspecialchars($symlinkOption); ?></textarea>
+</div>
+<?php endif; ?>
+
+<p class=topWarning id=jsDidntLoad><strong>Uh Oh.</strong> Minify was unable to
+ serve Javascript for this app. To troubleshoot this,
+ <a href="http://code.google.com/p/minify/wiki/Debugging">enable FirePHP debugging</a>
+ and request the <a id=builderScriptSrc href=#>Minify URL</a> directly. Hopefully the
+ FirePHP console will report the cause of the error.
+</p>
+
+<?php if ($cachePathCode): ?>
+<p class=topNote><strong>Note:</strong> <code><?php echo
+ htmlspecialchars($detectedTmp); ?></code> was discovered as a usable temp directory.<br>To
+ slightly improve performance you can hardcode this in /min/config.php:
+ <code><?php echo htmlspecialchars($cachePathCode); ?></code></p>
+<?php endIf; ?>
+
+<p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to
+ support mod_rewrite (used in /min/.htaccess). Your Minify URIs will contain "?", which
+<a href="http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/"
+>may reduce the benefit of proxy cache servers</a>.</p>
+
+<h1>Minify URI Builder</h1>
+
+<noscript><p class="topNote">Javascript and a browser supported by jQuery 1.2.6 is required
+for this application.</p></noscript>
+
+<div id=app class=hide>
+
+<p>Create a list of Javascript or CSS files (or 1 is fine) you'd like to combine
+and click [Update].</p>
+
+<ol id=sources><li></li></ol>
+<div id=add><button>Add file +</button></div>
+
+<div id=bmUris></div>
+
+<p><button id=update class=hide>Update</button></p>
+
+<div id=results class=hide>
+
+<h2>Minify URI</h2>
+<p>Place this URI in your HTML to serve the files above combined, minified, compressed and
+with cache headers.</p>
+<table id=uriTable>
+ <tr><th>URI</th><td><a id=uriA class=ext>/min</a> <small>(opens in new window)</small></td></tr>
+ <tr><th>HTML</th><td><input id=uriHtml type=text size=100 readonly></td></tr>
+</table>
+
+<h2>How to serve these files as a group</h2>
+<p>For the best performance you can serve these files as a pre-defined group with a URI
+like: <code><span class=minRoot>/min/?</span>g=keyName</code></p>
+<p>To do this, add a line like this to /min/groupsConfig.php:</p>
+
+<pre><code>return array(
+ <span style="color:#666">... your existing groups here ...</span>
+<input id=groupConfig size=100 type=text readonly>
+);</code></pre>
+
+<p><em>Make sure to replace <code>keyName</code> with a unique key for this group.</em></p>
+</div>
+
+<div id=getBm>
+<h3>Find URIs on a Page</h3>
+<p>You can use the bookmarklet below to fetch all CSS &amp; Javascript URIs from a page
+on your site. When you active it, this page will open in a new window with a list of
+available URIs to add.</p>
+
+<p><a id=bm>Create Minify URIs</a> <small>(right-click, add to bookmarks)</small></p>
+</div>
+
+<h3>Combining CSS files that contain <code>@import</code></h3>
+<p>If your CSS files contain <code>@import</code> declarations, Minify will not
+remove them. Therefore, you will want to remove those that point to files already
+in your list, and move any others to the top of the first file in your list
+(imports below any styles will be ignored by browsers as invalid).</p>
+<p>If you desire, you can use Minify URIs in imports and they will not be touched
+by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code></p>
+
+<h3>Debug Mode</h3>
+<p>When /min/config.php has <code>$min_allowDebugFlag = <strong>true</strong>;</code>
+ you can get debug output by appending <code>&amp;debug</code> to a Minify URL, or
+ by sending the cookie <code>minDebug=&lt;match&gt;</code>, where <code>&lt;match&gt;</code>
+ should be a string in the Minify URIs you'd like to debug. This bookmarklet will allow you to
+ set this cookie.</p>
+<p><a id=bm2>Minify Debug</a> <small>(right-click, add to bookmarks)</small></p>
+
+</div><!-- #app -->
+
+<hr>
+<p>Need help? Check the <a href="http://code.google.com/p/minify/w/list?can=3">wiki</a>,
+ or post to the <a class=ext href="http://groups.google.com/group/minify">discussion
+ list</a>.</p>
+ <p><small>Powered by Minify <?php echo Minify::VERSION; ?></small></p>
+
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
+<script>
+$(function () {
+ // give Minify a few seconds to serve _index.js before showing scary red warning
+ $('#jsDidntLoad').hide();
+ setTimeout(function () {
+ if (! window.MUB) {
+ // Minify didn't load
+ $('#jsDidntLoad').show();
+ }
+ }, 3000);
+
+ // detection of double output encoding
+ var msg = '<\p class=topWarning><\strong>Warning:<\/strong> ';
+ var url = 'ocCheck.php?' + (new Date()).getTime();
+ $.get(url, function (ocStatus) {
+ $.get(url + '&hello=1', function (ocHello) {
+ if (ocHello != 'World!') {
+ msg += 'It appears output is being automatically compressed, interfering '
+ + ' with Minify\'s own compression. ';
+ if (ocStatus == '1')
+ msg += 'The option "zlib.output_compression" is enabled in your PHP configuration. '
+ + 'Minify set this to "0", but it had no effect. This option must be disabled '
+ + 'in php.ini or .htaccess.';
+ else
+ msg += 'The option "zlib.output_compression" is disabled in your PHP configuration '
+ + 'so this behavior is likely due to a server option.';
+ $(document.body).prepend(msg + '<\/p>');
+ } else
+ if (ocStatus == '1')
+ $(document.body).prepend('<\p class=topNote><\strong>Note:</\strong> The option '
+ + '"zlib.output_compression" is enabled in your PHP configuration, but has been '
+ + 'successfully disabled via ini_set(). If you experience mangled output you '
+ + 'may want to consider disabling this option in your PHP configuration.<\/p>'
+ );
+ });
+ });
+});
+</script>
+<script>
+// workaround required to test when /min isn't child of web root
+var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1);
+src = "../?f=" + src;
+document.write('<\script type="text/javascript" src="' + src + '"><\/script>');
+$(function () {
+ $('#builderScriptSrc')[0].href = src;
+});
+</script>
+</body>
+<?php
+$content = ob_get_clean();
+
+// setup Minify
+if (0 === stripos(PHP_OS, 'win')) {
+ Minify::setDocRoot(); // we may be on IIS
+}
+Minify::setCache(
+ isset($min_cachePath) ? $min_cachePath : ''
+ ,$min_cacheFileLocking
+);
+Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
+
+Minify::serve('Page', array(
+ 'content' => $content
+ ,'id' => __FILE__
+ ,'lastModifiedTime' => max(
+ // regenerate cache if any of these change
+ filemtime(__FILE__)
+ ,filemtime(dirname(__FILE__) . '/../config.php')
+ ,filemtime(dirname(__FILE__) . '/../lib/Minify.php')
+ )
+ ,'minifyAll' => true
+ ,'encodeOutput' => $encodeOutput
+));
View
36 public/min/builder/ocCheck.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * AJAX checks for zlib.output_compression
+ *
+ * @package Minify
+ */
+
+$_oc = ini_get('zlib.output_compression');
+
+// allow access only if builder is enabled
+require dirname(__FILE__) . '/../config.php';
+if (! $min_enableBuilder) {
+ header('Location: /');
+ exit();
+}
+
+if (isset($_GET['hello'])) {
+ // echo 'World!'
+
+ // try to prevent double encoding (may not have an effect)
+ ini_set('zlib.output_compression', '0');
+
+ require $min_libPath . '/HTTP/Encoder.php';
+ HTTP_Encoder::$encodeToIe6 = true; // just in case
+ $he = new HTTP_Encoder(array(
+ 'content' => 'World!'
+ ,'method' => 'deflate'
+ ));
+ $he->encode();
+ $he->sendAll();
+
+} else {
+ // echo status "0" or "1"
+ header('Content-Type: text/plain');
+ echo (int)$_oc;
+}
View
1 public/min/builder/rewriteTest.js
@@ -0,0 +1 @@
+1
View
43 public/min/builder/test.php
@@ -0,0 +1,43 @@
+<?php
+exit();
+/* currently unused.
+
+// capture PHP's default setting (may get overridden in config
+$_oc = ini_get('zlib.output_compression');
+
+// allow access only if builder is enabled
+require dirname(__FILE__) . '/../config.php';
+if (! $min_enableBuilder) {
+ exit();
+}
+
+if (isset($_GET['oc'])) {
+ header('Content-Type: text/plain');
+ echo (int)$_oc;
+
+} elseif (isset($_GET['text']) && in_array($_GET['text'], array('js', 'css', 'fake'))) {
+ ini_set('zlib.output_compression', '0');
+ $type = ($_GET['text'] == 'js')
+ ? 'application/x-javascript'
+ : "text/{$_GET['text']}";
+ header("Content-Type: {$type}");
+ echo 'Hello';
+
+} elseif (isset($_GET['docroot'])) {
+ if (false === realpath($_SERVER['DOCUMENT_ROOT'])) {
+ echo "<p class=topWarning><strong>realpath(DOCUMENT_ROOT) failed.</strong> You may need "
+ . "to set \$min_documentRoot manually (hopefully realpath() is not "
+ . "broken in your environment).</p>";
+ }
+ if (0 !== strpos(realpath(__FILE__), realpath($_SERVER['DOCUMENT_ROOT']))) {
+ echo "<p class=topWarning><strong>DOCUMENT_ROOT doesn't contain this file.</strong> You may "
+ . " need to set \$min_documentRoot manually</p>";
+ }
+ if (isset($_SERVER['SUBDOMAIN_DOCUMENT_ROOT'])) {
+ echo "<p class=topNote><strong>\$_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] is set.</strong> "
+ . "You may need to set \$min_documentRoot to this in config.php</p>";
+ }
+
+}
+
+//*/
View
168 public/min/config.php
@@ -0,0 +1,168 @@
+<?php
+/**
+ * Configuration for "min", the default application built with the Minify
+ * library
+ *
+ * @package Minify
+ */
+
+
+/**
+ * Set to true to log messages to FirePHP (Firefox Firebug addon).
+ * Set to false for no error logging (Minify may be slightly faster).
+ * @link http://www.firephp.org/
+ *
+ * If you want to use a custom error logger, set this to your logger
+ * instance. Your object should have a method log(string $message).
+ *
+ * @todo cache system does not have error logging yet.
+ */
+$min_errorLogger = false;
+
+
+/**
+ * To allow debugging, you must set this option to true.
+ *
+ * Once true, you can send the cookie minDebug to request debug mode output. The
+ * cookie value should match the URIs you'd like to debug. E.g. to debug
+ * /min/f=file1.js send the cookie minDebug=file1.js
+ * You can manually enable debugging by appending "&debug" to a URI.
+ * E.g. /min/?f=script1.js,script2.js&debug
+ *
+ * In 'debug' mode, Minify combines files with no minification and adds comments
+ * to indicate line #s of the original files.
+ */
+$min_allowDebugFlag = false;
+
+
+/**
+ * Allow use of the Minify URI Builder app. If you no longer need
+ * this, set to false.
+ **/
+$min_enableBuilder = true;
+
+
+/**
+ * For best performance, specify your temp directory here. Otherwise Minify
+ * will have to load extra code to guess. Some examples below:
+ */
+//$min_cachePath = 'c:\\WINDOWS\\Temp';
+$min_cachePath = '/tmp';
+// $min_cachePath = preg_replace('/^\\d+;/', '', session_save_path());
+
+
+/**
+ * Leave an empty string to use PHP's $_SERVER['DOCUMENT_ROOT'].
+ *
+ * On some servers, this value may be misconfigured or missing. If so, set this
+ * to your full document root path with no trailing slash.
+ * E.g. '/home/accountname/public_html' or 'c:\\xampp\\htdocs'
+ *
+ * If /min/ is directly inside your document root, just uncomment the
+ * second line. The third line might work on some Apache servers.
+ */
+$min_documentRoot = '';
+//$min_documentRoot = substr(__FILE__, 0, -15);
+//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
+
+
+/**
+ * Cache file locking. Set to false if filesystem is NFS. On at least one
+ * NFS system flock-ing attempts stalled PHP for 30 seconds!
+ */
+$min_cacheFileLocking = true;
+
+
+/**
+ * Combining multiple CSS files can place @import declarations after rules, which
+ * is invalid. Minify will attempt to detect when this happens and place a
+ * warning comment at the top of the CSS output. To resolve this you can either
+ * move the @imports within your CSS files, or enable this option, which will
+ * move all @imports to the top of the output. Note that moving @imports could
+ * affect CSS values (which is why this option is disabled by default).
+ */
+$min_serveOptions['bubbleCssImports'] = false;
+
+
+/**
+ * Cache-Control: max-age value sent to browser (in seconds). After this period,
+ * the browser will send another conditional GET. Use a longer period for lower
+ * traffic but you may want to shorten this before making changes if it's crucial
+ * those changes are seen immediately.
+ *
+ * Note: Despite this setting, if you include a number at the end of the
+ * querystring, maxAge will be set to one year. E.g. /min/f=hello.css&123456
+ */
+$min_serveOptions['maxAge'] = 1800;
+
+
+/**
+ * If you'd like to restrict the "f" option to files within/below
+ * particular directories below DOCUMENT_ROOT, set this here.
+ * You will still need to include the directory in the
+ * f or b GET parameters.
+ *
+ * // = shortcut for DOCUMENT_ROOT
+ */
+//$min_serveOptions['minApp']['allowDirs'] = array('//js', '//css');
+
+/**
+ * Set to true to disable the "f" GET parameter for specifying files.
+ * Only the "g" parameter will be considered.
+ */
+$min_serveOptions['minApp']['groupsOnly'] = false;
+
+
+/**
+ * By default, Minify will not minify files with names containing .min or -min
+ * before the extension. E.g. myFile.min.js will not be processed by JSMin
+ *
+ * To minify all files, set this option to null. You could also specify your
+ * own pattern that is matched against the filename.
+ */
+//$min_serveOptions['minApp']['noMinPattern'] = '@[-\\.]min\\.(?:js|css)$@i';
+
+
+/**
+ * If you minify CSS files stored in symlink-ed directories, the URI rewriting
+ * algorithm can fail. To prevent this, 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.:
+ * <code>
+ * array('//symlink' => '/real/target/path') // unix
+ * array('//static' => 'D:\\staticStorage') // Windows
+ * </code>
+ */
+$min_symlinks = array();
+
+
+/**
+ * If you upload files from Windows to a non-Windows server, Windows may report
+ * incorrect mtimes for the files. This may cause Minify to keep serving stale
+ * cache files when source file changes are made too frequently (e.g. more than
+ * once an hour).
+ *
+ * Immediately after modifying and uploading a file, use the touch command to
+ * update the mtime on the server. If the mtime jumps ahead by a number of hours,
+ * set this variable to that number. If the mtime moves back, this should not be
+ * needed.
+ *
+ * In the Windows SFTP client WinSCP, there's an option that may fix this
+ * issue without changing the variable below. Under login > environment,
+ * select the option "Adjust remote timestamp with DST".
+ * @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
+ */
+$min_uploaderHoursBehind = 0;
+
+
+/**
+ * Path to Minify's lib folder. If you happen to move it, change
+ * this accordingly.
+ */
+$min_libPath = dirname(__FILE__) . '/lib';
+
+
+// try to disable output_compression (may not have an effect)
+ini_set('zlib.output_compression', '0');
View
25 public/min/groupsConfig.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Groups configuration for default Minify implementation
+ * @package Minify
+ */
+
+/**
+ * You may wish to use the Minify URI Builder app to suggest
+ * changes. http://yourdomain/min/builder/
+ *
+ * See http://code.google.com/p/minify/wiki/CustomSource for other ideas
+ **/
+
+return array(
+ 'js' => array(
+ '//public/docs/js/site.js',
+ '//public/docs/js/mootools-more.js',
+ '//public/docs/js/modernizr-2.0.min.js'
+ ),
+
+ 'css' => array(
+ '//public/docs/css/reset.css',
+ '//public/docs/css/screen.css'
+ )
+);
View
81 public/min/index.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * Front controller for default Minify implementation
+ *
+ * DO NOT EDIT! Configure this utility via config.php and groupsConfig.php
+ *
+ * @package Minify
+ */
+
+define('MINIFY_MIN_DIR', dirname(__FILE__));
+
+// 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 === stripos(PHP_OS, 'win')) {
+ Minify::setDocRoot(); // IIS may need help
+}
+
+$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) {
+ if (! empty($_COOKIE['minDebug'])) {
+ foreach (preg_split('/\\s+/', $_COOKIE['minDebug']) as $debugUri) {
+ if (false !== strpos($_SERVER['REQUEST_URI'], $debugUri)) {
+ $min_serveOptions['debug'] = true;
+ break;
+ }
+ }
+ }
+ // allow GET to override
+ if (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;
+}
+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!
+ Minify::serve('MinApp', $min_serveOptions);
+
+} elseif ($min_enableBuilder) {
+ header('Location: builder/');
+ exit();
+} else {
+ header("Location: /");
+ exit();
+}
View
1,370 public/min/lib/FirePHP.php
@@ -0,0 +1,1370 @@
+<?php
+/**
+ * *** BEGIN LICENSE BLOCK *****
+ *
+ * This file is part of FirePHP (http://www.firephp.org/).
+ *
+ * Software License Agreement (New BSD License)
+ *
+ * Copyright (c) 2006-2008, Christoph Dorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Christoph Dorn nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK *****
+ *
+ * @copyright Copyright (C) 2007-2008 Christoph Dorn
+ * @author Christoph Dorn <christoph@christophdorn.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @package FirePHP
+ */
+
+
+/**
+ * Sends the given data to the FirePHP Firefox Extension.
+ * The data can be displayed in the Firebug Console or in the
+ * "Server" request tab.
+ *
+ * For more information see: http://www.firephp.org/
+ *
+ * @copyright Copyright (C) 2007-2008 Christoph Dorn
+ * @author Christoph Dorn <christoph@christophdorn.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @package FirePHP
+ */
+class FirePHP {
+
+ /**
+ * FirePHP version
+ *
+ * @var string
+ */
+ const VERSION = '0.2.0';
+
+ /**
+ * Firebug LOG level
+ *
+ * Logs a message to firebug console.
+ *
+ * @var string
+ */
+ const LOG = 'LOG';
+
+ /**
+ * Firebug INFO level
+ *
+ * Logs a message to firebug console and displays an info icon before the message.
+ *
+ * @var string
+ */
+ const INFO = 'INFO';
+
+ /**
+ * Firebug WARN level
+ *
+ * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise.
+ *
+ * @var string
+ */
+ const WARN = 'WARN';
+
+ /**
+ * Firebug ERROR level
+ *
+ * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.
+ *
+ * @var string
+ */
+ const ERROR = 'ERROR';
+
+ /**
+ * Dumps a variable to firebug's server panel
+ *
+ * @var string
+ */
+ const DUMP = 'DUMP';
+
+ /**
+ * Displays a stack trace in firebug console
+ *
+ * @var string
+ */
+ const TRACE = 'TRACE';
+
+ /**
+ * Displays an exception in firebug console
+ *
+ * Increments the firebug error count.
+ *
+ * @var string
+ */
+ const EXCEPTION = 'EXCEPTION';
+
+ /**
+ * Displays an table in firebug console
+ *
+ * @var string
+ */
+ const TABLE = 'TABLE';
+
+ /**
+ * Starts a group in firebug console
+ *
+ * @var string
+ */
+ const GROUP_START = 'GROUP_START';
+
+ /**
+ * Ends a group in firebug console
+ *
+ * @var string
+ */
+ const GROUP_END = 'GROUP_END';
+
+ /**
+ * Singleton instance of FirePHP
+ *
+ * @var FirePHP
+ */
+ protected static $instance = null;
+
+ /**
+ * Wildfire protocol message index
+ *
+ * @var int
+ */
+ protected $messageIndex = 1;
+
+ /**
+ * Options for the library
+ *
+ * @var array
+ */
+ protected $options = array();
+
+ /**
+ * Filters used to exclude object members when encoding
+ *
+ * @var array
+ */
+ protected $objectFilters = array();
+
+ /**
+ * A stack of objects used to detect recursion during object encoding
+ *
+ * @var object
+ */
+ protected $objectStack = array();
+
+ /**
+ * Flag to enable/disable logging
+ *
+ * @var boolean
+ */
+ protected $enabled = true;
+
+ /**
+ * The object constructor
+ */
+ function __construct() {
+ $this->options['maxObjectDepth'] = 10;
+ $this->options['maxArrayDepth'] = 20;
+ $this->options['useNativeJsonEncode'] = true;
+ $this->options['includeLineNumbers'] = true;
+ }
+
+ /**
+ * When the object gets serialized only include specific object members.
+ *
+ * @return array
+ */
+ public function __sleep() {
+ return array('options','objectFilters','enabled');
+ }
+
+ /**
+ * Gets singleton instance of FirePHP
+ *
+ * @param boolean $AutoCreate
+ * @return FirePHP
+ */
+ public static function getInstance($AutoCreate=false) {
+ if($AutoCreate===true && !self::$instance) {
+ self::init();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Creates FirePHP object and stores it for singleton access
+ *
+ * @return FirePHP
+ */
+ public static function init() {
+ return self::$instance = new self();
+ }
+
+ /**
+ * Enable and disable logging to Firebug
+ *
+ * @param boolean $Enabled TRUE to enable, FALSE to disable
+ * @return void
+ */
+ public function setEnabled($Enabled) {
+ $this->enabled = $Enabled;
+ }
+
+ /**
+ * Check if logging is enabled
+ *
+ * @return boolean TRUE if enabled
+ */
+ public function getEnabled() {
+ return $this->enabled;
+ }
+
+ /**
+ * Specify a filter to be used when encoding an object
+ *
+ * Filters are used to exclude object members.
+ *
+ * @param string $Class The class name of the object
+ * @param array $Filter An array or members to exclude
+ * @return void
+ */
+ public function setObjectFilter($Class, $Filter) {
+ $this->objectFilters[$Class] = $Filter;
+ }
+
+ /**
+ * Set some options for the library
+ *
+ * Options:
+ * - maxObjectDepth: The maximum depth to traverse objects (default: 10)
+ * - maxArrayDepth: The maximum depth to traverse arrays (default: 20)
+ * - useNativeJsonEncode: If true will use json_encode() (default: true)
+ * - includeLineNumbers: If true will include line numbers and filenames (default: true)
+ *
+ * @param array $Options The options to be set
+ * @return void
+ */
+ public function setOptions($Options) {
+ $this->options = array_merge($this->options,$Options);
+ }
+
+ /**
+ * Register FirePHP as your error handler
+ *
+ * Will throw exceptions for each php error.
+ */
+ public function registerErrorHandler()
+ {
+ //NOTE: The following errors will not be caught by this error handler:
+ // E_ERROR, E_PARSE, E_CORE_ERROR,
+ // E_CORE_WARNING, E_COMPILE_ERROR,
+ // E_COMPILE_WARNING, E_STRICT
+
+ set_error_handler(array($this,'errorHandler'));
+ }
+
+ /**
+ * FirePHP's error handler
+ *
+ * Throws exception for each php error that will occur.
+ *
+ * @param int $errno
+ * @param string $errstr
+ * @param string $errfile
+ * @param int $errline
+ * @param array $errcontext
+ */
+ public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
+ {
+ // Don't throw exception if error reporting is switched off
+ if (error_reporting() == 0) {
+ return;
+ }
+ // Only throw exceptions for errors we are asking for
+ if (error_reporting() & $errno) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+ }
+ }
+
+ /**
+ * Register FirePHP as your exception handler
+ */
+ public function registerExceptionHandler()
+ {
+ set_exception_handler(array($this,'exceptionHandler'));
+ }
+
+ /**
+ * FirePHP's exception handler
+ *
+ * Logs all exceptions to your firebug console and then stops the script.
+ *
+ * @param Exception $Exception
+ * @throws Exception
+ */
+ function exceptionHandler($Exception) {
+ $this->fb($Exception);
+ }
+
+ /**
+ * Set custom processor url for FirePHP
+ *
+ * @param string $URL
+ */
+ public function setProcessorUrl($URL)
+ {
+ $this->setHeader('X-FirePHP-ProcessorURL', $URL);
+ }
+
+ /**
+ * Set custom renderer url for FirePHP
+ *
+ * @param string $URL
+ */
+ public function setRendererUrl($URL)
+ {
+ $this->setHeader('X-FirePHP-RendererURL', $URL);
+ }
+
+ /**
+ * Start a group for following messages
+ *
+ * @param string $Name
+ * @return true
+ * @throws Exception
+ */
+ public function group($Name) {
+ return $this->fb(null, $Name, FirePHP::GROUP_START);
+ }
+
+ /**
+ * Ends a group you have started before
+ *
+ * @return true
+ * @throws Exception
+ */
+ public function groupEnd() {
+ return $this->fb(null, null, FirePHP::GROUP_END);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::LOG
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function log($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::LOG);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::INFO
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function info($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::INFO);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::WARN
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function warn($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::WARN);
+ }
+
+ /**
+ * Log object with label to firebug console
+ *
+ * @see FirePHP::ERROR
+ * @param mixes $Object
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function error($Object, $Label=null) {
+ return $this->fb($Object, $Label, FirePHP::ERROR);
+ }
+
+ /**
+ * Dumps key and variable to firebug server panel
+ *
+ * @see FirePHP::DUMP
+ * @param string $Key
+ * @param mixed $Variable
+ * @return true
+ * @throws Exception
+ */
+ public function dump($Key, $Variable) {
+ return $this->fb($Variable, $Key, FirePHP::DUMP);
+ }
+
+ /**
+ * Log a trace in the firebug console
+ *
+ * @see FirePHP::TRACE
+ * @param string $Label
+ * @return true
+ * @throws Exception
+ */
+ public function trace($Label) {
+ return $this->fb($Label, FirePHP::TRACE);
+ }
+
+ /**
+ * Log a table in the firebug console
+ *
+ * @see FirePHP::TABLE
+ * @param string $Label
+ * @param string $Table
+ * @return true
+ * @throws Exception
+ */
+ public function table($Label, $Table) {
+ return $this->fb($Table, $Label, FirePHP::TABLE);
+ }
+
+ /**
+ * Check if FirePHP is installed on client
+ *
+ * @return boolean
+ */
+ public function detectClientExtension() {
+ /* Check if FirePHP is installed on client */
+ if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) ||
+ !version_compare($m[1][0],'0.0.6','>=')) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Log varible to Firebug
+ *
+ * @see http://www.firephp.org/Wiki/Reference/Fb
+ * @param mixed $Object The variable to be logged
+ * @return true Return TRUE if message was added to headers, FALSE otherwise
+ * @throws Exception
+ */
+ public function fb($Object) {
+
+ if(!$this->enabled) {
+ return false;
+ }
+
+ if (headers_sent($filename, $linenum)) {
+ throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.');
+ }
+
+ $Type = null;
+ $Label = null;
+
+ if(func_num_args()==1) {
+ } else
+ if(func_num_args()==2) {
+ switch(func_get_arg(1)) {
+ case self::LOG:
+ case self::INFO:
+ case self::WARN:
+ case self::ERROR:
+ case self::DUMP:
+ case self::TRACE:
+ case self::EXCEPTION:
+ case self::TABLE:
+ case self::GROUP_START:
+ case self::GROUP_END:
+ $Type = func_get_arg(1);
+ break;
+ default:
+ $Label = func_get_arg(1);
+ break;
+ }
+ } else
+ if(func_num_args()==3) {
+ $Type = func_get_arg(2);
+ $Label = func_get_arg(1);
+ } else {
+ throw $this->newException('Wrong number of arguments to fb() function!');
+ }
+
+
+ if(!$this->detectClientExtension()) {
+ return false;
+ }
+
+ $meta = array();
+ $skipFinalObjectEncode = false;
+
+ if($Object instanceof Exception) {
+
+ $meta['file'] = $this->_escapeTraceFile($Object->getFile());
+ $meta['line'] = $Object->getLine();
+
+ $trace = $Object->getTrace();
+ if($Object instanceof ErrorException
+ && isset($trace[0]['function'])
+ && $trace[0]['function']=='errorHandler'
+ && isset($trace[0]['class'])
+ && $trace[0]['class']=='FirePHP') {
+
+ $severity = false;
+ switch($Object->getSeverity()) {
+ case E_WARNING: $severity = 'E_WARNING'; break;
+ case E_NOTICE: $severity = 'E_NOTICE'; break;
+ case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
+ case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
+ case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
+ case E_STRICT: $severity = 'E_STRICT'; break;
+ case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
+ case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
+ case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
+ }
+
+ $Object = array('Class'=>get_class($Object),
+ 'Message'=>$severity.': '.$Object->getMessage(),
+ 'File'=>$this->_escapeTraceFile($Object->getFile()),
+ 'Line'=>$Object->getLine(),
+ 'Type'=>'trigger',
+ 'Trace'=>$this->_escapeTrace(array_splice($trace,2)));
+ $skipFinalObjectEncode = true;
+ } else {
+ $Object = array('Class'=>get_class($Object),
+ 'Message'=>$Object->getMessage(),
+ 'File'=>$this->_escapeTraceFile($Object->getFile()),
+ 'Line'=>$Object->getLine(),
+ 'Type'=>'throw',
+ 'Trace'=>$this->_escapeTrace($trace));
+ $skipFinalObjectEncode = true;
+ }
+ $Type = self::EXCEPTION;
+
+ } else
+ if($Type==self::TRACE) {
+
+ $trace = debug_backtrace();
+ if(!$trace) return false;
+ for( $i=0 ; $i<sizeof($trace) ; $i++ ) {
+
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i]['file'])
+ && ($trace[$i]['class']=='FirePHP'
+ || $trace[$i]['class']=='FB')
+ && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
+ || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
+ /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
+ } else
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i+1]['file'])
+ && $trace[$i]['class']=='FirePHP'
+ && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip fb() */
+ } else
+ if($trace[$i]['function']=='fb'
+ || $trace[$i]['function']=='trace'
+ || $trace[$i]['function']=='send') {
+ $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'',
+ 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'',
+ 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'',
+ 'Message'=>$trace[$i]['args'][0],
+ 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'',
+ 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'',
+ 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'',
+ 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1)));
+
+ $skipFinalObjectEncode = true;
+ $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
+ $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
+ break;
+ }
+ }
+
+ } else
+ if($Type==self::TABLE) {
+
+ if(isset($Object[0]) && is_string($Object[0])) {
+ $Object[1] = $this->encodeTable($Object[1]);
+ } else {
+ $Object = $this->encodeTable($Object);
+ }
+
+ $skipFinalObjectEncode = true;
+
+ } else {
+ if($Type===null) {
+ $Type = self::LOG;
+ }
+ }
+
+ if($this->options['includeLineNumbers']) {
+ if(!isset($meta['file']) || !isset($meta['line'])) {
+
+ $trace = debug_backtrace();
+ for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) {
+
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i]['file'])
+ && ($trace[$i]['class']=='FirePHP'
+ || $trace[$i]['class']=='FB')
+ && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
+ || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
+ /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
+ } else
+ if(isset($trace[$i]['class'])
+ && isset($trace[$i+1]['file'])
+ && $trace[$i]['class']=='FirePHP'
+ && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip fb() */
+ } else
+ if(isset($trace[$i]['file'])
+ && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') {
+ /* Skip FB::fb() */
+ } else {
+ $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
+ $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
+ break;
+ }
+ }
+
+ }
+ } else {
+ unset($meta['file']);
+ unset($meta['line']);
+ }
+
+ $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
+ $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION);
+
+ $structure_index = 1;
+ if($Type==self::DUMP) {
+ $structure_index = 2;
+ $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
+ } else {
+ $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
+ }
+
+ if($Type==self::DUMP) {
+ $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}';
+ } else {
+ $msg_meta = array('Type'=>$Type);
+ if($Label!==null) {
+ $msg_meta['Label'] = $Label;
+ }
+ if(isset($meta['file'])) {
+ $msg_meta['File'] = $meta['file'];
+ }
+ if(isset($meta['line'])) {
+ $msg_meta['Line'] = $meta['line'];
+ }
+ $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']';
+ }
+
+ $parts = explode("\n",chunk_split($msg, 5000, "\n"));
+
+ for( $i=0 ; $i<count($parts) ; $i++) {
+
+ $part = $parts[$i];
+ if ($part) {
+
+ if(count($parts)>2) {
+ // Message needs to be split into multiple parts
+ $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
+ (($i==0)?strlen($msg):'')
+ . '|' . $part . '|'
+ . (($i<count($parts)-2)?'\\':''));
+ } else {
+ $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
+ strlen($part) . '|' . $part . '|');
+ }
+
+ $this->messageIndex++;
+
+ if ($this->messageIndex > 99999) {
+ throw new Exception('Maximum number (99,999) of messages reached!');
+ }
+ }
+ }
+
+ $this->setHeader('X-Wf-1-Index',$this->messageIndex-1);
+
+ return true;
+ }
+
+ /**
+ * Standardizes path for windows systems.
+ *
+ * @param string $Path
+ * @return string
+ */
+ protected function _standardizePath($Path) {
+ return preg_replace('/\\\\+/','/',$Path);
+ }
+
+ /**
+ * Escape trace path for windows systems
+ *
+ * @param array $Trace
+ * @return array
+ */
+ protected function _escapeTrace($Trace) {
+ if(!$Trace) return $Trace;
+ for( $i=0 ; $i<sizeof($Trace) ; $i++ ) {
+ if(isset($Trace[$i]['file'])) {
+ $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']);
+ }
+ if(isset($Trace[$i]['args'])) {
+ $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']);
+ }
+ }
+ return $Trace;
+ }
+
+ /**
+ * Escape file information of trace for windows systems
+ *
+ * @param string $File
+ * @return string
+ */
+ protected function _escapeTraceFile($File) {
+ /* Check if we have a windows filepath */
+ if(strpos($File,'\\')) {
+ /* First strip down to single \ */
+
+ $file = preg_replace('/\\\\+/','\\',$File);
+
+ return $file;
+ }
+ return $File;
+ }
+
+ /**
+ * Send header
+ *
+ * @param string $Name
+ * @param string_type $Value
+ */
+ protected function setHeader($Name, $Value) {
+ return header($Name.': '.$Value);
+ }
+
+ /**
+ * Get user agent
+ *
+ * @return string|false
+ */
+ protected function getUserAgent() {
+ if(!isset($_SERVER['HTTP_USER_AGENT'])) return false;
+ return $_SERVER['HTTP_USER_AGENT'];
+ }
+
+ /**
+ * Returns a new exception
+ *
+ * @param string $Message
+ * @return Exception
+ */
+ protected function newException($Message) {
+ return new Exception($Message);
+ }
+
+ /**
+ * Encode an object into a JSON string
+ *
+ * Uses PHP's jeson_encode() if available
+ *
+ * @param object $Object The object to be encoded
+ * @return string The JSON string
+ */
+ protected function jsonEncode($Object, $skipObjectEncode=false)
+ {
+ if(!$skipObjectEncode) {
+ $Object = $this->encodeObject($Object);
+ }
+
+ if(function_exists('json_encode')
+ && $this->options['useNativeJsonEncode']!=false) {
+
+ return json_encode($Object);
+ } else {
+ return $this->json_encode($Object);
+ }
+ }
+
+ /**
+ * Encodes a table by encoding each row and column with encodeObject()
+ *
+ * @param array $Table The table to be encoded
+ * @return array
+ */
+ protected function encodeTable($Table) {
+ if(!$Table) return $Table;
+ for( $i=0 ; $i<count($Table) ; $i++ ) {
+ if(is_array($Table[$i])) {
+ for( $j=0 ; $j<count($Table[$i]) ; $j++ ) {
+ $Table[$i][$j] = $this->encodeObject($Table[$i][$j]);
+ }
+ }
+ }
+ return $Table;
+ }
+
+ /**
+ * Encodes an object including members with
+ * protected and private visibility
+ *
+ * @param Object $Object The object to be encoded
+ * @param int $Depth The current traversal depth
+ * @return array All members of the object
+ */
+ protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1)
+ {
+ $return = array();
+
+ if (is_object($Object)) {
+
+ if ($ObjectDepth > $this->options['maxObjectDepth']) {
+ return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **';
+ }
+
+ foreach ($this->objectStack as $refVal) {
+ if ($refVal === $Object) {
+ return '** Recursion ('.get_class($Object).') **';
+ }
+ }
+ array_push($this->objectStack, $Object);
+
+ $return['__className'] = $class = get_class($Object);
+
+ $reflectionClass = new ReflectionClass($class);
+ $properties = array();
+ foreach( $reflectionClass->getProperties() as $property) {
+ $properties[$property->getName()] = $property;
+ }
+
+ $members = (array)$Object;
+
+ foreach( $properties as $raw_name => $property ) {
+
+ $name = $raw_name;
+ if($property->isStatic()) {
+ $name = 'static:'.$name;
+ }
+ if($property->isPublic()) {
+ $name = 'public:'.$name;
+ } else
+ if($property->isPrivate()) {
+ $name = 'private:'.$name;
+ $raw_name = "\0".$class."\0".$raw_name;
+ } else
+ if($property->isProtected()) {
+ $name = 'protected:'.$name;
+ $raw_name = "\0".'*'."\0".$raw_name;
+ }
+
+ if(!(isset($this->objectFilters[$class])
+ && is_array($this->objectFilters[$class])
+ && in_array($raw_name,$this->objectFilters[$class]))) {
+
+ if(array_key_exists($raw_name,$members)
+ && !$property->isStatic()) {
+
+ $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1);
+
+ } else {
+ if(method_exists($property,'setAccessible')) {
+ $property->setAccessible(true);
+ $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1);
+ } else
+ if($property->isPublic()) {
+ $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1);
+ } else {
+ $return[$name] = '** Need PHP 5.3 to get value **';
+ }
+ }
+ } else {
+ $return[$name] = '** Excluded by Filter **';
+ }
+ }
+
+ // Include all members that are not defined in the class
+ // but exist in the object
+ foreach( $members as $raw_name => $value ) {
+
+ $name = $raw_name;
+
+ if ($name{0} == "\0") {
+ $parts = explode("\0", $name);
+ $name = $parts[2];
+ }
+
+ if(!isset($properties[$name])) {
+ $name = 'undeclared:'.$name;
+
+ if(!(isset($this->objectFilters[$class])
+ && is_array($this->objectFilters[$class])
+ && in_array($raw_name,$this->objectFilters[$class]))) {
+
+ $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1);
+ } else {
+ $return[$name] = '** Excluded by Filter **';
+ }
+ }
+ }
+
+ array_pop($this->objectStack);
+
+ } elseif (is_array($Object)) {
+
+ if ($ArrayDepth > $this->options['maxArrayDepth']) {
+ return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **';
+ }
+
+ foreach ($Object as $key => $val) {
+
+ // Encoding the $GLOBALS PHP array causes an infinite loop
+ // if the recursion is not reset here as it contains
+ // a reference to itself. This is the only way I have come up
+ // with to stop infinite recursion in this case.
+ if($key=='GLOBALS'
+ && is_array($val)
+ && array_key_exists('GLOBALS',$val)) {
+ $val['GLOBALS'] = '** Recursion (GLOBALS) **';
+ }
+
+ $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1);
+ }
+ } else {
+ if(self::is_utf8($Object)) {
+ return $Object;
+ } else {
+ return utf8_encode($Object);
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Returns true if $string is valid UTF-8 and false otherwise.
+ *
+ * @param mixed $str String to be tested
+ * @return boolean
+ */
+ protected static function is_utf8($str) {
+ $c=0; $b=0;
+ $bits=0;
+ $len=strlen($str);
+ for($i=0; $i<$len; $i++){
+ $c=ord($str[$i]);
+ if($c > 128){
+ if(($c >= 254)) return false;
+ elseif($c >= 252) $bits=6;
+ elseif($c >= 248) $bits=5;
+ elseif($c >= 240) $bits=4;
+ elseif($c >= 224) $bits=3;
+ elseif($c >= 192) $bits=2;
+ else return false;
+ if(($i+$bits) > $len) return false;
+ while($bits > 1){
+ $i++;
+ $b=ord($str[$i]);
+ if($b < 128 || $b > 191) return false;
+ $bits--;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Converts to and from JSON format.
+ *
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
+ * format. It is easy for humans to read and write. It is easy for machines
+ * to parse and generate. It is based on a subset of the JavaScript
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
+ * This feature can