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 ); ?>