mirror of
https://code.rocketnine.space/tslocum/tinyib.git
synced 2025-01-18 00:38:19 +01:00
Merge pull request #6 from socram8888/master
Added setting TINYIB_THREADSPERPAGE for number of threads shown per index page Added setting TINYIB_PREVIEWREPLIES for number of replies previewed on index pages Optimized index page generation
This commit is contained in:
commit
c6f45f9b6c
@ -150,11 +150,6 @@ function postsInThreadByID($id) {
|
||||
return convertPostsToSQLStyle($rows);
|
||||
}
|
||||
|
||||
function latestRepliesInThreadByID($id) {
|
||||
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON), 3, new OrderBy(POST_ID, DESCENDING, INTEGER_COMPARISON));
|
||||
return convertPostsToSQLStyle($rows);
|
||||
}
|
||||
|
||||
function postsByHex($hex) {
|
||||
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_FILE_HEX, '=', $hex, STRING_COMPARISON), 1);
|
||||
return convertPostsToSQLStyle($rows);
|
||||
|
@ -108,17 +108,6 @@ function postsInThreadByID($id) {
|
||||
return $posts;
|
||||
}
|
||||
|
||||
function latestRepliesInThreadByID($id) {
|
||||
$posts = array();
|
||||
$replies = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = " . $id . " ORDER BY `id` DESC LIMIT 3");
|
||||
if ($replies) {
|
||||
while ($post = mysql_fetch_assoc($replies)) {
|
||||
$posts[] = $post;
|
||||
}
|
||||
}
|
||||
return $posts;
|
||||
}
|
||||
|
||||
function postsByHex($hex) {
|
||||
$posts = array();
|
||||
$result = mysql_query("SELECT `id`, `parent` FROM `" . TINYIB_DBPOSTS . "` WHERE `file_hex` = '" . mysql_real_escape_string($hex) . "' LIMIT 1");
|
||||
|
@ -93,15 +93,6 @@ function postsInThreadByID($id) {
|
||||
return $posts;
|
||||
}
|
||||
|
||||
function latestRepliesInThreadByID($id) {
|
||||
$posts = array();
|
||||
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE parent = " . $id . " ORDER BY id DESC LIMIT 3"), SQLITE_ASSOC);
|
||||
foreach ($result as $post) {
|
||||
$posts[] = $post;
|
||||
}
|
||||
return $posts;
|
||||
}
|
||||
|
||||
function postsByHex($hex) {
|
||||
$posts = array();
|
||||
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT id, parent FROM " . TINYIB_DBPOSTS . " WHERE file_hex = '" . sqlite_escape_string($hex) . "' LIMIT 1"), SQLITE_ASSOC);
|
||||
|
25
inc/html.php
25
inc/html.php
@ -274,27 +274,26 @@ EOF;
|
||||
|
||||
function rebuildIndexes() {
|
||||
$page = 0; $i = 0; $htmlposts = '';
|
||||
$pages = ceil(countThreads() / 10) - 1;
|
||||
$threads = allThreads();
|
||||
$pages = ceil(count($threads) / TINYIB_THREADSPERPAGE) - 1;
|
||||
|
||||
foreach ($threads as $thread) {
|
||||
$replies = latestRepliesInThreadByID($thread['id']);
|
||||
|
||||
$htmlreplies = array();
|
||||
foreach ($replies as $reply) {
|
||||
$htmlreplies[] = buildPost($reply, TINYIB_INDEXPAGE);
|
||||
$replies = postsInThreadByID($thread['id']);
|
||||
$thread['omitted'] = max(0, count($replies) - TINYIB_PREVIEWREPLIES - 1);
|
||||
|
||||
$htmlposts .= buildPost($thread, TINYIB_INDEXPAGE);
|
||||
|
||||
for ($j = count($replies) - 1; $j > $thread['omitted']; $j--) {
|
||||
$htmlposts .= buildPost($replies[$j], TINYIB_INDEXPAGE);
|
||||
}
|
||||
|
||||
$htmlposts .= "<br clear=\"left\">\n<hr>";
|
||||
|
||||
$thread['omitted'] = (count($htmlreplies) == 3) ? (count(postsInThreadByID($thread['id'])) - 4) : 0;
|
||||
|
||||
$htmlposts .= buildPost($thread, TINYIB_INDEXPAGE) . implode('', array_reverse($htmlreplies)) . "<br clear=\"left\">\n<hr>";
|
||||
|
||||
$i += 1;
|
||||
if ($i == 10) {
|
||||
if (++$i >= TINYIB_THREADSPERPAGE) {
|
||||
$file = ($page == 0) ? 'index.html' : $page . '.html';
|
||||
writePage($file, buildPage($htmlposts, 0, $pages, $page));
|
||||
|
||||
$page += 1; $i = 0; $htmlposts = '';
|
||||
$page++; $i = 0; $htmlposts = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
define('TINYIB_BOARD', "b"); // Unique identifier for this board using only letters and numbers
|
||||
define('TINYIB_BOARDDESC', "TinyIB"); // Displayed at the top of every page
|
||||
define('TINYIB_MAXTHREADS', 100); // Oldest threads are discarded over this limit [0 to disable]
|
||||
@ -13,6 +13,8 @@ define('TINYIB_TRIPSEED', ""); // Enter some random text - Used when generating
|
||||
define('TINYIB_ADMINPASS', ""); // Text entered at the manage prompt to gain administrator access
|
||||
define('TINYIB_MODPASS', ""); // Moderators only have access to delete posts ["" to disable]
|
||||
define('TINYIB_DBMODE', "flatfile"); // Choose: flatfile / mysql / sqlite
|
||||
define('TINYIB_PREVIEWREPLIES', 3); // Max replies to show on index
|
||||
define('TINYIB_THREADSPERPAGE', 10); // Amount of threads per page on index
|
||||
|
||||
// Note: The following only apply when TINYIB_DBMODE is set to mysql
|
||||
define('TINYIB_DBHOST', "localhost");
|
||||
|
Loading…
x
Reference in New Issue
Block a user