mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-14 10:57:38 +01:00
Multi-board support.
This commit is contained in:
parent
ec5b314557
commit
e9e854829b
@ -85,7 +85,13 @@
|
|||||||
$offset = round($page*THREADS_PER_PAGE-THREADS_PER_PAGE);
|
$offset = round($page*THREADS_PER_PAGE-THREADS_PER_PAGE);
|
||||||
|
|
||||||
sql_open();
|
sql_open();
|
||||||
$query = mysql_query('SELECT * FROM `posts` WHERE `thread` IS NULL ORDER BY `bump` DESC LIMIT ' . $offset . ',' . THREADS_PER_PAGE, $sql) or error(mysql_error($sql));
|
$query = mysql_query(sprintf(
|
||||||
|
"SELECT * FROM `posts` WHERE `thread` IS NULL AND `board` = '%d' ORDER BY `bump` DESC LIMIT %d,%d",
|
||||||
|
$board['id'],
|
||||||
|
$offset,
|
||||||
|
THREADS_PER_PAGE
|
||||||
|
), $sql) or error(mysql_error($sql));
|
||||||
|
|
||||||
if(mysql_num_rows($query) < 1 && $page > 1) return false;
|
if(mysql_num_rows($query) < 1 && $page > 1) return false;
|
||||||
while($th = mysql_fetch_array($query)) {
|
while($th = mysql_fetch_array($query)) {
|
||||||
$thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename']);
|
$thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename']);
|
||||||
@ -120,7 +126,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildIndex() {
|
function buildIndex() {
|
||||||
global $sql;
|
global $sql, $board;
|
||||||
sql_open();
|
sql_open();
|
||||||
|
|
||||||
$res = mysql_query("SELECT COUNT(`id`) as `num` FROM `posts` WHERE `thread` IS NULL", $sql) or error(mysql_error($sql));
|
$res = mysql_query("SELECT COUNT(`id`) as `num` FROM `posts` WHERE `thread` IS NULL", $sql) or error(mysql_error($sql));
|
||||||
@ -129,7 +135,7 @@
|
|||||||
|
|
||||||
$pages = Array();
|
$pages = Array();
|
||||||
for($x=0;$x<$count && $x<MAX_PAGES;$x++) {
|
for($x=0;$x<$count && $x<MAX_PAGES;$x++) {
|
||||||
$pages[] = Array('num' => $x+1, 'link' => $x==0 ? ROOT . FILE_INDEX : ROOT . sprintf(FILE_PAGE, $x+1));
|
$pages[] = Array('num' => $x+1, 'link' => $x==0 ? ROOT . $board['dir'] . FILE_INDEX : ROOT . sprintf(FILE_PAGE, $x+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result($res);
|
mysql_free_result($res);
|
||||||
@ -138,7 +144,7 @@
|
|||||||
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
while($page <= MAX_PAGES && $content = index($page)) {
|
while($page <= MAX_PAGES && $content = index($page)) {
|
||||||
$filename = $page==1 ? FILE_INDEX : sprintf(FILE_PAGE, $page);
|
$filename = $board['dir'] . ($page==1 ? FILE_INDEX : sprintf(FILE_PAGE, $page));
|
||||||
if(file_exists($filename)) $md5 = md5_file($filename);
|
if(file_exists($filename)) $md5 = md5_file($filename);
|
||||||
|
|
||||||
$content['pages'] = $pages;
|
$content['pages'] = $pages;
|
||||||
@ -187,7 +193,7 @@
|
|||||||
|
|
||||||
$result = mysql_query(sprintf("SELECT `thread`,`id` FROM `posts` WHERE `id` = '%d'", $cite), $sql);
|
$result = mysql_query(sprintf("SELECT `thread`,`id` FROM `posts` WHERE `id` = '%d'", $cite), $sql);
|
||||||
if($post = mysql_fetch_array($result)) {
|
if($post = mysql_fetch_array($result)) {
|
||||||
$replacement = '<a onclick="highlightReply(\''.$cite.'\');" href="' . ROOT . DIR_RES . ($post['thread']?$post['thread']:$post['id']) . '.html#' . $cite . '">>>' . $cite . '</a>';
|
$replacement = '<a onclick="highlightReply(\''.$cite.'\');" href="' . ROOT . $board['dir'] . DIR_RES . ($post['thread']?$post['thread']:$post['id']) . '.html#' . $cite . '">>>' . $cite . '</a>';
|
||||||
} else {
|
} else {
|
||||||
$replacement = ">>{$cite}";
|
$replacement = ">>{$cite}";
|
||||||
}
|
}
|
||||||
@ -276,7 +282,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename']));
|
$thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename']));
|
||||||
}
|
}
|
||||||
@file_put_contents(DIR_RES . $id . '.html', Element('thread.html', Array('button'=>BUTTON_REPLY, 'board'=>$board, 'body'=>$thread->build(), 'post_url' => POST_URL, 'index' => ROOT, 'id' => $id))) or error("Couldn't write to file.");
|
@file_put_contents($board['dir'] . DIR_RES . $id . '.html', Element('thread.html', Array('button'=>BUTTON_REPLY, 'board'=>$board, 'body'=>$thread->build(), 'post_url' => POST_URL, 'index' => ROOT, 'id' => $id))) or error("Couldn't write to file.");
|
||||||
}
|
}
|
||||||
mysql_free_result($query);
|
mysql_free_result($query);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user