function smarty_function_getcomments($params, &$bBlog)
{
    $assign = "comments";
    $postid = $bBlog->show_post;
    $replyto = $_REQUEST['replyto'];
    if ($postid > 0) {
        $ch = $bBlog->get_comment_handler($postid);
    } else {
        $ch = $bBlog->get_comment_handler($_REQUEST['postid']);
    }
    prep_form(&$bBlog, $postid, $_REQUEST['replyto']);
    // are we posting a comment ?
    if ($_POST['do'] == 'submitcomment' && is_numeric($_POST['comment_postid'])) {
        // we are indeed!
        if (is_numeric($_POST['replytos'])) {
            $rt = $_POST['replytos'];
        } else {
            $rt = false;
        }
        $ch->new_comment($bBlog->_ph->get_post($_POST['comment_postid'], false, true), $rt, $_POST);
    }
    // get the comments.
    /* start loop and get posts*/
    $rt = false;
    if (is_numeric($_GET['replyto'])) {
        $rt = $_GET['replyto'];
        $cs = $ch->get_comment($_REQUEST['postid'], $rt);
    } else {
        $cs = $ch->get_comments(true);
    }
    /* assign loop variable */
    $bBlog->assign($assign, $cs);
}
function smarty_function_getcomments($params, &$loq)
{
    $assign = "comments";
    $postid = $loq->show_post;
    $replyto = null;
    $comment = null;
    if (isset($_POST['replyto']) && ctype_digit($_POST['replyto'])) {
        $replyto = intval($_POST['replyto']);
    }
    $ch = $loq->get_comment_handler();
    if (isset($_POST['do']) && $_POST['do'] == 'submitcomment' && ctype_digit($_POST['comment_postid'])) {
        if ($ch->new_comment($loq->_ph->get_post($_POST['comment_postid']), $replyto, $_POST) === FALSE) {
            $loq->assign('message', $ch->errors('html'));
        }
    }
    if (isset($_GET['replyto']) && ctype_digit($_GET['replyto'])) {
        $replyto = intval($_GET['replyto']);
        $comment = $ch->getComment($replyto, 'html');
        $comment = $comment[0]['body'];
    }
    $comments = $ch->getComments($postid, 'html', 'thread');
    prep_form($loq, $postid, $replyto, $comment);
    $loq->assign($assign, $comments);
}