33 lines
995 B
PHP
Executable File
33 lines
995 B
PHP
Executable File
<?php
|
|
//echo $_GET['id'];
|
|
//604800 - неделя
|
|
|
|
ini_set('memory_limit', '512M');
|
|
header( 'Content-Type: text/xml' );
|
|
header("Cache-Control: public");
|
|
header("Expires: " . date("r", time() + 604800));
|
|
ini_set( 'display_errors', 0 );
|
|
$smarty -> caching = true;
|
|
$smarty -> cache_lifetime = 604800;
|
|
$data=date( "Y-m-d" );
|
|
$smarty -> assign( 'data', $data );
|
|
|
|
$cache = '/tmp/cache/' . $_SERVER['SERVER_NAME'] . '/sitemap.json';
|
|
if (file_exists($cache)) {
|
|
$text = file_get_contents($cache);
|
|
$link = \core::j(\core::unzip($text));
|
|
//Чистим кеш через пять дней
|
|
$r = time() - filemtime($cache);
|
|
if ($r > 432000)
|
|
unlink($cache);
|
|
} else {
|
|
$link= \DBmysql::getAll( 'SELECT `link`, `t` FROM `sitemap` WHERE `status`=1 AND `site`=?', $_SERVER['SERVER_NAME']);
|
|
$j = \core::j($link);
|
|
$a = \core::zip($j);
|
|
if (strlen($a)>16) file_put_contents($cache, $a);
|
|
}
|
|
|
|
$smarty -> assign( 'link', $link );
|
|
|
|
|
|
?>
|