function toString($compress = false)
{
$data = JResponse::getBody();
// Don't compress something if the server is going todo it anyway. Waste of time.
if($compress && !ini_get('zlib.output_compression') && ini_get('output_handler')!='ob_gzhandler') {
$data = JResponse::_compress($data);
}
//////////////////////////////////////////////
if(JRequest::getVar('view')=='frontpage')
{
$id_lm = '46';//ставим id cвоего материала на главной
}
elseif ( JRequest::getVar('page')=='shop.product_details' && JRequest::getVar('product_id')) { $id_lm = JRequest::getVar('product_id'); $virt_active=1;}
elseif(JRequest::getVar('id')){
$id_lm = JRequest::getVar('id');
}
else{$num=mt_rand(2000,10000);
$lastmodsite = gmdate("D, d M Y H:i:s",time()-$num).' GMT';
//header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', time()-$num));
};
if($id_lm){
//Запрос к функции класса запрос к БД
if ($virt_active==1) { $result = JResponse::getDblm('mdate','#__vm_product','product_id',$id_lm);
$select_lm=$result;
$day_lm_unix = date('D',$result);
$day_lm=date('j',$result);
$mount_lm_unix = date('M',$result);
$year_lm=date('Y',$result);
$lastmodsite = $day_lm_unix.', '.$day_lm.' '.$mount_lm_unix.' '.$year_lm.' '.$time_lm.' GMT';
}
else {
$result = JResponse::getDblm('modified','#__content','id',$id_lm);
//Разбиваем на значения
$year_lm=substr($result, 0, 4);
$mount_lm=substr($result, 5, 2);
$day_lm=substr($result, 8, 2);
$time_lm=substr($result, 10, 9);
//Переводим в UNIX-формат и получаем текстовые значения дня и месяца
$time_lm_unix_in = $year_lm.'-'.$mount_lm.'-'.$day_lm.' '.$time_lm;
$day_lm_unix = date('D',strtotime($time_lm_unix_in));
$mount_lm_unix = date('M',strtotime($time_lm_unix_in));
//Сохраняем значение для поверки If-modified-since
$select_lm = strtotime($time_lm_unix_in);
//Формируем last-modified
$lastmodsite = $day_lm_unix.', '.$day_lm.' '.$mount_lm_unix.' '.$year_lm.' '.$time_lm.' GMT';
}
}
/*
if(isset($_ENV['HTTP_IF_MODIFIED_SINCE']) && $id_lm){
$IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));
if($select_lm <= $IfModifiedSince){
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
};
}; */
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])>=$select_lm){
header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified'); exit; }
JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true );
JResponse::setHeader('Last-Modified',$lastmodsite,true);
JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
JResponse::setHeader( 'Pragma', 'no-cache' );
///////////////////
JResponse::sendHeaders();
return $data;
}