Обсудить на форуме"; } block($post['title'],$body, true); foot(); } elseif(!empty($_GET['cat'])) { if (isset($_GET['page'])) { $page = intval($_GET['page']); } else { $page = 1; } if ($page > 0) $page -= 1; $start = $page * 10; $cat=intval($_GET['cat']); $r=db_query("SELECT name, urlname, reverse FROM categories WHERE id=$cat", __FILE__, __LINE__); if(mysql_num_rows($r)==0) { e404(); } list($category, $url, $reverse)=mysql_fetch_row($r); $context['title']=$category; if($reverse == 1) { $order = "ASC"; } else { $order = "DESC"; } $r=db_query("SELECT id, title, ID_MSG, ID_TOPIC, ID_MEMBER, posterName, brief, timestamp FROM publications INNER JOIN smf_messages ON publications.id_post=smf_messages.ID_MSG WHERE id_category=$cat ORDER BY timestamp $order LIMIT $start, 10", __FILE__, __LINE__); if(mysql_num_rows($r)==0) { e404(); } list($total_rows) = mysql_fetch_row( mysql_query("SELECT COUNT(*) FROM publications INNER JOIN smf_messages ON publications.id_post=smf_messages.ID_MSG WHERE id_category=$cat") ); $total_pages = ceil($total_rows/10); $txt=""; while($post=mysql_fetch_assoc($r)) { parsecode($post['brief']); $txt.='

'.$post['title'].'

добавил '.$post['posterName'].' '.date("d.m.Y H:i", $post['timestamp']).'

'.$post['brief'].'

'; } $txt .= pager($page+1, $total_pages, $url); head(); block($category,$txt); foot(); } else { e404(); } function pager($page, $page_count, $url){ if($page_count<2) return; $output = '
'; $limit = $page_count; //echo '
'; if(!empty($page)){ $limit = $page+5; if($limit>=$page_count) $limit = $page_count; $i = $page-5; if($page <= 6) $limit = 11; if($page >= $page_count-5) $i = $page_count - 11; if($page_count <= 10) $limit = $page_count; }else{ $page = $limit; if($page >= $page_count-6) $limit = $page_count - 11; } /*if($show_label){ ?>Pages ( total):
<< '; } if($i<1) $i=1; do{ if($i > $page_count) break; if($page == $i){ $output .= "$i "; }else{ $output .= ''.$i.' '; } }while(++$i < $limit+1); echo " "; if($page != $page_count){ $page_go = $page + 1; $output .= '>>'; } $output .= '
'; return $output; }