<?php /** * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) * Copyright (C) 2002-2004 The Nucleus Group * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * (see nucleus/documentation/index.html#license for more info) * * NP_GZip is a plugin which compresses the pages that Nucleus sends to * the client using GZip compression, saving bandwidth. * * Revision History: * 2.1 Yaroslav 'MOSSs' Sotnikov * - Plugin now works with latest Nucleus version (ie: 3.22) * Test your page Gzip status here: http://www.desilva.biz/gzip-test.php * * 2.0 Wouter Demuynck (2003-12-28) * - Added ob_end_flush call on PostSkinParse event * - Only starting obgzhandler when no output buffering is active * (fixes problems with xml-rss*.php) * 1.0 Wouter Demuynck * - Initial implementation * */ class NP_GZip extends NucleusPlugin { function supportsFeature($name) { switch($name) { case 'SqlTablePrefix': return true; } return false; } function getMinNucleusVersion() { return 155; } // name of plugin function getName() { return 'gzip encoding'; } // author of plugin function getAuthor() { return 'Wouter Demuynck'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL() { return 'http://nucleuscms.org/'; } // version of the plugin function getVersion() { return '2.1'; } // a description to be shown on the installed plugins listing function getDescription() { return 'Compresses the pages generated by Nucleus using gzip compression, if the requesting browser accepts this. This saves bandwidth. Works with latest Nuleus version (MOSSs)!'; } function getEventList() { return array('PreSkinParse', 'PostSkinParse'); } function init() { $this->obStarted = 0; } function event_PreSkinParse(&$data) { $bStart = 1; // don't start output buffering if we're not at the top level // (fixes problems with RSS feeds & ETAG) if (function_exists('ob_get_level') && (ob_get_level() > 0)) $bStart = 0; if ($bStart) $this->obStarted = ob_start("ob_gzhandler"); } function event_PostSkinParse(&$data) { if ($this->obStarted) ob_end_flush(); } } ?>