function editPost(&$loq, $postid = null)
{
    if (is_null($postid) || $postid === 0) {
        return;
    }
    $epost = $loq->_ph->get_post($postid, true);
    $loq->assign('title_text', htmlspecialchars($epost['title']));
    $loq->assign('body_text', htmlspecialchars($epost['body']));
    $loq->assign('selected_modifier', $epost['modifier']);
    $loq->assign('editpost', TRUE);
    $loq->assign('showarchives', 'no');
    $loq->assign('postid', $postid);
    $loq->assign('timestampform', timestampform($epost['posttime']));
    // to hide a post from the homepage
    if ($epost['hidefromhome'] == 1) {
        $loq->assign('hidefromhomevalue', " checked ");
    }
    // to disable comments either now or in the future
    if ($epost['allowcomments'] == 'timed') {
        $loq->assign('commentstimedvalue', "checked");
    } elseif ($epost['allowcomments'] == 'disallow') {
        $loq->assign('commentsdisallowvalue', "checked");
    } else {
        $loq->assign('commentsallowvalue', "checked");
    }
    $sects = $loq->sections;
    $editpostsections = array();
    $_post_sects = strlen($epost['sections']) > 1 ? explode(":", $epost['sections']) : array($epost['sections']);
    foreach ($sects as $id => $sect) {
        if (in_array($id, $_post_sects)) {
            $sect['checked'] = true;
            $sects[$id] = $sect;
        }
    }
    $loq->assign("sections", $sects);
    if ($epost['status'] == 'draft') {
        $loq->assign('statusdraft', 'checked');
    } else {
        $loq->assign('statuslive', 'checked');
    }
    defaultDisplay($loq);
}
        $bBlog->smartyObj->assign('showmessage', TRUE);
        $bBlog->smartyObj->assign('message_title', 'Are you sure you want to delete it?');
        $bBlog->smartyObj->assign('message_content', "\n            <form action='index.php' method='POST'>\n            <input type='hidden' name='b' value='archives'/>\n            <input type='hidden' name='confirm' value='cd" . $_POST['delete'] . "'/>\n            <input type='hidden' name='delete' value='" . $_POST['delete'] . "'/>\n            <center><input type='submit' class='bf' name='submit' value='Delete it'/></center>\n            </form>\n        ");
    }
}
if (isset($_POST['edit']) && is_numeric($_POST['edit'])) {
    $epost = $bBlog->get_post($_POST['edit'], TRUE, TRUE);
    $bBlog->smartyObj->assign('title_text', htmlspecialchars($epost->title));
    $bBlog->smartyObj->assign('pagename', htmlspecialchars($epost->pagename));
    $bBlog->smartyObj->assign('body_text', htmlspecialchars($epost->body));
    $bBlog->smartyObj->assign('fancyurl', htmlspecialchars($epost->fancyurl));
    $bBlog->smartyObj->assign('selected_modifier', $epost->modifier);
    $bBlog->smartyObj->assign('editpost', TRUE);
    $bBlog->smartyObj->assign('showarchives', 'no');
    $bBlog->smartyObj->assign('postid', $_POST['edit']);
    $bBlog->smartyObj->assign('timestampform', timestampform($epost->posttime));
    $bBlog->smartyObj->assign('wysiwyg', C_WYSIWYG);
    $bBlog->smartyObj->assign('fancy', C_FANCYURL);
    // to hide a post from the homepage
    if ($epost->hidefromhome == 1) {
        $bBlog->smartyObj->assign('hidefromhomevalue', " checked='checked' ");
    }
    // to disable comments either now or in the future
    if ($epost->allowcomments == 'timed') {
        $bBlog->smartyObj->assign('commentstimedvalue', " checked='checked' ");
    } elseif ($epost->allowcomments == 'disallow') {
        $bBlog->smartyObj->assign('commentsdisallowvalue', " checked='checked' ");
    } else {
        $bBlog->smartyObj->assign('commentsallowvalue', " checked='checked' ");
    }
    if ($epost->status == 'draft') {