예제 #1
0
function lastPage($threadid, $ppp)
{
    global $debug;
    $count = numPostsInThread($threadid);
    $debug->add('board', 'posts in thread ' . $threadid . ': ' . $count);
    $page = floor(($count - 1) / $ppp) + 1;
    return $page;
}
예제 #2
0
     $postid = postAdd($threadid, $_POST['post'], @$_POST['attachments']);
     redirect(makeURL('board', array('boardid' => $boardid, 'threadid' => $threadid, 'page' => lastPage($threadid, $config->get('board', 'posts-per-page'))), 'post' . $postid));
 }
 @($quoteid = (int) $_GET['quoteid']);
 if ($quoteid > 0) {
     $q = getQuote($quoteid);
     $u = $user->getUserByID($q['userid']);
     $a = str_replace("%u", $u['nickname'], $lang->get('quote_by'));
     $quote = '[quote][i][url="' . makeURL('profile', array('userid' => $q['userid'])) . '"]' . $a . "[/url][/i]\n" . $q['post'] . "[/quote]";
     $smarty->assign('quote', $quote);
 } else {
     $smarty->assign('quote', '');
 }
 // Pages
 $ppp = $config->get('board', 'posts-per-page');
 @$pages->setValues($_GET['page'], $ppp, numPostsInThread($threadid));
 $smarty->assign('pages', $pages->get('board', array('boardid' => $boardid, 'threadid' => $threadid)));
 $smarty->assign('path', $template_dir . "/thread.tpl");
 $smarty->assign('board', $board);
 $smarty->assign('thread', $thread);
 @($pl = postList($threadid, $_GET['page']));
 $smarty->assign('pl', $pl);
 $smarty->assign('number', $pl[count($pl) - 1]['number'] + 1);
 // if user is logged in, it is the last page and thread is not closed, show answer field
 $debug->add('board', 'lastpage: ' . $pages->lastPage() . ' page: ' . $pages->thisPage());
 if ($login->currentUser() !== false && $thread['closed'] == 0 && $pages->lastPage() == $pages->thisPage() && $mode != 'thread_add') {
     $smarty->assign('showadd', true);
     $u = $login->currentUser();
     $u['avatar'] = $avatar->makeAvatar($u['avatar']);
     $smarty->assign('me', $u);
     $smarty->assign('attach_file_button', uploadButton('media/attachments/', 'attachments', $lang->get('attach_file'), true));