Пример #1
0
    indexRSS();
    //redirect to newley created thread
    header('Location: ' . FORUM_URL . url(PATH_URL, $file), true, 303);
    exit;
}
/* ======================================================================================================================
   template the page
   ====================================================================================================================== */
//first load the list of threads in the forum so that we can determine the number of pages and validate the page number,
//the thread list won't be used until further down after templating begins
if ($threads = preg_grep('/\\.rss$/', scandir('.'))) {
    //sort the list of threads in the forum
    array_multisort(array_map(FORUM_LOCK == 'news' ? 'filectime' : 'filemtime', $threads), SORT_DESC, $threads);
    //get sticky list (see 'lib/functions.php')
    //(the use of `array_intersect` will only return filenames in `sticky.txt` that were also in the directory)
    $stickies = array_intersect(getStickies(), $threads);
    //order the stickies
    array_multisort(array_map(FORUM_LOCK == 'news' ? 'filectime' : 'filemtime', $stickies), SORT_DESC, $stickies);
    //remove the stickies from the thread list
    $threads = array_diff($threads, $stickies);
    //handle a rounding problem with working out the number of pages (PHP 5.3 has a fix for this)
    $PAGES = count($threads) % FORUM_THREADS == 1 ? floor(count($threads) / FORUM_THREADS) : ceil(count($threads) / FORUM_THREADS);
    //validate the given page number; an invalid page number returns the first instead
    $PAGE = !PAGE || PAGE > $PAGES ? 1 : PAGE;
} else {
    $PAGES = 1;
    $PAGE = 1;
}
/* load the template into DOM where we can manipulate it:
   ---------------------------------------------------------------------------------------------------------------------- */
//(see 'lib/domtemplate.php' or <camendesign.com/dom_templating> for more details. `prepareTemplate` can be found in
Пример #2
0
        fwrite($f, $rss);
    }
    //close the lock / file
    flock($f, LOCK_UN);
    fclose($f);
    //regenerate the forum / sub-forums's RSS file
    indexRSS();
    //refresh page to see the new post added
    header("Location: {$url}", true, 303);
    exit;
}
/* ======================================================================================================================
   template thread
   ====================================================================================================================== */
//is this thread stickied?
define('IS_STICKY', in_array("{$FILE}.rss", $stickies = getStickies()));
/* load the template into DOM where we can manipulate it:
   --------------------------------------------------------------------------------------------------------------------- */
//(see 'lib/domtemplate/domtemplate.php' or <camendesign.com/dom_templating> for more details)
$template = prepareTemplate(THEME_ROOT . 'thread.html', url(PATH_URL, $FILE, $PAGE), sprintf(THEME_TITLE, $xml->channel->title, $PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, $PAGE) : ''))->set(array('//link[@rel="alternate"]/@href, ' . 'a#nnf_rss@href' => FORUM_PATH . PATH_URL . "{$FILE}.rss"))->remove(array('#nnf_reply, #nnf_reply-form' => !CAN_REPLY, '.nnf_forum-locked' => FORUM_LOCK != 'posts', '#nnf_admin' => !IS_MOD, '#nnf_lock' => $xml->channel->xpath('category[.="locked"]'), '#nnf_unlock' => !$xml->channel->xpath('category[.="locked"]'), '#nnf_stick' => IS_STICKY, '#nnf_unstick' => !IS_STICKY));
/* post
   ---------------------------------------------------------------------------------------------------------------------- */
//take the first post from the thread (removing it from the rest)
$post = array_pop($thread);
//remember the original poster’s name, for marking replies by the OP
$author = (string) $post->author;
//prepare the first post, which on this forum appears above all pages of replies
$template->set(array('#nnf_post-title' => $xml->channel->title, 'time#nnf_post-time' => date(DATE_FORMAT, strtotime($post->pubDate)), 'time#nnf_post-time@datetime' => gmdate('r', strtotime($post->pubDate)), '#nnf_post-author' => $post->author, 'a#nnf_post-append@href' => url(PATH_URL, $FILE, $PAGE, 'append', substr(strstr($post->link, '#'), 1)) . '#append', 'a#nnf_post-delete@href' => url(PATH_URL, $FILE, $PAGE, 'delete')))->remove(array('.nnf_post@class, #nnf_post-author@class' => !isMod($post->author) ? 'nnf_mod' : false, '#nnf_post-append, #nnf_post-delete' => !CAN_REPLY));
try {
    //insert the post-text, dealing with an invalid HTML error
    $template->setValue('#nnf_post-text', $post->description, true);