//новый код будет создавать файл кеша с ид данной новости
if ($confn['assoc']) {
//проверяем если кеш есть то берем из кеша
if(file_exists("config/cache/newsrelated".$id.".tmp")){
$cont .= file_get_contents("config/cache/newsrelated".$id.".tmp");
}
//если нет то создаем фал кеша с ид данной новости
else{
if ($associated[strlen($associated)-1] == "-") $associated = substr($associated, 0, -1);
$asso = str_replace("-", ",", $associated);
$limit = intval($confn['asocnum']);
list($count) = $db->sql_fetchrow($db->sql_query("SELECT Count(sid) FROM ".$prefix."_news WHERE catid IN (".$asso.") AND sid!='".$id."' AND time<=now() AND status!='0'"));
if ($count >= $limit) {
$random = mt_rand(0, $count - $limit);
$result = $db->sql_query("SELECT sid, title, time FROM ".$prefix."_news WHERE catid IN (".$asso.") AND sid!='".$id."' AND time<=now() AND status!='0' ORDER BY time DESC LIMIT ".$random.", ".$limit);
$cont .= tpl_eval("open");
$cont .= "<h2>"._ASSTORY."</h2>"
."<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"hover\">";
while(list($s_sid, $title, $time) = $db->sql_fetchrow($result)) {
$cont .= "<tr><td><a href=\"index.php?name=".$conf['name']."&op=view&id=".$s_sid."\" title=\"".$title."\"><img src=\"".img_find("all/news.png")."\" border=\"0\"></a></td><td width=\"98%\"><a href=\"index.php?name=".$conf['name']."&op=view&id=".$s_sid."\" title=\"".$title."\">".$title."</a></td></tr>";
}
$cont .= "</table>";
$cont .= tpl_eval("close");
}
//записываем кеш
$fp = fopen("config/cache/newsrelated".$id.".tmp", "wb");fwrite($fp,$cont);fclose($fp);
}
}