コード例 #1
0
ファイル: index.php プロジェクト: Kroc/NoNonsenseForum
    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
// 'lib/functions.php' and handles some shared templating done across all pages)
$template = prepareTemplate(THEME_ROOT . 'index.html', url(PATH_URL, '', $PAGE), sprintf(THEME_TITLE, PATH ? SUBFORUM : FORUM_NAME, $PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, $PAGE) : ''))->setValue('a#nnf_rss@href', FORUM_PATH . PATH_URL . 'index.xml')->remove(array('#nnf_add, #nnf_new-form' => !CAN_POST, '#nnf_forum-lock-threads' => !FORUM_LOCK || FORUM_LOCK == 'posts' || IS_MOD, '#nnf_forum-lock-posts' => FORUM_LOCK != 'posts' || IS_MOD || IS_MEMBER));
//an 'about.html' file can be provided to add a description or other custom HTML to the forum / sub-forum,
//for translations, 'about_en.html' can be used where 'en' is the language code for the translation
//(see 'lang.example.php' in the themes folder for more details on translation)
if ($about = @array_shift(array_filter(array(@file_get_contents('about_' . LANG . '.html'), @file_get_contents('about.html'))))) {
    //load the 'about.html' file and insert it into the page
    $template->setValue('#nnf_about', $about, true);
} else {
    //no file? remove the element reserved for it
    $template->remove('#nnf_about');
}
/* sub-forums
   ---------------------------------------------------------------------------------------------------------------------- */
if ($folders = array_filter(preg_grep('/^(\\.|users$|themes$|lib$|cgi-bin$)/', scandir('.'), PREG_GREP_INVERT), 'is_dir')) {
    //get the dummy list-item to repeat (removes it and takes a copy)
    $item = $template->repeat('.nnf_folder');
コード例 #2
0
ファイル: index.php プロジェクト: rvanvelzen/NoNonsenseForum
        //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
// 'lib/functions.php' and handles some shared templating done across all pages)
$template = prepareTemplate(THEME_ROOT . 'index.html', sprintf(THEME_TITLE, PATH ? SUBFORUM : FORUM_NAME, $PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, $PAGE) : ''))->remove(array('#nnf_add, #nnf_new-form' => !CAN_POST, '#nnf_forum-lock-threads' => FORUM_LOCK != 'threads' || IS_MOD, '#nnf_forum-lock-posts' => FORUM_LOCK != 'posts' || IS_MOD || IS_MEMBER));
//an 'about.html' file can be provided to add a description or other custom HTML to the forum / sub-forum,
//for translations, 'about_en.html' can be used where 'en' is the language code for the translation
//(see 'lang.example.php' in the themes folder for more details on translation)
if ($about = @array_shift(array_filter(array(@file_get_contents('about_' . LANG . '.html'), @file_get_contents('about.html'))))) {
    //load the 'about.html' file and insert it into the page
    $template->setValue('#nnf_about', $about, true);
} else {
    //no file? remove the element reserved for it
    $template->remove('#nnf_about');
}
/* sub-forums
   ---------------------------------------------------------------------------------------------------------------------- */
if ($folders = array_filter(preg_grep('/^(\\.|users$|themes$|lib$)/', scandir('.'), PREG_GREP_INVERT), 'is_dir')) {
    //get the dummy list-item to repeat (removes it and takes a copy)
    $item = $template->repeat('.nnf_folder');
コード例 #3
0
ファイル: markup.php プロジェクト: rvanvelzen/NoNonsenseForum
<?php

//just display the markup documentation
/* ====================================================================================================================== */
/* NoNonsense Forum v19 © Copyright (CC-BY) Kroc Camen 2012
   licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
   you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
//bootstrap the forum; you should read that file first
require_once './start.php';
$template = prepareTemplate(THEME_ROOT . 'markup.html');
theme_custom($template);
die($template->html());
コード例 #4
0
ファイル: thread.php プロジェクト: nowaym/NoNonsenseForum
    }
    //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
   ====================================================================================================================== */
//load the template into DOM where we can manipulate it:
//(see 'lib/domtemplate.php' or <camendesign.com/dom_templating> for more details)
$template = prepareTemplate(THEME_ROOT . 'thread.html', sprintf(THEME_TITLE, $xml->channel->title, $PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, $PAGE) : ''), 'thread', $FILE, PATH_URL, $PAGE, '', true)->set(array('//link[@rel="alternate"]/@href, ' . 'a#nnf_rss@href' => FORUM_PATH . PATH_URL . "{$FILE}.rss", 'a#nnf_lock@href' => url('lock', PATH_URL, $FILE, $PAGE), 'a#nnf_unlock@href' => url('unlock', PATH_URL, $FILE, $PAGE)))->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"]')));
/* 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('append', PATH_URL, $FILE, $PAGE, substr(strstr($post->link, '#'), 1)) . '#append', 'a#nnf_post-delete@href' => url('delete', PATH_URL, $FILE, $PAGE)))->remove(array('#nnf_post@class, #nnf_post-author@class' => !isMod($post->author) ? 'mod' : false, '#nnf_post-append, #nnf_post-delete' => !CAN_REPLY));
//insert the post-text, dealing with an invalid HTML error
try {
    $template->setValue('#nnf_post-text', $post->description, true);
    $template->remove(array('#nnf_post@class' => 'nnf_error'));
} catch (Exception $e) {
    //if the HTML was invalid, replace with the corruption message
    $template->setValue('#nnf_post-text', THEME_HTML_ERROR, true);
コード例 #5
0
ファイル: privacy.php プロジェクト: Kroc/NoNonsenseForum
<?php

//just display the privacy policy
/* ====================================================================================================================== */
/* NoNonsense Forum v26 © Copyright (CC-BY) Kroc Camen 2010-2015
   licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
   you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
//bootstrap the forum; you should read that file first
require_once './start.php';
$template = prepareTemplate(THEME_ROOT . 'privacy.html', '/privacy.html');
theme_custom($template);
exit($template);
コード例 #6
0
ファイル: thread.php プロジェクト: nkrs/NoNonsenseForum
    }
    //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
   ====================================================================================================================== */
//load the template into DOM where we can manipulate it:
//(see 'lib/domtemplate.php' or <camendesign.com/dom_templating> for more details)
$template = prepareTemplate(FORUM_ROOT . '/themes/' . FORUM_THEME . '/thread.html', sprintf(THEME_TITLE, $xml->channel->title, PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, PAGE) : ''))->setValue('a#nnf_rss@href', PATH_URL . "{$FILE}.rss")->remove(array('#nnf_add, #nnf_reply-form' => !CAN_REPLY, '.nnf_forum-locked' => FORUM_LOCK != 'posts', '#nnf_admin' => !IS_MOD, '#nnf_lock' => $xml->channel->xpath("category[text()='locked']"), '#nnf_unlock' => !$xml->channel->xpath("category[text()='locked']")));
/* 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' => '?append=' . substr(strstr($post->link, '#'), 1) . '#append', 'a#nnf_post-delete@href' => '?delete'))->setHTML('#nnf_post-text', $post->description);
//if the user who made the post is a mod, also mark the whole post as by a mod
//(you might want to style any posts made by a mod differently)
if (isMod($post->author)) {
    $template->addClass('#nnf_post, #nnf_post-author', 'mod');
}
//append / delete links?
if (!CAN_REPLY) {
コード例 #7
0
ファイル: index.php プロジェクト: nkrs/NoNonsenseForum
    $rss = new DOMTemplate(FORUM_ROOT . '/lib/rss-template.xml');
    $rss->set(array('/rss/channel/title' => TITLE, '/rss/channel/link' => FORUM_URL . PATH_URL . $file, '/rss/channel/item/title' => TITLE, '/rss/channel/item/link' => FORUM_URL . PATH_URL . "{$file}#" . base_convert(microtime(), 10, 36), '/rss/channel/item/author' => NAME, '/rss/channel/item/pubDate' => gmdate('r'), '/rss/channel/item/description' => formatText(TEXT)));
    file_put_contents("{$file}.rss", $rss->html()) or die("Failed to save thread. Folder permissions may be incorrect.");
    //regenerate the folder's RSS file
    indexRSS();
    //redirect to newley created thread
    header('Location: ' . FORUM_URL . PATH_URL . $file, true, 303);
    exit;
}
/* ======================================================================================================================
   template the page
   ====================================================================================================================== */
//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
// 'lib/functions.php' and handles some shared templating done across all pages)
$template = prepareTemplate(FORUM_ROOT . '/themes/' . FORUM_THEME . '/index.html', sprintf(THEME_TITLE, PATH ? SUBFORUM : FORUM_NAME, PAGE > 1 ? sprintf(THEME_TITLE_PAGENO, PAGE) : ''))->remove(array('#nnf_add, #nnf_new-form' => !CAN_POST, '.nnf_forum-lock-threads' => FORUM_LOCK != 'threads', '.nnf_forum-lock-posts' => FORUM_LOCK != 'posts'));
//an 'about.html' file can be provided to add a description or other custom HTML to the forum / sub-forum
if (file_exists('about.html')) {
    //load the 'about.html' file and insert it into the page
    $template->setHTML('#nnf_about', file_get_contents('about.html'));
} else {
    //no file? remove the element reserved for it
    $template->remove('#nnf_about');
}
/* sub-forums
   ---------------------------------------------------------------------------------------------------------------------- */
if ($folders = array_filter(preg_grep('/^(\\.|users$|themes$|lib$)/', scandir('.'), PREG_GREP_INVERT), 'is_dir')) {
    //get the dummy list-item to repeat (removes it and takes a copy)
    $item = $template->repeat('.nnf_folder');
    foreach ($folders as $FOLDER) {
        //the sorting (below) requires we be in the directory at hand to use `filemtime`