Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
830640d
Adds the table posts to install.sql.
Sep 25, 2014
62f0a4a
Changes the post function in inc/functions.php
Sep 25, 2014
05a4fdf
Fixes the post function to return the right id.
Sep 25, 2014
4818406
Changes the templates to use id_for_board.
Sep 25, 2014
01f52e5
Updates rebuild.php to work with posts table.
Sep 25, 2014
51b7a15
A minor typo in functions.php
Sep 25, 2014
b36dda2
boards.php now uses the posts table
Sep 27, 2014
503d3ea
rebuildPost() now uses the posts table
Sep 27, 2014
e031400
Applies `` to the table name and removes sprintf.
Sep 27, 2014
76c0a98
Missed a parenthesis.
Sep 27, 2014
9913834
bumpThread() now uses the posts table
Sep 27, 2014
beb142e
deleteFile() and numPosts() now use the posts table
Sep 27, 2014
405a49a
deletePost now uses the posts table
Sep 27, 2014
6bdb15a
Couple of typos in rebuildPost.
Sep 27, 2014
a21b0be
More functions now use posts table.
Sep 27, 2014
cfb5066
buildThread() now uses the posts table
Sep 27, 2014
2ad9062
Fixes the table prefix syntax in tools/rebuild.php
Sep 27, 2014
f197364
Deletion in post.php now uses the posts table
Sep 27, 2014
f81f10a
More changes in post.php
Sep 27, 2014
e2fbedd
tools/stats.php now uses the posts table
Sep 29, 2014
f69c856
Catalog now uses the posts table.
Sep 29, 2014
d4984d3
Recent theme now uses the posts table.
Sep 29, 2014
a054116
Sitemap now uses the posts table.
Sep 29, 2014
e2adc88
post.php and functions.php now use posts table
Sep 29, 2014
38cd9a7
Last files moved to posts table.
Sep 30, 2014
ca9c37c
Removes posts.sql.
Oct 1, 2014
4e6c223
Renaming id_for_board to just id, duh
Oct 8, 2014
cc09792
Migration script.
Oct 9, 2014
257f01f
A little fix in functions.php.
Oct 9, 2014
9d5f85a
Forgot instance-config.php.
Oct 9, 2014
7e1f4be
Merge branch 'master' of github.com:ctrlcctrlv/8chan into posts-table
Oct 9, 2014
1ef6161
Changes the insert query because performance.
Oct 10, 2014
4ceab4f
Merge branch 'master' of github.com:ctrlcctrlv/8chan into posts-table
Oct 10, 2014
e8ff2d2
Changes sprintf to prepare.
Oct 15, 2014
e070b9d
Sprintf->prepare in inc/instance-config.php.
Oct 15, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions boards.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
$total_posts = 0;

foreach ($boards as $i => $board) {

//$query = prepare(sprintf("SELECT (SELECT MAX(id) from ``posts_%s``) AS max, (SELECT MAX(id) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) < DATE_SUB(NOW(), INTERVAL 1 HOUR)) AS oldmax, (SELECT MAX(id) from ``posts_%s``) AS max_d, (SELECT MAX(id) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) < DATE_SUB(NOW(), INTERVAL 1 DAY)) AS oldmax_d, (SELECT count(id) FROM ``posts_%s``) AS count;", $board['uri'], $board['uri'], $board['uri'], $board['uri'], $board['uri']));

$query = prepare(sprintf("
SELECT MAX(id) max, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 DAY)) ppd,
(SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 HOUR)) pph,
(SELECT count(id) FROM ``posts_%s``) count,
(SELECT COUNT(DISTINCT ip) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 3 DAY)) uniq_ip
FROM ``posts_%s``
", $board['uri'], $board['uri'], $board['uri'], $board['uri'], $board['uri']));
$query = prepare("
SELECT
(SELECT coalesce((SELECT max(`id`) FROM ``posts`` WHERE `board` = :board),0)) max,
(SELECT COUNT(*) FROM ``posts`` WHERE `board` = :board AND FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 DAY)) ppd,
(SELECT COUNT(*) FROM ``posts`` WHERE `board` = :board AND FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 HOUR)) pph,
(SELECT count(id) FROM ``posts`` WHERE `board` = :board) count,
(SELECT COUNT(DISTINCT ip) FROM ``posts`` WHERE `board` = :board AND FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 3 DAY)) uniq_ip
FROM ``posts``
WHERE `board` = :board");
$query->bindValue(':board', $board['uri']);
$pdo->beginTransaction();
$query->execute() or error(db_error($query));
$pdo->commit();
$r = $query->fetch(PDO::FETCH_ASSOC);

$pph = $r['pph'];
Expand Down
3 changes: 0 additions & 3 deletions create.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@
$query->bindValue(':subtitle', $_POST['subtitle']);
$query->execute() or error(db_error($query));

$query = Element('posts.sql', array('board' => $uri));
query($query) or error(db_error());

if (!openBoard($_POST['uri']))
error(_("Couldn't open board after creation."));
if ($config['cache']['enabled'])
Expand Down
12 changes: 8 additions & 4 deletions expire.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
}

// last post
$query = prepare(sprintf("SELECT MAX(time) AS time FROM posts_%s", $board));
$query = prepare("SELECT MAX(time) AS time FROM posts WHERE `board` = :board");
$query->bindValue(':board', $board);
$query->execute();
$row = $query->fetch();

//count posts
$query = prepare(sprintf("SELECT COUNT(id) AS count FROM posts_%s", $board));
$query = prepare("SELECT COUNT(id) AS count FROM posts WHERE `board` = :board", $board);
$query->bindValue(':board', $board);
$query->execute();
$count = $query->fetch();

Expand Down Expand Up @@ -79,8 +81,10 @@
cache::delete('all_boards');
}

// Delete posting table
$query = query(sprintf('DROP TABLE IF EXISTS ``posts_%s``', $board['uri'])) or error(db_error());
// Delete posts
$query = prepare('DELETE FROM ``posts`` WHERE `board` = :board');
$query->bindValue(':board', $board['uri']);
$query->execute() or error(db_error($query));

// Clear reports
$query = prepare('DELETE FROM ``reports`` WHERE `board` = :id');
Expand Down
103 changes: 73 additions & 30 deletions inc/functions.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion inc/instance-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ function purify($s){
openBoard($b);
buildIndex();
buildJavascript();
$query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $b)) or error(db_error());
$query = prepare("SELECT `id` FROM ``posts`` WHERE `board` = :board AND `thread` IS NULL");
$query->bindValue(':board', $b);
$query->execute() or error(db_error());
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
buildThread($post['id']);
}
Expand Down
Loading