Ahh, pruning.
This is one of those things that is pretty easy in something like kareha, where "boards" are self-contained, but a lot more complicated in ochiba where "boards" are really just label filters. I also had a a bunch of new ideas in mind (prune by date, prune by space on disk, prune by thread count, prune by post count). Plus, this kinda thing is harder to test for obvious reasons.
Anyway, those are my excuses. Here's some stop-gap code to provide pruning until the time I do this properly (probably ochiba v2).
conf.php
--- release/ochiba-1.1/conf.php 2005-09-21 19:46:39.000000000 -0700
+++ conf.php 2007-01-28 14:51:42.000000000 -0800
@@ -67,6 +67,7 @@
define("FEATURE_RSS",true); // Enable RSS feed?
define("FEATURE_FETCH",false); // Enable URL fetch instead of upload?
define("FEATURE_SAGE",20); // Number of replies before no longer bumped, or false
+define("FEATURE_PRUNE",35); // Number of threads to retain; false to retain all
define("FEATURE_MULTIPLE_CATEGORY",true); // Allow multiple categories per post?
// Restrict posting? If so, only tripcodes provided in a comma-separated list will
includes/post.php
--- release/ochiba-1.1/includes/post.php 2006-01-07 11:40:39.000000000 -0800
+++ includes/post.php 2007-01-28 14:52:46.000000000 -0800
@@ -313,6 +315,11 @@
}
}
+ //----- Prune? If FEATURE_PRUNE is set to a number, delete off old stuff
+ if(is_numeric(FEATURE_PRUNE) && FEATURE_PRUNE>0) {
+ prune($_POST['categories']);
+ }
+
echo $STRINGS["postthanks"];
echo JS_AUTO_CLOSE;
includes/functions.php - add the following function to the file
function prune($categories) {
global $db;
// Have to do this for each category posted...
foreach($categories as $c) {
// Get threads to delete, if any
$q = "select id from images where category like '%/$c/%' order by date desc";
if(eregi("^mysql",DB)) {
// Fuck you mysql
$q .= " limit " . FEATURE_PRUNE . ",10";
} else {
$q .= " limit 10 offset " . FEATURE_PRUNE;
}
$threads = $db->getCol($q);
$allchildren = getComments($threads);
foreach($allchildren as $children) {
foreach($children as $child) {
deleteImage($child["id"]);
}
}
foreach($threads as $thread) {
deleteImage($thread);
}
}
}