forked from GithubBackups/tinyib
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);
|
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) {
|
function postsByHex($hex) {
|
||||||
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_FILE_HEX, '=', $hex, STRING_COMPARISON), 1);
|
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_FILE_HEX, '=', $hex, STRING_COMPARISON), 1);
|
||||||
return convertPostsToSQLStyle($rows);
|
return convertPostsToSQLStyle($rows);
|
||||||
|
@ -108,17 +108,6 @@ function postsInThreadByID($id) {
|
|||||||
return $posts;
|
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) {
|
function postsByHex($hex) {
|
||||||
$posts = array();
|
$posts = array();
|
||||||
$result = mysql_query("SELECT `id`, `parent` FROM `" . TINYIB_DBPOSTS . "` WHERE `file_hex` = '" . mysql_real_escape_string($hex) . "' LIMIT 1");
|
$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;
|
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) {
|
function postsByHex($hex) {
|
||||||
$posts = array();
|
$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);
|
$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);
|
||||||
|
21
inc/html.php
21
inc/html.php
@ -274,27 +274,26 @@ EOF;
|
|||||||
|
|
||||||
function rebuildIndexes() {
|
function rebuildIndexes() {
|
||||||
$page = 0; $i = 0; $htmlposts = '';
|
$page = 0; $i = 0; $htmlposts = '';
|
||||||
$pages = ceil(countThreads() / 10) - 1;
|
|
||||||
$threads = allThreads();
|
$threads = allThreads();
|
||||||
|
$pages = ceil(count($threads) / TINYIB_THREADSPERPAGE) - 1;
|
||||||
|
|
||||||
foreach ($threads as $thread) {
|
foreach ($threads as $thread) {
|
||||||
$replies = latestRepliesInThreadByID($thread['id']);
|
$replies = postsInThreadByID($thread['id']);
|
||||||
|
$thread['omitted'] = max(0, count($replies) - TINYIB_PREVIEWREPLIES - 1);
|
||||||
|
|
||||||
$htmlreplies = array();
|
$htmlposts .= buildPost($thread, TINYIB_INDEXPAGE);
|
||||||
foreach ($replies as $reply) {
|
|
||||||
$htmlreplies[] = buildPost($reply, TINYIB_INDEXPAGE);
|
for ($j = count($replies) - 1; $j > $thread['omitted']; $j--) {
|
||||||
|
$htmlposts .= buildPost($replies[$j], TINYIB_INDEXPAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$thread['omitted'] = (count($htmlreplies) == 3) ? (count(postsInThreadByID($thread['id'])) - 4) : 0;
|
$htmlposts .= "<br clear=\"left\">\n<hr>";
|
||||||
|
|
||||||
$htmlposts .= buildPost($thread, TINYIB_INDEXPAGE) . implode('', array_reverse($htmlreplies)) . "<br clear=\"left\">\n<hr>";
|
if (++$i >= TINYIB_THREADSPERPAGE) {
|
||||||
|
|
||||||
$i += 1;
|
|
||||||
if ($i == 10) {
|
|
||||||
$file = ($page == 0) ? 'index.html' : $page . '.html';
|
$file = ($page == 0) ? 'index.html' : $page . '.html';
|
||||||
writePage($file, buildPage($htmlposts, 0, $pages, $page));
|
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_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_BOARDDESC', "TinyIB"); // Displayed at the top of every page
|
||||||
define('TINYIB_MAXTHREADS', 100); // Oldest threads are discarded over this limit [0 to disable]
|
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_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_MODPASS', ""); // Moderators only have access to delete posts ["" to disable]
|
||||||
define('TINYIB_DBMODE', "flatfile"); // Choose: flatfile / mysql / sqlite
|
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
|
// Note: The following only apply when TINYIB_DBMODE is set to mysql
|
||||||
define('TINYIB_DBHOST', "localhost");
|
define('TINYIB_DBHOST', "localhost");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user