2004-01-06 22:09:19 +00:00
|
|
|
<?php
|
|
|
|
|
2008-06-19 03:44:27 +00:00
|
|
|
// The forum tables contain items that can become inconsistent
|
|
|
|
// due to bugs and DB gremlins.
|
|
|
|
// This script repairs some of them.
|
2005-02-09 18:09:26 +00:00
|
|
|
|
2008-06-19 03:44:27 +00:00
|
|
|
require_once("../inc/forum_db.inc");
|
2004-01-06 22:09:19 +00:00
|
|
|
|
|
|
|
function update_thread_timestamps() {
|
2008-06-19 03:44:27 +00:00
|
|
|
$threads = BoincThread::enum();
|
|
|
|
foreach ($threads as $thread) {
|
2004-01-06 22:09:19 +00:00
|
|
|
$q = "select max(timestamp) as foo from post where thread=$thread->id";
|
|
|
|
$r2 = mysql_query($q);
|
|
|
|
$m = mysql_fetch_object($r2);
|
|
|
|
echo "id: $thread->id; min: $m->foo\n";
|
|
|
|
mysql_free_result($r2);
|
|
|
|
$n = $m->foo;
|
|
|
|
if ($n) {
|
|
|
|
$q = "update thread set timestamp=$n where id=$thread->id";
|
|
|
|
mysql_query($q);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_user_posts() {
|
2008-06-19 03:44:27 +00:00
|
|
|
$users = BoincUser::enum();
|
|
|
|
foreach ($users as $user) {
|
|
|
|
$num = BoincPost::count("user=$user->id");
|
|
|
|
if ($num != $user->posts) {
|
|
|
|
echo "user $user->id: $user->posts $num\n";
|
|
|
|
$user->update("posts=$num");
|
2004-01-06 22:09:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-19 03:44:27 +00:00
|
|
|
function update_thread_replies() {
|
|
|
|
$threads = BoincThread::enum();
|
|
|
|
foreach ($threads as $t) {
|
|
|
|
$n = BoincPost::count("thread=$t->id");
|
|
|
|
$n--;
|
|
|
|
if ($t->replies != $n) {
|
|
|
|
$t->update("replies=$n");
|
|
|
|
echo "updated thread $t->id; $t->replies -> $n\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//update_thread_replies(); exit();
|
|
|
|
|
|
|
|
echo "You must uncomment a function call in the script\n";
|
2004-01-06 22:09:19 +00:00
|
|
|
?>
|