<?php

$pg_d = 10;

$pg_c = B < 1 ? 1 : B;
$pg_s = $pg_d * ($pg_c - 1);
$arr = array();
$where = array();
$where[] = 'menu_id="' . MID . '"';
$wherestr = implode(' && ', $where);
$rs = $db->query('select * from (' . PF . 'article as article left join ' . PF .
    'posts as post on article.menu_id=' . MID .
    ' && article.post_id=post.id) left join ' . PF .
    'user as user on post.authorid=user.id where ' . $wherestr .
    ' order by article.post_time desc LIMIT ' . $pg_s . ',' . $pg_d);
while ($row = $db->fetch_array($rs))
{
    $id = $row['post_id'];
    $arr[$id] = $row;
    $arr[$id]['title'] = htmlxlang(unserialize($row['title']));

    $arr[$id]['post_time'] = date('m-d', $row['post_time']);
    $arr[$id]['authorid'] = $row['authorid'];
    $arr[$id]['name'] = htmlspecialchars($row['name']);
    $arr[$id]['doc'] = html(xstr(xlang(unserialize($row['doc'])), 200));
    $arr[$id]['comment'] = $row['comment'];
}
$rs = $db->query('select count(*) as pg_m from (' . PF .
    'article as article left join ' . PF . 'posts as post on article.menu_id=' . MID .
    ' && article.post_id=post.id) left join ' . PF .
    'user as user on post.authorid=user.id where ' . $wherestr);
$row = $db->fetch_array($rs);
$page = page(RPGM . MID . '/(*)/', $pg_c, $row['pg_m'], $pg_d);
arg($arr, $page);
apply('sidebar', 'tag()', 10, 'article', 'sidebar_menu');
if (isset($conf['sys_pmenus_sub'][MID]) || $conf['sys_menus'][MID]['pid'])
{
    setval('tplfile', array('list', $conf['sys_menus'][MID]['tplpf']));
} else
{
    setval('tplfile', array('list', $conf['sys_menus'][MID]['tplpf']));
}
apply('sidebar', 'tag()', 0, 'article', 'sidebar_hot');

?>