Location: PHPKode > projects > pkZoos Website > includes/compression.php
<?php
	if(!defined('PK_MAGIC'))
		die('hack or what?');





	/* */

	$compression_mode = '';





	/* */

	function compression_begin()
	{
		global $config;
		global $compression_mode;

        if($config['compression_gzip'])
        {
            if(strpos($_SERVER['HTTP_USER_AGENT'], 'compatible') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false)
            {
                if(@extension_loaded('zlib'))
                {
                	$compression_mode = 'gzip';

                	@ini_set('zlib.output_compression_level', $config['compression_gzip_level']);
                	ob_start('ob_gzhandler');
                }
            }
        }

        if($config['compression_simple'] && $compression_mode == '')
        {
        	ob_start();
           	$compression_mode = 'simple';
        }
	}





	/* */

	function compression_end()
	{
		global $config;
		global $compression_mode;

		if($compression_mode == 'simple')
		{
			$buffer = ob_get_contents();
			ob_end_clean();

			$buffer = str_replace("\r", '', $buffer);
			$buffer = str_replace("\n", '', $buffer);
			$buffer = str_replace("\t", '', $buffer);

			$buffer = preg_replace('#\s\s+#', ' ', $buffer);

			echo $buffer;
		}
	}
?>
Return current item: pkZoos Website