} $aPosts = array(); while ($row = mysql_fetch_assoc($sql)) { $aPosts[] = $row; } foreach ($aPosts as $v) { $tplItem = $tplRSS->fetchBlock('item'); $tplItem->assign('site', HOST); $tplItem->assign('id', $v['id']); $tplItem->assign('title', $v['title']); $tplItem->assign('text', normalize($v['text'])); $tplItem->assign('date', formatDate($v['t'])); $tplRSS->assign('item', $tplItem); $tplItem->reset(); } $a = $aPosts[0]; $tplRSS->assign('last_build_date', formatDate($a['t'])); $tplRSS->out(); exit; function formatDate($p) { $year = substr($p, 0, 4); $month = substr($p, 5, 2); $day = substr($p, 8, 2); $hour = substr($p, 11, 2); $min = substr($p, 14, 2); $sec = substr($p, 17, 2); $r = mktime($hour, $min, $sec, $month, $day, $year); $r = gmdate('D, d M Y H:i:s +0400', $r); return $r; }