Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
loadLanguage();
}
function onAfterRender()
{
$db= JFactory::getDBO();
$app =JFactory::getApplication();
$doc = JFactory::getDocument();
$jinput = JFactory::getApplication()->input;
//получение языка
$lang=JFactory::getLanguage();
$lang=$lang->getTag();
$lang = substr($lang,0,2);
if ($lang<>'ru') return false;
// проверка, что мы не в административной панели
if ($app->getName()!= 'site') {
return true;
}
// получаем текст сформированной страницы
$buffer = JResponse::getBody();
$server = "http://".$_SERVER['SERVER_NAME'];
$thisurl = $_SERVER['REQUEST_URI'];
$xml_path=$_SERVER['DOCUMENT_ROOT'].'/sitemap.xml';
$stop=array();
$stop=explode("\r\n",$this->params->get('stoplist'));
//Удаление записей старше 1 года
$db->setQuery( "DELETE FROM #__sitemap where date < DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)" )->Execute();
$n=array();
preg_match_all("~".'href=\"'."(.*?)".'\"'."~is", $buffer, $n);
$n=$n[1];
$n = array_unique($n);
foreach($n as $link)
{
$status=2;
$url=$link;
$ulr=str_replace($server,"",$url);
if (substr($url,0,7)<>"http://" and $url[0]<>'/') $url='/'.$url;
$ulr=str_replace("index.php","",$url);
if (stripos($url,"option=com_zoo")!==false and stripos($url,"Itemid=")==false) $status=1;
foreach ($stop as $str)
{
if (stripos($url,$str)!==false) $status=1;
}
$url=str_replace(array("&","'",""",">","&;"),array("&","'",'"',">","<"),$url);
$db->setQuery(
"INSERT INTO #__sitemap (link,source,status,date) VALUES (\"{$url}\",\"{$thisurl}\",\"{$status}\", NOW())
ON DUPLICATE KEY UPDATE source=\"{$thisurl}\", status= \"{$status}\", date=NOW() ;"
)->Execute();
}
//обновление файла раз в неделю
if (file_exists($xml_path))
{
if (date("Y-m-d H:i:s",strtotime("+7 day", filemtime($xml_path))) > date("Y-m-d H:i:s")) return false;
}
$m=array();
$m[] = "";
$m[] = "";
$list = $db->setQuery("SELECT link, date FROM #__sitemap where status=2")->loadAssocList();
foreach ($list as $link)
{
$link['link']=str_replace(array("&","'",'"',">","<"),array("&","'",""",">","&;"),$link['link']);
$m[] = "";
$m[] = "\t{$server}{$link['link']}";
$m[] = "\t{$link['date']}";
$m[] = "\tweekly";
$m[] = "\t0.5";
$m[] = "";
}
$m[] = "";
file_put_contents($xml_path, implode("\r\n",$m));
}
}