blob: 5d1053aba9ff5e8e81e97e0bb0b047c8105b0e56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
// A script to recount bumps to recover from a last-page-bump attack
// or to be run after the KusabaX Migration.
require __DIR__ . '/inc/cli.php';
if (!isset ($argv[1])) {
die("Usage: tools/recount-bumps.php board_uri\n");
}
$board = $argv[1];
$q = query(sprintf("SELECT `id`, `bump`, `time` FROM ``posts_%s``
WHERE `thread` IS NULL", $board));
while ($val = $q->fetch()) {
$lc = prepare(sprintf('SELECT MAX(`time`) AS `aq` FROM ``posts_%s``
WHERE ((`thread` = :thread and
`email` != "sage" ) OR `id` = :thread', $board));
$lc->bindValue(":thread", $val['id']);
$lc->execute();
$f = $lc->fetch();
if ($val['bump'] != $f['aq']) {
$query = prepare(sprintf("UPDATE ``posts_%s`` SET `bump`=:bump
WHERE `id`=:id", $board));
$query->bindValue(":bump", $f['aq']);
$query->bindValue(":id", $val['id']);
echo("Thread $val[id] - to be $val[bump] -> $f[aq]\n");
}
else {
echo("Thread $val[id] ok\n");
}
}
echo("done\n");
|